primnodes.h
来自「PostgreSQL7.4.6 for Linux」· C头文件 代码 · 共 832 行 · 第 1/3 页
H
832 行
/*------------------------------------------------------------------------- * * primnodes.h * Definitions for "primitive" node types, those that are used in more * than one of the parse/plan/execute stages of the query pipeline. * Currently, these are mostly nodes for executable expressions * and join trees. * * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * $Id: primnodes.h,v 1.92 2003/08/17 23:43:26 tgl Exp $ * *------------------------------------------------------------------------- */#ifndef PRIMNODES_H#define PRIMNODES_H#include "access/attnum.h"#include "nodes/pg_list.h"/* ---------------------------------------------------------------- * node definitions * ---------------------------------------------------------------- *//*-------------------- * Resdom (Result Domain) * * Notes: * * In a SELECT's targetlist, resno should always be equal to the item's * ordinal position (counting from 1). However, in an INSERT or UPDATE * targetlist, resno represents the attribute number of the destination * column for the item; so there may be missing or out-of-order resnos. * In an UPDATE, it is even legal to have duplicated resnos; consider * UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ... * The two meanings come together in the executor, because the planner * transforms INSERT/UPDATE tlists into a normalized form with exactly * one entry for each column of the destination table. Before that's * happened, however, it is risky to assume that resno == position. * Generally get_tle_by_resno() should be used rather than nth() to fetch * tlist entries by resno. * * resname is required to represent the correct column name in non-resjunk * entries of top-level SELECT targetlists, since it will be used as the * column title sent to the frontend. In most other contexts it is only * a debugging aid, and may be wrong or even NULL. (In particular, it may * be wrong in a tlist from a stored rule, if the referenced column has been * renamed by ALTER TABLE since the rule was made. Also, the planner tends * to store NULL rather than look up a valid name for tlist entries in * non-toplevel plan nodes.) In resjunk entries, resname should be either * a specific system-generated name (such as "ctid") or NULL; anything else * risks confusing ExecGetJunkAttribute! * * ressortgroupref is used in the representation of ORDER BY and * GROUP BY items. Targetlist entries with ressortgroupref=0 are not * sort/group items. If ressortgroupref>0, then this item is an ORDER BY or * GROUP BY value. No two entries in a targetlist may have the same nonzero * ressortgroupref --- but there is no particular meaning to the nonzero * values, except as tags. (For example, one must not assume that lower * ressortgroupref means a more significant sort key.) The order of the * associated SortClause or GroupClause lists determine the semantics. * * resorigtbl/resorigcol identify the source of the column, if it is a * simple reference to a column of a base table (or view). If it is not * a simple reference, these fields are zeroes. * * If resjunk is true then the column is a working column (such as a sort key) * that should be removed from the final output of the query. Resjunk columns * must have resnos that cannot duplicate any regular column's resno. Also * note that there are places that assume resjunk columns come after non-junk * columns. *-------------------- */typedef struct Resdom{ NodeTag type; AttrNumber resno; /* attribute number (see notes above) */ Oid restype; /* type of the value */ int32 restypmod; /* type-specific modifier of the value */ char *resname; /* name of the column (could be NULL) */ Index ressortgroupref;/* nonzero if referenced by a sort/group * clause */ Oid resorigtbl; /* OID of column's source table */ AttrNumber resorigcol; /* column's number in source table */ bool resjunk; /* set to true to eliminate the attribute * from final target list */} Resdom;/* * Alias - * specifies an alias for a range variable; the alias might also * specify renaming of columns within the table. */typedef struct Alias{ NodeTag type; char *aliasname; /* aliased rel name (never qualified) */ List *colnames; /* optional list of column aliases */ /* Note: colnames is a list of Value nodes (always strings) */} Alias;typedef enum InhOption{ INH_NO, /* Do NOT scan child tables */ INH_YES, /* DO scan child tables */ INH_DEFAULT /* Use current SQL_inheritance option */} InhOption;/* * RangeVar - range variable, used in FROM clauses * * Also used to represent table names in utility statements; there, the alias * field is not used, and inhOpt shows whether to apply the operation * recursively to child tables. In some contexts it is also useful to carry * a TEMP table indication here. */typedef struct RangeVar{ NodeTag type; char *catalogname; /* the catalog (database) name, or NULL */ char *schemaname; /* the schema name, or NULL */ char *relname; /* the relation/sequence name */ InhOption inhOpt; /* expand rel by inheritance? recursively * act on children? */ bool istemp; /* is this a temp relation/sequence? */ Alias *alias; /* table alias & optional column aliases */} RangeVar;/* ---------------------------------------------------------------- * node types for executable expressions * ---------------------------------------------------------------- *//* * Expr - generic superclass for executable-expression nodes * * All node types that are used in executable expression trees should derive * from Expr (that is, have Expr as their first field). Since Expr only * contains NodeTag, this is a formality, but it is an easy form of * documentation. See also the ExprState node types in execnodes.h. */typedef struct Expr{ NodeTag type;} Expr;/* * Var - expression node representing a variable (ie, a table column) * * Note: during parsing/planning, varnoold/varoattno are always just copies * of varno/varattno. At the tail end of planning, Var nodes appearing in * upper-level plan nodes are reassigned to point to the outputs of their * subplans; for example, in a join node varno becomes INNER or OUTER and * varattno becomes the index of the proper element of that subplan's target * list. But varnoold/varoattno continue to hold the original values. * The code doesn't really need varnoold/varoattno, but they are very useful * for debugging and interpreting completed plans, so we keep them around. */#define INNER 65000#define OUTER 65001#define PRS2_OLD_VARNO 1#define PRS2_NEW_VARNO 2typedef struct Var{ Expr xpr; Index varno; /* index of this var's relation in the * range table (could also be INNER or * OUTER) */ AttrNumber varattno; /* attribute number of this var, or zero * for all */ Oid vartype; /* pg_type tuple OID for the type of this * var */ int32 vartypmod; /* pg_attribute typmod value */ Index varlevelsup; /* * for subquery variables referencing outer relations; 0 in a normal * var, >0 means N levels up */ Index varnoold; /* original value of varno, for debugging */ AttrNumber varoattno; /* original value of varattno */} Var;/* * Const */typedef struct Const{ Expr xpr; Oid consttype; /* PG_TYPE OID of the constant's datatype */ int constlen; /* typlen of the constant's datatype */ Datum constvalue; /* the constant's value */ bool constisnull; /* whether the constant is null (if true, * constvalue is undefined) */ bool constbyval; /* whether this datatype is passed by * value. If true, then all the * information is stored in the Datum. If * false, then the Datum contains a * pointer to the information. */} Const;/* ---------------- * Param * paramkind - specifies the kind of parameter. The possible values * for this field are specified in "params.h", and they are: * * PARAM_NAMED: The parameter has a name, i.e. something * like `$.salary' or `$.foobar'. * In this case field `paramname' must be a valid name. * * PARAM_NUM: The parameter has only a numeric identifier, * i.e. something like `$1', `$2' etc. * The number is contained in the `paramid' field. * * PARAM_EXEC: The parameter is an internal executor parameter. * It has a number contained in the `paramid' field. * ---------------- */typedef struct Param{ Expr xpr; int paramkind; /* kind of parameter. See above */ AttrNumber paramid; /* numeric ID for parameter ("$1") */ char *paramname; /* name for parameter ("$.foo") */ Oid paramtype; /* PG_TYPE OID of parameter's datatype */} Param;/* * Aggref */typedef struct Aggref{ Expr xpr; Oid aggfnoid; /* pg_proc Oid of the aggregate */ Oid aggtype; /* type Oid of result of the aggregate */ Expr *target; /* expression we are aggregating on */ Index agglevelsup; /* > 0 if agg belongs to outer query */ bool aggstar; /* TRUE if argument was really '*' */ bool aggdistinct; /* TRUE if it's agg(DISTINCT ...) */} Aggref;/* ---------------- * ArrayRef: describes an array subscripting operation * * An ArrayRef can describe fetching a single element from an array, * fetching a subarray (array slice), storing a single element into * an array, or storing a slice. The "store" cases work with an * initial array value and a source value that is inserted into the * appropriate part of the array; the result of the operation is an * entire new modified array value. * * If reflowerindexpr = NIL, then we are fetching or storing a single array * element at the subscripts given by refupperindexpr. Otherwise we are * fetching or storing an array slice, that is a rectangular subarray * with lower and upper bounds given by the index expressions. * reflowerindexpr must be the same length as refupperindexpr when it * is not NIL. * * Note: refrestype is NOT the element type, but the array type, * when doing subarray fetch or either type of store. * ---------------- */typedef struct ArrayRef{ Expr xpr; Oid refrestype; /* type of the result of the ArrayRef * operation */ Oid refarraytype; /* type of the array proper */ Oid refelemtype; /* type of the array elements */ List *refupperindexpr;/* expressions that evaluate to upper
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?