OSDN Git Service

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