nodes.h 18 KB

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