]> granicus.if.org Git - postgresql/blob - src/include/nodes/nodes.h
fce48026b6d1d7ce8353e17efcfc1d24a96a72a7
[postgresql] / src / include / nodes / nodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * nodes.h
4  *        Definitions for tagged nodes.
5  *
6  *
7  * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/nodes/nodes.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef NODES_H
15 #define NODES_H
16
17 /*
18  * The first field of every node is NodeTag. Each node created (with makeNode)
19  * will have one of the following tags as the value of its first field.
20  *
21  * Note that inserting or deleting node types changes the numbers of other
22  * node types later in the list.  This is no problem during development, since
23  * the node numbers are never stored on disk.  But don't do it in a released
24  * branch, because that would represent an ABI break for extensions.
25  */
26 typedef enum NodeTag
27 {
28         T_Invalid = 0,
29
30         /*
31          * TAGS FOR EXECUTOR NODES (execnodes.h)
32          */
33         T_IndexInfo,
34         T_ExprContext,
35         T_ProjectionInfo,
36         T_JunkFilter,
37         T_OnConflictSetState,
38         T_ResultRelInfo,
39         T_EState,
40         T_TupleTableSlot,
41
42         /*
43          * TAGS FOR PLAN NODES (plannodes.h)
44          */
45         T_Plan,
46         T_Result,
47         T_ProjectSet,
48         T_ModifyTable,
49         T_Append,
50         T_MergeAppend,
51         T_RecursiveUnion,
52         T_BitmapAnd,
53         T_BitmapOr,
54         T_Scan,
55         T_SeqScan,
56         T_SampleScan,
57         T_IndexScan,
58         T_IndexOnlyScan,
59         T_BitmapIndexScan,
60         T_BitmapHeapScan,
61         T_TidScan,
62         T_SubqueryScan,
63         T_FunctionScan,
64         T_ValuesScan,
65         T_TableFuncScan,
66         T_CteScan,
67         T_NamedTuplestoreScan,
68         T_WorkTableScan,
69         T_ForeignScan,
70         T_CustomScan,
71         T_Join,
72         T_NestLoop,
73         T_MergeJoin,
74         T_HashJoin,
75         T_Material,
76         T_Sort,
77         T_Group,
78         T_Agg,
79         T_WindowAgg,
80         T_Unique,
81         T_Gather,
82         T_GatherMerge,
83         T_Hash,
84         T_SetOp,
85         T_LockRows,
86         T_Limit,
87         /* these aren't subclasses of Plan: */
88         T_NestLoopParam,
89         T_PlanRowMark,
90         T_PlanInvalItem,
91
92         /*
93          * TAGS FOR PLAN STATE NODES (execnodes.h)
94          *
95          * These should correspond one-to-one with Plan node types.
96          */
97         T_PlanState,
98         T_ResultState,
99         T_ProjectSetState,
100         T_MergeActionState,
101         T_ModifyTableState,
102         T_AppendState,
103         T_MergeAppendState,
104         T_RecursiveUnionState,
105         T_BitmapAndState,
106         T_BitmapOrState,
107         T_ScanState,
108         T_SeqScanState,
109         T_SampleScanState,
110         T_IndexScanState,
111         T_IndexOnlyScanState,
112         T_BitmapIndexScanState,
113         T_BitmapHeapScanState,
114         T_TidScanState,
115         T_SubqueryScanState,
116         T_FunctionScanState,
117         T_TableFuncScanState,
118         T_ValuesScanState,
119         T_CteScanState,
120         T_NamedTuplestoreScanState,
121         T_WorkTableScanState,
122         T_ForeignScanState,
123         T_CustomScanState,
124         T_JoinState,
125         T_NestLoopState,
126         T_MergeJoinState,
127         T_HashJoinState,
128         T_MaterialState,
129         T_SortState,
130         T_GroupState,
131         T_AggState,
132         T_WindowAggState,
133         T_UniqueState,
134         T_GatherState,
135         T_GatherMergeState,
136         T_HashState,
137         T_SetOpState,
138         T_LockRowsState,
139         T_LimitState,
140
141         /*
142          * TAGS FOR PRIMITIVE NODES (primnodes.h)
143          */
144         T_Alias,
145         T_RangeVar,
146         T_TableFunc,
147         T_Expr,
148         T_Var,
149         T_Const,
150         T_Param,
151         T_Aggref,
152         T_GroupingFunc,
153         T_WindowFunc,
154         T_ArrayRef,
155         T_FuncExpr,
156         T_NamedArgExpr,
157         T_OpExpr,
158         T_DistinctExpr,
159         T_NullIfExpr,
160         T_ScalarArrayOpExpr,
161         T_BoolExpr,
162         T_SubLink,
163         T_SubPlan,
164         T_AlternativeSubPlan,
165         T_FieldSelect,
166         T_FieldStore,
167         T_RelabelType,
168         T_CoerceViaIO,
169         T_ArrayCoerceExpr,
170         T_ConvertRowtypeExpr,
171         T_CollateExpr,
172         T_CaseExpr,
173         T_CaseWhen,
174         T_CaseTestExpr,
175         T_ArrayExpr,
176         T_RowExpr,
177         T_RowCompareExpr,
178         T_CoalesceExpr,
179         T_MinMaxExpr,
180         T_SQLValueFunction,
181         T_XmlExpr,
182         T_NullTest,
183         T_BooleanTest,
184         T_CoerceToDomain,
185         T_CoerceToDomainValue,
186         T_SetToDefault,
187         T_CurrentOfExpr,
188         T_NextValueExpr,
189         T_InferenceElem,
190         T_TargetEntry,
191         T_RangeTblRef,
192         T_JoinExpr,
193         T_FromExpr,
194         T_OnConflictExpr,
195         T_IntoClause,
196
197         /*
198          * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
199          *
200          * ExprState represents the evaluation state for a whole expression tree.
201          * Most Expr-based plan nodes do not have a corresponding expression state
202          * node, they're fully handled within execExpr* - but sometimes the state
203          * needs to be shared with other parts of the executor, as for example
204          * with AggrefExprState, which nodeAgg.c has to modify.
205          */
206         T_ExprState,
207         T_AggrefExprState,
208         T_WindowFuncExprState,
209         T_SetExprState,
210         T_SubPlanState,
211         T_AlternativeSubPlanState,
212         T_DomainConstraintState,
213
214         /*
215          * TAGS FOR PLANNER NODES (relation.h)
216          */
217         T_PlannerInfo,
218         T_PlannerGlobal,
219         T_RelOptInfo,
220         T_IndexOptInfo,
221         T_ForeignKeyOptInfo,
222         T_ParamPathInfo,
223         T_Path,
224         T_IndexPath,
225         T_BitmapHeapPath,
226         T_BitmapAndPath,
227         T_BitmapOrPath,
228         T_TidPath,
229         T_SubqueryScanPath,
230         T_ForeignPath,
231         T_CustomPath,
232         T_NestPath,
233         T_MergePath,
234         T_HashPath,
235         T_AppendPath,
236         T_MergeAppendPath,
237         T_ResultPath,
238         T_MaterialPath,
239         T_UniquePath,
240         T_GatherPath,
241         T_GatherMergePath,
242         T_ProjectionPath,
243         T_ProjectSetPath,
244         T_SortPath,
245         T_GroupPath,
246         T_UpperUniquePath,
247         T_AggPath,
248         T_GroupingSetsPath,
249         T_MinMaxAggPath,
250         T_WindowAggPath,
251         T_SetOpPath,
252         T_RecursiveUnionPath,
253         T_LockRowsPath,
254         T_ModifyTablePath,
255         T_LimitPath,
256         /* these aren't subclasses of Path: */
257         T_EquivalenceClass,
258         T_EquivalenceMember,
259         T_PathKey,
260         T_PathTarget,
261         T_RestrictInfo,
262         T_PlaceHolderVar,
263         T_SpecialJoinInfo,
264         T_AppendRelInfo,
265         T_PartitionedChildRelInfo,
266         T_PlaceHolderInfo,
267         T_MinMaxAggInfo,
268         T_PlannerParamItem,
269         T_RollupData,
270         T_GroupingSetData,
271         T_StatisticExtInfo,
272
273         /*
274          * TAGS FOR MEMORY NODES (memnodes.h)
275          */
276         T_MemoryContext,
277         T_AllocSetContext,
278         T_SlabContext,
279         T_GenerationContext,
280
281         /*
282          * TAGS FOR VALUE NODES (value.h)
283          */
284         T_Value,
285         T_Integer,
286         T_Float,
287         T_String,
288         T_BitString,
289         T_Null,
290
291         /*
292          * TAGS FOR LIST NODES (pg_list.h)
293          */
294         T_List,
295         T_IntList,
296         T_OidList,
297
298         /*
299          * TAGS FOR EXTENSIBLE NODES (extensible.h)
300          */
301         T_ExtensibleNode,
302
303         /*
304          * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
305          */
306         T_RawStmt,
307         T_Query,
308         T_PlannedStmt,
309         T_InsertStmt,
310         T_DeleteStmt,
311         T_UpdateStmt,
312         T_MergeStmt,
313         T_MergeAction,
314         T_SelectStmt,
315         T_AlterTableStmt,
316         T_AlterTableCmd,
317         T_AlterDomainStmt,
318         T_SetOperationStmt,
319         T_GrantStmt,
320         T_GrantRoleStmt,
321         T_AlterDefaultPrivilegesStmt,
322         T_ClosePortalStmt,
323         T_ClusterStmt,
324         T_CopyStmt,
325         T_CreateStmt,
326         T_DefineStmt,
327         T_DropStmt,
328         T_TruncateStmt,
329         T_CommentStmt,
330         T_FetchStmt,
331         T_IndexStmt,
332         T_CreateFunctionStmt,
333         T_AlterFunctionStmt,
334         T_DoStmt,
335         T_RenameStmt,
336         T_RuleStmt,
337         T_NotifyStmt,
338         T_ListenStmt,
339         T_UnlistenStmt,
340         T_TransactionStmt,
341         T_ViewStmt,
342         T_LoadStmt,
343         T_CreateDomainStmt,
344         T_CreatedbStmt,
345         T_DropdbStmt,
346         T_VacuumStmt,
347         T_ExplainStmt,
348         T_CreateTableAsStmt,
349         T_CreateSeqStmt,
350         T_AlterSeqStmt,
351         T_VariableSetStmt,
352         T_VariableShowStmt,
353         T_DiscardStmt,
354         T_CreateTrigStmt,
355         T_CreatePLangStmt,
356         T_CreateRoleStmt,
357         T_AlterRoleStmt,
358         T_DropRoleStmt,
359         T_LockStmt,
360         T_ConstraintsSetStmt,
361         T_ReindexStmt,
362         T_CheckPointStmt,
363         T_CreateSchemaStmt,
364         T_AlterDatabaseStmt,
365         T_AlterDatabaseSetStmt,
366         T_AlterRoleSetStmt,
367         T_CreateConversionStmt,
368         T_CreateCastStmt,
369         T_CreateOpClassStmt,
370         T_CreateOpFamilyStmt,
371         T_AlterOpFamilyStmt,
372         T_PrepareStmt,
373         T_ExecuteStmt,
374         T_DeallocateStmt,
375         T_DeclareCursorStmt,
376         T_CreateTableSpaceStmt,
377         T_DropTableSpaceStmt,
378         T_AlterObjectDependsStmt,
379         T_AlterObjectSchemaStmt,
380         T_AlterOwnerStmt,
381         T_AlterOperatorStmt,
382         T_DropOwnedStmt,
383         T_ReassignOwnedStmt,
384         T_CompositeTypeStmt,
385         T_CreateEnumStmt,
386         T_CreateRangeStmt,
387         T_AlterEnumStmt,
388         T_AlterTSDictionaryStmt,
389         T_AlterTSConfigurationStmt,
390         T_CreateFdwStmt,
391         T_AlterFdwStmt,
392         T_CreateForeignServerStmt,
393         T_AlterForeignServerStmt,
394         T_CreateUserMappingStmt,
395         T_AlterUserMappingStmt,
396         T_DropUserMappingStmt,
397         T_AlterTableSpaceOptionsStmt,
398         T_AlterTableMoveAllStmt,
399         T_SecLabelStmt,
400         T_CreateForeignTableStmt,
401         T_ImportForeignSchemaStmt,
402         T_CreateExtensionStmt,
403         T_AlterExtensionStmt,
404         T_AlterExtensionContentsStmt,
405         T_CreateEventTrigStmt,
406         T_AlterEventTrigStmt,
407         T_RefreshMatViewStmt,
408         T_ReplicaIdentityStmt,
409         T_AlterSystemStmt,
410         T_CreatePolicyStmt,
411         T_AlterPolicyStmt,
412         T_CreateTransformStmt,
413         T_CreateAmStmt,
414         T_CreatePublicationStmt,
415         T_AlterPublicationStmt,
416         T_CreateSubscriptionStmt,
417         T_AlterSubscriptionStmt,
418         T_DropSubscriptionStmt,
419         T_CreateStatsStmt,
420         T_AlterCollationStmt,
421         T_CallStmt,
422
423         /*
424          * TAGS FOR PARSE TREE NODES (parsenodes.h)
425          */
426         T_A_Expr,
427         T_ColumnRef,
428         T_ParamRef,
429         T_A_Const,
430         T_FuncCall,
431         T_A_Star,
432         T_A_Indices,
433         T_A_Indirection,
434         T_A_ArrayExpr,
435         T_ResTarget,
436         T_MultiAssignRef,
437         T_TypeCast,
438         T_CollateClause,
439         T_SortBy,
440         T_WindowDef,
441         T_RangeSubselect,
442         T_RangeFunction,
443         T_RangeTableSample,
444         T_RangeTableFunc,
445         T_RangeTableFuncCol,
446         T_TypeName,
447         T_ColumnDef,
448         T_IndexElem,
449         T_Constraint,
450         T_DefElem,
451         T_RangeTblEntry,
452         T_RangeTblFunction,
453         T_TableSampleClause,
454         T_WithCheckOption,
455         T_SortGroupClause,
456         T_GroupingSet,
457         T_WindowClause,
458         T_ObjectWithArgs,
459         T_AccessPriv,
460         T_CreateOpClassItem,
461         T_TableLikeClause,
462         T_FunctionParameter,
463         T_LockingClause,
464         T_RowMarkClause,
465         T_XmlSerialize,
466         T_WithClause,
467         T_InferClause,
468         T_OnConflictClause,
469         T_CommonTableExpr,
470         T_RoleSpec,
471         T_TriggerTransition,
472         T_PartitionElem,
473         T_PartitionSpec,
474         T_PartitionBoundSpec,
475         T_PartitionRangeDatum,
476         T_PartitionCmd,
477         T_VacuumRelation,
478
479         /*
480          * TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
481          */
482         T_IdentifySystemCmd,
483         T_BaseBackupCmd,
484         T_CreateReplicationSlotCmd,
485         T_DropReplicationSlotCmd,
486         T_StartReplicationCmd,
487         T_TimeLineHistoryCmd,
488         T_SQLCmd,
489
490         /*
491          * TAGS FOR RANDOM OTHER STUFF
492          *
493          * These are objects that aren't part of parse/plan/execute node tree
494          * structures, but we give them NodeTags anyway for identification
495          * purposes (usually because they are involved in APIs where we want to
496          * pass multiple object types through the same pointer).
497          */
498         T_TriggerData,                          /* in commands/trigger.h */
499         T_EventTriggerData,                     /* in commands/event_trigger.h */
500         T_ReturnSetInfo,                        /* in nodes/execnodes.h */
501         T_WindowObjectData,                     /* private in nodeWindowAgg.c */
502         T_TIDBitmap,                            /* in nodes/tidbitmap.h */
503         T_InlineCodeBlock,                      /* in nodes/parsenodes.h */
504         T_FdwRoutine,                           /* in foreign/fdwapi.h */
505         T_IndexAmRoutine,                       /* in access/amapi.h */
506         T_TsmRoutine,                           /* in access/tsmapi.h */
507         T_ForeignKeyCacheInfo,          /* in utils/rel.h */
508         T_CallContext                           /* in nodes/parsenodes.h */
509 } NodeTag;
510
511 /*
512  * The first field of a node of any type is guaranteed to be the NodeTag.
513  * Hence the type of any node can be gotten by casting it to Node. Declaring
514  * a variable to be of Node * (instead of void *) can also facilitate
515  * debugging.
516  */
517 typedef struct Node
518 {
519         NodeTag         type;
520 } Node;
521
522 #define nodeTag(nodeptr)                (((const Node*)(nodeptr))->type)
523
524 /*
525  * newNode -
526  *        create a new node of the specified size and tag the node with the
527  *        specified tag.
528  *
529  * !WARNING!: Avoid using newNode directly. You should be using the
530  *        macro makeNode.  eg. to create a Query node, use makeNode(Query)
531  *
532  * Note: the size argument should always be a compile-time constant, so the
533  * apparent risk of multiple evaluation doesn't matter in practice.
534  */
535 #ifdef __GNUC__
536
537 /* With GCC, we can use a compound statement within an expression */
538 #define newNode(size, tag) \
539 ({      Node   *_result; \
540         AssertMacro((size) >= sizeof(Node));            /* need the tag, at least */ \
541         _result = (Node *) palloc0fast(size); \
542         _result->type = (tag); \
543         _result; \
544 })
545 #else
546
547 /*
548  *      There is no way to dereference the palloc'ed pointer to assign the
549  *      tag, and also return the pointer itself, so we need a holder variable.
550  *      Fortunately, this macro isn't recursive so we just define
551  *      a global variable for this purpose.
552  */
553 extern PGDLLIMPORT Node *newNodeMacroHolder;
554
555 #define newNode(size, tag) \
556 ( \
557         AssertMacro((size) >= sizeof(Node)),            /* need the tag, at least */ \
558         newNodeMacroHolder = (Node *) palloc0fast(size), \
559         newNodeMacroHolder->type = (tag), \
560         newNodeMacroHolder \
561 )
562 #endif                                                  /* __GNUC__ */
563
564
565 #define makeNode(_type_)                ((_type_ *) newNode(sizeof(_type_),T_##_type_))
566 #define NodeSetTag(nodeptr,t)   (((Node*)(nodeptr))->type = (t))
567
568 #define IsA(nodeptr,_type_)             (nodeTag(nodeptr) == T_##_type_)
569
570 /*
571  * castNode(type, ptr) casts ptr to "type *", and if assertions are enabled,
572  * verifies that the node has the appropriate type (using its nodeTag()).
573  *
574  * Use an inline function when assertions are enabled, to avoid multiple
575  * evaluations of the ptr argument (which could e.g. be a function call).
576  */
577 #ifdef USE_ASSERT_CHECKING
578 static inline Node *
579 castNodeImpl(NodeTag type, void *ptr)
580 {
581         Assert(ptr == NULL || nodeTag(ptr) == type);
582         return (Node *) ptr;
583 }
584 #define castNode(_type_, nodeptr) ((_type_ *) castNodeImpl(T_##_type_, nodeptr))
585 #else
586 #define castNode(_type_, nodeptr) ((_type_ *) (nodeptr))
587 #endif                                                  /* USE_ASSERT_CHECKING */
588
589
590 /* ----------------------------------------------------------------
591  *                                        extern declarations follow
592  * ----------------------------------------------------------------
593  */
594
595 /*
596  * nodes/{outfuncs.c,print.c}
597  */
598 struct Bitmapset;                               /* not to include bitmapset.h here */
599 struct StringInfoData;                  /* not to include stringinfo.h here */
600
601 extern void outNode(struct StringInfoData *str, const void *obj);
602 extern void outToken(struct StringInfoData *str, const char *s);
603 extern void outBitmapset(struct StringInfoData *str,
604                          const struct Bitmapset *bms);
605 extern void outDatum(struct StringInfoData *str, uintptr_t value,
606                  int typlen, bool typbyval);
607 extern char *nodeToString(const void *obj);
608 extern char *bmsToString(const struct Bitmapset *bms);
609
610 /*
611  * nodes/{readfuncs.c,read.c}
612  */
613 extern void *stringToNode(char *str);
614 extern struct Bitmapset *readBitmapset(void);
615 extern uintptr_t readDatum(bool typbyval);
616 extern bool *readBoolCols(int numCols);
617 extern int *readIntCols(int numCols);
618 extern Oid *readOidCols(int numCols);
619 extern int16 *readAttrNumberCols(int numCols);
620
621 /*
622  * nodes/copyfuncs.c
623  */
624 extern void *copyObjectImpl(const void *obj);
625
626 /* cast result back to argument type, if supported by compiler */
627 #ifdef HAVE_TYPEOF
628 #define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
629 #else
630 #define copyObject(obj) copyObjectImpl(obj)
631 #endif
632
633 /*
634  * nodes/equalfuncs.c
635  */
636 extern bool equal(const void *a, const void *b);
637
638
639 /*
640  * Typedefs for identifying qualifier selectivities and plan costs as such.
641  * These are just plain "double"s, but declaring a variable as Selectivity
642  * or Cost makes the intent more obvious.
643  *
644  * These could have gone into plannodes.h or some such, but many files
645  * depend on them...
646  */
647 typedef double Selectivity;             /* fraction of tuples a qualifier will pass */
648 typedef double Cost;                    /* execution cost (in page-access units) */
649
650
651 /*
652  * CmdType -
653  *        enums for type of operation represented by a Query or PlannedStmt
654  *
655  * This is needed in both parsenodes.h and plannodes.h, so put it here...
656  */
657 typedef enum CmdType
658 {
659         CMD_UNKNOWN,
660         CMD_SELECT,                                     /* select stmt */
661         CMD_UPDATE,                                     /* update stmt */
662         CMD_INSERT,                                     /* insert stmt */
663         CMD_DELETE,                                     /* delete stmt */
664         CMD_MERGE,                                      /* merge stmt */
665         CMD_UTILITY,                            /* cmds like create, destroy, copy, vacuum,
666                                                                  * etc. */
667         CMD_NOTHING                                     /* dummy command for instead nothing rules
668                                                                  * with qual */
669 } CmdType;
670
671
672 /*
673  * JoinType -
674  *        enums for types of relation joins
675  *
676  * JoinType determines the exact semantics of joining two relations using
677  * a matching qualification.  For example, it tells what to do with a tuple
678  * that has no match in the other relation.
679  *
680  * This is needed in both parsenodes.h and plannodes.h, so put it here...
681  */
682 typedef enum JoinType
683 {
684         /*
685          * The canonical kinds of joins according to the SQL JOIN syntax. Only
686          * these codes can appear in parser output (e.g., JoinExpr nodes).
687          */
688         JOIN_INNER,                                     /* matching tuple pairs only */
689         JOIN_LEFT,                                      /* pairs + unmatched LHS tuples */
690         JOIN_FULL,                                      /* pairs + unmatched LHS + unmatched RHS */
691         JOIN_RIGHT,                                     /* pairs + unmatched RHS tuples */
692
693         /*
694          * Semijoins and anti-semijoins (as defined in relational theory) do not
695          * appear in the SQL JOIN syntax, but there are standard idioms for
696          * representing them (e.g., using EXISTS).  The planner recognizes these
697          * cases and converts them to joins.  So the planner and executor must
698          * support these codes.  NOTE: in JOIN_SEMI output, it is unspecified
699          * which matching RHS row is joined to.  In JOIN_ANTI output, the row is
700          * guaranteed to be null-extended.
701          */
702         JOIN_SEMI,                                      /* 1 copy of each LHS row that has match(es) */
703         JOIN_ANTI,                                      /* 1 copy of each LHS row that has no match */
704
705         /*
706          * These codes are used internally in the planner, but are not supported
707          * by the executor (nor, indeed, by most of the planner).
708          */
709         JOIN_UNIQUE_OUTER,                      /* LHS path must be made unique */
710         JOIN_UNIQUE_INNER                       /* RHS path must be made unique */
711
712         /*
713          * We might need additional join types someday.
714          */
715 } JoinType;
716
717 /*
718  * OUTER joins are those for which pushed-down quals must behave differently
719  * from the join's own quals.  This is in fact everything except INNER and
720  * SEMI joins.  However, this macro must also exclude the JOIN_UNIQUE symbols
721  * since those are temporary proxies for what will eventually be an INNER
722  * join.
723  *
724  * Note: semijoins are a hybrid case, but we choose to treat them as not
725  * being outer joins.  This is okay principally because the SQL syntax makes
726  * it impossible to have a pushed-down qual that refers to the inner relation
727  * of a semijoin; so there is no strong need to distinguish join quals from
728  * pushed-down quals.  This is convenient because for almost all purposes,
729  * quals attached to a semijoin can be treated the same as innerjoin quals.
730  */
731 #define IS_OUTER_JOIN(jointype) \
732         (((1 << (jointype)) & \
733           ((1 << JOIN_LEFT) | \
734            (1 << JOIN_FULL) | \
735            (1 << JOIN_RIGHT) | \
736            (1 << JOIN_ANTI))) != 0)
737
738 /*
739  * AggStrategy -
740  *        overall execution strategies for Agg plan nodes
741  *
742  * This is needed in both plannodes.h and relation.h, so put it here...
743  */
744 typedef enum AggStrategy
745 {
746         AGG_PLAIN,                                      /* simple agg across all input rows */
747         AGG_SORTED,                                     /* grouped agg, input must be sorted */
748         AGG_HASHED,                                     /* grouped agg, use internal hashtable */
749         AGG_MIXED                                       /* grouped agg, hash and sort both used */
750 } AggStrategy;
751
752 /*
753  * AggSplit -
754  *        splitting (partial aggregation) modes for Agg plan nodes
755  *
756  * This is needed in both plannodes.h and relation.h, so put it here...
757  */
758
759 /* Primitive options supported by nodeAgg.c: */
760 #define AGGSPLITOP_COMBINE              0x01    /* substitute combinefn for transfn */
761 #define AGGSPLITOP_SKIPFINAL    0x02    /* skip finalfn, return state as-is */
762 #define AGGSPLITOP_SERIALIZE    0x04    /* apply serializefn to output */
763 #define AGGSPLITOP_DESERIALIZE  0x08    /* apply deserializefn to input */
764
765 /* Supported operating modes (i.e., useful combinations of these options): */
766 typedef enum AggSplit
767 {
768         /* Basic, non-split aggregation: */
769         AGGSPLIT_SIMPLE = 0,
770         /* Initial phase of partial aggregation, with serialization: */
771         AGGSPLIT_INITIAL_SERIAL = AGGSPLITOP_SKIPFINAL | AGGSPLITOP_SERIALIZE,
772         /* Final phase of partial aggregation, with deserialization: */
773         AGGSPLIT_FINAL_DESERIAL = AGGSPLITOP_COMBINE | AGGSPLITOP_DESERIALIZE
774 } AggSplit;
775
776 /* Test whether an AggSplit value selects each primitive option: */
777 #define DO_AGGSPLIT_COMBINE(as)         (((as) & AGGSPLITOP_COMBINE) != 0)
778 #define DO_AGGSPLIT_SKIPFINAL(as)       (((as) & AGGSPLITOP_SKIPFINAL) != 0)
779 #define DO_AGGSPLIT_SERIALIZE(as)       (((as) & AGGSPLITOP_SERIALIZE) != 0)
780 #define DO_AGGSPLIT_DESERIALIZE(as) (((as) & AGGSPLITOP_DESERIALIZE) != 0)
781
782 /*
783  * SetOpCmd and SetOpStrategy -
784  *        overall semantics and execution strategies for SetOp plan nodes
785  *
786  * This is needed in both plannodes.h and relation.h, so put it here...
787  */
788 typedef enum SetOpCmd
789 {
790         SETOPCMD_INTERSECT,
791         SETOPCMD_INTERSECT_ALL,
792         SETOPCMD_EXCEPT,
793         SETOPCMD_EXCEPT_ALL
794 } SetOpCmd;
795
796 typedef enum SetOpStrategy
797 {
798         SETOP_SORTED,                           /* input must be sorted */
799         SETOP_HASHED                            /* use internal hashtable */
800 } SetOpStrategy;
801
802 /*
803  * OnConflictAction -
804  *        "ON CONFLICT" clause type of query
805  *
806  * This is needed in both parsenodes.h and plannodes.h, so put it here...
807  */
808 typedef enum OnConflictAction
809 {
810         ONCONFLICT_NONE,                        /* No "ON CONFLICT" clause */
811         ONCONFLICT_NOTHING,                     /* ON CONFLICT ... DO NOTHING */
812         ONCONFLICT_UPDATE                       /* ON CONFLICT ... DO UPDATE */
813 } OnConflictAction;
814
815 #endif                                                  /* NODES_H */