1 /*-------------------------------------------------------------------------
4 * definitions for parse tree nodes
7 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: parsenodes.h,v 1.102 2000/03/14 23:06:47 thomas Exp $
12 *-------------------------------------------------------------------------
17 #include "nodes/primnodes.h"
19 /*****************************************************************************
21 *****************************************************************************/
25 * all statments are turned into a Query tree (via transformStmt)
26 * for further processing by the optimizer
27 * utility statements (i.e. non-optimizable statements)
28 * have the *utilityStmt field set.
30 * we need the isPortal flag because portal names can be null too; can
31 * get rid of it if we support CURSOR as a commandType.
38 CmdType commandType; /* select|insert|update|delete|utility */
40 Node *utilityStmt; /* non-null if this is a non-optimizable
43 int resultRelation; /* target relation (index to rtable) */
44 char *into; /* portal (cursor) name */
45 bool isPortal; /* is this a retrieve into portal? */
46 bool isBinary; /* binary portal? */
47 bool isTemp; /* is 'into' a temp table? */
48 bool unionall; /* union without unique sort */
49 bool hasAggs; /* has aggregates in tlist or havingQual */
50 bool hasSubLinks; /* has subquery SubLink */
52 List *rtable; /* list of range table entries */
53 List *targetList; /* target list (of TargetEntry) */
54 Node *qual; /* qualifications applied to tuples */
55 List *rowMark; /* list of RowMark entries */
57 List *distinctClause; /* a list of SortClause's */
59 List *sortClause; /* a list of SortClause's */
61 List *groupClause; /* a list of GroupClause's */
63 Node *havingQual; /* qualifications applied to groups */
65 List *intersectClause;
66 List *unionClause; /* unions are linked under the previous
69 Node *limitOffset; /* # of result tuples to skip */
70 Node *limitCount; /* # of result tuples to return */
72 /* internal to planner */
73 List *base_rel_list; /* list of base-relation RelOptInfos */
74 List *join_rel_list; /* list of join-relation RelOptInfos */
75 List *equi_key_list; /* list of lists of equijoined PathKeyItems */
76 List *query_pathkeys; /* pathkeys for query_planner()'s result */
80 /*****************************************************************************
81 * Other Statements (no optimizations required)
83 * Some of them require a little bit of transformation (which is also
84 * done by transformStmt). The whole structure is then passed on to
85 * ProcessUtility (by-passing the optimization step) as the utilityStmt
87 *****************************************************************************/
89 /* ----------------------
91 * ----------------------
93 /* The fields are used in different ways by the different variants of this command */
94 typedef struct AlterTableStmt
97 char subtype; /* A = add, T = alter, D = drop, C = add constr, X = drop constr */
98 char *relname; /* table to work on */
99 bool inh; /* recursively on children? */
100 char *name; /* column or constraint name to act on */
101 Node *def; /* definition of new column or constraint */
102 int behavior; /* CASCADE or RESTRICT drop behavior */
105 /* ----------------------
106 * Change ACL Statement
107 * ----------------------
109 typedef struct ChangeACLStmt
112 struct AclItem *aclitem;
117 /* ----------------------
118 * Close Portal Statement
119 * ----------------------
121 typedef struct ClosePortalStmt
124 char *portalname; /* name of the portal (cursor) */
127 /* ----------------------
129 * ----------------------
131 typedef struct CopyStmt
134 bool binary; /* is a binary copy? */
135 char *relname; /* the relation to copy */
136 bool oids; /* copy oid's? */
137 int direction; /* TO or FROM */
138 char *filename; /* if NULL, use stdin/stdout */
139 char *delimiter; /* delimiter character, \t by default */
140 char *null_print; /* how to print NULLs, `\N' by default */
143 /* ----------------------
144 * Create Table Statement
145 * ----------------------
147 typedef struct CreateStmt
150 bool istemp; /* is this a temp table? */
151 char *relname; /* name of relation to create */
152 List *tableElts; /* column definitions (list of ColumnDef) */
153 List *inhRelnames; /* relations to inherit from (list of
154 * T_String Values) */
155 List *constraints; /* constraints (list of Constraint and
156 * FkConstraint nodes) */
160 * Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt
162 * XXX probably these ought to be unified with FkConstraints at some point?
164 * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
165 * we may have the expression in either "raw" form (an untransformed
166 * parse tree) or "cooked" form (the nodeToString representation of
167 * an executable expression tree), depending on how this Constraint
168 * node was created (by parsing, or by inheritance from an existing
169 * relation). We should never have both in the same node!
171 * Constraint attributes (DEFERRABLE etc) are initially represented as
172 * separate Constraint nodes for simplicity of parsing. analyze.c makes
173 * a pass through the constraints list to attach the info to the appropriate
174 * FkConstraint node (and, perhaps, someday to other kinds of constraints).
178 typedef enum ConstrType /* types of constraints */
180 CONSTR_NULL, /* not SQL92, but a lot of people expect it */
186 CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
187 CONSTR_ATTR_NOT_DEFERRABLE,
188 CONSTR_ATTR_DEFERRED,
189 CONSTR_ATTR_IMMEDIATE
192 typedef struct Constraint
196 char *name; /* name, or NULL if unnamed */
197 Node *raw_expr; /* expr, as untransformed parse tree */
198 char *cooked_expr; /* expr, as nodeToString representation */
199 List *keys; /* list of primary keys (or unique columns) */
204 * Definitions for FOREIGN KEY constraints in CreateStmt
207 #define FKCONSTR_ON_KEY_NOACTION 0x0000
208 #define FKCONSTR_ON_KEY_RESTRICT 0x0001
209 #define FKCONSTR_ON_KEY_CASCADE 0x0002
210 #define FKCONSTR_ON_KEY_SETNULL 0x0004
211 #define FKCONSTR_ON_KEY_SETDEFAULT 0x0008
213 #define FKCONSTR_ON_DELETE_MASK 0x000F
214 #define FKCONSTR_ON_DELETE_SHIFT 0
216 #define FKCONSTR_ON_UPDATE_MASK 0x00F0
217 #define FKCONSTR_ON_UPDATE_SHIFT 4
219 typedef struct FkConstraint
222 char *constr_name; /* Constraint name */
223 char *pktable_name; /* Primary key table name */
224 List *fk_attrs; /* Attributes of foreign key */
225 List *pk_attrs; /* Corresponding attrs in PK table */
226 char *match_type; /* FULL or PARTIAL */
227 int32 actions; /* ON DELETE/UPDATE actions */
228 bool deferrable; /* DEFERRABLE */
229 bool initdeferred; /* INITIALLY DEFERRED */
233 /* ----------------------
234 * Create/Drop TRIGGER Statements
235 * ----------------------
238 typedef struct CreateTrigStmt
241 char *trigname; /* TRIGGER' name */
242 char *relname; /* triggered relation */
243 char *funcname; /* function to call (or NULL) */
244 List *args; /* list of (T_String) Values or NULL */
245 bool before; /* BEFORE/AFTER */
246 bool row; /* ROW/STATEMENT */
247 char actions[4]; /* Insert, Update, Delete */
248 char *lang; /* NULL (which means Clanguage) */
249 char *text; /* AS 'text' */
250 List *attr; /* UPDATE OF a, b,... (NI) or NULL */
251 char *when; /* WHEN 'a > 10 ...' (NI) or NULL */
253 /* The following are used for referential */
254 /* integrity constraint triggers */
255 bool isconstraint; /* This is an RI trigger */
256 bool deferrable; /* [NOT] DEFERRABLE */
257 bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
258 char *constrrelname; /* opposite relation */
261 typedef struct DropTrigStmt
264 char *trigname; /* TRIGGER' name */
265 char *relname; /* triggered relation */
269 /* ----------------------
270 * Create/Drop PROCEDURAL LANGUAGE Statement
271 * ----------------------
273 typedef struct CreatePLangStmt
276 char *plname; /* PL name */
277 char *plhandler; /* PL call handler function */
278 char *plcompiler; /* lancompiler text */
279 bool pltrusted; /* PL is trusted */
282 typedef struct DropPLangStmt
285 char *plname; /* PL name */
289 /* ----------------------
290 * Create/Alter/Drop User Statements
291 * ----------------------
293 typedef struct CreateUserStmt
296 char *user; /* PostgreSQL user login */
297 char *password; /* PostgreSQL user password */
298 int sysid; /* PgSQL system id (-1 if don't care) */
299 bool createdb; /* Can the user create databases? */
300 bool createuser; /* Can this user create users? */
301 List *groupElts; /* The groups the user is a member of */
302 char *validUntil; /* The time the login is valid until */
305 typedef struct AlterUserStmt
308 char *user; /* PostgreSQL user login */
309 char *password; /* PostgreSQL user password */
310 int createdb; /* Can the user create databases? */
311 int createuser; /* Can this user create users? */
312 char *validUntil; /* The time the login is valid until */
315 typedef struct DropUserStmt
318 List *users; /* List of users to remove */
322 /* ----------------------
323 * Create/Alter/Drop Group Statements
324 * ----------------------
326 typedef struct CreateGroupStmt
329 char *name; /* name of the new group */
330 int sysid; /* group id (-1 if pick default) */
331 List *initUsers; /* list of initial users */
334 typedef struct AlterGroupStmt
337 char *name; /* name of group to alter */
338 int action; /* +1 = add, -1 = drop user */
339 int sysid; /* sysid change */
340 List *listUsers; /* list of users to add/drop */
343 typedef struct DropGroupStmt
350 /* ----------------------
351 * Create SEQUENCE Statement
352 * ----------------------
355 typedef struct CreateSeqStmt
358 char *seqname; /* the relation to create */
362 /* ----------------------
363 * Create Version Statement
364 * ----------------------
366 typedef struct VersionStmt
369 char *relname; /* the new relation */
370 int direction; /* FORWARD | BACKWARD */
371 char *fromRelname; /* relation to create a version */
372 char *date; /* date of the snapshot */
375 /* ----------------------
376 * Create {Operator|Type|Aggregate} Statement
377 * ----------------------
379 typedef struct DefineStmt
382 int defType; /* OPERATOR|P_TYPE|AGGREGATE */
384 List *definition; /* a list of DefElem */
387 /* ----------------------
388 * Drop Table Statement
389 * ----------------------
391 typedef struct DropStmt
394 List *relNames; /* relations to be dropped */
398 /* ----------------------
399 * Truncate Table Statement
400 * ----------------------
402 typedef struct TruncateStmt
405 char *relName; /* relation to be truncated */
408 /* ----------------------
409 * Comment On Statement
410 * ----------------------
412 typedef struct CommentStmt
415 int objtype; /* Object's type */
416 char *objname; /* Name of the object */
417 char *objproperty; /* Property Id (such as column) */
418 List *objlist; /* Arguments for VAL objects */
419 char *comment; /* The comment to insert */
422 /* ----------------------
423 * Extend Index Statement
424 * ----------------------
426 typedef struct ExtendStmt
429 char *idxname; /* name of the index */
430 Node *whereClause; /* qualifications */
431 List *rangetable; /* range table, filled in by
435 /* ----------------------
436 * Begin Recipe Statement
437 * ----------------------
439 typedef struct RecipeStmt
442 char *recipeName; /* name of the recipe */
445 /* ----------------------
447 * ----------------------
449 typedef struct FetchStmt
452 int direction; /* FORWARD or BACKWARD */
453 int howMany; /* amount to fetch ("ALL" --> 0) */
454 char *portalname; /* name of portal (cursor) */
455 bool ismove; /* TRUE if MOVE */
458 /* ----------------------
459 * Create Index Statement
460 * ----------------------
462 typedef struct IndexStmt
465 char *idxname; /* name of the index */
466 char *relname; /* name of relation to index on */
467 char *accessMethod; /* name of acess methood (eg. btree) */
468 List *indexParams; /* a list of IndexElem */
469 List *withClause; /* a list of DefElem */
470 Node *whereClause; /* qualifications */
471 List *rangetable; /* range table, filled in by
473 bool *lossy; /* is index lossy? */
474 bool unique; /* is index unique? */
475 bool primary; /* is index on primary key? */
478 /* ----------------------
479 * Create Function Statement
480 * ----------------------
482 typedef struct ProcedureStmt
485 char *funcname; /* name of function to create */
486 List *defArgs; /* list of definitions a list of strings
488 Node *returnType; /* the return type (as a string or a
489 * TypeName (ie.setof) */
490 List *withClause; /* a list of DefElem */
491 List *as; /* the SQL statement or filename */
492 char *language; /* C or SQL */
495 /* ----------------------
496 * Drop Aggregate Statement
497 * ----------------------
499 typedef struct RemoveAggrStmt
502 char *aggname; /* aggregate to drop */
503 char *aggtype; /* for this type */
506 /* ----------------------
507 * Drop Function Statement
508 * ----------------------
510 typedef struct RemoveFuncStmt
513 char *funcname; /* function to drop */
514 List *args; /* types of the arguments */
517 /* ----------------------
518 * Drop Operator Statement
519 * ----------------------
521 typedef struct RemoveOperStmt
524 char *opname; /* operator to drop */
525 List *args; /* types of the arguments */
528 /* ----------------------
529 * Drop {Type|Index|Rule|View} Statement
530 * ----------------------
532 typedef struct RemoveStmt
535 int removeType; /* P_TYPE|INDEX|RULE|VIEW */
536 char *name; /* name to drop */
539 /* ----------------------
540 * Alter Table Statement
541 * ----------------------
543 typedef struct RenameStmt
546 char *relname; /* relation to be altered */
547 bool inh; /* recursively alter children? */
548 char *column; /* if NULL, rename the relation name to
549 * the new name. Otherwise, rename this
551 char *newname; /* the new name */
554 /* ----------------------
555 * Create Rule Statement
556 * ----------------------
558 typedef struct RuleStmt
561 char *rulename; /* name of the rule */
562 Node *whereClause; /* qualifications */
563 CmdType event; /* RETRIEVE */
564 struct Attr *object; /* object affected */
565 bool instead; /* is a 'do instead'? */
566 List *actions; /* the action statements */
569 /* ----------------------
571 * ----------------------
573 typedef struct NotifyStmt
576 char *relname; /* relation to notify */
579 /* ----------------------
581 * ----------------------
583 typedef struct ListenStmt
586 char *relname; /* relation to listen on */
589 /* ----------------------
591 * ----------------------
593 typedef struct UnlistenStmt
596 char *relname; /* relation to unlisten on */
599 /* ----------------------
600 * {Begin|Abort|End} Transaction Statement
601 * ----------------------
603 typedef struct TransactionStmt
606 int command; /* BEGIN|END|ABORT */
609 /* ----------------------
610 * Create View Statement
611 * ----------------------
613 typedef struct ViewStmt
616 char *viewname; /* name of the view */
617 List *aliases; /* target column names */
618 Query *query; /* the SQL statement */
621 /* ----------------------
623 * ----------------------
625 typedef struct LoadStmt
628 char *filename; /* file to load */
631 /* ----------------------
633 * ----------------------
635 typedef struct CreatedbStmt
638 char *dbname; /* database to create */
639 char *dbpath; /* location of database */
640 int encoding; /* default encoding (see regex/pg_wchar.h) */
643 /* ----------------------
645 * ----------------------
647 typedef struct DropdbStmt
650 char *dbname; /* database to drop */
653 /* ----------------------
654 * Cluster Statement (support pbrown's cluster index implementation)
655 * ----------------------
657 typedef struct ClusterStmt
660 char *relname; /* relation being indexed */
661 char *indexname; /* original index defined */
664 /* ----------------------
666 * ----------------------
668 typedef struct VacuumStmt
671 bool verbose; /* print status info */
672 bool analyze; /* analyze data */
673 char *vacrel; /* table to vacuum */
674 List *va_spec; /* columns to analyse */
677 /* ----------------------
679 * ----------------------
681 typedef struct ExplainStmt
684 Query *query; /* the query */
685 bool verbose; /* print plan info */
688 /* ----------------------
690 * ----------------------
693 typedef struct VariableSetStmt
700 /* ----------------------
702 * ----------------------
705 typedef struct VariableShowStmt
711 /* ----------------------
713 * ----------------------
716 typedef struct VariableResetStmt
722 /* ----------------------
724 * ----------------------
726 typedef struct LockStmt
729 char *relname; /* relation to lock */
730 int mode; /* lock mode */
734 /* ----------------------
735 * SET CONSTRAINTS Statement
736 * ----------------------
738 typedef struct ConstraintsSetStmt
743 } ConstraintsSetStmt;
745 /* ----------------------
747 * ----------------------
749 typedef struct ReindexStmt
752 int reindexType; /* INDEX|TABLE|DATABASE */
753 const char *name; /* name to reindex */
759 /*****************************************************************************
760 * Optimizable Statements
761 *****************************************************************************/
763 /* ----------------------
765 * ----------------------
767 typedef struct InsertStmt
770 char *relname; /* relation to insert into */
771 List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
772 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
773 List *cols; /* names of the columns */
774 List *targetList; /* the target list (of ResTarget) */
775 List *fromClause; /* the from clause */
776 Node *whereClause; /* qualifications */
777 List *groupClause; /* GROUP BY clauses */
778 Node *havingClause; /* having conditional-expression */
779 List *unionClause; /* union subselect parameters */
780 bool unionall; /* union without unique sort */
781 List *intersectClause;
782 List *forUpdate; /* FOR UPDATE clause */
785 /* ----------------------
787 * ----------------------
789 typedef struct DeleteStmt
792 char *relname; /* relation to delete from */
793 Node *whereClause; /* qualifications */
796 /* ----------------------
798 * ----------------------
800 typedef struct UpdateStmt
803 char *relname; /* relation to update */
804 List *targetList; /* the target list (of ResTarget) */
805 Node *whereClause; /* qualifications */
806 List *fromClause; /* the from clause */
809 /* ----------------------
811 * ----------------------
813 typedef struct SelectStmt
816 List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
817 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
818 char *into; /* name of table (for select into table) */
819 List *targetList; /* the target list (of ResTarget) */
820 List *fromClause; /* the from clause */
821 Node *whereClause; /* qualifications */
822 List *groupClause; /* GROUP BY clauses */
823 Node *havingClause; /* having conditional-expression */
824 List *intersectClause;
827 List *unionClause; /* union subselect parameters */
828 List *sortClause; /* sort clause (a list of SortGroupBy's) */
829 char *portalname; /* the portal (cursor) to create */
830 bool binary; /* a binary (internal) portal? */
831 bool istemp; /* into is a temp table */
832 bool unionall; /* union without unique sort */
833 Node *limitOffset; /* # of result tuples to skip */
834 Node *limitCount; /* # of result tuples to return */
835 List *forUpdate; /* FOR UPDATE clause */
838 /****************************************************************************
839 * Supporting data structures for Parse Trees
841 * Most of these node types appear in raw parsetrees output by the grammar,
842 * and get transformed to something else by the analyzer. A few of them
843 * are used as-is in transformed querytrees.
844 ****************************************************************************/
847 * TypeName - specifies a type in definitions
849 typedef struct TypeName
852 char *name; /* name of the type */
853 bool timezone; /* timezone specified? */
854 bool setof; /* is a set? */
855 int32 typmod; /* type modifier */
856 List *arrayBounds; /* array bounds */
860 * ParamNo - specifies a parameter reference
862 typedef struct ParamNo
865 int number; /* the number of the parameter */
866 TypeName *typename; /* the typecast */
867 List *indirection; /* array references */
871 * A_Expr - binary expressions
873 typedef struct A_Expr
876 int oper; /* type of operation
877 * {OP,OR,AND,NOT,ISNULL,NOTNULL} */
878 char *opname; /* name of operator/function */
879 Node *lexpr; /* left argument */
880 Node *rexpr; /* right argument */
885 * specifies an Attribute (ie. a Column); could have nested dots or
892 char *relname; /* name of relation (can be "*") */
893 ParamNo *paramNo; /* or a parameter */
894 List *attrs; /* attributes (possibly nested); list of
895 * Values (strings) */
896 List *indirection; /* array refs (list of A_Indices') */
900 * A_Const - a constant expression
902 typedef struct A_Const
905 Value val; /* the value (with the tag) */
906 TypeName *typename; /* typecast */
910 * TypeCast - a CAST expression
912 * NOTE: for mostly historical reasons, A_Const and ParamNo parsenodes contain
913 * room for a TypeName; we only generate a separate TypeCast node if the
914 * argument to be casted is neither of those kinds of nodes. In theory either
915 * representation would work, but it is convenient (especially for A_Const)
916 * to have the target type immediately available.
918 typedef struct TypeCast
921 Node *arg; /* the expression being casted */
922 TypeName *typename; /* the target type */
926 * CaseExpr - a CASE expression
928 typedef struct CaseExpr
932 Node *arg; /* implicit equality comparison argument */
933 List *args; /* the arguments (list of WHEN clauses) */
934 Node *defresult; /* the default result (ELSE clause) */
938 * CaseWhen - an argument to a CASE expression
940 typedef struct CaseWhen
943 Node *expr; /* comparison expression */
944 Node *result; /* substitution result */
948 * ColumnDef - column definition (used in various creates)
950 * If the column has a default value, we may have the value expression
951 * in either "raw" form (an untransformed parse tree) or "cooked" form
952 * (the nodeToString representation of an executable expression tree),
953 * depending on how this ColumnDef node was created (by parsing, or by
954 * inheritance from an existing relation). We should never have both
957 * The constraints list may contain a CONSTR_DEFAULT item in a raw
958 * parsetree produced by gram.y, but transformCreateStmt will remove
959 * the item and set raw_default instead. CONSTR_DEFAULT items
960 * should not appear in any subsequent processing.
962 typedef struct ColumnDef
965 char *colname; /* name of column */
966 TypeName *typename; /* type of column */
967 bool is_not_null; /* flag to NOT NULL constraint */
968 bool is_sequence; /* is a sequence? */
969 Node *raw_default; /* default value (untransformed parse tree) */
970 char *cooked_default; /* nodeToString representation */
971 List *constraints; /* other constraints on column */
976 * an identifier (could be an attribute or a relation name). Depending
977 * on the context at transformStmt time, the identifier is treated as
978 * either a relation name (in which case, isRel will be set) or an
979 * attribute (in which case, it will be transformed into an Attr).
984 char *name; /* its name */
985 List *indirection; /* array references */
986 bool isRel; /* is a relation - filled in by
991 * FuncCall - a function or aggregate invocation
993 * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
994 * indicates we saw 'foo(DISTINCT ...)'. In either case, the construct
995 * *must* be an aggregate call. Otherwise, it might be either an
996 * aggregate or some other kind of function.
998 typedef struct FuncCall
1001 char *funcname; /* name of function */
1002 List *args; /* the arguments (list of exprs) */
1003 bool agg_star; /* argument was really '*' */
1004 bool agg_distinct; /* arguments were labeled DISTINCT */
1008 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
1010 typedef struct A_Indices
1013 Node *lidx; /* could be NULL */
1019 * result target (used in target list of pre-transformed Parse trees)
1021 * In a SELECT or INSERT target list, 'name' is either NULL or
1022 * the column name assigned to the value. (If there is an 'AS ColumnLabel'
1023 * clause, the grammar sets 'name' from it; otherwise 'name' is initially NULL
1024 * and is filled in during the parse analysis phase.)
1025 * The 'indirection' field is not used at all.
1027 * In an UPDATE target list, 'name' is the name of the destination column,
1028 * and 'indirection' stores any subscripts attached to the destination.
1029 * That is, our representation is UPDATE table SET name [indirection] = val.
1031 typedef struct ResTarget
1034 char *name; /* column name or NULL */
1035 List *indirection; /* subscripts for destination column, or
1037 Node *val; /* the value expression to compute or
1042 * RelExpr - relation expressions
1044 typedef struct RelExpr
1047 char *relname; /* the relation name */
1048 bool inh; /* inheritance query */
1052 * SortGroupBy - for ORDER BY clause
1054 typedef struct SortGroupBy
1057 char *useOp; /* operator to use */
1058 Node *node; /* Expression */
1062 * RangeVar - range variable, used in FROM clauses
1064 typedef struct RangeVar
1067 RelExpr *relExpr; /* the relation expression */
1068 Attr *name; /* the name to be referenced (optional) */
1072 * IndexElem - index parameters (used in CREATE INDEX)
1074 typedef struct IndexElem
1077 char *name; /* name of index */
1078 List *args; /* if not NULL, function index */
1080 TypeName *typename; /* type of index's keys (optional) */
1085 * a definition (used in definition lists in the form of defname = arg)
1087 typedef struct DefElem
1091 Node *arg; /* a (Value *) or a (TypeName *) */
1095 * JoinExpr - for JOIN expressions
1097 typedef struct JoinExpr
1101 bool isNatural; /* Natural join? Will need to shape table */
1102 Node *larg; /* RangeVar or join expression */
1103 Node *rarg; /* RangeVar or join expression */
1104 Attr *alias; /* table and column aliases, if any */
1105 List *quals; /* qualifiers on join, if any */
1109 /****************************************************************************
1110 * Nodes for a Query tree
1111 ****************************************************************************/
1115 * a target entry (used in the transformed target list)
1117 * one of resdom or fjoin is not NULL. a target list is
1118 * ((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
1120 typedef struct TargetEntry
1123 Resdom *resdom; /* fjoin overload this to be a list?? */
1128 /*--------------------
1130 * A range table is a List of RangeTblEntry nodes.
1132 * Some of the following are only used in one of
1133 * the parsing, optimizing, execution stages.
1135 * eref is the expanded table name and columns for the underlying
1136 * relation. Note that for outer join syntax, allowed reference names
1137 * could be modified as one evaluates the nested clauses (e.g.
1138 * "SELECT ... FROM t1 NATURAL JOIN t2 WHERE ..." forbids explicit mention
1139 * of a table name in any reference to the join column.
1141 * inFromCl marks those range variables that are listed in the FROM clause.
1142 * In SQL, the query can only refer to range variables listed in the
1143 * FROM clause, but POSTQUEL allows you to refer to tables not listed,
1144 * in which case a range table entry will be generated. We still support
1145 * this POSTQUEL feature, although there is some doubt whether it's
1146 * convenient or merely confusing. The flag is needed since an
1147 * implicitly-added RTE shouldn't change the namespace for unqualified
1148 * column names processed later, and it also shouldn't affect the
1151 * inJoinSet marks those range variables that the planner should join
1152 * over even if they aren't explicitly referred to in the query. For
1153 * example, "SELECT COUNT(1) FROM tx" should produce the number of rows
1154 * in tx. A more subtle example uses a POSTQUEL implicit RTE:
1155 * SELECT COUNT(1) FROM tx WHERE TRUE OR (tx.f1 = ty.f2)
1156 * Here we should get the product of the sizes of tx and ty. However,
1157 * the query optimizer can simplify the WHERE clause to "TRUE", so
1158 * ty will no longer be referred to explicitly; without a flag forcing
1159 * it to be included in the join, we will get the wrong answer. So,
1160 * a POSTQUEL implicit RTE must be marked inJoinSet but not inFromCl.
1161 *--------------------
1163 typedef struct RangeTblEntry
1166 char *relname; /* real name of the relation */
1167 Attr *ref; /* reference names (given in FROM clause) */
1168 Attr *eref; /* expanded reference names */
1169 Oid relid; /* OID of the relation */
1170 bool inh; /* inheritance requested? */
1171 bool inFromCl; /* present in FROM clause */
1172 bool inJoinSet; /* planner must include this rel */
1173 bool skipAcl; /* skip ACL check in executor */
1178 * representation of ORDER BY clauses
1180 * tleSortGroupRef must match ressortgroupref of exactly one Resdom of the
1181 * associated targetlist; that is the expression to be sorted (or grouped) by.
1182 * sortop is the OID of the ordering operator.
1184 * SortClauses are also used to identify Resdoms that we will do a "Unique"
1185 * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON). The
1186 * distinctClause list is simply a copy of the relevant members of the
1187 * sortClause list. Note that distinctClause can be a subset of sortClause,
1188 * but cannot have members not present in sortClause; and the members that
1189 * do appear must be in the same order as in sortClause.
1191 typedef struct SortClause
1194 Index tleSortGroupRef;/* reference into targetlist */
1195 Oid sortop; /* the sort operator to use */
1200 * representation of GROUP BY clauses
1202 * GroupClause is exactly like SortClause except for the nodetag value
1203 * (it's probably not even really necessary to have two different
1204 * nodetags...). We have routines that operate interchangeably on both.
1206 typedef SortClause GroupClause;
1208 #define ROW_MARK_FOR_UPDATE (1 << 0)
1209 #define ROW_ACL_FOR_UPDATE (1 << 1)
1211 typedef struct RowMark
1214 Index rti; /* index in Query->rtable */
1215 bits8 info; /* as above */
1218 #endif /* PARSENODES_H */