nodes.h 21 KB

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