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_PartitionPruneInfo,
91 T_PartitionedRelPruneInfo,
92 T_PartitionPruneStepOp,
93 T_PartitionPruneStepCombine,
94 T_PlanInvalItem,
95
96 /*
97 * TAGS FOR PLAN STATE NODES (execnodes.h)
98 *
99 * These should correspond one-to-one with Plan node types.
100 */
101 T_PlanState,
102 T_ResultState,
103 T_ProjectSetState,
104 T_ModifyTableState,
105 T_AppendState,
106 T_MergeAppendState,
107 T_RecursiveUnionState,
108 T_BitmapAndState,
109 T_BitmapOrState,
110 T_ScanState,
111 T_SeqScanState,
112 T_SampleScanState,
113 T_IndexScanState,
114 T_IndexOnlyScanState,
115 T_BitmapIndexScanState,
116 T_BitmapHeapScanState,
117 T_TidScanState,
118 T_SubqueryScanState,
119 T_FunctionScanState,
120 T_TableFuncScanState,
121 T_ValuesScanState,
122 T_CteScanState,
123 T_NamedTuplestoreScanState,
124 T_WorkTableScanState,
125 T_ForeignScanState,
126 T_CustomScanState,
127 T_JoinState,
128 T_NestLoopState,
129 T_MergeJoinState,
130 T_HashJoinState,
131 T_MaterialState,
132 T_SortState,
133 T_GroupState,
134 T_AggState,
135 T_WindowAggState,
136 T_UniqueState,
137 T_GatherState,
138 T_GatherMergeState,
139 T_HashState,
140 T_SetOpState,
141 T_LockRowsState,
142 T_LimitState,
143
144 /*
145 * TAGS FOR PRIMITIVE NODES (primnodes.h)
146 */
147 T_Alias,
148 T_RangeVar,
149 T_TableFunc,
150 T_Expr,
151 T_Var,
152 T_Const,
153 T_Param,
154 T_Aggref,
155 T_GroupingFunc,
156 T_WindowFunc,
157 T_ArrayRef,
158 T_FuncExpr,
159 T_NamedArgExpr,
160 T_OpExpr,
161 T_DistinctExpr,
162 T_NullIfExpr,
163 T_ScalarArrayOpExpr,
164 T_BoolExpr,
165 T_SubLink,
166 T_SubPlan,
167 T_AlternativeSubPlan,
168 T_FieldSelect,
169 T_FieldStore,
170 T_RelabelType,
171 T_CoerceViaIO,
172 T_ArrayCoerceExpr,
173 T_ConvertRowtypeExpr,
174 T_CollateExpr,
175 T_CaseExpr,
176 T_CaseWhen,
177 T_CaseTestExpr,
178 T_ArrayExpr,
179 T_RowExpr,
180 T_RowCompareExpr,
181 T_CoalesceExpr,
182 T_MinMaxExpr,
183 T_SQLValueFunction,
184 T_XmlExpr,
185 T_NullTest,
186 T_BooleanTest,
187 T_CoerceToDomain,
188 T_CoerceToDomainValue,
189 T_SetToDefault,
190 T_CurrentOfExpr,
191 T_NextValueExpr,
192 T_InferenceElem,
193 T_TargetEntry,
194 T_RangeTblRef,
195 T_JoinExpr,
196 T_FromExpr,
197 T_OnConflictExpr,
198 T_IntoClause,
199
200 /*
201 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
202 *
203 * ExprState represents the evaluation state for a whole expression tree.
204 * Most Expr-based plan nodes do not have a corresponding expression state
205 * node, they're fully handled within execExpr* - but sometimes the state
206 * needs to be shared with other parts of the executor, as for example
207 * with AggrefExprState, which nodeAgg.c has to modify.
208 */
209 T_ExprState,
210 T_AggrefExprState,
211 T_WindowFuncExprState,
212 T_SetExprState,
213 T_SubPlanState,
214 T_AlternativeSubPlanState,
215 T_DomainConstraintState,
216
217 /*
218 * TAGS FOR PLANNER NODES (relation.h)
219 */
220 T_PlannerInfo,
221 T_PlannerGlobal,
222 T_RelOptInfo,
223 T_IndexOptInfo,
224 T_ForeignKeyOptInfo,
225 T_ParamPathInfo,
226 T_Path,
227 T_IndexPath,
228 T_BitmapHeapPath,
229 T_BitmapAndPath,
230 T_BitmapOrPath,
231 T_TidPath,
232 T_SubqueryScanPath,
233 T_ForeignPath,
234 T_CustomPath,
235 T_NestPath,
236 T_MergePath,
237 T_HashPath,
238 T_AppendPath,
239 T_MergeAppendPath,
240 T_ResultPath,
241 T_MaterialPath,
242 T_UniquePath,
243 T_GatherPath,
244 T_GatherMergePath,
245 T_ProjectionPath,
246 T_ProjectSetPath,
247 T_SortPath,
248 T_GroupPath,
249 T_UpperUniquePath,
250 T_AggPath,
251 T_GroupingSetsPath,
252 T_MinMaxAggPath,
253 T_WindowAggPath,
254 T_SetOpPath,
255 T_RecursiveUnionPath,
256 T_LockRowsPath,
257 T_ModifyTablePath,
258 T_LimitPath,
259 /* these aren't subclasses of Path: */
260 T_EquivalenceClass,
261 T_EquivalenceMember,
262 T_PathKey,
263 T_PathTarget,
264 T_RestrictInfo,
265 T_PlaceHolderVar,
266 T_SpecialJoinInfo,
267 T_AppendRelInfo,
268 T_PlaceHolderInfo,
269 T_MinMaxAggInfo,
270 T_PlannerParamItem,
271 T_RollupData,
272 T_GroupingSetData,
273 T_StatisticExtInfo,
274
275 /*
276 * TAGS FOR MEMORY NODES (memnodes.h)
277 */
278 T_MemoryContext,
279 T_AllocSetContext,
280 T_SlabContext,
281 T_GenerationContext,
282
283 /*
284 * TAGS FOR VALUE NODES (value.h)
285 */
286 T_Value,
287 T_Integer,
288 T_Float,
289 T_String,
290 T_BitString,
291 T_Null,
292
293 /*
294 * TAGS FOR LIST NODES (pg_list.h)
295 */
296 T_List,
297 T_IntList,
298 T_OidList,
299
300 /*
301 * TAGS FOR EXTENSIBLE NODES (extensible.h)
302 */
303 T_ExtensibleNode,
304
305 /*
306 * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
307 */
308 T_RawStmt,
309 T_Query,
310 T_PlannedStmt,
311 T_InsertStmt,
312 T_DeleteStmt,
313 T_UpdateStmt,
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 *
castNodeImpl(NodeTag type,void * ptr)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,
664 CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
665 * etc. */
666 CMD_NOTHING /* dummy command for instead nothing rules
667 * with qual */
668 } CmdType;
669
670
671 /*
672 * JoinType -
673 * enums for types of relation joins
674 *
675 * JoinType determines the exact semantics of joining two relations using
676 * a matching qualification. For example, it tells what to do with a tuple
677 * that has no match in the other relation.
678 *
679 * This is needed in both parsenodes.h and plannodes.h, so put it here...
680 */
681 typedef enum JoinType
682 {
683 /*
684 * The canonical kinds of joins according to the SQL JOIN syntax. Only
685 * these codes can appear in parser output (e.g., JoinExpr nodes).
686 */
687 JOIN_INNER, /* matching tuple pairs only */
688 JOIN_LEFT, /* pairs + unmatched LHS tuples */
689 JOIN_FULL, /* pairs + unmatched LHS + unmatched RHS */
690 JOIN_RIGHT, /* pairs + unmatched RHS tuples */
691
692 /*
693 * Semijoins and anti-semijoins (as defined in relational theory) do not
694 * appear in the SQL JOIN syntax, but there are standard idioms for
695 * representing them (e.g., using EXISTS). The planner recognizes these
696 * cases and converts them to joins. So the planner and executor must
697 * support these codes. NOTE: in JOIN_SEMI output, it is unspecified
698 * which matching RHS row is joined to. In JOIN_ANTI output, the row is
699 * guaranteed to be null-extended.
700 */
701 JOIN_SEMI, /* 1 copy of each LHS row that has match(es) */
702 JOIN_ANTI, /* 1 copy of each LHS row that has no match */
703
704 /*
705 * These codes are used internally in the planner, but are not supported
706 * by the executor (nor, indeed, by most of the planner).
707 */
708 JOIN_UNIQUE_OUTER, /* LHS path must be made unique */
709 JOIN_UNIQUE_INNER /* RHS path must be made unique */
710
711 /*
712 * We might need additional join types someday.
713 */
714 } JoinType;
715
716 /*
717 * OUTER joins are those for which pushed-down quals must behave differently
718 * from the join's own quals. This is in fact everything except INNER and
719 * SEMI joins. However, this macro must also exclude the JOIN_UNIQUE symbols
720 * since those are temporary proxies for what will eventually be an INNER
721 * join.
722 *
723 * Note: semijoins are a hybrid case, but we choose to treat them as not
724 * being outer joins. This is okay principally because the SQL syntax makes
725 * it impossible to have a pushed-down qual that refers to the inner relation
726 * of a semijoin; so there is no strong need to distinguish join quals from
727 * pushed-down quals. This is convenient because for almost all purposes,
728 * quals attached to a semijoin can be treated the same as innerjoin quals.
729 */
730 #define IS_OUTER_JOIN(jointype) \
731 (((1 << (jointype)) & \
732 ((1 << JOIN_LEFT) | \
733 (1 << JOIN_FULL) | \
734 (1 << JOIN_RIGHT) | \
735 (1 << JOIN_ANTI))) != 0)
736
737 /*
738 * AggStrategy -
739 * overall execution strategies for Agg plan nodes
740 *
741 * This is needed in both plannodes.h and relation.h, so put it here...
742 */
743 typedef enum AggStrategy
744 {
745 AGG_PLAIN, /* simple agg across all input rows */
746 AGG_SORTED, /* grouped agg, input must be sorted */
747 AGG_HASHED, /* grouped agg, use internal hashtable */
748 AGG_MIXED /* grouped agg, hash and sort both used */
749 } AggStrategy;
750
751 /*
752 * AggSplit -
753 * splitting (partial aggregation) modes for Agg plan nodes
754 *
755 * This is needed in both plannodes.h and relation.h, so put it here...
756 */
757
758 /* Primitive options supported by nodeAgg.c: */
759 #define AGGSPLITOP_COMBINE 0x01 /* substitute combinefn for transfn */
760 #define AGGSPLITOP_SKIPFINAL 0x02 /* skip finalfn, return state as-is */
761 #define AGGSPLITOP_SERIALIZE 0x04 /* apply serializefn to output */
762 #define AGGSPLITOP_DESERIALIZE 0x08 /* apply deserializefn to input */
763
764 /* Supported operating modes (i.e., useful combinations of these options): */
765 typedef enum AggSplit
766 {
767 /* Basic, non-split aggregation: */
768 AGGSPLIT_SIMPLE = 0,
769 /* Initial phase of partial aggregation, with serialization: */
770 AGGSPLIT_INITIAL_SERIAL = AGGSPLITOP_SKIPFINAL | AGGSPLITOP_SERIALIZE,
771 /* Final phase of partial aggregation, with deserialization: */
772 AGGSPLIT_FINAL_DESERIAL = AGGSPLITOP_COMBINE | AGGSPLITOP_DESERIALIZE
773 } AggSplit;
774
775 /* Test whether an AggSplit value selects each primitive option: */
776 #define DO_AGGSPLIT_COMBINE(as) (((as) & AGGSPLITOP_COMBINE) != 0)
777 #define DO_AGGSPLIT_SKIPFINAL(as) (((as) & AGGSPLITOP_SKIPFINAL) != 0)
778 #define DO_AGGSPLIT_SERIALIZE(as) (((as) & AGGSPLITOP_SERIALIZE) != 0)
779 #define DO_AGGSPLIT_DESERIALIZE(as) (((as) & AGGSPLITOP_DESERIALIZE) != 0)
780
781 /*
782 * SetOpCmd and SetOpStrategy -
783 * overall semantics and execution strategies for SetOp plan nodes
784 *
785 * This is needed in both plannodes.h and relation.h, so put it here...
786 */
787 typedef enum SetOpCmd
788 {
789 SETOPCMD_INTERSECT,
790 SETOPCMD_INTERSECT_ALL,
791 SETOPCMD_EXCEPT,
792 SETOPCMD_EXCEPT_ALL
793 } SetOpCmd;
794
795 typedef enum SetOpStrategy
796 {
797 SETOP_SORTED, /* input must be sorted */
798 SETOP_HASHED /* use internal hashtable */
799 } SetOpStrategy;
800
801 /*
802 * OnConflictAction -
803 * "ON CONFLICT" clause type of query
804 *
805 * This is needed in both parsenodes.h and plannodes.h, so put it here...
806 */
807 typedef enum OnConflictAction
808 {
809 ONCONFLICT_NONE, /* No "ON CONFLICT" clause */
810 ONCONFLICT_NOTHING, /* ON CONFLICT ... DO NOTHING */
811 ONCONFLICT_UPDATE /* ON CONFLICT ... DO UPDATE */
812 } OnConflictAction;
813
814 #endif /* NODES_H */
815