gooderp18绿色标准版
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

825 lines
20KB

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