1/*-------------------------------------------------------------------------
2 *
3 * nodes.h
4 * Definitions for tagged nodes.
5 *
6 *
7 * Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/nodes/nodes.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#pragma once
15
16#include "pg_definitions.hpp"
17
18namespace duckdb_libpgquery {
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 inserting or deleting node types changes the numbers of other
25 * node types later in the list. This is no problem during development, since
26 * the node numbers are never stored on disk. But don't do it in a released
27 * branch, because that would represent an ABI break for extensions.
28 */
29typedef enum PGNodeTag {
30 T_PGInvalid = 0,
31
32 /*
33 * TAGS FOR EXECUTOR NODES (execnodes.h)
34 */
35 T_PGIndexInfo,
36 T_PGExprContext,
37 T_PGProjectionInfo,
38 T_PGJunkFilter,
39 T_PGResultRelInfo,
40 T_PGEState,
41 T_PGTupleTableSlot,
42
43 /*
44 * TAGS FOR PLAN NODES (plannodes.h)
45 */
46 T_PGPlan,
47 T_PGResult,
48 T_PGProjectSet,
49 T_PGModifyTable,
50 T_PGAppend,
51 T_PGMergeAppend,
52 T_PGRecursiveUnion,
53 T_PGBitmapAnd,
54 T_PGBitmapOr,
55 T_PGScan,
56 T_PGSeqScan,
57 T_PGSampleScan,
58 T_PGIndexScan,
59 T_PGIndexOnlyScan,
60 T_PGBitmapIndexScan,
61 T_PGBitmapHeapScan,
62 T_PGTidScan,
63 T_PGSubqueryScan,
64 T_PGFunctionScan,
65 T_PGValuesScan,
66 T_PGTableFuncScan,
67 T_PGCteScan,
68 T_PGNamedTuplestoreScan,
69 T_PGWorkTableScan,
70 T_PGForeignScan,
71 T_PGCustomScan,
72 T_PGJoin,
73 T_PGNestLoop,
74 T_PGMergeJoin,
75 T_PGHashJoin,
76 T_PGMaterial,
77 T_PGSort,
78 T_PGGroup,
79 T_PGAgg,
80 T_PGWindowAgg,
81 T_PGUnique,
82 T_PGGather,
83 T_PGGatherMerge,
84 T_PGHash,
85 T_PGSetOp,
86 T_PGLockRows,
87 T_PGLimit,
88 /* these aren't subclasses of PGPlan: */
89 T_PGNestLoopParam,
90 T_PGPlanRowMark,
91 T_PGPlanInvalItem,
92
93 /*
94 * TAGS FOR PLAN STATE NODES (execnodes.h)
95 *
96 * These should correspond one-to-one with PGPlan node types.
97 */
98 T_PGPlanState,
99 T_PGResultState,
100 T_PGProjectSetState,
101 T_PGModifyTableState,
102 T_PGAppendState,
103 T_PGMergeAppendState,
104 T_PGRecursiveUnionState,
105 T_PGBitmapAndState,
106 T_PGBitmapOrState,
107 T_PGScanState,
108 T_PGSeqScanState,
109 T_PGSampleScanState,
110 T_PGIndexScanState,
111 T_PGIndexOnlyScanState,
112 T_PGBitmapIndexScanState,
113 T_PGBitmapHeapScanState,
114 T_PGTidScanState,
115 T_PGSubqueryScanState,
116 T_PGFunctionScanState,
117 T_PGTableFuncScanState,
118 T_PGValuesScanState,
119 T_PGCteScanState,
120 T_PGNamedTuplestoreScanState,
121 T_PGWorkTableScanState,
122 T_PGForeignScanState,
123 T_PGCustomScanState,
124 T_PGJoinState,
125 T_PGNestLoopState,
126 T_PGMergeJoinState,
127 T_PGHashJoinState,
128 T_PGMaterialState,
129 T_PGSortState,
130 T_PGGroupState,
131 T_PGAggState,
132 T_PGWindowAggState,
133 T_PGUniqueState,
134 T_PGGatherState,
135 T_PGGatherMergeState,
136 T_PGHashState,
137 T_PGSetOpState,
138 T_PGLockRowsState,
139 T_PGLimitState,
140
141 /*
142 * TAGS FOR PRIMITIVE NODES (primnodes.h)
143 */
144 T_PGAlias,
145 T_PGRangeVar,
146 T_PGTableFunc,
147 T_PGExpr,
148 T_PGVar,
149 T_PGConst,
150 T_PGParam,
151 T_PGAggref,
152 T_PGGroupingFunc,
153 T_PGWindowFunc,
154 T_PGArrayRef,
155 T_PGFuncExpr,
156 T_PGNamedArgExpr,
157 T_PGOpExpr,
158 T_PGDistinctExpr,
159 T_PGNullIfExpr,
160 T_PGScalarArrayOpExpr,
161 T_PGBoolExpr,
162 T_PGSubLink,
163 T_PGSubPlan,
164 T_PGAlternativeSubPlan,
165 T_PGFieldSelect,
166 T_PGFieldStore,
167 T_PGRelabelType,
168 T_PGCoerceViaIO,
169 T_PGArrayCoerceExpr,
170 T_PGConvertRowtypeExpr,
171 T_PGCollateExpr,
172 T_PGCaseExpr,
173 T_PGCaseWhen,
174 T_PGCaseTestExpr,
175 T_PGArrayExpr,
176 T_PGRowExpr,
177 T_PGRowCompareExpr,
178 T_PGCoalesceExpr,
179 T_PGMinMaxExpr,
180 T_PGSQLValueFunction,
181 T_PGXmlExpr,
182 T_PGNullTest,
183 T_PGBooleanTest,
184 T_PGCoerceToDomain,
185 T_PGCoerceToDomainValue,
186 T_PGSetToDefault,
187 T_PGCurrentOfExpr,
188 T_PGNextValueExpr,
189 T_PGInferenceElem,
190 T_PGTargetEntry,
191 T_PGRangeTblRef,
192 T_PGJoinExpr,
193 T_PGFromExpr,
194 T_PGOnConflictExpr,
195 T_PGIntoClause,
196 T_PGLambdaFunction,
197 T_PGPivotExpr,
198 T_PGPivot,
199 T_PGPivotStmt,
200
201 /*
202 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
203 *
204 * ExprState represents the evaluation state for a whole expression tree.
205 * Most Expr-based plan nodes do not have a corresponding expression state
206 * node, they're fully handled within execExpr* - but sometimes the state
207 * needs to be shared with other parts of the executor, as for example
208 * with AggrefExprState, which nodeAgg.c has to modify.
209 */
210 T_PGExprState,
211 T_PGAggrefExprState,
212 T_PGWindowFuncExprState,
213 T_PGSetExprState,
214 T_PGSubPlanState,
215 T_PGAlternativeSubPlanState,
216 T_PGDomainConstraintState,
217
218 /*
219 * TAGS FOR PLANNER NODES (relation.h)
220 */
221 T_PGPlannerInfo,
222 T_PGPlannerGlobal,
223 T_PGRelOptInfo,
224 T_PGIndexOptInfo,
225 T_PGForeignKeyOptInfo,
226 T_PGParamPathInfo,
227 T_PGPath,
228 T_PGIndexPath,
229 T_PGBitmapHeapPath,
230 T_PGBitmapAndPath,
231 T_PGBitmapOrPath,
232 T_PGTidPath,
233 T_PGSubqueryScanPath,
234 T_PGForeignPath,
235 T_PGCustomPath,
236 T_PGNestPath,
237 T_PGMergePath,
238 T_PGHashPath,
239 T_PGAppendPath,
240 T_PGMergeAppendPath,
241 T_PGResultPath,
242 T_PGMaterialPath,
243 T_PGUniquePath,
244 T_PGGatherPath,
245 T_PGGatherMergePath,
246 T_PGProjectionPath,
247 T_PGProjectSetPath,
248 T_PGSortPath,
249 T_PGGroupPath,
250 T_PGUpperUniquePath,
251 T_PGAggPath,
252 T_PGGroupingSetsPath,
253 T_PGMinMaxAggPath,
254 T_PGWindowAggPath,
255 T_PGSetOpPath,
256 T_PGRecursiveUnionPath,
257 T_PGLockRowsPath,
258 T_PGModifyTablePath,
259 T_PGLimitPath,
260 /* these aren't subclasses of Path: */
261 T_PGEquivalenceClass,
262 T_PGEquivalenceMember,
263 T_PGPathKey,
264 T_PGPathTarget,
265 T_PGRestrictInfo,
266 T_PGPlaceHolderVar,
267 T_PGSpecialJoinInfo,
268 T_PGAppendRelInfo,
269 T_PGPartitionedChildRelInfo,
270 T_PGPlaceHolderInfo,
271 T_PGMinMaxAggInfo,
272 T_PGPlannerParamItem,
273 T_PGRollupData,
274 T_PGGroupingSetData,
275 T_PGStatisticExtInfo,
276
277 /*
278 * TAGS FOR MEMORY NODES (memnodes.h)
279 */
280 T_PGMemoryContext,
281 T_PGAllocSetContext,
282 T_PGSlabContext,
283
284 /*
285 * TAGS FOR VALUE NODES (value.h)
286 */
287 T_PGValue,
288 T_PGInteger,
289 T_PGFloat,
290 T_PGString,
291 T_PGBitString,
292 T_PGNull,
293
294 /*
295 * TAGS FOR LIST NODES (pg_list.h)
296 */
297 T_PGList,
298 T_PGIntList,
299 T_PGOidList,
300
301 /*
302 * TAGS FOR EXTENSIBLE NODES (extensible.h)
303 */
304 T_PGExtensibleNode,
305
306 /*
307 * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
308 */
309 T_PGRawStmt,
310 T_PGQuery,
311 T_PGPlannedStmt,
312 T_PGInsertStmt,
313 T_PGDeleteStmt,
314 T_PGUpdateStmt,
315 T_PGSelectStmt,
316 T_PGAlterTableStmt,
317 T_PGAlterTableCmd,
318 T_PGAlterDomainStmt,
319 T_PGSetOperationStmt,
320 T_PGGrantStmt,
321 T_PGGrantRoleStmt,
322 T_PGAlterDefaultPrivilegesStmt,
323 T_PGClosePortalStmt,
324 T_PGClusterStmt,
325 T_PGCopyStmt,
326 T_PGCreateStmt,
327 T_PGDefineStmt,
328 T_PGDropStmt,
329 T_PGTruncateStmt,
330 T_PGCommentStmt,
331 T_PGFetchStmt,
332 T_PGIndexStmt,
333 T_PGCreateFunctionStmt,
334 T_PGAlterFunctionStmt,
335 T_PGDoStmt,
336 T_PGRenameStmt,
337 T_PGRuleStmt,
338 T_PGNotifyStmt,
339 T_PGListenStmt,
340 T_PGUnlistenStmt,
341 T_PGTransactionStmt,
342 T_PGViewStmt,
343 T_PGLoadStmt,
344 T_PGCreateDomainStmt,
345 T_PGCreatedbStmt,
346 T_PGDropdbStmt,
347 T_PGVacuumStmt,
348 T_PGExplainStmt,
349 T_PGCreateTableAsStmt,
350 T_PGCreateSeqStmt,
351 T_PGAlterSeqStmt,
352 T_PGVariableSetStmt,
353 T_PGVariableShowStmt,
354 T_PGVariableShowSelectStmt,
355 T_PGDiscardStmt,
356 T_PGCreateTrigStmt,
357 T_PGCreatePLangStmt,
358 T_PGCreateRoleStmt,
359 T_PGAlterRoleStmt,
360 T_PGDropRoleStmt,
361 T_PGLockStmt,
362 T_PGConstraintsSetStmt,
363 T_PGReindexStmt,
364 T_PGCheckPointStmt,
365 T_PGCreateSchemaStmt,
366 T_PGAlterDatabaseStmt,
367 T_PGAlterDatabaseSetStmt,
368 T_PGAlterRoleSetStmt,
369 T_PGCreateConversionStmt,
370 T_PGCreateCastStmt,
371 T_PGCreateOpClassStmt,
372 T_PGCreateOpFamilyStmt,
373 T_PGAlterOpFamilyStmt,
374 T_PGPrepareStmt,
375 T_PGExecuteStmt,
376 T_PGCallStmt,
377 T_PGDeallocateStmt,
378 T_PGDeclareCursorStmt,
379 T_PGCreateTableSpaceStmt,
380 T_PGDropTableSpaceStmt,
381 T_PGAlterObjectDependsStmt,
382 T_PGAlterObjectSchemaStmt,
383 T_PGAlterOwnerStmt,
384 T_PGAlterOperatorStmt,
385 T_PGDropOwnedStmt,
386 T_PGReassignOwnedStmt,
387 T_PGCompositeTypeStmt,
388 T_PGCreateTypeStmt,
389 T_PGCreateRangeStmt,
390 T_PGAlterEnumStmt,
391 T_PGAlterTSDictionaryStmt,
392 T_PGAlterTSConfigurationStmt,
393 T_PGCreateFdwStmt,
394 T_PGAlterFdwStmt,
395 T_PGCreateForeignServerStmt,
396 T_PGAlterForeignServerStmt,
397 T_PGCreateUserMappingStmt,
398 T_PGAlterUserMappingStmt,
399 T_PGDropUserMappingStmt,
400 T_PGAlterTableSpaceOptionsStmt,
401 T_PGAlterTableMoveAllStmt,
402 T_PGSecLabelStmt,
403 T_PGCreateForeignTableStmt,
404 T_PGImportForeignSchemaStmt,
405 T_PGCreateExtensionStmt,
406 T_PGAlterExtensionStmt,
407 T_PGAlterExtensionContentsStmt,
408 T_PGCreateEventTrigStmt,
409 T_PGAlterEventTrigStmt,
410 T_PGRefreshMatViewStmt,
411 T_PGReplicaIdentityStmt,
412 T_PGAlterSystemStmt,
413 T_PGCreatePolicyStmt,
414 T_PGAlterPolicyStmt,
415 T_PGCreateTransformStmt,
416 T_PGCreateAmStmt,
417 T_PGCreatePublicationStmt,
418 T_PGAlterPublicationStmt,
419 T_PGCreateSubscriptionStmt,
420 T_PGAlterSubscriptionStmt,
421 T_PGDropSubscriptionStmt,
422 T_PGCreateStatsStmt,
423 T_PGAlterCollationStmt,
424 T_PGPragmaStmt,
425 T_PGExportStmt,
426 T_PGImportStmt,
427 T_PGAttachStmt,
428 T_PGDetachStmt,
429 T_PGUseStmt,
430
431 /*
432 * TAGS FOR PARSE TREE NODES (parsenodes.h)
433 */
434 T_PGAExpr,
435 T_PGColumnRef,
436 T_PGParamRef,
437 T_PGAConst,
438 T_PGFuncCall,
439 T_PGAStar,
440 T_PGAIndices,
441 T_PGAIndirection,
442 T_PGAArrayExpr,
443 T_PGResTarget,
444 T_PGMultiAssignRef,
445 T_PGTypeCast,
446 T_PGCollateClause,
447 T_PGSortBy,
448 T_PGWindowDef,
449 T_PGRangeSubselect,
450 T_PGRangeFunction,
451 T_PGRangeTableSample,
452 T_PGRangeTableFunc,
453 T_PGRangeTableFuncCol,
454 T_PGTypeName,
455 T_PGColumnDef,
456 T_PGIndexElem,
457 T_PGConstraint,
458 T_PGDefElem,
459 T_PGRangeTblEntry,
460 T_PGRangeTblFunction,
461 T_PGTableSampleClause,
462 T_PGWithCheckOption,
463 T_PGSortGroupClause,
464 T_PGGroupingSet,
465 T_PGWindowClause,
466 T_PGObjectWithArgs,
467 T_PGAccessPriv,
468 T_PGCreateOpClassItem,
469 T_PGTableLikeClause,
470 T_PGFunctionParameter,
471 T_PGLockingClause,
472 T_PGRowMarkClause,
473 T_PGXmlSerialize,
474 T_PGWithClause,
475 T_PGInferClause,
476 T_PGOnConflictClause,
477 T_PGCommonTableExpr,
478 T_PGRoleSpec,
479 T_PGTriggerTransition,
480 T_PGPartitionElem,
481 T_PGPartitionSpec,
482 T_PGPartitionBoundSpec,
483 T_PGPartitionRangeDatum,
484 T_PGPartitionCmd,
485 T_PGIntervalConstant,
486 T_PGSampleSize,
487 T_PGSampleOptions,
488 T_PGLimitPercent,
489 T_PGPositionalReference,
490
491 /*
492 * TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
493 */
494 T_PGIdentifySystemCmd,
495 T_PGBaseBackupCmd,
496 T_PGCreateReplicationSlotCmd,
497 T_PGDropReplicationSlotCmd,
498 T_PGStartReplicationCmd,
499 T_PGTimeLineHistoryCmd,
500 T_PGSQLCmd,
501
502 /*
503 * TAGS FOR RANDOM OTHER STUFF
504 *
505 * These are objects that aren't part of parse/plan/execute node tree
506 * structures, but we give them NodeTags anyway for identification
507 * purposes (usually because they are involved in APIs where we want to
508 * pass multiple object types through the same pointer).
509 */
510 T_PGTriggerData, /* in commands/trigger.h */
511 T_PGEventTriggerData, /* in commands/event_trigger.h */
512 T_PGReturnSetInfo, /* in nodes/execnodes.h */
513 T_PGWindowObjectData, /* private in nodeWindowAgg.c */
514 T_PGTIDBitmap, /* in nodes/tidbitmap.h */
515 T_PGInlineCodeBlock, /* in nodes/parsenodes.h */
516 T_PGFdwRoutine, /* in foreign/fdwapi.h */
517 T_PGIndexAmRoutine, /* in access/amapi.h */
518 T_PGTsmRoutine, /* in access/tsmapi.h */
519 T_PGForeignKeyCacheInfo /* in utils/rel.h */
520} PGNodeTag;
521
522/*
523 * The first field of a node of any type is guaranteed to be the NodeTag.
524 * Hence the type of any node can be gotten by casting it to Node. Declaring
525 * a variable to be of PGNode * (instead of void *) can also facilitate
526 * debugging.
527 */
528typedef struct PGNode {
529 PGNodeTag type;
530} PGNode;
531
532#define nodeTag(nodeptr) (((const PGNode *)(nodeptr))->type)
533
534#define makeNode(_type_) ((_type_ *)newNode(sizeof(_type_), T_##_type_))
535
536#define NodeSetTag(nodeptr, t) (((PGNode *)(nodeptr))->type = (t))
537
538#define IsA(nodeptr, _type_) (nodeTag(nodeptr) == T_##_type_)
539
540/*
541 * castNode(type, ptr) casts ptr to "type *", and if assertions are enabled,
542 * verifies that the node has the appropriate type (using its nodeTag()).
543 *
544 * Use an inline function when assertions are enabled, to avoid multiple
545 * evaluations of the ptr argument (which could e.g. be a function call).
546 */
547#ifdef USE_ASSERT_CHECKING
548static inline PGNode *castNodeImpl(PGNodeTag type, void *ptr) {
549 Assert(ptr == NULL || nodeTag(ptr) == type);
550 return (PGNode *)ptr;
551}
552#define castNode(_type_, nodeptr) ((_type_ *)castNodeImpl(T_##_type_, nodeptr))
553#else
554#define castNode(_type_, nodeptr) ((_type_ *)(nodeptr))
555#endif /* USE_ASSERT_CHECKING */
556
557/* ----------------------------------------------------------------
558 * extern declarations follow
559 * ----------------------------------------------------------------
560 */
561
562/*
563 * nodes/{outfuncs.c,print.c}
564 */
565struct PGBitmapset; /* not to include bitmapset.h here */
566struct PGStringInfoData; /* not to include stringinfo.h here */
567
568PGNode* newNode(size_t size, PGNodeTag type);
569
570void outNode(struct PGStringInfoData *str, const void *obj);
571void outToken(struct PGStringInfoData *str, const char *s);
572void outBitmapset(struct PGStringInfoData *str, const struct PGBitmapset *bms);
573void outDatum(struct PGStringInfoData *str, uintptr_t value, int typlen, bool typbyval);
574char *nodeToString(const void *obj);
575char *bmsToString(const struct PGBitmapset *bms);
576
577/*
578 * nodes/{readfuncs.c,read.c}
579 */
580void *stringToNode(char *str);
581struct PGBitmapset *readBitmapset(void);
582uintptr_t readDatum(bool typbyval);
583bool *readBoolCols(int numCols);
584int *readIntCols(int numCols);
585PGOid *readOidCols(int numCols);
586int16_t *readAttrNumberCols(int numCols);
587
588/*
589 * nodes/copyfuncs.c
590 */
591void *copyObjectImpl(const void *obj);
592
593/* cast result back to argument type, if supported by compiler */
594//#ifdef HAVE_TYPEOF
595//#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
596//#else
597//#define copyObject(obj) copyObjectImpl(obj)
598//#endif
599
600/*
601 * nodes/equalfuncs.c
602 */
603// extern bool equal(const void *a, const void *b);
604
605/*
606 * Typedefs for identifying qualifier selectivities and plan costs as such.
607 * These are just plain "double"s, but declaring a variable as Selectivity
608 * or Cost makes the intent more obvious.
609 *
610 * These could have gone into plannodes.h or some such, but many files
611 * depend on them...
612 */
613typedef double Selectivity; /* fraction of tuples a qualifier will pass */
614typedef double Cost; /* execution cost (in page-access units) */
615
616/*
617 * PGCmdType -
618 * enums for type of operation represented by a PGQuery or PGPlannedStmt
619 *
620 * This is needed in both parsenodes.h and plannodes.h, so put it here...
621 */
622typedef enum PGCmdType {
623 PG_CMD_UNKNOWN,
624 PG_CMD_SELECT, /* select stmt */
625 PG_CMD_UPDATE, /* update stmt */
626 PG_CMD_INSERT, /* insert stmt */
627 PG_CMD_DELETE,
628 PG_CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
629 * etc. */
630 PG_CMD_NOTHING /* dummy command for instead nothing rules
631 * with qual */
632} PGCmdType;
633
634/*
635 * PGJoinType -
636 * enums for types of relation joins
637 *
638 * PGJoinType determines the exact semantics of joining two relations using
639 * a matching qualification. For example, it tells what to do with a tuple
640 * that has no match in the other relation.
641 *
642 * This is needed in both parsenodes.h and plannodes.h, so put it here...
643 */
644typedef enum PGJoinType {
645 /*
646 * The canonical kinds of joins according to the SQL JOIN syntax. Only
647 * these codes can appear in parser output (e.g., PGJoinExpr nodes).
648 */
649 PG_JOIN_INNER, /* matching tuple pairs only */
650 PG_JOIN_LEFT, /* pairs + unmatched LHS tuples */
651 PG_JOIN_FULL, /* pairs + unmatched LHS + unmatched RHS */
652 PG_JOIN_RIGHT, /* pairs + unmatched RHS tuples */
653
654 /*
655 * Semijoins and anti-semijoins (as defined in relational theory) do not
656 * appear in the SQL JOIN syntax, but there are standard idioms for
657 * representing them (e.g., using EXISTS). The planner recognizes these
658 * cases and converts them to joins. So the planner and executor must
659 * support these codes. NOTE: in PG_JOIN_SEMI output, it is unspecified
660 * which matching RHS row is joined to. In PG_JOIN_ANTI output, the row is
661 * guaranteed to be null-extended.
662 */
663 PG_JOIN_SEMI, /* 1 copy of each LHS row that has match(es) */
664 PG_JOIN_ANTI, /* 1 copy of each LHS row that has no match */
665
666 /*
667 * These codes are used internally in the planner, but are not supported
668 * by the executor (nor, indeed, by most of the planner).
669 */
670 PG_JOIN_UNIQUE_OUTER, /* LHS path must be made unique */
671 PG_JOIN_UNIQUE_INNER, /* RHS path must be made unique */
672
673 /*
674 * Positional joins are essentially parallel table scans.
675 */
676 PG_JOIN_POSITION /* Two tables of the same length */
677
678 /*
679 * We might need additional join types someday.
680 */
681} PGJoinType;
682
683/*
684 * PGJoinRefType -
685 * enums for the types of implied conditions
686 *
687 * PGJoinRefType specifies the semantics of interpreting the join conditions.
688 * These can be explicit (e.g., REGULAR) implied (e.g., NATURAL)
689 * or interpreted in a particular manner (e.g., ASOF)
690 *
691 * This is a generalisation of the old Postgres isNatural flag.
692 */
693typedef enum PGJoinRefType {
694 PG_JOIN_REGULAR, /* Join conditions are interpreted as is */
695 PG_JOIN_NATURAL, /* Join conditions are inferred from the column names */
696
697 /*
698 * ASOF joins are joins with a single inequality predicate
699 * and optional equality predicates.
700 * The semantics are equivalent to the following window join:
701 * times t
702 * <jointype> JOIN (
703 * SELECT *,
704 * LEAD(begin, 1, 'infinity') OVER ([PARTITION BY key] ORDER BY begin) AS end)
705 * FROM events) e
706 * ON t.ts >= e.begin AND t.ts < e.end [AND t.key = e.key]
707 */
708 PG_JOIN_ASOF
709
710 /*
711 * Positional join is a candidate to move here
712 */
713} PGJoinRefType;
714
715/*
716 * OUTER joins are those for which pushed-down quals must behave differently
717 * from the join's own quals. This is in fact everything except INNER and
718 * SEMI joins. However, this macro must also exclude the JOIN_UNIQUE symbols
719 * since those are temporary proxies for what will eventually be an INNER
720 * join.
721 *
722 * Note: semijoins are a hybrid case, but we choose to treat them as not
723 * being outer joins. This is okay principally because the SQL syntax makes
724 * it impossible to have a pushed-down qual that refers to the inner relation
725 * of a semijoin; so there is no strong need to distinguish join quals from
726 * pushed-down quals. This is convenient because for almost all purposes,
727 * quals attached to a semijoin can be treated the same as innerjoin quals.
728 */
729#define IS_OUTER_JOIN(jointype) \
730 (((1 << (jointype)) & ((1 << PG_JOIN_LEFT) | (1 << PG_JOIN_FULL) | (1 << PG_JOIN_RIGHT) | (1 << PG_JOIN_ANTI))) != 0)
731
732/*
733 * PGAggStrategy -
734 * overall execution strategies for PGAgg plan nodes
735 *
736 * This is needed in both plannodes.h and relation.h, so put it here...
737 */
738typedef enum PGAggStrategy {
739 PG_AGG_PLAIN, /* simple agg across all input rows */
740 PG_AGG_SORTED, /* grouped agg, input must be sorted */
741 PG_AGG_HASHED, /* grouped agg, use internal hashtable */
742 AGG_MIXED /* grouped agg, hash and sort both used */
743} PGAggStrategy;
744
745/*
746 * PGAggSplit -
747 * splitting (partial aggregation) modes for PGAgg plan nodes
748 *
749 * This is needed in both plannodes.h and relation.h, so put it here...
750 */
751
752/* Primitive options supported by nodeAgg.c: */
753#define AGGSPLITOP_COMBINE 0x01 /* substitute combinefn for transfn */
754#define AGGSPLITOP_SKIPFINAL 0x02 /* skip finalfn, return state as-is */
755#define AGGSPLITOP_SERIALIZE 0x04 /* apply serializefn to output */
756#define AGGSPLITOP_DESERIALIZE 0x08 /* apply deserializefn to input */
757
758/* Supported operating modes (i.e., useful combinations of these options): */
759typedef enum PGAggSplit {
760 /* Basic, non-split aggregation: */
761 PG_AGGSPLIT_SIMPLE = 0,
762 /* Initial phase of partial aggregation, with serialization: */
763 PG_AGGSPLIT_INITIAL_SERIAL = AGGSPLITOP_SKIPFINAL | AGGSPLITOP_SERIALIZE,
764 /* Final phase of partial aggregation, with deserialization: */
765 PG_AGGSPLIT_FINAL_DESERIAL = AGGSPLITOP_COMBINE | AGGSPLITOP_DESERIALIZE
766} PGAggSplit;
767
768/* Test whether an PGAggSplit value selects each primitive option: */
769#define DO_AGGSPLIT_COMBINE(as) (((as)&AGGSPLITOP_COMBINE) != 0)
770#define DO_AGGSPLIT_SKIPFINAL(as) (((as)&AGGSPLITOP_SKIPFINAL) != 0)
771#define DO_AGGSPLIT_SERIALIZE(as) (((as)&AGGSPLITOP_SERIALIZE) != 0)
772#define DO_AGGSPLIT_DESERIALIZE(as) (((as)&AGGSPLITOP_DESERIALIZE) != 0)
773
774/*
775 * PGSetOpCmd and PGSetOpStrategy -
776 * overall semantics and execution strategies for PGSetOp plan nodes
777 *
778 * This is needed in both plannodes.h and relation.h, so put it here...
779 */
780typedef enum PGSetOpCmd {
781 PG_SETOPCMD_INTERSECT,
782 PG_SETOPCMD_INTERSECT_ALL,
783 PG_SETOPCMD_EXCEPT,
784 PG_SETOPCMD_EXCEPT_ALL
785} PGSetOpCmd;
786
787typedef enum PGSetOpStrategy {
788 PG_SETOP_SORTED, /* input must be sorted */
789 PG_SETOP_HASHED /* use internal hashtable */
790} PGSetOpStrategy;
791
792/*
793 * PGOnConflictAction -
794 * "ON CONFLICT" clause type of query
795 *
796 * This is needed in both parsenodes.h and plannodes.h, so put it here...
797 */
798typedef enum PGOnConflictAction {
799 PG_ONCONFLICT_NONE, /* No "ON CONFLICT" clause */
800 PG_ONCONFLICT_NOTHING, /* ON CONFLICT ... DO NOTHING */
801 PG_ONCONFLICT_UPDATE /* ON CONFLICT ... DO UPDATE */
802} PGOnConflictAction;
803
804/*
805 * PGOnConflictActionAlias -
806 * "INSERT OR [REPLACE|IGNORE]" aliases for OnConflictAction
807 *
808 * This is needed in both parsenodes.h and plannodes.h, so put it here...
809 */
810typedef enum PGOnConflictActionAlias {
811 PG_ONCONFLICT_ALIAS_NONE, /* No "OR [IGNORE|REPLACE]" clause */
812 PG_ONCONFLICT_ALIAS_REPLACE, /* INSERT OR REPLACE */
813 PG_ONCONFLICT_ALIAS_IGNORE /* INSERT OR IGNORE */
814} PGOnConflictActionAlias;
815
816/*
817 * PGInsertByNameOrPosition
818 * "INSERT BY [POSITION|NAME]
819 */
820typedef enum PGInsertColumnOrder {
821 PG_INSERT_BY_POSITION, /* INSERT BY POSITION (default behavior) */
822 PG_INSERT_BY_NAME, /* INSERT BY NAME */
823} PGInsertColumnOrder;
824
825}
826