Eneboo - Documentación para desarrolladores
src/libpq/include/nodes/parsenodes.h
Ir a la documentación de este archivo.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * parsenodes.h
00004  *        definitions for parse tree nodes
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.292.2.1 2005/11/22 18:23:28 momjian Exp $
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef PARSENODES_H
00015 #define PARSENODES_H
00016 
00017 #include "nodes/primnodes.h"
00018 
00019 
00020 /* Possible sources of a Query */
00021 typedef enum QuerySource
00022 {
00023         QSRC_ORIGINAL,                          /* original parsetree (explicit query) */
00024         QSRC_PARSER,                            /* added by parse analysis */
00025         QSRC_INSTEAD_RULE,                      /* added by unconditional INSTEAD rule */
00026         QSRC_QUAL_INSTEAD_RULE,         /* added by conditional INSTEAD rule */
00027         QSRC_NON_INSTEAD_RULE           /* added by non-INSTEAD rule */
00028 } QuerySource;
00029 
00030 /*
00031  * Grantable rights are encoded so that we can OR them together in a bitmask.
00032  * The present representation of AclItem limits us to 16 distinct rights,
00033  * even though AclMode is defined as uint32.  See utils/acl.h.
00034  *
00035  * Caution: changing these codes breaks stored ACLs, hence forces initdb.
00036  */
00037 typedef uint32 AclMode;                 /* a bitmask of privilege bits */
00038 
00039 #define ACL_INSERT              (1<<0)  /* for relations */
00040 #define ACL_SELECT              (1<<1)
00041 #define ACL_UPDATE              (1<<2)
00042 #define ACL_DELETE              (1<<3)
00043 #define ACL_RULE                (1<<4)
00044 #define ACL_REFERENCES  (1<<5)
00045 #define ACL_TRIGGER             (1<<6)
00046 #define ACL_EXECUTE             (1<<7)  /* for functions */
00047 #define ACL_USAGE               (1<<8)  /* for languages and namespaces */
00048 #define ACL_CREATE              (1<<9)  /* for namespaces and databases */
00049 #define ACL_CREATE_TEMP (1<<10) /* for databases */
00050 #define N_ACL_RIGHTS    11              /* 1 plus the last 1<<x */
00051 #define ACL_NO_RIGHTS   0
00052 /* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */
00053 #define ACL_SELECT_FOR_UPDATE   ACL_UPDATE
00054 
00055 
00056 /*****************************************************************************
00057  *      Query Tree
00058  *****************************************************************************/
00059 
00060 /*
00061  * Query -
00062  *        all statements are turned into a Query tree (via transformStmt)
00063  *        for further processing by the optimizer
00064  *
00065  *        utility statements (i.e. non-optimizable statements) have the
00066  *        utilityStmt field set, and the Query itself is mostly dummy.
00067  */
00068 typedef struct Query
00069 {
00070         NodeTag         type;
00071 
00072         CmdType         commandType;    /* select|insert|update|delete|utility */
00073 
00074         QuerySource querySource;        /* where did I come from? */
00075 
00076         bool            canSetTag;              /* do I set the command result tag? */
00077 
00078         Node       *utilityStmt;        /* non-null if this is a non-optimizable
00079                                                                  * statement */
00080 
00081         int                     resultRelation; /* target relation (index into rtable) */
00082 
00083         RangeVar   *into;                       /* target relation for SELECT INTO */
00084         bool            intoHasOids;    /* should target relation contain OIDs? */
00085 
00086         bool            hasAggs;                /* has aggregates in tlist or havingQual */
00087         bool            hasSubLinks;    /* has subquery SubLink */
00088 
00089         List       *rtable;                     /* list of range table entries */
00090         FromExpr   *jointree;           /* table join tree (FROM and WHERE clauses) */
00091 
00092         List       *rowMarks;           /* integer list of RT indexes of relations
00093                                                                  * that are selected FOR UPDATE/SHARE */
00094 
00095         bool            forUpdate;              /* true if rowMarks are FOR UPDATE, false if
00096                                                                  * they are FOR SHARE */
00097         bool            rowNoWait;              /* FOR UPDATE/SHARE NOWAIT option */
00098 
00099         List       *targetList;         /* target list (of TargetEntry) */
00100 
00101         List       *groupClause;        /* a list of GroupClause's */
00102 
00103         Node       *havingQual;         /* qualifications applied to groups */
00104 
00105         List       *distinctClause; /* a list of SortClause's */
00106 
00107         List       *sortClause;         /* a list of SortClause's */
00108 
00109         Node       *limitOffset;        /* # of result tuples to skip */
00110         Node       *limitCount;         /* # of result tuples to return */
00111 
00112         Node       *setOperations;      /* set-operation tree if this is top level of
00113                                                                  * a UNION/INTERSECT/EXCEPT query */
00114 
00115         /*
00116          * If the resultRelation turns out to be the parent of an inheritance
00117          * tree, the planner will add all the child tables to the rtable and store
00118          * a list of the rtindexes of all the result relations here. This is done
00119          * at plan time, not parse time, since we don't want to commit to the
00120          * exact set of child tables at parse time.  This field ought to go in
00121          * some sort of TopPlan plan node, not in the Query.
00122          */
00123         List       *resultRelations;    /* integer list of RT indexes, or NIL */
00124 } Query;
00125 
00126 
00127 /****************************************************************************
00128  *      Supporting data structures for Parse Trees
00129  *
00130  *      Most of these node types appear in raw parsetrees output by the grammar,
00131  *      and get transformed to something else by the analyzer.  A few of them
00132  *      are used as-is in transformed querytrees.
00133  ****************************************************************************/
00134 
00135 /*
00136  * TypeName - specifies a type in definitions
00137  *
00138  * For TypeName structures generated internally, it is often easier to
00139  * specify the type by OID than by name.  If "names" is NIL then the
00140  * actual type OID is given by typeid, otherwise typeid is unused.
00141  *
00142  * If pct_type is TRUE, then names is actually a field name and we look up
00143  * the type of that field.      Otherwise (the normal case), names is a type
00144  * name possibly qualified with schema and database name.
00145  */
00146 typedef struct TypeName
00147 {
00148         NodeTag         type;
00149         List       *names;                      /* qualified name (list of Value strings) */
00150         Oid                     typeid;                 /* type identified by OID */
00151         bool            timezone;               /* timezone specified? */
00152         bool            setof;                  /* is a set? */
00153         bool            pct_type;               /* %TYPE specified? */
00154         int32           typmod;                 /* type modifier */
00155         List       *arrayBounds;        /* array bounds */
00156 } TypeName;
00157 
00158 /*
00159  * ColumnRef - specifies a reference to a column, or possibly a whole tuple
00160  *
00161  *              The "fields" list must be nonempty; its last component may be "*"
00162  *              instead of a regular field name.
00163  *
00164  * Note: any array subscripting or selection of fields from composite columns
00165  * is represented by an A_Indirection node above the ColumnRef.  However,
00166  * for simplicity in the normal case, initial field selection from a table
00167  * name is represented within ColumnRef and not by adding A_Indirection.
00168  */
00169 typedef struct ColumnRef
00170 {
00171         NodeTag         type;
00172         List       *fields;                     /* field names (list of Value strings) */
00173 } ColumnRef;
00174 
00175 /*
00176  * ParamRef - specifies a $n parameter reference
00177  */
00178 typedef struct ParamRef
00179 {
00180         NodeTag         type;
00181         int                     number;                 /* the number of the parameter */
00182 } ParamRef;
00183 
00184 /*
00185  * A_Expr - infix, prefix, and postfix expressions
00186  */
00187 typedef enum A_Expr_Kind
00188 {
00189         AEXPR_OP,                                       /* normal operator */
00190         AEXPR_AND,                                      /* booleans - name field is unused */
00191         AEXPR_OR,
00192         AEXPR_NOT,
00193         AEXPR_OP_ANY,                           /* scalar op ANY (array) */
00194         AEXPR_OP_ALL,                           /* scalar op ALL (array) */
00195         AEXPR_DISTINCT,                         /* IS DISTINCT FROM - name must be "=" */
00196         AEXPR_NULLIF,                           /* NULLIF - name must be "=" */
00197         AEXPR_OF                                        /* IS (not) OF - name must be "=" or "!=" */
00198 } A_Expr_Kind;
00199 
00200 typedef struct A_Expr
00201 {
00202         NodeTag         type;
00203         A_Expr_Kind kind;                       /* see above */
00204         List       *name;                       /* possibly-qualified name of operator */
00205         Node       *lexpr;                      /* left argument, or NULL if none */
00206         Node       *rexpr;                      /* right argument, or NULL if none */
00207 } A_Expr;
00208 
00209 /*
00210  * A_Const - a constant expression
00211  */
00212 typedef struct A_Const
00213 {
00214         NodeTag         type;
00215         Value           val;                    /* the value (with the tag) */
00216         TypeName   *typename;           /* typecast */
00217 } A_Const;
00218 
00219 /*
00220  * TypeCast - a CAST expression
00221  *
00222  * NOTE: for mostly historical reasons, A_Const parsenodes contain
00223  * room for a TypeName; we only generate a separate TypeCast node if the
00224  * argument to be casted is not a constant.  In theory either representation
00225  * would work, but it is convenient to have the target type immediately
00226  * available while resolving a constant's datatype.
00227  */
00228 typedef struct TypeCast
00229 {
00230         NodeTag         type;
00231         Node       *arg;                        /* the expression being casted */
00232         TypeName   *typename;           /* the target type */
00233 } TypeCast;
00234 
00235 /*
00236  * FuncCall - a function or aggregate invocation
00237  *
00238  * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
00239  * indicates we saw 'foo(DISTINCT ...)'.  In either case, the construct
00240  * *must* be an aggregate call.  Otherwise, it might be either an
00241  * aggregate or some other kind of function.
00242  */
00243 typedef struct FuncCall
00244 {
00245         NodeTag         type;
00246         List       *funcname;           /* qualified name of function */
00247         List       *args;                       /* the arguments (list of exprs) */
00248         bool            agg_star;               /* argument was really '*' */
00249         bool            agg_distinct;   /* arguments were labeled DISTINCT */
00250 } FuncCall;
00251 
00252 /*
00253  * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
00254  */
00255 typedef struct A_Indices
00256 {
00257         NodeTag         type;
00258         Node       *lidx;                       /* could be NULL */
00259         Node       *uidx;
00260 } A_Indices;
00261 
00262 /*
00263  * A_Indirection - select a field and/or array element from an expression
00264  *
00265  * The indirection list can contain both A_Indices nodes (representing
00266  * subscripting) and string Value nodes (representing field selection
00267  * --- the string value is the name of the field to select).  For example,
00268  * a complex selection operation like
00269  *                              (foo).field1[42][7].field2
00270  * would be represented with a single A_Indirection node having a 4-element
00271  * indirection list.
00272  *
00273  * Note: as of Postgres 8.0, we don't support arrays of composite values,
00274  * so cases in which a field select follows a subscript aren't actually
00275  * semantically legal.  However the parser is prepared to handle such.
00276  */
00277 typedef struct A_Indirection
00278 {
00279         NodeTag         type;
00280         Node       *arg;                        /* the thing being selected from */
00281         List       *indirection;        /* subscripts and/or field names */
00282 } A_Indirection;
00283 
00284 /*
00285  * ResTarget -
00286  *        result target (used in target list of pre-transformed parse trees)
00287  *
00288  * In a SELECT or INSERT target list, 'name' is the column label from an
00289  * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
00290  * value expression itself.  The 'indirection' field is not used.
00291  *
00292  * INSERT has a second ResTarget list which is the target-column-names list.
00293  * Here, 'val' is not used, 'name' is the name of the destination column,
00294  * and 'indirection' stores any subscripts attached to the destination.
00295  *
00296  * In an UPDATE target list, 'name' is the name of the destination column,
00297  * 'indirection' stores any subscripts attached to the destination, and
00298  * 'val' is the expression to assign.
00299  *
00300  * See A_Indirection for more info about what can appear in 'indirection'.
00301  */
00302 typedef struct ResTarget
00303 {
00304         NodeTag         type;
00305         char       *name;                       /* column name or NULL */
00306         List       *indirection;        /* subscripts and field names, or NIL */
00307         Node       *val;                        /* the value expression to compute or assign */
00308 } ResTarget;
00309 
00310 /*
00311  * SortBy - for ORDER BY clause
00312  */
00313 #define SORTBY_ASC              1
00314 #define SORTBY_DESC             2
00315 #define SORTBY_USING    3
00316 
00317 typedef struct SortBy
00318 {
00319         NodeTag         type;
00320         int                     sortby_kind;    /* see codes above */
00321         List       *useOp;                      /* name of op to use, if SORTBY_USING */
00322         Node       *node;                       /* expression to sort on */
00323 } SortBy;
00324 
00325 /*
00326  * RangeSubselect - subquery appearing in a FROM clause
00327  */
00328 typedef struct RangeSubselect
00329 {
00330         NodeTag         type;
00331         Node       *subquery;           /* the untransformed sub-select clause */
00332         Alias      *alias;                      /* table alias & optional column aliases */
00333 } RangeSubselect;
00334 
00335 /*
00336  * RangeFunction - function call appearing in a FROM clause
00337  */
00338 typedef struct RangeFunction
00339 {
00340         NodeTag         type;
00341         Node       *funccallnode;       /* untransformed function call tree */
00342         Alias      *alias;                      /* table alias & optional column aliases */
00343         List       *coldeflist;         /* list of ColumnDef nodes for runtime
00344                                                                  * assignment of RECORD TupleDesc */
00345 } RangeFunction;
00346 
00347 /*
00348  * ColumnDef - column definition (used in various creates)
00349  *
00350  * If the column has a default value, we may have the value expression
00351  * in either "raw" form (an untransformed parse tree) or "cooked" form
00352  * (the nodeToString representation of an executable expression tree),
00353  * depending on how this ColumnDef node was created (by parsing, or by
00354  * inheritance from an existing relation).      We should never have both
00355  * in the same node!
00356  *
00357  * The constraints list may contain a CONSTR_DEFAULT item in a raw
00358  * parsetree produced by gram.y, but transformCreateStmt will remove
00359  * the item and set raw_default instead.  CONSTR_DEFAULT items
00360  * should not appear in any subsequent processing.
00361  *
00362  * The "support" field, if not null, denotes a supporting relation that
00363  * should be linked by an internal dependency to the column.  Currently
00364  * this is only used to link a SERIAL column's sequence to the column.
00365  */
00366 typedef struct ColumnDef
00367 {
00368         NodeTag         type;
00369         char       *colname;            /* name of column */
00370         TypeName   *typename;           /* type of column */
00371         int                     inhcount;               /* number of times column is inherited */
00372         bool            is_local;               /* column has local (non-inherited) def'n */
00373         bool            is_not_null;    /* NOT NULL constraint specified? */
00374         Node       *raw_default;        /* default value (untransformed parse tree) */
00375         char       *cooked_default; /* nodeToString representation */
00376         List       *constraints;        /* other constraints on column */
00377         RangeVar   *support;            /* supporting relation, if any */
00378 } ColumnDef;
00379 
00380 /*
00381  * inhRelation - Relations a CREATE TABLE is to inherit attributes of
00382  */
00383 typedef struct InhRelation
00384 {
00385         NodeTag         type;
00386         RangeVar   *relation;
00387         bool            including_defaults;
00388 } InhRelation;
00389 
00390 /*
00391  * IndexElem - index parameters (used in CREATE INDEX)
00392  *
00393  * For a plain index attribute, 'name' is the name of the table column to
00394  * index, and 'expr' is NULL.  For an index expression, 'name' is NULL and
00395  * 'expr' is the expression tree.
00396  */
00397 typedef struct IndexElem
00398 {
00399         NodeTag         type;
00400         char       *name;                       /* name of attribute to index, or NULL */
00401         Node       *expr;                       /* expression to index, or NULL */
00402         List       *opclass;            /* name of desired opclass; NIL = default */
00403 } IndexElem;
00404 
00405 /*
00406  * DefElem -
00407  *        a definition (used in definition lists in the form of defname = arg)
00408  */
00409 typedef struct DefElem
00410 {
00411         NodeTag         type;
00412         char       *defname;
00413         Node       *arg;                        /* a (Value *) or a (TypeName *) */
00414 } DefElem;
00415 
00416 /*
00417  * LockingClause - raw representation of FOR UPDATE/SHARE options
00418  *
00419  * Note: lockedRels == NIL means "all relations in query".      Otherwise it
00420  * is a list of String nodes giving relation eref names.
00421  */
00422 typedef struct LockingClause
00423 {
00424         NodeTag         type;
00425         List       *lockedRels;         /* FOR UPDATE or FOR SHARE relations */
00426         bool            forUpdate;              /* true = FOR UPDATE, false = FOR SHARE */
00427         bool            nowait;                 /* NOWAIT option */
00428 } LockingClause;
00429 
00430 
00431 /****************************************************************************
00432  *      Nodes for a Query tree
00433  ****************************************************************************/
00434 
00435 /*--------------------
00436  * RangeTblEntry -
00437  *        A range table is a List of RangeTblEntry nodes.
00438  *
00439  *        A range table entry may represent a plain relation, a sub-select in
00440  *        FROM, or the result of a JOIN clause.  (Only explicit JOIN syntax
00441  *        produces an RTE, not the implicit join resulting from multiple FROM
00442  *        items.  This is because we only need the RTE to deal with SQL features
00443  *        like outer joins and join-output-column aliasing.)  Other special
00444  *        RTE types also exist, as indicated by RTEKind.
00445  *
00446  *        alias is an Alias node representing the AS alias-clause attached to the
00447  *        FROM expression, or NULL if no clause.
00448  *
00449  *        eref is the table reference name and column reference names (either
00450  *        real or aliases).  Note that system columns (OID etc) are not included
00451  *        in the column list.
00452  *        eref->aliasname is required to be present, and should generally be used
00453  *        to identify the RTE for error messages etc.
00454  *
00455  *        In RELATION RTEs, the colnames in both alias and eref are indexed by
00456  *        physical attribute number; this means there must be colname entries for
00457  *        dropped columns.      When building an RTE we insert empty strings ("") for
00458  *        dropped columns.      Note however that a stored rule may have nonempty
00459  *        colnames for columns dropped since the rule was created (and for that
00460  *        matter the colnames might be out of date due to column renamings).
00461  *        The same comments apply to FUNCTION RTEs when the function's return type
00462  *        is a named composite type.
00463  *
00464  *        In JOIN RTEs, the colnames in both alias and eref are one-to-one with
00465  *        joinaliasvars entries.  A JOIN RTE will omit columns of its inputs when
00466  *        those columns are known to be dropped at parse time.  Again, however,
00467  *        a stored rule might contain entries for columns dropped since the rule
00468  *        was created.  (This is only possible for columns not actually referenced
00469  *        in the rule.)  When loading a stored rule, we replace the joinaliasvars
00470  *        items for any such columns with NULL Consts.  (We can't simply delete
00471  *        them from the joinaliasvars list, because that would affect the attnums
00472  *        of Vars referencing the rest of the list.)
00473  *
00474  *        inh is TRUE for relation references that should be expanded to include
00475  *        inheritance children, if the rel has any.  This *must* be FALSE for
00476  *        RTEs other than RTE_RELATION entries.
00477  *
00478  *        inFromCl marks those range variables that are listed in the FROM clause.
00479  *        It's false for RTEs that are added to a query behind the scenes, such
00480  *        as the NEW and OLD variables for a rule, or the subqueries of a UNION.
00481  *        This flag is not used anymore during parsing, since the parser now uses
00482  *        a separate "namespace" data structure to control visibility, but it is
00483  *        needed by ruleutils.c to determine whether RTEs should be shown in
00484  *        decompiled queries.
00485  *
00486  *        requiredPerms and checkAsUser specify run-time access permissions
00487  *        checks to be performed at query startup.      The user must have *all*
00488  *        of the permissions that are OR'd together in requiredPerms (zero
00489  *        indicates no permissions checking).  If checkAsUser is not zero,
00490  *        then do the permissions checks using the access rights of that user,
00491  *        not the current effective user ID.  (This allows rules to act as
00492  *        setuid gateways.)
00493  *--------------------
00494  */
00495 typedef enum RTEKind
00496 {
00497         RTE_RELATION,                           /* ordinary relation reference */
00498         RTE_SUBQUERY,                           /* subquery in FROM */
00499         RTE_JOIN,                                       /* join */
00500         RTE_SPECIAL,                            /* special rule relation (NEW or OLD) */
00501         RTE_FUNCTION                            /* function in FROM */
00502 } RTEKind;
00503 
00504 typedef struct RangeTblEntry
00505 {
00506         NodeTag         type;
00507 
00508         RTEKind         rtekind;                /* see above */
00509 
00510         /*
00511          * XXX the fields applicable to only some rte kinds should be merged into
00512          * a union.  I didn't do this yet because the diffs would impact a lot of
00513          * code that is being actively worked on.  FIXME later.
00514          */
00515 
00516         /*
00517          * Fields valid for a plain relation RTE (else zero):
00518          */
00519         Oid                     relid;                  /* OID of the relation */
00520 
00521         /*
00522          * Fields valid for a subquery RTE (else NULL):
00523          */
00524         Query      *subquery;           /* the sub-query */
00525 
00526         /*
00527          * Fields valid for a function RTE (else NULL):
00528          */
00529         Node       *funcexpr;           /* expression tree for func call */
00530         List       *coldeflist;         /* list of ColumnDef nodes for runtime
00531                                                                  * assignment of RECORD TupleDesc */
00532 
00533         /*
00534          * Fields valid for a join RTE (else NULL/zero):
00535          *
00536          * joinaliasvars is a list of Vars or COALESCE expressions corresponding
00537          * to the columns of the join result.  An alias Var referencing column K
00538          * of the join result can be replaced by the K'th element of joinaliasvars
00539          * --- but to simplify the task of reverse-listing aliases correctly, we
00540          * do not do that until planning time.  In a Query loaded from a stored
00541          * rule, it is also possible for joinaliasvars items to be NULL Consts,
00542          * denoting columns dropped since the rule was made.
00543          */
00544         JoinType        jointype;               /* type of join */
00545         List       *joinaliasvars;      /* list of alias-var expansions */
00546 
00547         /*
00548          * Fields valid in all RTEs:
00549          */
00550         Alias      *alias;                      /* user-written alias clause, if any */
00551         Alias      *eref;                       /* expanded reference names */
00552         bool            inh;                    /* inheritance requested? */
00553         bool            inFromCl;               /* present in FROM clause? */
00554         AclMode         requiredPerms;  /* bitmask of required access permissions */
00555         Oid                     checkAsUser;    /* if valid, check access as this role */
00556 } RangeTblEntry;
00557 
00558 /*
00559  * SortClause -
00560  *         representation of ORDER BY clauses
00561  *
00562  * tleSortGroupRef must match ressortgroupref of exactly one entry of the
00563  * associated targetlist; that is the expression to be sorted (or grouped) by.
00564  * sortop is the OID of the ordering operator.
00565  *
00566  * SortClauses are also used to identify targets that we will do a "Unique"
00567  * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON).  The
00568  * distinctClause list is simply a copy of the relevant members of the
00569  * sortClause list.  Note that distinctClause can be a subset of sortClause,
00570  * but cannot have members not present in sortClause; and the members that
00571  * do appear must be in the same order as in sortClause.
00572  */
00573 typedef struct SortClause
00574 {
00575         NodeTag         type;
00576         Index           tleSortGroupRef;        /* reference into targetlist */
00577         Oid                     sortop;                 /* the sort operator to use */
00578 } SortClause;
00579 
00580 /*
00581  * GroupClause -
00582  *         representation of GROUP BY clauses
00583  *
00584  * GroupClause is exactly like SortClause except for the nodetag value
00585  * (it's probably not even really necessary to have two different
00586  * nodetags...).  We have routines that operate interchangeably on both.
00587  */
00588 typedef SortClause GroupClause;
00589 
00590 
00591 /*****************************************************************************
00592  *              Optimizable Statements
00593  *****************************************************************************/
00594 
00595 /* ----------------------
00596  *              Insert Statement
00597  * ----------------------
00598  */
00599 typedef struct InsertStmt
00600 {
00601         NodeTag         type;
00602         RangeVar   *relation;           /* relation to insert into */
00603         List       *cols;                       /* optional: names of the target columns */
00604 
00605         /*
00606          * An INSERT statement has *either* VALUES or SELECT, never both. If
00607          * VALUES, a targetList is supplied (empty for DEFAULT VALUES). If SELECT,
00608          * a complete SelectStmt (or set-operation tree) is supplied.
00609          */
00610         List       *targetList;         /* the target list (of ResTarget) */
00611         Node       *selectStmt;         /* the source SELECT */
00612 } InsertStmt;
00613 
00614 /* ----------------------
00615  *              Delete Statement
00616  * ----------------------
00617  */
00618 typedef struct DeleteStmt
00619 {
00620         NodeTag         type;
00621         RangeVar   *relation;           /* relation to delete from */
00622         Node       *whereClause;        /* qualifications */
00623         List       *usingClause;        /* optional using clause for more tables */
00624 } DeleteStmt;
00625 
00626 /* ----------------------
00627  *              Update Statement
00628  * ----------------------
00629  */
00630 typedef struct UpdateStmt
00631 {
00632         NodeTag         type;
00633         RangeVar   *relation;           /* relation to update */
00634         List       *targetList;         /* the target list (of ResTarget) */
00635         Node       *whereClause;        /* qualifications */
00636         List       *fromClause;         /* optional from clause for more tables */
00637 } UpdateStmt;
00638 
00639 /* ----------------------
00640  *              Select Statement
00641  *
00642  * A "simple" SELECT is represented in the output of gram.y by a single
00643  * SelectStmt node.  A SELECT construct containing set operators (UNION,
00644  * INTERSECT, EXCEPT) is represented by a tree of SelectStmt nodes, in
00645  * which the leaf nodes are component SELECTs and the internal nodes
00646  * represent UNION, INTERSECT, or EXCEPT operators.  Using the same node
00647  * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
00648  * LIMIT, etc, clause values into a SELECT statement without worrying
00649  * whether it is a simple or compound SELECT.
00650  * ----------------------
00651  */
00652 typedef enum SetOperation
00653 {
00654         SETOP_NONE = 0,
00655         SETOP_UNION,
00656         SETOP_INTERSECT,
00657         SETOP_EXCEPT
00658 } SetOperation;
00659 
00660 typedef enum ContainsOids
00661 {
00662         MUST_HAVE_OIDS,                         /* WITH OIDS explicitely specified */
00663         MUST_NOT_HAVE_OIDS,                     /* WITHOUT OIDS explicitely specified */
00664         DEFAULT_OIDS                            /* neither specified; use the default, which
00665                                                                  * is the value of the default_with_oids GUC
00666                                                                  * var */
00667 } ContainsOids;
00668 
00669 typedef struct SelectStmt
00670 {
00671         NodeTag         type;
00672 
00673         /*
00674          * These fields are used only in "leaf" SelectStmts.
00675          *
00676          * into, intoColNames and intoHasOids are a kluge; they belong somewhere
00677          * else...
00678          */
00679         List       *distinctClause; /* NULL, list of DISTINCT ON exprs, or
00680                                                                  * lcons(NIL,NIL) for all (SELECT DISTINCT) */
00681         RangeVar   *into;                       /* target table (for select into table) */
00682         List       *intoColNames;       /* column names for into table */
00683         ContainsOids intoHasOids;       /* should target table have OIDs? */
00684         List       *targetList;         /* the target list (of ResTarget) */
00685         List       *fromClause;         /* the FROM clause */
00686         Node       *whereClause;        /* WHERE qualification */
00687         List       *groupClause;        /* GROUP BY clauses */
00688         Node       *havingClause;       /* HAVING conditional-expression */
00689 
00690         /*
00691          * These fields are used in both "leaf" SelectStmts and upper-level
00692          * SelectStmts.
00693          */
00694         List       *sortClause;         /* sort clause (a list of SortBy's) */
00695         Node       *limitOffset;        /* # of result tuples to skip */
00696         Node       *limitCount;         /* # of result tuples to return */
00697         LockingClause *lockingClause;           /* FOR UPDATE/FOR SHARE */
00698 
00699         /*
00700          * These fields are used only in upper-level SelectStmts.
00701          */
00702         SetOperation op;                        /* type of set op */
00703         bool            all;                    /* ALL specified? */
00704         struct SelectStmt *larg;        /* left child */
00705         struct SelectStmt *rarg;        /* right child */
00706         /* Eventually add fields for CORRESPONDING spec here */
00707 } SelectStmt;
00708 
00709 
00710 /* ----------------------
00711  *              Set Operation node for post-analysis query trees
00712  *
00713  * After parse analysis, a SELECT with set operations is represented by a
00714  * top-level Query node containing the leaf SELECTs as subqueries in its
00715  * range table.  Its setOperations field shows the tree of set operations,
00716  * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
00717  * nodes replaced by SetOperationStmt nodes.
00718  * ----------------------
00719  */
00720 typedef struct SetOperationStmt
00721 {
00722         NodeTag         type;
00723         SetOperation op;                        /* type of set op */
00724         bool            all;                    /* ALL specified? */
00725         Node       *larg;                       /* left child */
00726         Node       *rarg;                       /* right child */
00727         /* Eventually add fields for CORRESPONDING spec here */
00728 
00729         /* Fields derived during parse analysis: */
00730         List       *colTypes;           /* list of OIDs of output column types */
00731 } SetOperationStmt;
00732 
00733 
00734 /*****************************************************************************
00735  *              Other Statements (no optimizations required)
00736  *
00737  *              Some of them require a little bit of transformation (which is also
00738  *              done by transformStmt). The whole structure is then passed on to
00739  *              ProcessUtility (by-passing the optimization step) as the utilityStmt
00740  *              field in Query.
00741  *****************************************************************************/
00742 
00743 /*
00744  * When a command can act on several kinds of objects with only one
00745  * parse structure required, use these constants to designate the
00746  * object type.
00747  */
00748 
00749 typedef enum ObjectType
00750 {
00751         OBJECT_AGGREGATE,
00752         OBJECT_CAST,
00753         OBJECT_COLUMN,
00754         OBJECT_CONSTRAINT,
00755         OBJECT_CONVERSION,
00756         OBJECT_DATABASE,
00757         OBJECT_DOMAIN,
00758         OBJECT_FUNCTION,
00759         OBJECT_INDEX,
00760         OBJECT_LANGUAGE,
00761         OBJECT_LARGEOBJECT,
00762         OBJECT_OPCLASS,
00763         OBJECT_OPERATOR,
00764         OBJECT_ROLE,
00765         OBJECT_RULE,
00766         OBJECT_SCHEMA,
00767         OBJECT_SEQUENCE,
00768         OBJECT_TABLE,
00769         OBJECT_TABLESPACE,
00770         OBJECT_TRIGGER,
00771         OBJECT_TYPE,
00772         OBJECT_VIEW
00773 } ObjectType;
00774 
00775 /* ----------------------
00776  *              Create Schema Statement
00777  *
00778  * NOTE: the schemaElts list contains raw parsetrees for component statements
00779  * of the schema, such as CREATE TABLE, GRANT, etc.  These are analyzed and
00780  * executed after the schema itself is created.
00781  * ----------------------
00782  */
00783 typedef struct CreateSchemaStmt
00784 {
00785         NodeTag         type;
00786         char       *schemaname;         /* the name of the schema to create */
00787         char       *authid;                     /* the owner of the created schema */
00788         List       *schemaElts;         /* schema components (list of parsenodes) */
00789 } CreateSchemaStmt;
00790 
00791 typedef enum DropBehavior
00792 {
00793         DROP_RESTRICT,                          /* drop fails if any dependent objects */
00794         DROP_CASCADE                            /* remove dependent objects too */
00795 } DropBehavior;
00796 
00797 /* ----------------------
00798  *      Alter Table
00799  * ----------------------
00800  */
00801 typedef struct AlterTableStmt
00802 {
00803         NodeTag         type;
00804         RangeVar   *relation;           /* table to work on */
00805         List       *cmds;                       /* list of subcommands */
00806         ObjectType      relkind;                /* type of object */
00807 } AlterTableStmt;
00808 
00809 typedef enum AlterTableType
00810 {
00811         AT_AddColumn,                           /* add column */
00812         AT_ColumnDefault,                       /* alter column default */
00813         AT_DropNotNull,                         /* alter column drop not null */
00814         AT_SetNotNull,                          /* alter column set not null */
00815         AT_SetStatistics,                       /* alter column statistics */
00816         AT_SetStorage,                          /* alter column storage */
00817         AT_DropColumn,                          /* drop column */
00818         AT_DropColumnRecurse,           /* internal to commands/tablecmds.c */
00819         AT_AddIndex,                            /* add index */
00820         AT_ReAddIndex,                          /* internal to commands/tablecmds.c */
00821         AT_AddConstraint,                       /* add constraint */
00822         AT_ProcessedConstraint,         /* pre-processed add constraint (local in
00823                                                                  * parser/analyze.c) */
00824         AT_DropConstraint,                      /* drop constraint */
00825         AT_DropConstraintQuietly,       /* drop constraint, no error/warning (local in
00826                                                                  * commands/tablecmds.c) */
00827         AT_AlterColumnType,                     /* alter column type */
00828         AT_ToastTable,                          /* create toast table */
00829         AT_ChangeOwner,                         /* change owner */
00830         AT_ClusterOn,                           /* CLUSTER ON */
00831         AT_DropCluster,                         /* SET WITHOUT CLUSTER */
00832         AT_DropOids,                            /* SET WITHOUT OIDS */
00833         AT_SetTableSpace,                       /* SET TABLESPACE */
00834         AT_EnableTrig,                          /* ENABLE TRIGGER name */
00835         AT_DisableTrig,                         /* DISABLE TRIGGER name */
00836         AT_EnableTrigAll,                       /* ENABLE TRIGGER ALL */
00837         AT_DisableTrigAll,                      /* DISABLE TRIGGER ALL */
00838         AT_EnableTrigUser,                      /* ENABLE TRIGGER USER */
00839         AT_DisableTrigUser                      /* DISABLE TRIGGER USER */
00840 } AlterTableType;
00841 
00842 typedef struct AlterTableCmd    /* one subcommand of an ALTER TABLE */
00843 {
00844         NodeTag         type;
00845         AlterTableType subtype;         /* Type of table alteration to apply */
00846         char       *name;                       /* column, constraint, or trigger to act on,
00847                                                                  * or new owner or tablespace */
00848         Node       *def;                        /* definition of new column, column type,
00849                                                                  * index, or constraint */
00850         Node       *transform;          /* transformation expr for ALTER TYPE */
00851         DropBehavior behavior;          /* RESTRICT or CASCADE for DROP cases */
00852 } AlterTableCmd;
00853 
00854 
00855 /* ----------------------
00856  *      Alter Domain
00857  *
00858  * The fields are used in different ways by the different variants of
00859  * this command.
00860  * ----------------------
00861  */
00862 typedef struct AlterDomainStmt
00863 {
00864         NodeTag         type;
00865         char            subtype;                /*------------
00866                                                                  *      T = alter column default
00867                                                                  *      N = alter column drop not null
00868                                                                  *      O = alter column set not null
00869                                                                  *      C = add constraint
00870                                                                  *      X = drop constraint
00871                                                                  *------------
00872                                                                  */
00873         List       *typename;           /* domain to work on */
00874         char       *name;                       /* column or constraint name to act on */
00875         Node       *def;                        /* definition of default or constraint */
00876         DropBehavior behavior;          /* RESTRICT or CASCADE for DROP cases */
00877 } AlterDomainStmt;
00878 
00879 
00880 /* ----------------------
00881  *              Grant|Revoke Statement
00882  * ----------------------
00883  */
00884 typedef enum GrantObjectType
00885 {
00886         ACL_OBJECT_RELATION,            /* table, view, sequence */
00887         ACL_OBJECT_DATABASE,            /* database */
00888         ACL_OBJECT_FUNCTION,            /* function */
00889         ACL_OBJECT_LANGUAGE,            /* procedural language */
00890         ACL_OBJECT_NAMESPACE,           /* namespace */
00891         ACL_OBJECT_TABLESPACE           /* tablespace */
00892 } GrantObjectType;
00893 
00894 typedef struct GrantStmt
00895 {
00896         NodeTag         type;
00897         bool            is_grant;               /* true = GRANT, false = REVOKE */
00898         GrantObjectType objtype;        /* kind of object being operated on */
00899         List       *objects;            /* list of RangeVar nodes, FuncWithArgs nodes,
00900                                                                  * or plain names (as Value strings) */
00901         List       *privileges;         /* list of privilege names (as Strings) */
00902         /* privileges == NIL denotes "all privileges" */
00903         List       *grantees;           /* list of PrivGrantee nodes */
00904         bool            grant_option;   /* grant or revoke grant option */
00905         DropBehavior behavior;          /* drop behavior (for REVOKE) */
00906 } GrantStmt;
00907 
00908 typedef struct PrivGrantee
00909 {
00910         NodeTag         type;
00911         char       *rolname;            /* if NULL then PUBLIC */
00912 } PrivGrantee;
00913 
00914 /*
00915  * Note: FuncWithArgs carries only the types of the input parameters of the
00916  * function.  So it is sufficient to identify an existing function, but it
00917  * is not enough info to define a function nor to call it.
00918  */
00919 typedef struct FuncWithArgs
00920 {
00921         NodeTag         type;
00922         List       *funcname;           /* qualified name of function */
00923         List       *funcargs;           /* list of Typename nodes */
00924 } FuncWithArgs;
00925 
00926 /* This is only used internally in gram.y. */
00927 typedef struct PrivTarget
00928 {
00929         NodeTag         type;
00930         GrantObjectType objtype;
00931         List       *objs;
00932 } PrivTarget;
00933 
00934 /* ----------------------
00935  *              Grant/Revoke Role Statement
00936  *
00937  * Note: the lists of roles are lists of names, as Value strings
00938  * ----------------------
00939  */
00940 typedef struct GrantRoleStmt
00941 {
00942         NodeTag         type;
00943         List       *granted_roles;      /* list of roles to be granted/revoked */
00944         List       *grantee_roles;      /* list of member roles to add/delete */
00945         bool            is_grant;               /* true = GRANT, false = REVOKE */
00946         bool            admin_opt;              /* with admin option */
00947         char       *grantor;            /* set grantor to other than current role */
00948         DropBehavior behavior;          /* drop behavior (for REVOKE) */
00949 } GrantRoleStmt;
00950 
00951 /* ----------------------
00952  *              Copy Statement
00953  * ----------------------
00954  */
00955 typedef struct CopyStmt
00956 {
00957         NodeTag         type;
00958         RangeVar   *relation;           /* the relation to copy */
00959         List       *attlist;            /* List of column names (as Strings), or NIL
00960                                                                  * for all columns */
00961         bool            is_from;                /* TO or FROM */
00962         char       *filename;           /* if NULL, use stdin/stdout */
00963         List       *options;            /* List of DefElem nodes */
00964 } CopyStmt;
00965 
00966 /* ----------------------
00967  *              Create Table Statement
00968  *
00969  * NOTE: in the raw gram.y output, ColumnDef, Constraint, and FkConstraint
00970  * nodes are intermixed in tableElts, and constraints is NIL.  After parse
00971  * analysis, tableElts contains just ColumnDefs, and constraints contains
00972  * just Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
00973  * implementation).
00974  * ----------------------
00975  */
00976 
00977 /* What to do at commit time for temporary relations */
00978 typedef enum OnCommitAction
00979 {
00980         ONCOMMIT_NOOP,                          /* No ON COMMIT clause (do nothing) */
00981         ONCOMMIT_PRESERVE_ROWS,         /* ON COMMIT PRESERVE ROWS (do nothing) */
00982         ONCOMMIT_DELETE_ROWS,           /* ON COMMIT DELETE ROWS */
00983         ONCOMMIT_DROP                           /* ON COMMIT DROP */
00984 } OnCommitAction;
00985 
00986 typedef struct CreateStmt
00987 {
00988         NodeTag         type;
00989         RangeVar   *relation;           /* relation to create */
00990         List       *tableElts;          /* column definitions (list of ColumnDef) */
00991         List       *inhRelations;       /* relations to inherit from (list of
00992                                                                  * inhRelation) */
00993         List       *constraints;        /* constraints (list of Constraint nodes) */
00994         ContainsOids hasoids;           /* should it have OIDs? */
00995         OnCommitAction oncommit;        /* what do we do at COMMIT? */
00996         char       *tablespacename; /* table space to use, or NULL */
00997 } CreateStmt;
00998 
00999 /* ----------
01000  * Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt
01001  *
01002  * XXX probably these ought to be unified with FkConstraints at some point?
01003  * To this end we include CONSTR_FOREIGN in the ConstrType enum, even though
01004  * the parser does not generate it.
01005  *
01006  * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
01007  * we may have the expression in either "raw" form (an untransformed
01008  * parse tree) or "cooked" form (the nodeToString representation of
01009  * an executable expression tree), depending on how this Constraint
01010  * node was created (by parsing, or by inheritance from an existing
01011  * relation).  We should never have both in the same node!
01012  *
01013  * Constraint attributes (DEFERRABLE etc) are initially represented as
01014  * separate Constraint nodes for simplicity of parsing.  analyze.c makes
01015  * a pass through the constraints list to attach the info to the appropriate
01016  * FkConstraint node (and, perhaps, someday to other kinds of constraints).
01017  * ----------
01018  */
01019 
01020 typedef enum ConstrType                 /* types of constraints */
01021 {
01022         CONSTR_NULL,                            /* not SQL92, but a lot of people expect it */
01023         CONSTR_NOTNULL,
01024         CONSTR_DEFAULT,
01025         CONSTR_CHECK,
01026         CONSTR_FOREIGN,
01027         CONSTR_PRIMARY,
01028         CONSTR_UNIQUE,
01029         CONSTR_ATTR_DEFERRABLE,         /* attributes for previous constraint node */
01030         CONSTR_ATTR_NOT_DEFERRABLE,
01031         CONSTR_ATTR_DEFERRED,
01032         CONSTR_ATTR_IMMEDIATE
01033 } ConstrType;
01034 
01035 typedef struct Constraint
01036 {
01037         NodeTag         type;
01038         ConstrType      contype;
01039         char       *name;                       /* name, or NULL if unnamed */
01040         Node       *raw_expr;           /* expr, as untransformed parse tree */
01041         char       *cooked_expr;        /* expr, as nodeToString representation */
01042         List       *keys;                       /* String nodes naming referenced column(s) */
01043         char       *indexspace;         /* index tablespace for PKEY/UNIQUE
01044                                                                  * constraints; NULL for default */
01045 } Constraint;
01046 
01047 /* ----------
01048  * Definitions for FOREIGN KEY constraints in CreateStmt
01049  *
01050  * Note: FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
01051  * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
01052  * stored into pg_constraint.confmatchtype.  Changing the code values may
01053  * require an initdb!
01054  *
01055  * If skip_validation is true then we skip checking that the existing rows
01056  * in the table satisfy the constraint, and just install the catalog entries
01057  * for the constraint.  This is currently used only during CREATE TABLE
01058  * (when we know the table must be empty).
01059  * ----------
01060  */
01061 #define FKCONSTR_ACTION_NOACTION        'a'
01062 #define FKCONSTR_ACTION_RESTRICT        'r'
01063 #define FKCONSTR_ACTION_CASCADE         'c'
01064 #define FKCONSTR_ACTION_SETNULL         'n'
01065 #define FKCONSTR_ACTION_SETDEFAULT      'd'
01066 
01067 #define FKCONSTR_MATCH_FULL                     'f'
01068 #define FKCONSTR_MATCH_PARTIAL          'p'
01069 #define FKCONSTR_MATCH_UNSPECIFIED      'u'
01070 
01071 typedef struct FkConstraint
01072 {
01073         NodeTag         type;
01074         char       *constr_name;        /* Constraint name, or NULL if unnamed */
01075         RangeVar   *pktable;            /* Primary key table */
01076         List       *fk_attrs;           /* Attributes of foreign key */
01077         List       *pk_attrs;           /* Corresponding attrs in PK table */
01078         char            fk_matchtype;   /* FULL, PARTIAL, UNSPECIFIED */
01079         char            fk_upd_action;  /* ON UPDATE action */
01080         char            fk_del_action;  /* ON DELETE action */
01081         bool            deferrable;             /* DEFERRABLE */
01082         bool            initdeferred;   /* INITIALLY DEFERRED */
01083         bool            skip_validation;        /* skip validation of existing rows? */
01084 } FkConstraint;
01085 
01086 
01087 /* ----------------------
01088  *              Create/Drop Table Space Statements
01089  * ----------------------
01090  */
01091 
01092 typedef struct CreateTableSpaceStmt
01093 {
01094         NodeTag         type;
01095         char       *tablespacename;
01096         char       *owner;
01097         char       *location;
01098 } CreateTableSpaceStmt;
01099 
01100 typedef struct DropTableSpaceStmt
01101 {
01102         NodeTag         type;
01103         char       *tablespacename;
01104 } DropTableSpaceStmt;
01105 
01106 /* ----------------------
01107  *              Create/Drop TRIGGER Statements
01108  * ----------------------
01109  */
01110 
01111 typedef struct CreateTrigStmt
01112 {
01113         NodeTag         type;
01114         char       *trigname;           /* TRIGGER's name */
01115         RangeVar   *relation;           /* relation trigger is on */
01116         List       *funcname;           /* qual. name of function to call */
01117         List       *args;                       /* list of (T_String) Values or NIL */
01118         bool            before;                 /* BEFORE/AFTER */
01119         bool            row;                    /* ROW/STATEMENT */
01120         char            actions[4];             /* 1 to 3 of 'i', 'u', 'd', + trailing \0 */
01121 
01122         /* The following are used for referential */
01123         /* integrity constraint triggers */
01124         bool            isconstraint;   /* This is an RI trigger */
01125         bool            deferrable;             /* [NOT] DEFERRABLE */
01126         bool            initdeferred;   /* INITIALLY {DEFERRED|IMMEDIATE} */
01127         RangeVar   *constrrel;          /* opposite relation */
01128 } CreateTrigStmt;
01129 
01130 /* ----------------------
01131  *              Create/Drop PROCEDURAL LANGUAGE Statement
01132  * ----------------------
01133  */
01134 typedef struct CreatePLangStmt
01135 {
01136         NodeTag         type;
01137         char       *plname;                     /* PL name */
01138         List       *plhandler;          /* PL call handler function (qual. name) */
01139         List       *plvalidator;        /* optional validator function (qual. name) */
01140         bool            pltrusted;              /* PL is trusted */
01141 } CreatePLangStmt;
01142 
01143 typedef struct DropPLangStmt
01144 {
01145         NodeTag         type;
01146         char       *plname;                     /* PL name */
01147         DropBehavior behavior;          /* RESTRICT or CASCADE behavior */
01148 } DropPLangStmt;
01149 
01150 /* ----------------------
01151  *      Create/Alter/Drop Role Statements
01152  *
01153  * Note: these node types are also used for the backwards-compatible
01154  * Create/Alter/Drop User/Group statements.  In the ALTER and DROP cases
01155  * there's really no need to distinguish what the original spelling was,
01156  * but for CREATE we mark the type because the defaults vary.
01157  * ----------------------
01158  */
01159 typedef enum RoleStmtType
01160 {
01161         ROLESTMT_ROLE,
01162         ROLESTMT_USER,
01163         ROLESTMT_GROUP
01164 } RoleStmtType;
01165 
01166 typedef struct CreateRoleStmt
01167 {
01168         NodeTag         type;
01169         RoleStmtType stmt_type;         /* ROLE/USER/GROUP */
01170         char       *role;                       /* role name */
01171         List       *options;            /* List of DefElem nodes */
01172 } CreateRoleStmt;
01173 
01174 typedef struct AlterRoleStmt
01175 {
01176         NodeTag         type;
01177         char       *role;                       /* role name */
01178         List       *options;            /* List of DefElem nodes */
01179         int                     action;                 /* +1 = add members, -1 = drop members */
01180 } AlterRoleStmt;
01181 
01182 typedef struct AlterRoleSetStmt
01183 {
01184         NodeTag         type;
01185         char       *role;                       /* role name */
01186         char       *variable;           /* GUC variable name */
01187         List       *value;                      /* value for variable, or NIL for Reset */
01188 } AlterRoleSetStmt;
01189 
01190 typedef struct DropRoleStmt
01191 {
01192         NodeTag         type;
01193         List       *roles;                      /* List of roles to remove */
01194 } DropRoleStmt;
01195 
01196 /* ----------------------
01197  *              {Create|Alter} SEQUENCE Statement
01198  * ----------------------
01199  */
01200 
01201 typedef struct CreateSeqStmt
01202 {
01203         NodeTag         type;
01204         RangeVar   *sequence;           /* the sequence to create */
01205         List       *options;
01206 } CreateSeqStmt;
01207 
01208 typedef struct AlterSeqStmt
01209 {
01210         NodeTag         type;
01211         RangeVar   *sequence;           /* the sequence to alter */
01212         List       *options;
01213 } AlterSeqStmt;
01214 
01215 /* ----------------------
01216  *              Create {Aggregate|Operator|Type} Statement
01217  * ----------------------
01218  */
01219 typedef struct DefineStmt
01220 {
01221         NodeTag         type;
01222         ObjectType      kind;                   /* aggregate, operator, type */
01223         List       *defnames;           /* qualified name (list of Value strings) */
01224         List       *definition;         /* a list of DefElem */
01225 } DefineStmt;
01226 
01227 /* ----------------------
01228  *              Create Domain Statement
01229  * ----------------------
01230  */
01231 typedef struct CreateDomainStmt
01232 {
01233         NodeTag         type;
01234         List       *domainname;         /* qualified name (list of Value strings) */
01235         TypeName   *typename;           /* the base type */
01236         List       *constraints;        /* constraints (list of Constraint nodes) */
01237 } CreateDomainStmt;
01238 
01239 /* ----------------------
01240  *              Create Operator Class Statement
01241  * ----------------------
01242  */
01243 typedef struct CreateOpClassStmt
01244 {
01245         NodeTag         type;
01246         List       *opclassname;        /* qualified name (list of Value strings) */
01247         char       *amname;                     /* name of index AM opclass is for */
01248         TypeName   *datatype;           /* datatype of indexed column */
01249         List       *items;                      /* List of CreateOpClassItem nodes */
01250         bool            isDefault;              /* Should be marked as default for type? */
01251 } CreateOpClassStmt;
01252 
01253 #define OPCLASS_ITEM_OPERATOR           1
01254 #define OPCLASS_ITEM_FUNCTION           2
01255 #define OPCLASS_ITEM_STORAGETYPE        3
01256 
01257 typedef struct CreateOpClassItem
01258 {
01259         NodeTag         type;
01260         int                     itemtype;               /* see codes above */
01261         /* fields used for an operator or function item: */
01262         List       *name;                       /* operator or function name */
01263         List       *args;                       /* argument types */
01264         int                     number;                 /* strategy num or support proc num */
01265         bool            recheck;                /* only used for operators */
01266         /* fields used for a storagetype item: */
01267         TypeName   *storedtype;         /* datatype stored in index */
01268 } CreateOpClassItem;
01269 
01270 /* ----------------------
01271  *              Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
01272  * ----------------------
01273  */
01274 
01275 typedef struct DropStmt
01276 {
01277         NodeTag         type;
01278         List       *objects;            /* list of sublists of names (as Values) */
01279         ObjectType      removeType;             /* object type */
01280         DropBehavior behavior;          /* RESTRICT or CASCADE behavior */
01281 } DropStmt;
01282 
01283 /* ----------------------
01284  *              Drop Rule|Trigger Statement
01285  *
01286  * In general this may be used for dropping any property of a relation;
01287  * for example, someday soon we may have DROP ATTRIBUTE.
01288  * ----------------------
01289  */
01290 
01291 typedef struct DropPropertyStmt
01292 {
01293         NodeTag         type;
01294         RangeVar   *relation;           /* owning relation */
01295         char       *property;           /* name of rule, trigger, etc */
01296         ObjectType      removeType;             /* OBJECT_RULE or OBJECT_TRIGGER */
01297         DropBehavior behavior;          /* RESTRICT or CASCADE behavior */
01298 } DropPropertyStmt;
01299 
01300 /* ----------------------
01301  *                              Truncate Table Statement
01302  * ----------------------
01303  */
01304 typedef struct TruncateStmt
01305 {
01306         NodeTag         type;
01307         List       *relations;          /* relations (RangeVars) to be truncated */
01308 } TruncateStmt;
01309 
01310 /* ----------------------
01311  *                              Comment On Statement
01312  * ----------------------
01313  */
01314 typedef struct CommentStmt
01315 {
01316         NodeTag         type;
01317         ObjectType      objtype;                /* Object's type */
01318         List       *objname;            /* Qualified name of the object */
01319         List       *objargs;            /* Arguments if needed (eg, for functions) */
01320         char       *comment;            /* Comment to insert, or NULL to remove */
01321 } CommentStmt;
01322 
01323 /* ----------------------
01324  *              Declare Cursor Statement
01325  * ----------------------
01326  */
01327 #define CURSOR_OPT_BINARY               0x0001
01328 #define CURSOR_OPT_SCROLL               0x0002
01329 #define CURSOR_OPT_NO_SCROLL    0x0004
01330 #define CURSOR_OPT_INSENSITIVE  0x0008
01331 #define CURSOR_OPT_HOLD                 0x0010
01332 
01333 typedef struct DeclareCursorStmt
01334 {
01335         NodeTag         type;
01336         char       *portalname;         /* name of the portal (cursor) */
01337         int                     options;                /* bitmask of options (see above) */
01338         Node       *query;                      /* the SELECT query */
01339 } DeclareCursorStmt;
01340 
01341 /* ----------------------
01342  *              Close Portal Statement
01343  * ----------------------
01344  */
01345 typedef struct ClosePortalStmt
01346 {
01347         NodeTag         type;
01348         char       *portalname;         /* name of the portal (cursor) */
01349 } ClosePortalStmt;
01350 
01351 /* ----------------------
01352  *              Fetch Statement (also Move)
01353  * ----------------------
01354  */
01355 typedef enum FetchDirection
01356 {
01357         /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
01358         FETCH_FORWARD,
01359         FETCH_BACKWARD,
01360         /* for these, howMany indicates a position; only one row is fetched */
01361         FETCH_ABSOLUTE,
01362         FETCH_RELATIVE
01363 } FetchDirection;
01364 
01365 #define FETCH_ALL       LONG_MAX
01366 
01367 typedef struct FetchStmt
01368 {
01369         NodeTag         type;
01370         FetchDirection direction;       /* see above */
01371         long            howMany;                /* number of rows, or position argument */
01372         char       *portalname;         /* name of portal (cursor) */
01373         bool            ismove;                 /* TRUE if MOVE */
01374 } FetchStmt;
01375 
01376 /* ----------------------
01377  *              Create Index Statement
01378  * ----------------------
01379  */
01380 typedef struct IndexStmt
01381 {
01382         NodeTag         type;
01383         char       *idxname;            /* name of new index, or NULL for default */
01384         RangeVar   *relation;           /* relation to build index on */
01385         char       *accessMethod;       /* name of access method (eg. btree) */
01386         char       *tableSpace;         /* tablespace, or NULL to use parent's */
01387         List       *indexParams;        /* a list of IndexElem */
01388         Node       *whereClause;        /* qualification (partial-index predicate) */
01389         List       *rangetable;         /* range table for qual and/or expressions,
01390                                                                  * filled in by transformStmt() */
01391         bool            unique;                 /* is index unique? */
01392         bool            primary;                /* is index on primary key? */
01393         bool            isconstraint;   /* is it from a CONSTRAINT clause? */
01394 } IndexStmt;
01395 
01396 /* ----------------------
01397  *              Create Function Statement
01398  * ----------------------
01399  */
01400 typedef struct CreateFunctionStmt
01401 {
01402         NodeTag         type;
01403         bool            replace;                /* T => replace if already exists */
01404         List       *funcname;           /* qualified name of function to create */
01405         List       *parameters;         /* a list of FunctionParameter */
01406         TypeName   *returnType;         /* the return type */
01407         List       *options;            /* a list of DefElem */
01408         List       *withClause;         /* a list of DefElem */
01409 } CreateFunctionStmt;
01410 
01411 typedef enum FunctionParameterMode
01412 {
01413         /* the assigned enum values appear in pg_proc, don't change 'em! */
01414         FUNC_PARAM_IN = 'i',            /* input only */
01415         FUNC_PARAM_OUT = 'o',           /* output only */
01416         FUNC_PARAM_INOUT = 'b'          /* both */
01417 } FunctionParameterMode;
01418 
01419 typedef struct FunctionParameter
01420 {
01421         NodeTag         type;
01422         char       *name;                       /* parameter name, or NULL if not given */
01423         TypeName   *argType;            /* TypeName for parameter type */
01424         FunctionParameterMode mode; /* IN/OUT/INOUT */
01425 } FunctionParameter;
01426 
01427 typedef struct AlterFunctionStmt
01428 {
01429         NodeTag         type;
01430         FuncWithArgs *func;                     /* name and args of function */
01431         List       *actions;            /* list of DefElem */
01432 } AlterFunctionStmt;
01433 
01434 /* ----------------------
01435  *              Drop Aggregate Statement
01436  * ----------------------
01437  */
01438 typedef struct RemoveAggrStmt
01439 {
01440         NodeTag         type;
01441         List       *aggname;            /* aggregate to drop */
01442         TypeName   *aggtype;            /* TypeName for input datatype, or NULL */
01443         DropBehavior behavior;          /* RESTRICT or CASCADE behavior */
01444 } RemoveAggrStmt;
01445 
01446 /* ----------------------
01447  *              Drop Function Statement
01448  * ----------------------
01449  */
01450 typedef struct RemoveFuncStmt
01451 {
01452         NodeTag         type;
01453         List       *funcname;           /* function to drop */
01454         List       *args;                       /* types of the arguments */
01455         DropBehavior behavior;          /* RESTRICT or CASCADE behavior */
01456 } RemoveFuncStmt;
01457 
01458 /* ----------------------
01459  *              Drop Operator Statement
01460  * ----------------------
01461  */
01462 typedef struct RemoveOperStmt
01463 {
01464         NodeTag         type;
01465         List       *opname;                     /* operator to drop */
01466         List       *args;                       /* types of the arguments */
01467         DropBehavior behavior;          /* RESTRICT or CASCADE behavior */
01468 } RemoveOperStmt;
01469 
01470 /* ----------------------
01471  *              Drop Operator Class Statement
01472  * ----------------------
01473  */
01474 typedef struct RemoveOpClassStmt
01475 {
01476         NodeTag         type;
01477         List       *opclassname;        /* qualified name (list of Value strings) */
01478         char       *amname;                     /* name of index AM opclass is for */
01479         DropBehavior behavior;          /* RESTRICT or CASCADE behavior */
01480 } RemoveOpClassStmt;
01481 
01482 /* ----------------------
01483  *              Alter Object Rename Statement
01484  * ----------------------
01485  */
01486 typedef struct RenameStmt
01487 {
01488         NodeTag         type;
01489         ObjectType      renameType;             /* OBJECT_TABLE, OBJECT_COLUMN, etc */
01490         RangeVar   *relation;           /* in case it's a table */
01491         List       *object;                     /* in case it's some other object */
01492         List       *objarg;                     /* argument types, if applicable */
01493         char       *subname;            /* name of contained object (column, rule,
01494                                                                  * trigger, etc) */
01495         char       *newname;            /* the new name */
01496 } RenameStmt;
01497 
01498 /* ----------------------
01499  *              ALTER object SET SCHEMA Statement
01500  * ----------------------
01501  */
01502 typedef struct AlterObjectSchemaStmt
01503 {
01504         NodeTag         type;
01505         ObjectType objectType;          /* OBJECT_TABLE, OBJECT_TYPE, etc */
01506         RangeVar   *relation;           /* in case it's a table */
01507         List       *object;                     /* in case it's some other object */
01508         List       *objarg;                     /* argument types, if applicable */
01509         char       *addname;            /* additional name if needed */
01510         char       *newschema;          /* the new schema */
01511 } AlterObjectSchemaStmt;
01512 
01513 /* ----------------------
01514  *              Alter Object Owner Statement
01515  * ----------------------
01516  */
01517 typedef struct AlterOwnerStmt
01518 {
01519         NodeTag         type;
01520         ObjectType objectType;          /* OBJECT_TABLE, OBJECT_TYPE, etc */
01521         RangeVar   *relation;           /* in case it's a table */
01522         List       *object;                     /* in case it's some other object */
01523         List       *objarg;                     /* argument types, if applicable */
01524         char       *addname;            /* additional name if needed */
01525         char       *newowner;           /* the new owner */
01526 } AlterOwnerStmt;
01527 
01528 
01529 /* ----------------------
01530  *              Create Rule Statement
01531  * ----------------------
01532  */
01533 typedef struct RuleStmt
01534 {
01535         NodeTag         type;
01536         RangeVar   *relation;           /* relation the rule is for */
01537         char       *rulename;           /* name of the rule */
01538         Node       *whereClause;        /* qualifications */
01539         CmdType         event;                  /* SELECT, INSERT, etc */
01540         bool            instead;                /* is a 'do instead'? */
01541         List       *actions;            /* the action statements */
01542         bool            replace;                /* OR REPLACE */
01543 } RuleStmt;
01544 
01545 /* ----------------------
01546  *              Notify Statement
01547  * ----------------------
01548  */
01549 typedef struct NotifyStmt
01550 {
01551         NodeTag         type;
01552         RangeVar   *relation;           /* qualified name to notify */
01553 } NotifyStmt;
01554 
01555 /* ----------------------
01556  *              Listen Statement
01557  * ----------------------
01558  */
01559 typedef struct ListenStmt
01560 {
01561         NodeTag         type;
01562         RangeVar   *relation;           /* qualified name to listen on */
01563 } ListenStmt;
01564 
01565 /* ----------------------
01566  *              Unlisten Statement
01567  * ----------------------
01568  */
01569 typedef struct UnlistenStmt
01570 {
01571         NodeTag         type;
01572         RangeVar   *relation;           /* qualified name to unlisten on, or '*' */
01573 } UnlistenStmt;
01574 
01575 /* ----------------------
01576  *              {Begin|Commit|Rollback} Transaction Statement
01577  * ----------------------
01578  */
01579 typedef enum TransactionStmtKind
01580 {
01581         TRANS_STMT_BEGIN,
01582         TRANS_STMT_START,                       /* semantically identical to BEGIN */
01583         TRANS_STMT_COMMIT,
01584         TRANS_STMT_ROLLBACK,
01585         TRANS_STMT_SAVEPOINT,
01586         TRANS_STMT_RELEASE,
01587         TRANS_STMT_ROLLBACK_TO,
01588         TRANS_STMT_PREPARE,
01589         TRANS_STMT_COMMIT_PREPARED,
01590         TRANS_STMT_ROLLBACK_PREPARED
01591 } TransactionStmtKind;
01592 
01593 typedef struct TransactionStmt
01594 {
01595         NodeTag         type;
01596         TransactionStmtKind kind;       /* see above */
01597         List       *options;            /* for BEGIN/START and savepoint commands */
01598         char       *gid;                        /* for two-phase-commit related commands */
01599 } TransactionStmt;
01600 
01601 /* ----------------------
01602  *              Create Type Statement, composite types
01603  * ----------------------
01604  */
01605 typedef struct CompositeTypeStmt
01606 {
01607         NodeTag         type;
01608         RangeVar   *typevar;            /* the composite type to be created */
01609         List       *coldeflist;         /* list of ColumnDef nodes */
01610 } CompositeTypeStmt;
01611 
01612 
01613 /* ----------------------
01614  *              Create View Statement
01615  * ----------------------
01616  */
01617 typedef struct ViewStmt
01618 {
01619         NodeTag         type;
01620         RangeVar   *view;                       /* the view to be created */
01621         List       *aliases;            /* target column names */
01622         Query      *query;                      /* the SQL statement */
01623         bool            replace;                /* replace an existing view? */
01624 } ViewStmt;
01625 
01626 /* ----------------------
01627  *              Load Statement
01628  * ----------------------
01629  */
01630 typedef struct LoadStmt
01631 {
01632         NodeTag         type;
01633         char       *filename;           /* file to load */
01634 } LoadStmt;
01635 
01636 /* ----------------------
01637  *              Createdb Statement
01638  * ----------------------
01639  */
01640 typedef struct CreatedbStmt
01641 {
01642         NodeTag         type;
01643         char       *dbname;                     /* name of database to create */
01644         List       *options;            /* List of DefElem nodes */
01645 } CreatedbStmt;
01646 
01647 /* ----------------------
01648  *      Alter Database
01649  * ----------------------
01650  */
01651 typedef struct AlterDatabaseStmt
01652 {
01653         NodeTag         type;
01654         char       *dbname;                     /* name of database to alter */
01655         List       *options;            /* List of DefElem nodes */
01656 } AlterDatabaseStmt;
01657 
01658 typedef struct AlterDatabaseSetStmt
01659 {
01660         NodeTag         type;
01661         char       *dbname;
01662         char       *variable;
01663         List       *value;
01664 } AlterDatabaseSetStmt;
01665 
01666 /* ----------------------
01667  *              Dropdb Statement
01668  * ----------------------
01669  */
01670 typedef struct DropdbStmt
01671 {
01672         NodeTag         type;
01673         char       *dbname;                     /* database to drop */
01674 } DropdbStmt;
01675 
01676 /* ----------------------
01677  *              Cluster Statement (support pbrown's cluster index implementation)
01678  * ----------------------
01679  */
01680 typedef struct ClusterStmt
01681 {
01682         NodeTag         type;
01683         RangeVar   *relation;           /* relation being indexed, or NULL if all */
01684         char       *indexname;          /* original index defined */
01685 } ClusterStmt;
01686 
01687 /* ----------------------
01688  *              Vacuum and Analyze Statements
01689  *
01690  * Even though these are nominally two statements, it's convenient to use
01691  * just one node type for both.
01692  * ----------------------
01693  */
01694 typedef struct VacuumStmt
01695 {
01696         NodeTag         type;
01697         bool            vacuum;                 /* do VACUUM step */
01698         bool            full;                   /* do FULL (non-concurrent) vacuum */
01699         bool            analyze;                /* do ANALYZE step */
01700         bool            freeze;                 /* early-freeze option */
01701         bool            verbose;                /* print progress info */
01702         RangeVar   *relation;           /* single table to process, or NULL */
01703         List       *va_cols;            /* list of column names, or NIL for all */
01704 } VacuumStmt;
01705 
01706 /* ----------------------
01707  *              Explain Statement
01708  * ----------------------
01709  */
01710 typedef struct ExplainStmt
01711 {
01712         NodeTag         type;
01713         Query      *query;                      /* the query */
01714         bool            verbose;                /* print plan info */
01715         bool            analyze;                /* get statistics by executing plan */
01716 } ExplainStmt;
01717 
01718 /* ----------------------
01719  * Checkpoint Statement
01720  * ----------------------
01721  */
01722 typedef struct CheckPointStmt
01723 {
01724         NodeTag         type;
01725 } CheckPointStmt;
01726 
01727 /* ----------------------
01728  * Set Statement
01729  * ----------------------
01730  */
01731 
01732 typedef struct VariableSetStmt
01733 {
01734         NodeTag         type;
01735         char       *name;
01736         List       *args;
01737         bool            is_local;               /* SET LOCAL */
01738 } VariableSetStmt;
01739 
01740 /* ----------------------
01741  * Show Statement
01742  * ----------------------
01743  */
01744 
01745 typedef struct VariableShowStmt
01746 {
01747         NodeTag         type;
01748         char       *name;
01749 } VariableShowStmt;
01750 
01751 /* ----------------------
01752  * Reset Statement
01753  * ----------------------
01754  */
01755 
01756 typedef struct VariableResetStmt
01757 {
01758         NodeTag         type;
01759         char       *name;
01760 } VariableResetStmt;
01761 
01762 /* ----------------------
01763  *              LOCK Statement
01764  * ----------------------
01765  */
01766 typedef struct LockStmt
01767 {
01768         NodeTag         type;
01769         List       *relations;          /* relations to lock */
01770         int                     mode;                   /* lock mode */
01771         bool            nowait;                 /* no wait mode */
01772 } LockStmt;
01773 
01774 /* ----------------------
01775  *              SET CONSTRAINTS Statement
01776  * ----------------------
01777  */
01778 typedef struct ConstraintsSetStmt
01779 {
01780         NodeTag         type;
01781         List       *constraints;        /* List of names as Value strings */
01782         bool            deferred;
01783 } ConstraintsSetStmt;
01784 
01785 /* ----------------------
01786  *              REINDEX Statement
01787  * ----------------------
01788  */
01789 typedef struct ReindexStmt
01790 {
01791         NodeTag         type;
01792         ObjectType      kind;                   /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */
01793         RangeVar   *relation;           /* Table or index to reindex */
01794         const char *name;                       /* name of database to reindex */
01795         bool            do_system;              /* include system tables in database case */
01796         bool            do_user;                /* include user tables in database case */
01797 } ReindexStmt;
01798 
01799 /* ----------------------
01800  *              CREATE CONVERSION Statement
01801  * ----------------------
01802  */
01803 typedef struct CreateConversionStmt
01804 {
01805         NodeTag         type;
01806         List       *conversion_name;    /* Name of the conversion */
01807         char       *for_encoding_name;          /* source encoding name */
01808         char       *to_encoding_name;           /* destination encoding name */
01809         List       *func_name;          /* qualified conversion function name */
01810         bool            def;                    /* is this a default conversion? */
01811 } CreateConversionStmt;
01812 
01813 /* ----------------------
01814  *      CREATE CAST Statement
01815  * ----------------------
01816  */
01817 typedef struct CreateCastStmt
01818 {
01819         NodeTag         type;
01820         TypeName   *sourcetype;
01821         TypeName   *targettype;
01822         FuncWithArgs *func;
01823         CoercionContext context;
01824 } CreateCastStmt;
01825 
01826 /* ----------------------
01827  *      DROP CAST Statement
01828  * ----------------------
01829  */
01830 typedef struct DropCastStmt
01831 {
01832         NodeTag         type;
01833         TypeName   *sourcetype;
01834         TypeName   *targettype;
01835         DropBehavior behavior;
01836 } DropCastStmt;
01837 
01838 
01839 /* ----------------------
01840  *              PREPARE Statement
01841  * ----------------------
01842  */
01843 typedef struct PrepareStmt
01844 {
01845         NodeTag         type;
01846         char       *name;                       /* Name of plan, arbitrary */
01847         List       *argtypes;           /* Types of parameters (TypeNames) */
01848         List       *argtype_oids;       /* Types of parameters (OIDs) */
01849         Query      *query;                      /* The query itself */
01850 } PrepareStmt;
01851 
01852 
01853 /* ----------------------
01854  *              EXECUTE Statement
01855  * ----------------------
01856  */
01857 
01858 typedef struct ExecuteStmt
01859 {
01860         NodeTag         type;
01861         char       *name;                       /* The name of the plan to execute */
01862         RangeVar   *into;                       /* Optional table to store results in */
01863         List       *params;                     /* Values to assign to parameters */
01864 } ExecuteStmt;
01865 
01866 
01867 /* ----------------------
01868  *              DEALLOCATE Statement
01869  * ----------------------
01870  */
01871 typedef struct DeallocateStmt
01872 {
01873         NodeTag         type;
01874         char       *name;                       /* The name of the plan to remove */
01875 } DeallocateStmt;
01876 
01877 #endif   /* PARSENODES_H */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'