parsenodes.h
来自「PostgreSQL7.4.6 for Linux」· C头文件 代码 · 共 1,701 行 · 第 1/4 页
H
1,701 行
/*------------------------------------------------------------------------- * * parsenodes.h * definitions for parse tree nodes * * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * $Id: parsenodes.h,v 1.248 2003/09/17 04:25:29 ishii Exp $ * *------------------------------------------------------------------------- */#ifndef PARSENODES_H#define PARSENODES_H#include "nodes/primnodes.h"/* Possible sources of a Query */typedef enum QuerySource{ QSRC_ORIGINAL, /* original parsetree (explicit query) */ QSRC_PARSER, /* added by parse analysis */ QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */ QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */ QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */} QuerySource;/***************************************************************************** * Query Tree *****************************************************************************//* * Query - * all statements are turned into a Query tree (via transformStmt) * for further processing by the optimizer * utility statements (i.e. non-optimizable statements) * have the *utilityStmt field set. */typedef struct Query{ NodeTag type; CmdType commandType; /* select|insert|update|delete|utility */ QuerySource querySource; /* where did I come from? */ bool canSetTag; /* do I set the command result tag? */ Node *utilityStmt; /* non-null if this is a non-optimizable * statement */ int resultRelation; /* target relation (index into rtable) */ RangeVar *into; /* target relation for SELECT INTO */ bool hasAggs; /* has aggregates in tlist or havingQual */ bool hasSubLinks; /* has subquery SubLink */ List *rtable; /* list of range table entries */ FromExpr *jointree; /* table join tree (FROM and WHERE * clauses) */ List *rowMarks; /* integer list of RT indexes of relations * that are selected FOR UPDATE */ List *targetList; /* target list (of TargetEntry) */ List *groupClause; /* a list of GroupClause's */ Node *havingQual; /* qualifications applied to groups */ List *distinctClause; /* a list of SortClause's */ List *sortClause; /* a list of SortClause's */ Node *limitOffset; /* # of result tuples to skip */ Node *limitCount; /* # of result tuples to return */ Node *setOperations; /* set-operation tree if this is top level * of a UNION/INTERSECT/EXCEPT query */ /* * If the resultRelation turns out to be the parent of an inheritance * tree, the planner will add all the child tables to the rtable and * store a list of the rtindexes of all the result relations here. * This is done at plan time, not parse time, since we don't want to * commit to the exact set of child tables at parse time. This field * ought to go in some sort of TopPlan plan node, not in the Query. */ List *resultRelations; /* integer list of RT indexes, or NIL */ /* internal to planner */ List *base_rel_list; /* list of base-relation RelOptInfos */ List *other_rel_list; /* list of other 1-relation RelOptInfos */ List *join_rel_list; /* list of join-relation RelOptInfos */ List *equi_key_list; /* list of lists of equijoined * PathKeyItems */ List *in_info_list; /* list of InClauseInfos */ List *query_pathkeys; /* desired pathkeys for query_planner() */ bool hasJoinRTEs; /* true if any RTEs are RTE_JOIN kind */} Query;/**************************************************************************** * Supporting data structures for Parse Trees * * Most of these node types appear in raw parsetrees output by the grammar, * and get transformed to something else by the analyzer. A few of them * are used as-is in transformed querytrees. ****************************************************************************//* * TypeName - specifies a type in definitions * * For TypeName structures generated internally, it is often easier to * specify the type by OID than by name. If "names" is NIL then the * actual type OID is given by typeid, otherwise typeid is unused. * * If pct_type is TRUE, then names is actually a field name and we look up * the type of that field. Otherwise (the normal case), names is a type * name possibly qualified with schema and database name. */typedef struct TypeName{ NodeTag type; List *names; /* qualified name (list of Value strings) */ Oid typeid; /* type identified by OID */ bool timezone; /* timezone specified? */ bool setof; /* is a set? */ bool pct_type; /* %TYPE specified? */ int32 typmod; /* type modifier */ List *arrayBounds; /* array bounds */} TypeName;/* * ColumnRef - specifies a reference to a column, or possibly a whole tuple * * The "fields" list must be nonempty; its last component may be "*" * instead of a field name. Subscripts are optional. */typedef struct ColumnRef{ NodeTag type; List *fields; /* field names (list of Value strings) */ List *indirection; /* subscripts (list of A_Indices) */} ColumnRef;/* * ParamRef - specifies a parameter reference * * The parameter could be qualified with field names and/or subscripts */typedef struct ParamRef{ NodeTag type; int number; /* the number of the parameter */ List *fields; /* field names (list of Value strings) */ List *indirection; /* subscripts (list of A_Indices) */} ParamRef;/* * A_Expr - infix, prefix, and postfix expressions */typedef enum A_Expr_Kind{ AEXPR_OP, /* normal operator */ AEXPR_AND, /* booleans - name field is unused */ AEXPR_OR, AEXPR_NOT, AEXPR_OP_ANY, /* scalar op ANY (array) */ AEXPR_OP_ALL, /* scalar op ALL (array) */ AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */ AEXPR_NULLIF, /* NULLIF - name must be "=" */ AEXPR_OF /* IS (not) OF - name must be "=" or "!=" */} A_Expr_Kind;typedef struct A_Expr{ NodeTag type; A_Expr_Kind kind; /* see above */ List *name; /* possibly-qualified name of operator */ Node *lexpr; /* left argument, or NULL if none */ Node *rexpr; /* right argument, or NULL if none */} A_Expr;/* * A_Const - a constant expression */typedef struct A_Const{ NodeTag type; Value val; /* the value (with the tag) */ TypeName *typename; /* typecast */} A_Const;/* * TypeCast - a CAST expression * * NOTE: for mostly historical reasons, A_Const parsenodes contain * room for a TypeName; we only generate a separate TypeCast node if the * argument to be casted is not a constant. In theory either representation * would work, but it is convenient to have the target type immediately * available while resolving a constant's datatype. */typedef struct TypeCast{ NodeTag type; Node *arg; /* the expression being casted */ TypeName *typename; /* the target type */} TypeCast;/* * FuncCall - a function or aggregate invocation * * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct * indicates we saw 'foo(DISTINCT ...)'. In either case, the construct * *must* be an aggregate call. Otherwise, it might be either an * aggregate or some other kind of function. */typedef struct FuncCall{ NodeTag type; List *funcname; /* qualified name of function */ List *args; /* the arguments (list of exprs) */ bool agg_star; /* argument was really '*' */ bool agg_distinct; /* arguments were labeled DISTINCT */} FuncCall;/* * A_Indices - array reference or bounds ([lidx:uidx] or [uidx]) */typedef struct A_Indices{ NodeTag type; Node *lidx; /* could be NULL */ Node *uidx;} A_Indices;/* * ExprFieldSelect - select a field and/or array element from an expression * * This is used in the raw parsetree to represent selection from an * arbitrary expression (not a column or param reference). Either * fields or indirection may be NIL if not used. */typedef struct ExprFieldSelect{ NodeTag type; Node *arg; /* the thing being selected from */ List *fields; /* field names (list of Value strings) */ List *indirection; /* subscripts (list of A_Indices) */} ExprFieldSelect;/* * ResTarget - * result target (used in target list of pre-transformed Parse trees) * * In a SELECT or INSERT target list, 'name' is either NULL or * the column name assigned to the value. (If there is an 'AS ColumnLabel' * clause, the grammar sets 'name' from it; otherwise 'name' is initially NULL * and is filled in during the parse analysis phase.) * The 'indirection' field is not used at all. * * In an UPDATE target list, 'name' is the name of the destination column, * and 'indirection' stores any subscripts attached to the destination. * That is, our representation is UPDATE table SET name [indirection] = val. */typedef struct ResTarget{ NodeTag type; char *name; /* column name or NULL */ List *indirection; /* subscripts for destination column, or * NIL */ Node *val; /* the value expression to compute or * assign */} ResTarget;/* * SortBy - for ORDER BY clause */#define SORTBY_ASC 1#define SORTBY_DESC 2#define SORTBY_USING 3typedef struct SortBy{ NodeTag type; int sortby_kind; /* see codes above */ List *useOp; /* name of op to use, if SORTBY_USING */ Node *node; /* expression to sort on */} SortBy;/* * RangeSubselect - subquery appearing in a FROM clause */typedef struct RangeSubselect{ NodeTag type; Node *subquery; /* the untransformed sub-select clause */ Alias *alias; /* table alias & optional column aliases */} RangeSubselect;/* * RangeFunction - function call appearing in a FROM clause */typedef struct RangeFunction{ NodeTag type; Node *funccallnode; /* untransformed function call tree */ Alias *alias; /* table alias & optional column aliases */ List *coldeflist; /* list of ColumnDef nodes for runtime * assignment of RECORD TupleDesc */} RangeFunction;/* * ColumnDef - column definition (used in various creates) * * If the column has a default value, we may have the value expression * in either "raw" form (an untransformed parse tree) or "cooked" form * (the nodeToString representation of an executable expression tree), * depending on how this ColumnDef node was created (by parsing, or by * inheritance from an existing relation). We should never have both * in the same node! * * The constraints list may contain a CONSTR_DEFAULT item in a raw * parsetree produced by gram.y, but transformCreateStmt will remove * the item and set raw_default instead. CONSTR_DEFAULT items * should not appear in any subsequent processing. * * The "support" field, if not null, denotes a supporting relation that * should be linked by an internal dependency to the column. Currently * this is only used to link a SERIAL column's sequence to the column. */typedef struct ColumnDef{ NodeTag type; char *colname; /* name of column */ TypeName *typename; /* type of column */ int inhcount; /* number of times column is inherited */ bool is_local; /* column has local (non-inherited) def'n */ bool is_not_null; /* NOT NULL constraint specified? */ Node *raw_default; /* default value (untransformed parse * tree) */ char *cooked_default; /* nodeToString representation */ List *constraints; /* other constraints on column */ RangeVar *support; /* supporting relation, if any */} ColumnDef;/* * inhRelation - Relations a CREATE TABLE is to inherit attributes of */typedef struct InhRelation{ NodeTag type; RangeVar *relation; bool including_defaults;} InhRelation;/* * IndexElem - index parameters (used in CREATE INDEX) * * For a plain index attribute, 'name' is the name of the table column to * index, and 'expr' is NULL. For an index expression, 'name' is NULL and * 'expr' is the expression tree. */typedef struct IndexElem{ NodeTag type; char *name; /* name of attribute to index, or NULL */ Node *expr; /* expression to index, or NULL */ List *opclass; /* name of desired opclass; NIL = default */} IndexElem;/* * DefElem - * a definition (used in definition lists in the form of defname = arg) */typedef struct DefElem{ NodeTag type; char *defname; Node *arg; /* a (Value *) or a (TypeName *) */} DefElem;/**************************************************************************** * Nodes for a Query tree ****************************************************************************//*-------------------- * RangeTblEntry - * A range table is a List of RangeTblEntry nodes. * * A range table entry may represent a plain relation, a sub-select in * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax * produces an RTE, not the implicit join resulting from multiple FROM * items. This is because we only need the RTE to deal with SQL features * like outer joins and join-output-column aliasing.) Other special * RTE types also exist, as indicated by RTEKind. * * alias is an Alias node representing the AS alias-clause attached to the * FROM expression, or NULL if no clause. * * eref is the table reference name and column reference names (either * real or aliases). Note that system columns (OID etc) are not included * in the column list. * eref->aliasname is required to be present, and should generally be used * to identify the RTE for error messages etc. * * inh is TRUE for relation references that should be expanded to include * inheritance children, if the rel has any. This *must* be FALSE for * RTEs other than RTE_RELATION entries. * * inFromCl marks those range variables that are listed in the FROM clause. * In SQL, the query can only refer to range variables listed in the * FROM clause, but POSTQUEL allows you to refer to tables not listed, * in which case a range table entry will be generated. We still support * this POSTQUEL feature, although there is some doubt whether it's * convenient or merely confusing. The flag is needed since an * implicitly-added RTE shouldn't change the namespace for unqualified * column names processed later, and it also shouldn't affect the * expansion of '*'. *
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?