]> granicus.if.org Git - postgresql/blob - src/include/nodes/parsenodes.h
Reimplement parsing and storage of default expressions and constraint
[postgresql] / src / include / nodes / parsenodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * parsenodes.h
4  *        definitions for parse tree nodes
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: parsenodes.h,v 1.83 1999/10/03 23:55:36 tgl Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef PARSENODES_H
14 #define PARSENODES_H
15
16 #include "nodes/primnodes.h"
17
18 /*****************************************************************************
19  *      Query Tree
20  *****************************************************************************/
21
22 /*
23  * Query -
24  *        all statments are turned into a Query tree (via transformStmt)
25  *        for further processing by the optimizer
26  *        utility statements (i.e. non-optimizable statements)
27  *        have the *utilityStmt field set.
28  *
29  * we need the isPortal flag because portal names can be null too; can
30  * get rid of it if we support CURSOR as a commandType.
31  *
32  */
33 typedef struct Query
34 {
35         NodeTag         type;
36
37         CmdType         commandType;    /* select|insert|update|delete|utility */
38
39         Node       *utilityStmt;        /* non-null if this is a non-optimizable
40                                                                  * statement */
41
42         int                     resultRelation; /* target relation (index to rtable) */
43         char       *into;                       /* portal (cursor) name */
44         bool            isPortal;               /* is this a retrieve into portal? */
45         bool            isBinary;               /* binary portal? */
46         bool            isTemp;                 /* is 'into' a temp table? */
47         bool            unionall;               /* union without unique sort */
48         bool            hasAggs;                /* has aggregates in target list */
49         bool            hasSubLinks;    /* has subquery SubLink */
50
51         List       *rtable;                     /* list of range table entries */
52         List       *targetList;         /* target list (of TargetEntry) */
53         Node       *qual;                       /* qualifications applied to tuples */
54         List       *rowMark;            /* list of RowMark entries */
55
56         char       *uniqueFlag;         /* NULL, '*', or Unique attribute name */
57         List       *sortClause;         /* a list of SortClause's */
58
59         List       *groupClause;        /* a list of GroupClause's */
60
61         Node       *havingQual;         /* qualifications applied to groups */
62
63         List       *intersectClause;
64         List       *unionClause;        /* unions are linked under the previous
65                                                                  * query */
66
67         Node       *limitOffset;        /* # of result tuples to skip */
68         Node       *limitCount;         /* # of result tuples to return */
69
70         /* internal to planner */
71         List       *base_rel_list;      /* list of base-relation RelOptInfos */
72         List       *join_rel_list;      /* list of join-relation RelOptInfos */
73         List       *query_pathkeys; /* pathkeys for query_planner()'s result */
74 } Query;
75
76
77 /*****************************************************************************
78  *              Other Statements (no optimizations required)
79  *
80  *              Some of them require a little bit of transformation (which is also
81  *              done by transformStmt). The whole structure is then passed on to
82  *              ProcessUtility (by-passing the optimization step) as the utilityStmt
83  *              field in Query.
84  *****************************************************************************/
85
86 /* ----------------------
87  *              Add Column Statement
88  * ----------------------
89  */
90 typedef struct AddAttrStmt
91 {
92         NodeTag         type;
93         char       *relname;            /* the relation to add attr */
94         bool            inh;                    /* add recursively to children? */
95         Node       *colDef;                     /* the attribute definition */
96 } AddAttrStmt;
97
98 /* ----------------------
99  *              Change ACL Statement
100  * ----------------------
101  */
102 typedef struct ChangeACLStmt
103 {
104         NodeTag         type;
105         struct AclItem *aclitem;
106         unsigned        modechg;
107         List       *relNames;
108 } ChangeACLStmt;
109
110 /* ----------------------
111  *              Close Portal Statement
112  * ----------------------
113  */
114 typedef struct ClosePortalStmt
115 {
116         NodeTag         type;
117         char       *portalname;         /* name of the portal (cursor) */
118 } ClosePortalStmt;
119
120 /* ----------------------
121  *              Copy Statement
122  * ----------------------
123  */
124 typedef struct CopyStmt
125 {
126         NodeTag         type;
127         bool            binary;                 /* is a binary copy? */
128         char       *relname;            /* the relation to copy */
129         bool            oids;                   /* copy oid's? */
130         int                     direction;              /* TO or FROM */
131         char       *filename;           /* if NULL, use stdin/stdout */
132         char       *delimiter;          /* delimiter character, \t by default */
133 } CopyStmt;
134
135 /* ----------------------
136  *              Create Table Statement
137  * ----------------------
138  */
139 typedef struct CreateStmt
140 {
141         NodeTag         type;
142         bool            istemp;                 /* is this a temp table? */
143         char       *relname;            /* name of relation to create */
144         List       *tableElts;          /* column definitions (list of ColumnDef) */
145         List       *inhRelnames;        /* relations to inherit from (list of
146                                                                  * T_String Values) */
147         List       *constraints;        /* list of constraints (Constraint nodes) */
148 } CreateStmt;
149
150 typedef enum ConstrType                 /* types of constraints */
151 {
152         CONSTR_NULL, CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK,
153         CONSTR_PRIMARY, CONSTR_UNIQUE
154 } ConstrType;
155
156 /*
157  * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
158  * we may have the expression in either "raw" form (an untransformed
159  * parse tree) or "cooked" form (the nodeToString representation of
160  * an executable expression tree), depending on how this Constraint
161  * node was created (by parsing, or by inheritance from an existing
162  * relation).  We should never have both in the same node!
163  */
164
165 typedef struct Constraint
166 {
167         NodeTag         type;
168         ConstrType      contype;
169         char       *name;                       /* name */
170         Node       *raw_expr;           /* untransformed parse tree */
171         char       *cooked_expr;        /* nodeToString representation */
172         List       *keys;                       /* list of primary keys */
173 } Constraint;
174
175 /* ----------------------
176  *              Create/Drop TRIGGER Statements
177  * ----------------------
178  */
179
180 typedef struct CreateTrigStmt
181 {
182         NodeTag         type;
183         char       *trigname;           /* TRIGGER' name */
184         char       *relname;            /* triggered relation */
185         char       *funcname;           /* function to call (or NULL) */
186         List       *args;                       /* list of (T_String) Values or NULL */
187         bool            before;                 /* BEFORE/AFTER */
188         bool            row;                    /* ROW/STATEMENT */
189         char            actions[4];             /* Insert, Update, Delete */
190         char       *lang;                       /* NULL (which means Clanguage) */
191         char       *text;                       /* AS 'text' */
192         List       *attr;                       /* UPDATE OF a, b,... (NI) or NULL */
193         char       *when;                       /* WHEN 'a > 10 ...' (NI) or NULL */
194
195                                                                 /* The following are used for referential */
196                                                                 /* integrity constraint triggers */
197         bool            isconstraint;   /* This is an RI trigger */
198         bool            deferrable;             /* [NOT] DEFERRABLE */
199         bool            initdeferred;   /* INITIALLY {DEFERRED|IMMEDIATE} */
200         char       *constrrelname;      /* opposite relation */
201 } CreateTrigStmt;
202
203 typedef struct DropTrigStmt
204 {
205         NodeTag         type;
206         char       *trigname;           /* TRIGGER' name */
207         char       *relname;            /* triggered relation */
208 } DropTrigStmt;
209
210
211 /* ----------------------
212  *              Create/Drop PROCEDURAL LANGUAGE Statement
213  * ----------------------
214  */
215 typedef struct CreatePLangStmt
216 {
217         NodeTag         type;
218         char       *plname;                     /* PL name */
219         char       *plhandler;          /* PL call handler function */
220         char       *plcompiler;         /* lancompiler text */
221         bool            pltrusted;              /* PL is trusted */
222 } CreatePLangStmt;
223
224 typedef struct DropPLangStmt
225 {
226         NodeTag         type;
227         char       *plname;                     /* PL name */
228 } DropPLangStmt;
229
230
231 /* ----------------------
232  *                              Create/Alter/Drop User Statements
233  * ----------------------
234  */
235 typedef struct CreateUserStmt
236 {
237         NodeTag         type;
238         char       *user;                       /* PostgreSQL user login                          */
239         char       *password;           /* PostgreSQL user password                       */
240         bool       *createdb;           /* Can the user create databases?         */
241         bool       *createuser;         /* Can this user create users?            */
242         List       *groupElts;          /* The groups the user is a member of */
243         char       *validUntil;         /* The time the login is valid until  */
244 } CreateUserStmt;
245
246 typedef CreateUserStmt AlterUserStmt;
247
248 typedef struct DropUserStmt
249 {
250         NodeTag         type;
251         char       *user;                       /* PostgreSQL user login                          */
252 } DropUserStmt;
253
254
255 /* ----------------------
256  *              Create SEQUENCE Statement
257  * ----------------------
258  */
259
260 typedef struct CreateSeqStmt
261 {
262         NodeTag         type;
263         char       *seqname;            /* the relation to create */
264         List       *options;
265 } CreateSeqStmt;
266
267 /* ----------------------
268  *              Create Version Statement
269  * ----------------------
270  */
271 typedef struct VersionStmt
272 {
273         NodeTag         type;
274         char       *relname;            /* the new relation */
275         int                     direction;              /* FORWARD | BACKWARD */
276         char       *fromRelname;        /* relation to create a version */
277         char       *date;                       /* date of the snapshot */
278 } VersionStmt;
279
280 /* ----------------------
281  *              Create {Operator|Type|Aggregate} Statement
282  * ----------------------
283  */
284 typedef struct DefineStmt
285 {
286         NodeTag         type;
287         int                     defType;                /* OPERATOR|P_TYPE|AGGREGATE */
288         char       *defname;
289         List       *definition;         /* a list of DefElem */
290 } DefineStmt;
291
292 /* ----------------------
293  *              Drop Table Statement
294  * ----------------------
295  */
296 typedef struct DestroyStmt
297 {
298         NodeTag         type;
299         List       *relNames;           /* relations to be dropped */
300         bool            sequence;
301 } DestroyStmt;
302
303 /* ----------------------
304  *              Truncate Table Statement
305  * ----------------------
306  */
307 typedef struct TruncateStmt
308 {
309         NodeTag         type;
310         char       *relName;            /* relation to be truncated */
311 } TruncateStmt;
312       
313 /* ----------------------
314  *              Extend Index Statement
315  * ----------------------
316  */
317 typedef struct ExtendStmt
318 {
319         NodeTag         type;
320         char       *idxname;            /* name of the index */
321         Node       *whereClause;        /* qualifications */
322         List       *rangetable;         /* range table, filled in by
323                                                                  * transformStmt() */
324 } ExtendStmt;
325
326 /* ----------------------
327  *              Begin Recipe Statement
328  * ----------------------
329  */
330 typedef struct RecipeStmt
331 {
332         NodeTag         type;
333         char       *recipeName;         /* name of the recipe */
334 } RecipeStmt;
335
336 /* ----------------------
337  *              Fetch Statement
338  * ----------------------
339  */
340 typedef struct FetchStmt
341 {
342         NodeTag         type;
343         int                     direction;              /* FORWARD or BACKWARD */
344         int                     howMany;                /* amount to fetch ("ALL" --> 0) */
345         char       *portalname;         /* name of portal (cursor) */
346         bool            ismove;                 /* TRUE if MOVE */
347 } FetchStmt;
348
349 /* ----------------------
350  *              Create Index Statement
351  * ----------------------
352  */
353 typedef struct IndexStmt
354 {
355         NodeTag         type;
356         char       *idxname;            /* name of the index */
357         char       *relname;            /* name of relation to index on */
358         char       *accessMethod;       /* name of acess methood (eg. btree) */
359         List       *indexParams;        /* a list of IndexElem */
360         List       *withClause;         /* a list of DefElem */
361         Node       *whereClause;        /* qualifications */
362         List       *rangetable;         /* range table, filled in by
363                                                                  * transformStmt() */
364         bool       *lossy;                      /* is index lossy? */
365         bool            unique;                 /* is index unique? */
366         bool            primary;                /* is index on primary key? */
367 } IndexStmt;
368
369 /* ----------------------
370  *              Create Function Statement
371  * ----------------------
372  */
373 typedef struct ProcedureStmt
374 {
375         NodeTag         type;
376         char       *funcname;           /* name of function to create */
377         List       *defArgs;            /* list of definitions a list of strings
378                                                                  * (as Value *) */
379         Node       *returnType;         /* the return type (as a string or a
380                                                                  * TypeName (ie.setof) */
381         List       *withClause;         /* a list of DefElem */
382         List       *as;                         /* the SQL statement or filename */
383         char       *language;           /* C or SQL */
384 } ProcedureStmt;
385
386 /* ----------------------
387  *              Drop Aggregate Statement
388  * ----------------------
389  */
390 typedef struct RemoveAggrStmt
391 {
392         NodeTag         type;
393         char       *aggname;            /* aggregate to drop */
394         char       *aggtype;            /* for this type */
395 } RemoveAggrStmt;
396
397 /* ----------------------
398  *              Drop Function Statement
399  * ----------------------
400  */
401 typedef struct RemoveFuncStmt
402 {
403         NodeTag         type;
404         char       *funcname;           /* function to drop */
405         List       *args;                       /* types of the arguments */
406 } RemoveFuncStmt;
407
408 /* ----------------------
409  *              Drop Operator Statement
410  * ----------------------
411  */
412 typedef struct RemoveOperStmt
413 {
414         NodeTag         type;
415         char       *opname;                     /* operator to drop */
416         List       *args;                       /* types of the arguments */
417 } RemoveOperStmt;
418
419 /* ----------------------
420  *              Drop {Type|Index|Rule|View} Statement
421  * ----------------------
422  */
423 typedef struct RemoveStmt
424 {
425         NodeTag         type;
426         int                     removeType;             /* P_TYPE|INDEX|RULE|VIEW */
427         char       *name;                       /* name to drop */
428 } RemoveStmt;
429
430 /* ----------------------
431  *              Alter Table Statement
432  * ----------------------
433  */
434 typedef struct RenameStmt
435 {
436         NodeTag         type;
437         char       *relname;            /* relation to be altered */
438         bool            inh;                    /* recursively alter children? */
439         char       *column;                     /* if NULL, rename the relation name to
440                                                                  * the new name. Otherwise, rename this
441                                                                  * column name. */
442         char       *newname;            /* the new name */
443 } RenameStmt;
444
445 /* ----------------------
446  *              Create Rule Statement
447  * ----------------------
448  */
449 typedef struct RuleStmt
450 {
451         NodeTag         type;
452         char       *rulename;           /* name of the rule */
453         Node       *whereClause;        /* qualifications */
454         CmdType         event;                  /* RETRIEVE */
455         struct Attr *object;            /* object affected */
456         bool            instead;                /* is a 'do instead'? */
457         List       *actions;            /* the action statements */
458 } RuleStmt;
459
460 /* ----------------------
461  *              Notify Statement
462  * ----------------------
463  */
464 typedef struct NotifyStmt
465 {
466         NodeTag         type;
467         char       *relname;            /* relation to notify */
468 } NotifyStmt;
469
470 /* ----------------------
471  *              Listen Statement
472  * ----------------------
473  */
474 typedef struct ListenStmt
475 {
476         NodeTag         type;
477         char       *relname;            /* relation to listen on */
478 } ListenStmt;
479
480 /* ----------------------
481  *              Unlisten Statement
482  * ----------------------
483  */
484 typedef struct UnlistenStmt
485 {
486         NodeTag         type;
487         char       *relname;            /* relation to unlisten on */
488 } UnlistenStmt;
489
490 /* ----------------------
491  *              {Begin|Abort|End} Transaction Statement
492  * ----------------------
493  */
494 typedef struct TransactionStmt
495 {
496         NodeTag         type;
497         int                     command;                /* BEGIN|END|ABORT */
498 } TransactionStmt;
499
500 /* ----------------------
501  *              Create View Statement
502  * ----------------------
503  */
504 typedef struct ViewStmt
505 {
506         NodeTag         type;
507         char       *viewname;           /* name of the view */
508         Query      *query;                      /* the SQL statement */
509 } ViewStmt;
510
511 /* ----------------------
512  *              Load Statement
513  * ----------------------
514  */
515 typedef struct LoadStmt
516 {
517         NodeTag         type;
518         char       *filename;           /* file to load */
519 } LoadStmt;
520
521 /* ----------------------
522  *              Createdb Statement
523  * ----------------------
524  */
525 typedef struct CreatedbStmt
526 {
527         NodeTag         type;
528         char       *dbname;                     /* database to create */
529         char       *dbpath;                     /* location of database */
530         int                     encoding;               /* default encoding (see regex/pg_wchar.h) */
531 } CreatedbStmt;
532
533 /* ----------------------
534  *              Destroydb Statement
535  * ----------------------
536  */
537 typedef struct DestroydbStmt
538 {
539         NodeTag         type;
540         char       *dbname;                     /* database to drop */
541 } DestroydbStmt;
542
543 /* ----------------------
544  *              Cluster Statement (support pbrown's cluster index implementation)
545  * ----------------------
546  */
547 typedef struct ClusterStmt
548 {
549         NodeTag         type;
550         char       *relname;            /* relation being indexed */
551         char       *indexname;          /* original index defined */
552 } ClusterStmt;
553
554 /* ----------------------
555  *              Vacuum Statement
556  * ----------------------
557  */
558 typedef struct VacuumStmt
559 {
560         NodeTag         type;
561         bool            verbose;                /* print status info */
562         bool            analyze;                /* analyze data */
563         char       *vacrel;                     /* table to vacuum */
564         List       *va_spec;            /* columns to analyse */
565 } VacuumStmt;
566
567 /* ----------------------
568  *              Explain Statement
569  * ----------------------
570  */
571 typedef struct ExplainStmt
572 {
573         NodeTag         type;
574         Query      *query;                      /* the query */
575         bool            verbose;                /* print plan info */
576 } ExplainStmt;
577
578 /* ----------------------
579  * Set Statement
580  * ----------------------
581  */
582
583 typedef struct VariableSetStmt
584 {
585         NodeTag         type;
586         char       *name;
587         char       *value;
588 } VariableSetStmt;
589
590 /* ----------------------
591  * Show Statement
592  * ----------------------
593  */
594
595 typedef struct VariableShowStmt
596 {
597         NodeTag         type;
598         char       *name;
599 } VariableShowStmt;
600
601 /* ----------------------
602  * Reset Statement
603  * ----------------------
604  */
605
606 typedef struct VariableResetStmt
607 {
608         NodeTag         type;
609         char       *name;
610 } VariableResetStmt;
611
612 /* ----------------------
613  *              LOCK Statement
614  * ----------------------
615  */
616 typedef struct LockStmt
617 {
618         NodeTag         type;
619         char       *relname;            /* relation to lock */
620         int                     mode;                   /* lock mode */
621 } LockStmt;
622
623
624 /* ----------------------
625  *              SET CONSTRAINTS Statement
626  * ----------------------
627  */
628 typedef struct ConstraintsSetStmt
629 {
630         NodeTag         type;
631         List            *constraints;
632         bool            deferred;
633 } ConstraintsSetStmt;
634
635
636 /*****************************************************************************
637  *              Optimizable Statements
638  *****************************************************************************/
639
640 /* ----------------------
641  *              Insert Statement
642  * ----------------------
643  */
644 typedef struct InsertStmt
645 {
646         NodeTag         type;
647         char       *relname;            /* relation to insert into */
648         char       *unique;                     /* NULL, '*', or unique attribute name */
649         List       *cols;                       /* names of the columns */
650         List       *targetList;         /* the target list (of ResTarget) */
651         List       *fromClause;         /* the from clause */
652         Node       *whereClause;        /* qualifications */
653         List       *groupClause;        /* GROUP BY clauses */
654         Node       *havingClause;       /* having conditional-expression */
655         List       *unionClause;        /* union subselect parameters */
656         bool            unionall;               /* union without unique sort */
657         List       *intersectClause;
658         List       *forUpdate;          /* FOR UPDATE clause */
659 } InsertStmt;
660
661 /* ----------------------
662  *              Delete Statement
663  * ----------------------
664  */
665 typedef struct DeleteStmt
666 {
667         NodeTag         type;
668         char       *relname;            /* relation to delete from */
669         Node       *whereClause;        /* qualifications */
670 } DeleteStmt;
671
672 /* ----------------------
673  *              Update Statement
674  * ----------------------
675  */
676 typedef struct UpdateStmt
677 {
678         NodeTag         type;
679         char       *relname;            /* relation to update */
680         List       *targetList;         /* the target list (of ResTarget) */
681         Node       *whereClause;        /* qualifications */
682         List       *fromClause;         /* the from clause */
683 } UpdateStmt;
684
685 /* ----------------------
686  *              Select Statement
687  * ----------------------
688  */
689 typedef struct SelectStmt
690 {
691         NodeTag         type;
692         char       *unique;                     /* NULL, '*', or unique attribute name */
693         char       *into;                       /* name of table (for select into table) */
694         List       *targetList;         /* the target list (of ResTarget) */
695         List       *fromClause;         /* the from clause */
696         Node       *whereClause;        /* qualifications */
697         List       *groupClause;        /* GROUP BY clauses */
698         Node       *havingClause;       /* having conditional-expression */
699         List       *intersectClause;
700         List       *exceptClause;
701
702         List       *unionClause;        /* union subselect parameters */
703         List       *sortClause;         /* sort clause (a list of SortGroupBy's) */
704         char       *portalname;         /* the portal (cursor) to create */
705         bool            binary;                 /* a binary (internal) portal? */
706         bool            istemp;                 /* into is a temp table */
707         bool            unionall;               /* union without unique sort */
708         Node       *limitOffset;        /* # of result tuples to skip */
709         Node       *limitCount;         /* # of result tuples to return */
710         List       *forUpdate;          /* FOR UPDATE clause */
711 } SelectStmt;
712
713 /****************************************************************************
714  *      Supporting data structures for Parse Trees
715  ****************************************************************************/
716
717 /*
718  * TypeName - specifies a type in definitions
719  */
720 typedef struct TypeName
721 {
722         NodeTag         type;
723         char       *name;                       /* name of the type */
724         bool            timezone;               /* timezone specified? */
725         bool            setof;                  /* is a set? */
726         int32           typmod;                 /* type modifier */
727         List       *arrayBounds;        /* array bounds */
728 } TypeName;
729
730 /*
731  * ParamNo - specifies a parameter reference
732  */
733 typedef struct ParamNo
734 {
735         NodeTag         type;
736         int                     number;                 /* the number of the parameter */
737         TypeName   *typename;           /* the typecast */
738         List       *indirection;        /* array references */
739 } ParamNo;
740
741 /*
742  * A_Expr - binary expressions
743  */
744 typedef struct A_Expr
745 {
746         NodeTag         type;
747         int                     oper;                   /* type of operation
748                                                                  * {OP,OR,AND,NOT,ISNULL,NOTNULL} */
749         char       *opname;                     /* name of operator/function */
750         Node       *lexpr;                      /* left argument */
751         Node       *rexpr;                      /* right argument */
752 } A_Expr;
753
754 /*
755  * Attr -
756  *        specifies an Attribute (ie. a Column); could have nested dots or
757  *        array references.
758  *
759  */
760 typedef struct Attr
761 {
762         NodeTag         type;
763         char       *relname;            /* name of relation (can be "*") */
764         ParamNo    *paramNo;            /* or a parameter */
765         List       *attrs;                      /* attributes (possibly nested); list of
766                                                                  * Values (strings) */
767         List       *indirection;        /* array refs (list of A_Indices') */
768 } Attr;
769
770 /*
771  * A_Const - a constant expression
772  */
773 typedef struct A_Const
774 {
775         NodeTag         type;
776         Value           val;                    /* the value (with the tag) */
777         TypeName   *typename;           /* typecast */
778 } A_Const;
779
780 /*
781  * CaseExpr - a CASE expression
782  */
783 typedef struct CaseExpr
784 {
785         NodeTag         type;
786         Oid                     casetype;
787         Node       *arg;                        /* implicit equality comparison argument */
788         List       *args;                       /* the arguments (list of WHEN clauses) */
789         Node       *defresult;          /* the default result (ELSE clause) */
790 } CaseExpr;
791
792 /*
793  * CaseWhen - an argument to a CASE expression
794  */
795 typedef struct CaseWhen
796 {
797         NodeTag         type;
798         Node       *expr;                       /* comparison expression */
799         Node       *result;                     /* substitution result */
800 } CaseWhen;
801
802 /*
803  * ColumnDef - column definition (used in various creates)
804  *
805  * If the column has a default value, we may have the value expression
806  * in either "raw" form (an untransformed parse tree) or "cooked" form
807  * (the nodeToString representation of an executable expression tree),
808  * depending on how this ColumnDef node was created (by parsing, or by
809  * inheritance from an existing relation).  We should never have both
810  * in the same node!
811  *
812  * The constraints list may contain a CONSTR_DEFAULT item in a raw
813  * parsetree produced by gram.y, but transformCreateStmt will remove
814  * the item and set raw_default instead.  CONSTR_DEFAULT items
815  * should not appear in any subsequent processing.
816  */
817 typedef struct ColumnDef
818 {
819         NodeTag         type;
820         char       *colname;            /* name of column */
821         TypeName   *typename;           /* type of column */
822         bool            is_not_null;    /* flag to NOT NULL constraint */
823         bool            is_sequence;    /* is a sequence? */
824         Node       *raw_default;        /* default value (untransformed parse tree) */
825         char       *cooked_default;     /* nodeToString representation */
826         List       *constraints;        /* other constraints on column */
827 } ColumnDef;
828
829 /*
830  * Ident -
831  *        an identifier (could be an attribute or a relation name). Depending
832  *        on the context at transformStmt time, the identifier is treated as
833  *        either a relation name (in which case, isRel will be set) or an
834  *        attribute (in which case, it will be transformed into an Attr).
835  */
836 typedef struct Ident
837 {
838         NodeTag         type;
839         char       *name;                       /* its name */
840         List       *indirection;        /* array references */
841         bool            isRel;                  /* is a relation - filled in by
842                                                                  * transformExpr() */
843 } Ident;
844
845 /*
846  * FuncCall - a function/aggregate invocation
847  */
848 typedef struct FuncCall
849 {
850         NodeTag         type;
851         char       *funcname;           /* name of function */
852         List       *args;                       /* the arguments (list of exprs) */
853 } FuncCall;
854
855 /*
856  * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
857  */
858 typedef struct A_Indices
859 {
860         NodeTag         type;
861         Node       *lidx;                       /* could be NULL */
862         Node       *uidx;
863 } A_Indices;
864
865 /*
866  * ResTarget -
867  *        result target (used in target list of pre-transformed Parse trees)
868  *
869  * In a SELECT or INSERT target list, 'name' is either NULL or
870  * the column name assigned to the value.  (If there is an 'AS ColumnLabel'
871  * clause, the grammar sets 'name' from it; otherwise 'name' is initially NULL
872  * and is filled in during the parse analysis phase.)
873  * The 'indirection' field is not used at all.
874  *
875  * In an UPDATE target list, 'name' is the name of the destination column,
876  * and 'indirection' stores any subscripts attached to the destination.
877  * That is, our representation is UPDATE table SET name [indirection] = val.
878  */
879 typedef struct ResTarget
880 {
881         NodeTag         type;
882         char       *name;                       /* column name or NULL */
883         List       *indirection;        /* subscripts for destination column, or
884                                                                  * NIL */
885         Node       *val;                        /* the value expression to compute or
886                                                                  * assign */
887 } ResTarget;
888
889 /*
890  * RelExpr - relation expressions
891  */
892 typedef struct RelExpr
893 {
894         NodeTag         type;
895         char       *relname;            /* the relation name */
896         bool            inh;                    /* inheritance query */
897 } RelExpr;
898
899 /*
900  * SortGroupBy - for ORDER BY clause
901  */
902 typedef struct SortGroupBy
903 {
904         NodeTag         type;
905         char       *useOp;                      /* operator to use */
906         Node       *node;                       /* Expression  */
907 } SortGroupBy;
908
909 /*
910  * RangeVar - range variable, used in FROM clauses
911  */
912 typedef struct RangeVar
913 {
914         NodeTag         type;
915         RelExpr    *relExpr;            /* the relation expression */
916         char       *name;                       /* the name to be referenced (optional) */
917 } RangeVar;
918
919 /*
920  * IndexElem - index parameters (used in CREATE INDEX)
921  */
922 typedef struct IndexElem
923 {
924         NodeTag         type;
925         char       *name;                       /* name of index */
926         List       *args;                       /* if not NULL, function index */
927         char       *class;
928         TypeName   *typename;           /* type of index's keys (optional) */
929 } IndexElem;
930
931 /*
932  * DefElem -
933  *        a definition (used in definition lists in the form of defname = arg)
934  */
935 typedef struct DefElem
936 {
937         NodeTag         type;
938         char       *defname;
939         Node       *arg;                        /* a (Value *) or a (TypeName *) */
940 } DefElem;
941
942 /*
943  * JoinExpr - for JOIN expressions
944  */
945 typedef struct JoinExpr
946 {
947         NodeTag         type;
948         int                     jointype;
949         RangeVar   *larg;
950         Node       *rarg;
951         List       *quals;
952 } JoinExpr;
953
954
955 /****************************************************************************
956  *      Nodes for a Query tree
957  ****************************************************************************/
958
959 /*
960  * TargetEntry -
961  *         a target  entry (used in the transformed target list)
962  *
963  * one of resdom or fjoin is not NULL. a target list is
964  *              ((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
965  */
966 typedef struct TargetEntry
967 {
968         NodeTag         type;
969         Resdom     *resdom;                     /* fjoin overload this to be a list?? */
970         Fjoin      *fjoin;
971         Node       *expr;                       /* can be a list too */
972 } TargetEntry;
973
974 /*
975  * RangeTblEntry -
976  *        used in range tables. Some of the following are only used in one of
977  *        the parsing, optimizing, execution stages.
978  *
979  *        inFromCl marks those range variables that are listed in the from clause.
980  *        In SQL, the targetlist can only refer to range variables listed in the
981  *        from clause but POSTQUEL allows you to refer to tables not specified, in
982  *        which case a range table entry will be generated. We use POSTQUEL
983  *        semantics which is more powerful. However, we need SQL semantics in
984  *        some cases (eg. when expanding a '*')
985  */
986 typedef struct RangeTblEntry
987 {
988         NodeTag         type;
989         char       *relname;            /* real name of the relation */
990         char       *refname;            /* the reference name (specified in the
991                                                                  * from clause) */
992         Oid                     relid;
993         bool            inh;                    /* inheritance? */
994         bool            inFromCl;               /* comes from From Clause */
995         bool            skipAcl;                /* skip ACL check in executor */
996 } RangeTblEntry;
997
998 /*
999  * SortClause -
1000  *         representation of ORDER BY clauses
1001  *
1002  * tleSortGroupRef must match ressortgroupref of exactly one Resdom of the
1003  * associated targetlist; that is the expression to be sorted (or grouped) by.
1004  * sortop is the OID of the ordering operator.
1005  */
1006 typedef struct SortClause
1007 {
1008         NodeTag         type;
1009         Index           tleSortGroupRef;/* reference into targetlist */
1010         Oid                     sortop;                 /* the sort operator to use */
1011 } SortClause;
1012
1013 /*
1014  * GroupClause -
1015  *         representation of GROUP BY clauses
1016  *
1017  * GroupClause is exactly like SortClause except for the nodetag value
1018  * (and it's probably not even really necessary to have two different
1019  * nodetags...).  We have routines that operate interchangeably on both.
1020  */
1021 typedef SortClause GroupClause;
1022
1023 #define ROW_MARK_FOR_UPDATE             (1 << 0)
1024 #define ROW_ACL_FOR_UPDATE              (1 << 1)
1025
1026 typedef struct RowMark
1027 {
1028         NodeTag         type;
1029         Index           rti;                    /* index in Query->rtable */
1030         bits8           info;                   /* as above */
1031 } RowMark;
1032
1033 #endif   /* PARSENODES_H */