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