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