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