Cppgres
Build Postgres extensions in C++
Loading...
Searching...
No Matches
node.hpp
1#pragma once
2#include <concepts>
3#include <type_traits>
4
5#include "imports.h"
6#include "utils/pfr.hpp"
7
8namespace cppgres {
9
10using node_tag = ::NodeTag;
11
12template <typename T>
13concept node_tagged = std::is_standard_layout_v<T> && requires(T t) {
14 { t.type } -> std::convertible_to<node_tag>;
15} && (offsetof(T, type) == 0);
16
17template <typename T>
18concept node_xpr_tagged = std::is_standard_layout_v<T> && requires(T t) {
19 { t.xpr } -> std::convertible_to<::Expr>;
20} && (offsetof(T, xpr) == 0);
21
22template <typename T>
23concept node_inherited_base = std::is_standard_layout_v<std::remove_cvref_t<T>> && requires(T t) {
25 node_xpr_tagged<std::remove_cvref_t<decltype(boost::pfr::get<0>(t))>>;
26};
27
28template <typename T>
29concept node_inherited = std::is_standard_layout_v<std::remove_cvref_t<T>> && requires(T t) {
31 node_xpr_tagged<std::remove_cvref_t<decltype(boost::pfr::get<0>(t))>> ||
32 node_inherited_base<std::remove_cvref_t<decltype(boost::pfr::get<0>(t))>>;
33};
34
35template <typename T>
37
38template <typename T> struct node_traits {
39 static inline bool is(auto &node) { return false; }
40};
41template <node_tag T> struct node_tag_traits;
42
43#define node_mapping(name) \
44 namespace nodes { \
45 struct name { \
46 using underlying_type = ::name; \
47 static constexpr inline node_tag tag = T_##name; \
48 name(::name v) : val(v) {} \
49 name() { reinterpret_cast<node_tag &>(val) = T_##name; } \
50 ::name &operator*() { return val; } \
51 \
52 private: \
53 [[maybe_unused]] ::name val{}; \
54 }; \
55 } \
56 static_assert((sizeof(name) == sizeof(::name)) && (alignof(name) == alignof(::name))); \
57 template <> struct node_tag_traits<node_tag::T_##name> { \
58 using type = nodes::name; \
59 }; \
60 template <> struct node_traits<nodes::name> { \
61 static inline constexpr node_tag tag = node_tag::T_##name; \
62 static inline bool is(::Node *node) { \
63 return *reinterpret_cast<node_tag *>(node) == node_tag::T_##name; \
64 } \
65 static inline bool is(::name *node) { \
66 return *reinterpret_cast<node_tag *>(node) == node_tag::T_##name; \
67 } \
68 static inline bool is(nodes::name &node) { return true; } \
69 static inline bool is(auto &node) { return false; } \
70 static inline nodes::name *allocate(abstract_memory_context &&ctx = memory_context()) { \
71 auto ptr = ctx.alloc<nodes::name>(); \
72 reinterpret_cast<node_tag &>(ptr) = tag; \
73 return ptr; \
74 } \
75 }
76
77#define node_mapping_no_node_traits(name) \
78 namespace nodes { \
79 using name = ::name; \
80 } \
81 template <> struct node_tag_traits<node_tag::T_##name> { \
82 using type = nodes::name; \
83 static_assert(::cppgres::node<name>); \
84 }
85
86node_mapping(List);
87node_mapping(Alias);
88node_mapping(RangeVar);
89node_mapping(TableFunc);
90node_mapping(IntoClause);
91node_mapping(Var);
92node_mapping(Const);
93node_mapping(Param);
94node_mapping(Aggref);
95node_mapping(GroupingFunc);
96node_mapping(WindowFunc);
97#if PG_MAJORVERSION_NUM >= 17
98node_mapping(WindowFuncRunCondition);
99node_mapping(MergeSupportFunc);
100#endif
101node_mapping(SubscriptingRef);
102node_mapping(FuncExpr);
103node_mapping(NamedArgExpr);
104node_mapping(OpExpr);
105node_mapping_no_node_traits(DistinctExpr);
106node_mapping_no_node_traits(NullIfExpr);
107node_mapping(ScalarArrayOpExpr);
108node_mapping(BoolExpr);
109node_mapping(SubLink);
110node_mapping(SubPlan);
111node_mapping(AlternativeSubPlan);
112node_mapping(FieldSelect);
113node_mapping(FieldStore);
114node_mapping(RelabelType);
115node_mapping(CoerceViaIO);
116node_mapping(ArrayCoerceExpr);
117node_mapping(ConvertRowtypeExpr);
118node_mapping(CollateExpr);
119node_mapping(CaseExpr);
120node_mapping(CaseWhen);
121node_mapping(CaseTestExpr);
122node_mapping(ArrayExpr);
123node_mapping(RowExpr);
124node_mapping(RowCompareExpr);
125node_mapping(CoalesceExpr);
126node_mapping(MinMaxExpr);
127node_mapping(SQLValueFunction);
128node_mapping(XmlExpr);
129#if PG_MAJORVERSION_NUM >= 16
130node_mapping(JsonFormat);
131node_mapping(JsonReturning);
132node_mapping(JsonValueExpr);
133node_mapping(JsonConstructorExpr);
134node_mapping(JsonIsPredicate);
135#endif
136#if PG_MAJORVERSION_NUM >= 17
137node_mapping(JsonBehavior);
138node_mapping(JsonExpr);
139node_mapping(JsonTablePath);
140node_mapping(JsonTablePathScan);
141node_mapping(JsonTableSiblingJoin);
142#endif
143node_mapping(NullTest);
144node_mapping(BooleanTest);
145#if PG_MAJORVERSION_NUM >= 15
146node_mapping(MergeAction);
147#endif
148node_mapping(CoerceToDomain);
149node_mapping(CoerceToDomainValue);
150node_mapping(SetToDefault);
151node_mapping(CurrentOfExpr);
152node_mapping(NextValueExpr);
153node_mapping(InferenceElem);
154#if PG_MAJORVERSION_NUM >= 18
155node_mapping(ReturningExpr);
156#endif
157node_mapping(TargetEntry);
158node_mapping(RangeTblRef);
159node_mapping(JoinExpr);
160node_mapping(FromExpr);
161node_mapping(OnConflictExpr);
162node_mapping(Query);
163node_mapping(TypeName);
164node_mapping(ColumnRef);
165node_mapping(ParamRef);
166node_mapping(A_Expr);
167node_mapping(A_Const);
168node_mapping(TypeCast);
169node_mapping(CollateClause);
170node_mapping(RoleSpec);
171node_mapping(FuncCall);
172node_mapping(A_Star);
173node_mapping(A_Indices);
174node_mapping(A_Indirection);
175node_mapping(A_ArrayExpr);
176node_mapping(ResTarget);
177node_mapping(MultiAssignRef);
178node_mapping(SortBy);
179node_mapping(WindowDef);
180node_mapping(RangeSubselect);
181node_mapping(RangeFunction);
182node_mapping(RangeTableFunc);
183node_mapping(RangeTableFuncCol);
184node_mapping(RangeTableSample);
185node_mapping(ColumnDef);
186node_mapping(TableLikeClause);
187node_mapping(IndexElem);
188node_mapping(DefElem);
189node_mapping(LockingClause);
190node_mapping(XmlSerialize);
191node_mapping(PartitionElem);
192#if PG_MAJORVERSION_NUM == 17
193node_mapping(SinglePartitionSpec);
194#endif
195node_mapping(PartitionSpec);
196node_mapping(PartitionBoundSpec);
197node_mapping(PartitionRangeDatum);
198node_mapping(PartitionCmd);
199node_mapping(RangeTblEntry);
200#if PG_MAJORVERSION_NUM >= 16
201node_mapping(RTEPermissionInfo);
202#endif
203node_mapping(RangeTblFunction);
204node_mapping(TableSampleClause);
205node_mapping(WithCheckOption);
206node_mapping(SortGroupClause);
207node_mapping(GroupingSet);
208node_mapping(WindowClause);
209node_mapping(RowMarkClause);
210node_mapping(WithClause);
211node_mapping(InferClause);
212node_mapping(OnConflictClause);
213#if PG_MAJORVERSION_NUM >= 14
214node_mapping(CTESearchClause);
215node_mapping(CTECycleClause);
216#endif
217node_mapping(CommonTableExpr);
218#if PG_MAJORVERSION_NUM >= 15
219node_mapping(MergeWhenClause);
220#endif
221#if PG_MAJORVERSION_NUM >= 18
222node_mapping(ReturningOption);
223node_mapping(ReturningClause);
224#endif
225node_mapping(TriggerTransition);
226#if PG_MAJORVERSION_NUM >= 16
227node_mapping(JsonOutput);
228#endif
229#if PG_MAJORVERSION_NUM >= 17
230node_mapping(JsonArgument);
231node_mapping(JsonFuncExpr);
232node_mapping(JsonTablePathSpec);
233node_mapping(JsonTable);
234node_mapping(JsonTableColumn);
235node_mapping(JsonKeyValue);
236node_mapping(JsonParseExpr);
237node_mapping(JsonScalarExpr);
238node_mapping(JsonSerializeExpr);
239#endif
240#if PG_MAJORVERSION_NUM >= 16
241node_mapping(JsonObjectConstructor);
242node_mapping(JsonArrayConstructor);
243node_mapping(JsonArrayQueryConstructor);
244node_mapping(JsonAggConstructor);
245node_mapping(JsonObjectAgg);
246node_mapping(JsonArrayAgg);
247#endif
248node_mapping(RawStmt);
249node_mapping(InsertStmt);
250node_mapping(DeleteStmt);
251node_mapping(UpdateStmt);
252#if PG_MAJORVERSION_NUM >= 15
253node_mapping(MergeStmt);
254#endif
255node_mapping(SelectStmt);
256node_mapping(SetOperationStmt);
257#if PG_MAJORVERSION_NUM >= 14
258node_mapping(ReturnStmt);
259#endif
260#if PG_MAJORVERSION_NUM >= 14
261node_mapping(PLAssignStmt);
262#endif
263node_mapping(CreateSchemaStmt);
264node_mapping(AlterTableStmt);
265node_mapping(AlterTableCmd);
266#if PG_MAJORVERSION_NUM >= 18
267node_mapping(ATAlterConstraint);
268#endif
269node_mapping(ReplicaIdentityStmt);
270node_mapping(AlterCollationStmt);
271node_mapping(AlterDomainStmt);
272node_mapping(GrantStmt);
273node_mapping(ObjectWithArgs);
274node_mapping(AccessPriv);
275node_mapping(GrantRoleStmt);
276node_mapping(AlterDefaultPrivilegesStmt);
277node_mapping(CopyStmt);
278node_mapping(VariableSetStmt);
279node_mapping(VariableShowStmt);
280node_mapping(CreateStmt);
281node_mapping(Constraint);
282node_mapping(CreateTableSpaceStmt);
283node_mapping(DropTableSpaceStmt);
284node_mapping(AlterTableSpaceOptionsStmt);
285node_mapping(AlterTableMoveAllStmt);
286node_mapping(CreateExtensionStmt);
287node_mapping(AlterExtensionStmt);
288node_mapping(AlterExtensionContentsStmt);
289node_mapping(CreateFdwStmt);
290node_mapping(AlterFdwStmt);
291node_mapping(CreateForeignServerStmt);
292node_mapping(AlterForeignServerStmt);
293node_mapping(CreateForeignTableStmt);
294node_mapping(CreateUserMappingStmt);
295node_mapping(AlterUserMappingStmt);
296node_mapping(DropUserMappingStmt);
297node_mapping(ImportForeignSchemaStmt);
298node_mapping(CreatePolicyStmt);
299node_mapping(AlterPolicyStmt);
300node_mapping(CreateAmStmt);
301node_mapping(CreateTrigStmt);
302node_mapping(CreateEventTrigStmt);
303node_mapping(AlterEventTrigStmt);
304node_mapping(CreatePLangStmt);
305node_mapping(CreateRoleStmt);
306node_mapping(AlterRoleStmt);
307node_mapping(AlterRoleSetStmt);
308node_mapping(DropRoleStmt);
309node_mapping(CreateSeqStmt);
310node_mapping(AlterSeqStmt);
311node_mapping(DefineStmt);
312node_mapping(CreateDomainStmt);
313node_mapping(CreateOpClassStmt);
314node_mapping(CreateOpClassItem);
315node_mapping(CreateOpFamilyStmt);
316node_mapping(AlterOpFamilyStmt);
317node_mapping(DropStmt);
318node_mapping(TruncateStmt);
319node_mapping(CommentStmt);
320node_mapping(SecLabelStmt);
321node_mapping(DeclareCursorStmt);
322node_mapping(ClosePortalStmt);
323node_mapping(FetchStmt);
324node_mapping(IndexStmt);
325node_mapping(CreateStatsStmt);
326#if PG_MAJORVERSION_NUM >= 14
327node_mapping(StatsElem);
328#endif
329node_mapping(AlterStatsStmt);
330node_mapping(CreateFunctionStmt);
331node_mapping(FunctionParameter);
332node_mapping(AlterFunctionStmt);
333node_mapping(DoStmt);
334node_mapping(InlineCodeBlock);
335node_mapping(CallStmt);
336node_mapping(CallContext);
337node_mapping(RenameStmt);
338node_mapping(AlterObjectDependsStmt);
339node_mapping(AlterObjectSchemaStmt);
340node_mapping(AlterOwnerStmt);
341node_mapping(AlterOperatorStmt);
342node_mapping(AlterTypeStmt);
343node_mapping(RuleStmt);
344node_mapping(NotifyStmt);
345node_mapping(ListenStmt);
346node_mapping(UnlistenStmt);
347node_mapping(TransactionStmt);
348node_mapping(CompositeTypeStmt);
349node_mapping(CreateEnumStmt);
350node_mapping(CreateRangeStmt);
351node_mapping(AlterEnumStmt);
352node_mapping(ViewStmt);
353node_mapping(LoadStmt);
354node_mapping(CreatedbStmt);
355node_mapping(AlterDatabaseStmt);
356#if PG_MAJORVERSION_NUM >= 15
357node_mapping(AlterDatabaseRefreshCollStmt);
358#endif
359node_mapping(AlterDatabaseSetStmt);
360node_mapping(DropdbStmt);
361node_mapping(AlterSystemStmt);
362node_mapping(ClusterStmt);
363node_mapping(VacuumStmt);
364node_mapping(VacuumRelation);
365node_mapping(ExplainStmt);
366node_mapping(CreateTableAsStmt);
367node_mapping(RefreshMatViewStmt);
368node_mapping(CheckPointStmt);
369node_mapping(DiscardStmt);
370node_mapping(LockStmt);
371node_mapping(ConstraintsSetStmt);
372node_mapping(ReindexStmt);
373node_mapping(CreateConversionStmt);
374node_mapping(CreateCastStmt);
375node_mapping(CreateTransformStmt);
376node_mapping(PrepareStmt);
377node_mapping(ExecuteStmt);
378node_mapping(DeallocateStmt);
379node_mapping(DropOwnedStmt);
380node_mapping(ReassignOwnedStmt);
381node_mapping(AlterTSDictionaryStmt);
382node_mapping(AlterTSConfigurationStmt);
383#if PG_MAJORVERSION_NUM >= 15
384node_mapping(PublicationTable);
385node_mapping(PublicationObjSpec);
386#endif
387node_mapping(CreatePublicationStmt);
388node_mapping(AlterPublicationStmt);
389node_mapping(CreateSubscriptionStmt);
390node_mapping(AlterSubscriptionStmt);
391node_mapping(DropSubscriptionStmt);
392node_mapping(PlannerGlobal);
393node_mapping(PlannerInfo);
394node_mapping(RelOptInfo);
395node_mapping(IndexOptInfo);
396node_mapping(ForeignKeyOptInfo);
397node_mapping(StatisticExtInfo);
398#if PG_MAJORVERSION_NUM >= 16
399node_mapping(JoinDomain);
400#endif
401node_mapping(EquivalenceClass);
402node_mapping(EquivalenceMember);
403node_mapping(PathKey);
404#if PG_MAJORVERSION_NUM >= 17
405node_mapping(GroupByOrdering);
406#endif
407node_mapping(PathTarget);
408node_mapping(ParamPathInfo);
409node_mapping(Path);
410node_mapping(IndexPath);
411node_mapping(IndexClause);
412node_mapping(BitmapHeapPath);
413node_mapping(BitmapAndPath);
414node_mapping(BitmapOrPath);
415node_mapping(TidPath);
416#if PG_MAJORVERSION_NUM >= 14
417node_mapping(TidRangePath);
418#endif
419node_mapping(SubqueryScanPath);
420node_mapping(ForeignPath);
421node_mapping(CustomPath);
422node_mapping(AppendPath);
423node_mapping(MergeAppendPath);
424node_mapping(GroupResultPath);
425node_mapping(MaterialPath);
426#if PG_MAJORVERSION_NUM >= 14
427node_mapping(MemoizePath);
428#endif
429node_mapping(UniquePath);
430node_mapping(GatherPath);
431node_mapping(GatherMergePath);
432node_mapping(NestPath);
433node_mapping(MergePath);
434node_mapping(HashPath);
435node_mapping(ProjectionPath);
436node_mapping(ProjectSetPath);
437node_mapping(SortPath);
438node_mapping(IncrementalSortPath);
439node_mapping(GroupPath);
440node_mapping(UpperUniquePath);
441node_mapping(AggPath);
442node_mapping(GroupingSetData);
443node_mapping(RollupData);
444node_mapping(GroupingSetsPath);
445node_mapping(MinMaxAggPath);
446node_mapping(WindowAggPath);
447node_mapping(SetOpPath);
448node_mapping(RecursiveUnionPath);
449node_mapping(LockRowsPath);
450node_mapping(ModifyTablePath);
451node_mapping(LimitPath);
452node_mapping(RestrictInfo);
453node_mapping(PlaceHolderVar);
454node_mapping(SpecialJoinInfo);
455#if PG_MAJORVERSION_NUM >= 16
456node_mapping(OuterJoinClauseInfo);
457#endif
458node_mapping(AppendRelInfo);
459#if PG_MAJORVERSION_NUM >= 14
460node_mapping(RowIdentityVarInfo);
461#endif
462node_mapping(PlaceHolderInfo);
463node_mapping(MinMaxAggInfo);
464node_mapping(PlannerParamItem);
465#if PG_MAJORVERSION_NUM >= 16
466node_mapping(AggInfo);
467node_mapping(AggTransInfo);
468#endif
469#if PG_MAJORVERSION_NUM >= 18
470node_mapping(UniqueRelInfo);
471#endif
472node_mapping(PlannedStmt);
473node_mapping(Result);
474node_mapping(ProjectSet);
475node_mapping(ModifyTable);
476node_mapping(Append);
477node_mapping(MergeAppend);
478node_mapping(RecursiveUnion);
479node_mapping(BitmapAnd);
480node_mapping(BitmapOr);
481node_mapping(SeqScan);
482node_mapping(SampleScan);
483node_mapping(IndexScan);
484node_mapping(IndexOnlyScan);
485node_mapping(BitmapIndexScan);
486node_mapping(BitmapHeapScan);
487node_mapping(TidScan);
488#if PG_MAJORVERSION_NUM >= 14
489node_mapping(TidRangeScan);
490#endif
491node_mapping(SubqueryScan);
492node_mapping(FunctionScan);
493node_mapping(ValuesScan);
494node_mapping(TableFuncScan);
495node_mapping(CteScan);
496node_mapping(NamedTuplestoreScan);
497node_mapping(WorkTableScan);
498node_mapping(ForeignScan);
499node_mapping(CustomScan);
500node_mapping(NestLoop);
501node_mapping(NestLoopParam);
502node_mapping(MergeJoin);
503node_mapping(HashJoin);
504node_mapping(Material);
505#if PG_MAJORVERSION_NUM >= 14
506node_mapping(Memoize);
507#endif
508node_mapping(Sort);
509node_mapping(IncrementalSort);
510node_mapping(Group);
511node_mapping(Agg);
512node_mapping(WindowAgg);
513node_mapping(Unique);
514node_mapping(Gather);
515node_mapping(GatherMerge);
516node_mapping(Hash);
517node_mapping(SetOp);
518node_mapping(LockRows);
519node_mapping(Limit);
520node_mapping(PlanRowMark);
521node_mapping(PartitionPruneInfo);
522node_mapping(PartitionedRelPruneInfo);
523node_mapping(PartitionPruneStepOp);
524node_mapping(PartitionPruneStepCombine);
525node_mapping(PlanInvalItem);
526node_mapping(ExprState);
527node_mapping(IndexInfo);
528node_mapping(ExprContext);
529node_mapping(ReturnSetInfo);
530node_mapping(ProjectionInfo);
531node_mapping(JunkFilter);
532node_mapping(OnConflictSetState);
533#if PG_MAJORVERSION_NUM >= 15
534node_mapping(MergeActionState);
535#endif
536node_mapping(ResultRelInfo);
537node_mapping(EState);
538node_mapping(WindowFuncExprState);
539node_mapping(SetExprState);
540node_mapping(SubPlanState);
541node_mapping(DomainConstraintState);
542node_mapping(ResultState);
543node_mapping(ProjectSetState);
544node_mapping(ModifyTableState);
545node_mapping(AppendState);
546node_mapping(MergeAppendState);
547node_mapping(RecursiveUnionState);
548node_mapping(BitmapAndState);
549node_mapping(BitmapOrState);
550node_mapping(ScanState);
551node_mapping(SeqScanState);
552node_mapping(SampleScanState);
553node_mapping(IndexScanState);
554node_mapping(IndexOnlyScanState);
555node_mapping(BitmapIndexScanState);
556node_mapping(BitmapHeapScanState);
557node_mapping(TidScanState);
558#if PG_MAJORVERSION_NUM >= 14
559node_mapping(TidRangeScanState);
560#endif
561node_mapping(SubqueryScanState);
562node_mapping(FunctionScanState);
563node_mapping(ValuesScanState);
564node_mapping(TableFuncScanState);
565node_mapping(CteScanState);
566node_mapping(NamedTuplestoreScanState);
567node_mapping(WorkTableScanState);
568node_mapping(ForeignScanState);
569node_mapping(CustomScanState);
570node_mapping(JoinState);
571node_mapping(NestLoopState);
572node_mapping(MergeJoinState);
573node_mapping(HashJoinState);
574node_mapping(MaterialState);
575#if PG_MAJORVERSION_NUM >= 14
576node_mapping(MemoizeState);
577#endif
578node_mapping(SortState);
579node_mapping(IncrementalSortState);
580node_mapping(GroupState);
581node_mapping(AggState);
582node_mapping(WindowAggState);
583node_mapping(UniqueState);
584node_mapping(GatherState);
585node_mapping(GatherMergeState);
586node_mapping(HashState);
587node_mapping(SetOpState);
588node_mapping(LockRowsState);
589node_mapping(LimitState);
590node_mapping(IndexAmRoutine);
591node_mapping(TableAmRoutine);
592node_mapping(TsmRoutine);
593node_mapping(EventTriggerData);
594node_mapping(TriggerData);
595node_mapping(TupleTableSlot);
596node_mapping(FdwRoutine);
597#if PG_MAJORVERSION_NUM >= 16
598node_mapping(Bitmapset);
599#endif
600node_mapping(ExtensibleNode);
601#if PG_MAJORVERSION_NUM >= 16
602node_mapping(ErrorSaveContext);
603#endif
604node_mapping(IdentifySystemCmd);
605node_mapping(BaseBackupCmd);
606node_mapping(CreateReplicationSlotCmd);
607node_mapping(DropReplicationSlotCmd);
608#if PG_MAJORVERSION_NUM >= 17
609node_mapping(AlterReplicationSlotCmd);
610#endif
611node_mapping(StartReplicationCmd);
612#if PG_MAJORVERSION_NUM >= 15
613node_mapping(ReadReplicationSlotCmd);
614#endif
615node_mapping(TimeLineHistoryCmd);
616#if PG_MAJORVERSION_NUM >= 17
617node_mapping(UploadManifestCmd);
618#endif
619node_mapping(SupportRequestSimplify);
620node_mapping(SupportRequestSelectivity);
621node_mapping(SupportRequestCost);
622node_mapping(SupportRequestRows);
623node_mapping(SupportRequestIndexCondition);
624#if PG_MAJORVERSION_NUM >= 15
625node_mapping(SupportRequestWFuncMonotonic);
626#endif
627#if PG_MAJORVERSION_NUM >= 17
628node_mapping(SupportRequestOptimizeWindowClause);
629#endif
630#if PG_MAJORVERSION_NUM >= 18
631node_mapping(SupportRequestModifyInPlace);
632#endif
633#if PG_MAJORVERSION_NUM >= 15
634node_mapping(Integer);
635node_mapping(Float);
636node_mapping(Boolean);
637node_mapping(String);
638node_mapping(BitString);
639#endif
640node_mapping(ForeignKeyCacheInfo);
641
642#undef node_mapping
643
644#define node_dispatch(name) \
645 if (node_traits<nodes::name>::is(node)) { \
646 visitor(reinterpret_cast<nodes::name &>(node)); \
647 return; \
648 } else
649
650template <typename Visitor> void visit_node(auto node, Visitor &&visitor) {
651 // clang-format off
652node_dispatch(List)
653node_dispatch(Alias)
654node_dispatch(RangeVar)
655node_dispatch(TableFunc)
656node_dispatch(IntoClause)
657node_dispatch(Var)
658node_dispatch(Const)
659node_dispatch(Param)
660node_dispatch(Aggref)
661node_dispatch(GroupingFunc)
662node_dispatch(WindowFunc)
663#if PG_MAJORVERSION_NUM >= 17
664node_dispatch(WindowFuncRunCondition)
665node_dispatch(MergeSupportFunc)
666#endif
667node_dispatch(SubscriptingRef)
668node_dispatch(FuncExpr)
669node_dispatch(NamedArgExpr)
670node_dispatch(OpExpr)
671node_dispatch(DistinctExpr)
672node_dispatch(NullIfExpr)
673node_dispatch(ScalarArrayOpExpr)
674node_dispatch(BoolExpr)
675node_dispatch(SubLink)
676node_dispatch(SubPlan)
677node_dispatch(AlternativeSubPlan)
678node_dispatch(FieldSelect)
679node_dispatch(FieldStore)
680node_dispatch(RelabelType)
681node_dispatch(CoerceViaIO)
682node_dispatch(ArrayCoerceExpr)
683node_dispatch(ConvertRowtypeExpr)
684node_dispatch(CollateExpr)
685node_dispatch(CaseExpr)
686node_dispatch(CaseWhen)
687node_dispatch(CaseTestExpr)
688node_dispatch(ArrayExpr)
689node_dispatch(RowExpr)
690node_dispatch(RowCompareExpr)
691node_dispatch(CoalesceExpr)
692node_dispatch(MinMaxExpr)
693node_dispatch(SQLValueFunction)
694node_dispatch(XmlExpr)
695#if PG_MAJORVERSION_NUM >= 16
696node_dispatch(JsonFormat)
697node_dispatch(JsonReturning)
698node_dispatch(JsonValueExpr)
699node_dispatch(JsonConstructorExpr)
700node_dispatch(JsonIsPredicate)
701#endif
702#if PG_MAJORVERSION_NUM >= 17
703node_dispatch(JsonBehavior)
704node_dispatch(JsonExpr)
705node_dispatch(JsonTablePath)
706node_dispatch(JsonTablePathScan)
707node_dispatch(JsonTableSiblingJoin)
708#endif
709node_dispatch(NullTest)
710node_dispatch(BooleanTest)
711#if PG_MAJORVERSION_NUM >= 15
712node_dispatch(MergeAction)
713#endif
714node_dispatch(CoerceToDomain)
715node_dispatch(CoerceToDomainValue)
716node_dispatch(SetToDefault)
717node_dispatch(CurrentOfExpr)
718node_dispatch(NextValueExpr)
719node_dispatch(InferenceElem)
720#if PG_MAJORVERSION_NUM >= 18
721node_dispatch(ReturningExpr)
722#endif
723node_dispatch(TargetEntry)
724node_dispatch(RangeTblRef)
725node_dispatch(JoinExpr)
726node_dispatch(FromExpr)
727node_dispatch(OnConflictExpr)
728node_dispatch(Query)
729node_dispatch(TypeName)
730node_dispatch(ColumnRef)
731node_dispatch(ParamRef)
732node_dispatch(A_Expr)
733node_dispatch(A_Const)
734node_dispatch(TypeCast)
735node_dispatch(CollateClause)
736node_dispatch(RoleSpec)
737node_dispatch(FuncCall)
738node_dispatch(A_Star)
739node_dispatch(A_Indices)
740node_dispatch(A_Indirection)
741node_dispatch(A_ArrayExpr)
742node_dispatch(ResTarget)
743node_dispatch(MultiAssignRef)
744node_dispatch(SortBy)
745node_dispatch(WindowDef)
746node_dispatch(RangeSubselect)
747node_dispatch(RangeFunction)
748node_dispatch(RangeTableFunc)
749node_dispatch(RangeTableFuncCol)
750node_dispatch(RangeTableSample)
751node_dispatch(ColumnDef)
752node_dispatch(TableLikeClause)
753node_dispatch(IndexElem)
754node_dispatch(DefElem)
755node_dispatch(LockingClause)
756node_dispatch(XmlSerialize)
757node_dispatch(PartitionElem)
758#if PG_MAJORVERSION_NUM == 17
759node_dispatch(SinglePartitionSpec)
760#endif
761node_dispatch(PartitionSpec)
762node_dispatch(PartitionBoundSpec)
763node_dispatch(PartitionRangeDatum)
764node_dispatch(PartitionCmd)
765node_dispatch(RangeTblEntry)
766#if PG_MAJORVERSION_NUM >= 16
767node_dispatch(RTEPermissionInfo)
768#endif
769node_dispatch(RangeTblFunction)
770node_dispatch(TableSampleClause)
771node_dispatch(WithCheckOption)
772node_dispatch(SortGroupClause)
773node_dispatch(GroupingSet)
774node_dispatch(WindowClause)
775node_dispatch(RowMarkClause)
776node_dispatch(WithClause)
777node_dispatch(InferClause)
778node_dispatch(OnConflictClause)
779#if PG_MAJORVERSION_NUM >= 14
780node_dispatch(CTESearchClause)
781node_dispatch(CTECycleClause)
782#endif
783node_dispatch(CommonTableExpr)
784#if PG_MAJORVERSION_NUM >= 15
785node_dispatch(MergeWhenClause)
786#endif
787#if PG_MAJORVERSION_NUM >= 18
788node_dispatch(ReturningOption)
789node_dispatch(ReturningClause)
790#endif
791node_dispatch(TriggerTransition)
792#if PG_MAJORVERSION_NUM >= 16
793node_dispatch(JsonOutput)
794#endif
795#if PG_MAJORVERSION_NUM >= 17
796node_dispatch(JsonArgument)
797node_dispatch(JsonFuncExpr)
798node_dispatch(JsonTablePathSpec)
799node_dispatch(JsonTable)
800node_dispatch(JsonTableColumn)
801node_dispatch(JsonKeyValue)
802node_dispatch(JsonParseExpr)
803node_dispatch(JsonScalarExpr)
804node_dispatch(JsonSerializeExpr)
805#endif
806#if PG_MAJORVERSION_NUM >= 16
807node_dispatch(JsonObjectConstructor)
808node_dispatch(JsonArrayConstructor)
809node_dispatch(JsonArrayQueryConstructor)
810node_dispatch(JsonAggConstructor)
811node_dispatch(JsonObjectAgg)
812node_dispatch(JsonArrayAgg)
813#endif
814node_dispatch(RawStmt)
815node_dispatch(InsertStmt)
816node_dispatch(DeleteStmt)
817node_dispatch(UpdateStmt)
818#if PG_MAJORVERSION_NUM >= 15
819node_dispatch(MergeStmt)
820#endif
821node_dispatch(SelectStmt)
822node_dispatch(SetOperationStmt)
823#if PG_MAJORVERSION_NUM >= 14
824node_dispatch(ReturnStmt)
825#endif
826#if PG_MAJORVERSION_NUM >= 14
827node_dispatch(PLAssignStmt)
828#endif
829node_dispatch(CreateSchemaStmt)
830node_dispatch(AlterTableStmt)
831node_dispatch(AlterTableCmd)
832#if PG_MAJORVERSION_NUM >= 18
833node_dispatch(ATAlterConstraint)
834#endif
835node_dispatch(ReplicaIdentityStmt)
836node_dispatch(AlterCollationStmt)
837node_dispatch(AlterDomainStmt)
838node_dispatch(GrantStmt)
839node_dispatch(ObjectWithArgs)
840node_dispatch(AccessPriv)
841node_dispatch(GrantRoleStmt)
842node_dispatch(AlterDefaultPrivilegesStmt)
843node_dispatch(CopyStmt)
844node_dispatch(VariableSetStmt)
845node_dispatch(VariableShowStmt)
846node_dispatch(CreateStmt)
847node_dispatch(Constraint)
848node_dispatch(CreateTableSpaceStmt)
849node_dispatch(DropTableSpaceStmt)
850node_dispatch(AlterTableSpaceOptionsStmt)
851node_dispatch(AlterTableMoveAllStmt)
852node_dispatch(CreateExtensionStmt)
853node_dispatch(AlterExtensionStmt)
854node_dispatch(AlterExtensionContentsStmt)
855node_dispatch(CreateFdwStmt)
856node_dispatch(AlterFdwStmt)
857node_dispatch(CreateForeignServerStmt)
858node_dispatch(AlterForeignServerStmt)
859node_dispatch(CreateForeignTableStmt)
860node_dispatch(CreateUserMappingStmt)
861node_dispatch(AlterUserMappingStmt)
862node_dispatch(DropUserMappingStmt)
863node_dispatch(ImportForeignSchemaStmt)
864node_dispatch(CreatePolicyStmt)
865node_dispatch(AlterPolicyStmt)
866node_dispatch(CreateAmStmt)
867node_dispatch(CreateTrigStmt)
868node_dispatch(CreateEventTrigStmt)
869node_dispatch(AlterEventTrigStmt)
870node_dispatch(CreatePLangStmt)
871node_dispatch(CreateRoleStmt)
872node_dispatch(AlterRoleStmt)
873node_dispatch(AlterRoleSetStmt)
874node_dispatch(DropRoleStmt)
875node_dispatch(CreateSeqStmt)
876node_dispatch(AlterSeqStmt)
877node_dispatch(DefineStmt)
878node_dispatch(CreateDomainStmt)
879node_dispatch(CreateOpClassStmt)
880node_dispatch(CreateOpClassItem)
881node_dispatch(CreateOpFamilyStmt)
882node_dispatch(AlterOpFamilyStmt)
883node_dispatch(DropStmt)
884node_dispatch(TruncateStmt)
885node_dispatch(CommentStmt)
886node_dispatch(SecLabelStmt)
887node_dispatch(DeclareCursorStmt)
888node_dispatch(ClosePortalStmt)
889node_dispatch(FetchStmt)
890node_dispatch(IndexStmt)
891node_dispatch(CreateStatsStmt)
892#if PG_MAJORVERSION_NUM >= 14
893node_dispatch(StatsElem)
894#endif
895node_dispatch(AlterStatsStmt)
896node_dispatch(CreateFunctionStmt)
897node_dispatch(FunctionParameter)
898node_dispatch(AlterFunctionStmt)
899node_dispatch(DoStmt)
900node_dispatch(InlineCodeBlock)
901node_dispatch(CallStmt)
902node_dispatch(CallContext)
903node_dispatch(RenameStmt)
904node_dispatch(AlterObjectDependsStmt)
905node_dispatch(AlterObjectSchemaStmt)
906node_dispatch(AlterOwnerStmt)
907node_dispatch(AlterOperatorStmt)
908node_dispatch(AlterTypeStmt)
909node_dispatch(RuleStmt)
910node_dispatch(NotifyStmt)
911node_dispatch(ListenStmt)
912node_dispatch(UnlistenStmt)
913node_dispatch(TransactionStmt)
914node_dispatch(CompositeTypeStmt)
915node_dispatch(CreateEnumStmt)
916node_dispatch(CreateRangeStmt)
917node_dispatch(AlterEnumStmt)
918node_dispatch(ViewStmt)
919node_dispatch(LoadStmt)
920node_dispatch(CreatedbStmt)
921node_dispatch(AlterDatabaseStmt)
922#if PG_MAJORVERSION_NUM >= 15
923node_dispatch(AlterDatabaseRefreshCollStmt)
924#endif
925node_dispatch(AlterDatabaseSetStmt)
926node_dispatch(DropdbStmt)
927node_dispatch(AlterSystemStmt)
928node_dispatch(ClusterStmt)
929node_dispatch(VacuumStmt)
930node_dispatch(VacuumRelation)
931node_dispatch(ExplainStmt)
932node_dispatch(CreateTableAsStmt)
933node_dispatch(RefreshMatViewStmt)
934node_dispatch(CheckPointStmt)
935node_dispatch(DiscardStmt)
936node_dispatch(LockStmt)
937node_dispatch(ConstraintsSetStmt)
938node_dispatch(ReindexStmt)
939node_dispatch(CreateConversionStmt)
940node_dispatch(CreateCastStmt)
941node_dispatch(CreateTransformStmt)
942node_dispatch(PrepareStmt)
943node_dispatch(ExecuteStmt)
944node_dispatch(DeallocateStmt)
945node_dispatch(DropOwnedStmt)
946node_dispatch(ReassignOwnedStmt)
947node_dispatch(AlterTSDictionaryStmt)
948node_dispatch(AlterTSConfigurationStmt)
949#if PG_MAJORVERSION_NUM >= 15
950node_dispatch(PublicationTable)
951node_dispatch(PublicationObjSpec)
952#endif
953node_dispatch(CreatePublicationStmt)
954node_dispatch(AlterPublicationStmt)
955node_dispatch(CreateSubscriptionStmt)
956node_dispatch(AlterSubscriptionStmt)
957node_dispatch(DropSubscriptionStmt)
958node_dispatch(PlannerGlobal)
959node_dispatch(PlannerInfo)
960node_dispatch(RelOptInfo)
961node_dispatch(IndexOptInfo)
962node_dispatch(ForeignKeyOptInfo)
963node_dispatch(StatisticExtInfo)
964#if PG_MAJORVERSION_NUM >= 16
965node_dispatch(JoinDomain)
966#endif
967node_dispatch(EquivalenceClass)
968node_dispatch(EquivalenceMember)
969node_dispatch(PathKey)
970#if PG_MAJORVERSION_NUM >= 17
971node_dispatch(GroupByOrdering)
972#endif
973node_dispatch(PathTarget)
974node_dispatch(ParamPathInfo)
975node_dispatch(Path)
976node_dispatch(IndexPath)
977node_dispatch(IndexClause)
978node_dispatch(BitmapHeapPath)
979node_dispatch(BitmapAndPath)
980node_dispatch(BitmapOrPath)
981node_dispatch(TidPath)
982#if PG_MAJORVERSION_NUM >= 14
983node_dispatch(TidRangePath)
984#endif
985node_dispatch(SubqueryScanPath)
986node_dispatch(ForeignPath)
987node_dispatch(CustomPath)
988node_dispatch(AppendPath)
989node_dispatch(MergeAppendPath)
990node_dispatch(GroupResultPath)
991node_dispatch(MaterialPath)
992#if PG_MAJORVERSION_NUM >= 14
993node_dispatch(MemoizePath)
994#endif
995node_dispatch(UniquePath)
996node_dispatch(GatherPath)
997node_dispatch(GatherMergePath)
998node_dispatch(NestPath)
999node_dispatch(MergePath)
1000node_dispatch(HashPath)
1001node_dispatch(ProjectionPath)
1002node_dispatch(ProjectSetPath)
1003node_dispatch(SortPath)
1004node_dispatch(IncrementalSortPath)
1005node_dispatch(GroupPath)
1006node_dispatch(UpperUniquePath)
1007node_dispatch(AggPath)
1008node_dispatch(GroupingSetData)
1009node_dispatch(RollupData)
1010node_dispatch(GroupingSetsPath)
1011node_dispatch(MinMaxAggPath)
1012node_dispatch(WindowAggPath)
1013node_dispatch(SetOpPath)
1014node_dispatch(RecursiveUnionPath)
1015node_dispatch(LockRowsPath)
1016node_dispatch(ModifyTablePath)
1017node_dispatch(LimitPath)
1018node_dispatch(RestrictInfo)
1019node_dispatch(PlaceHolderVar)
1020node_dispatch(SpecialJoinInfo)
1021#if PG_MAJORVERSION_NUM >= 16
1022node_dispatch(OuterJoinClauseInfo)
1023#endif
1024node_dispatch(AppendRelInfo)
1025#if PG_MAJORVERSION_NUM >= 14
1026node_dispatch(RowIdentityVarInfo)
1027#endif
1028node_dispatch(PlaceHolderInfo)
1029node_dispatch(MinMaxAggInfo)
1030node_dispatch(PlannerParamItem)
1031#if PG_MAJORVERSION_NUM >= 16
1032node_dispatch(AggInfo)
1033node_dispatch(AggTransInfo)
1034#endif
1035#if PG_MAJORVERSION_NUM >= 18
1036node_dispatch(UniqueRelInfo)
1037#endif
1038node_dispatch(PlannedStmt)
1039node_dispatch(Result)
1040node_dispatch(ProjectSet)
1041node_dispatch(ModifyTable)
1042node_dispatch(Append)
1043node_dispatch(MergeAppend)
1044node_dispatch(RecursiveUnion)
1045node_dispatch(BitmapAnd)
1046node_dispatch(BitmapOr)
1047node_dispatch(SeqScan)
1048node_dispatch(SampleScan)
1049node_dispatch(IndexScan)
1050node_dispatch(IndexOnlyScan)
1051node_dispatch(BitmapIndexScan)
1052node_dispatch(BitmapHeapScan)
1053node_dispatch(TidScan)
1054#if PG_MAJORVERSION_NUM >= 14
1055node_dispatch(TidRangeScan)
1056#endif
1057node_dispatch(SubqueryScan)
1058node_dispatch(FunctionScan)
1059node_dispatch(ValuesScan)
1060node_dispatch(TableFuncScan)
1061node_dispatch(CteScan)
1062node_dispatch(NamedTuplestoreScan)
1063node_dispatch(WorkTableScan)
1064node_dispatch(ForeignScan)
1065node_dispatch(CustomScan)
1066node_dispatch(NestLoop)
1067node_dispatch(NestLoopParam)
1068node_dispatch(MergeJoin)
1069node_dispatch(HashJoin)
1070node_dispatch(Material)
1071#if PG_MAJORVERSION_NUM >= 14
1072node_dispatch(Memoize)
1073#endif
1074node_dispatch(Sort)
1075node_dispatch(IncrementalSort)
1076node_dispatch(Group)
1077node_dispatch(Agg)
1078node_dispatch(WindowAgg)
1079node_dispatch(Unique)
1080node_dispatch(Gather)
1081node_dispatch(GatherMerge)
1082node_dispatch(Hash)
1083node_dispatch(SetOp)
1084node_dispatch(LockRows)
1085node_dispatch(Limit)
1086node_dispatch(PlanRowMark)
1087node_dispatch(PartitionPruneInfo)
1088node_dispatch(PartitionedRelPruneInfo)
1089node_dispatch(PartitionPruneStepOp)
1090node_dispatch(PartitionPruneStepCombine)
1091node_dispatch(PlanInvalItem)
1092node_dispatch(ExprState)
1093node_dispatch(IndexInfo)
1094node_dispatch(ExprContext)
1095node_dispatch(ReturnSetInfo)
1096node_dispatch(ProjectionInfo)
1097node_dispatch(JunkFilter)
1098node_dispatch(OnConflictSetState)
1099#if PG_MAJORVERSION_NUM >= 15
1100node_dispatch(MergeActionState)
1101#endif
1102node_dispatch(ResultRelInfo)
1103node_dispatch(EState)
1104node_dispatch(WindowFuncExprState)
1105node_dispatch(SetExprState)
1106node_dispatch(SubPlanState)
1107node_dispatch(DomainConstraintState)
1108node_dispatch(ResultState)
1109node_dispatch(ProjectSetState)
1110node_dispatch(ModifyTableState)
1111node_dispatch(AppendState)
1112node_dispatch(MergeAppendState)
1113node_dispatch(RecursiveUnionState)
1114node_dispatch(BitmapAndState)
1115node_dispatch(BitmapOrState)
1116node_dispatch(ScanState)
1117node_dispatch(SeqScanState)
1118node_dispatch(SampleScanState)
1119node_dispatch(IndexScanState)
1120node_dispatch(IndexOnlyScanState)
1121node_dispatch(BitmapIndexScanState)
1122node_dispatch(BitmapHeapScanState)
1123node_dispatch(TidScanState)
1124#if PG_MAJORVERSION_NUM >= 14
1125node_dispatch(TidRangeScanState)
1126#endif
1127node_dispatch(SubqueryScanState)
1128node_dispatch(FunctionScanState)
1129node_dispatch(ValuesScanState)
1130node_dispatch(TableFuncScanState)
1131node_dispatch(CteScanState)
1132node_dispatch(NamedTuplestoreScanState)
1133node_dispatch(WorkTableScanState)
1134node_dispatch(ForeignScanState)
1135node_dispatch(CustomScanState)
1136node_dispatch(JoinState)
1137node_dispatch(NestLoopState)
1138node_dispatch(MergeJoinState)
1139node_dispatch(HashJoinState)
1140node_dispatch(MaterialState)
1141#if PG_MAJORVERSION_NUM >= 14
1142node_dispatch(MemoizeState)
1143#endif
1144node_dispatch(SortState)
1145node_dispatch(IncrementalSortState)
1146node_dispatch(GroupState)
1147node_dispatch(AggState)
1148node_dispatch(WindowAggState)
1149node_dispatch(UniqueState)
1150node_dispatch(GatherState)
1151node_dispatch(GatherMergeState)
1152node_dispatch(HashState)
1153node_dispatch(SetOpState)
1154node_dispatch(LockRowsState)
1155node_dispatch(LimitState)
1156node_dispatch(IndexAmRoutine)
1157node_dispatch(TableAmRoutine)
1158node_dispatch(TsmRoutine)
1159node_dispatch(EventTriggerData)
1160node_dispatch(TriggerData)
1161node_dispatch(TupleTableSlot)
1162node_dispatch(FdwRoutine)
1163#if PG_MAJORVERSION_NUM >= 16
1164node_dispatch(Bitmapset)
1165#endif
1166node_dispatch(ExtensibleNode)
1167#if PG_MAJORVERSION_NUM >= 16
1168node_dispatch(ErrorSaveContext)
1169#endif
1170node_dispatch(IdentifySystemCmd)
1171node_dispatch(BaseBackupCmd)
1172node_dispatch(CreateReplicationSlotCmd)
1173node_dispatch(DropReplicationSlotCmd)
1174#if PG_MAJORVERSION_NUM >= 17
1175node_dispatch(AlterReplicationSlotCmd)
1176#endif
1177node_dispatch(StartReplicationCmd)
1178#if PG_MAJORVERSION_NUM >= 15
1179node_dispatch(ReadReplicationSlotCmd)
1180#endif
1181node_dispatch(TimeLineHistoryCmd)
1182#if PG_MAJORVERSION_NUM >= 17
1183node_dispatch(UploadManifestCmd)
1184#endif
1185node_dispatch(SupportRequestSimplify)
1186node_dispatch(SupportRequestSelectivity)
1187node_dispatch(SupportRequestCost)
1188node_dispatch(SupportRequestRows)
1189node_dispatch(SupportRequestIndexCondition)
1190#if PG_MAJORVERSION_NUM >= 15
1191node_dispatch(SupportRequestWFuncMonotonic)
1192#endif
1193#if PG_MAJORVERSION_NUM >= 17
1194node_dispatch(SupportRequestOptimizeWindowClause)
1195#endif
1196#if PG_MAJORVERSION_NUM >= 18
1197node_dispatch(SupportRequestModifyInPlace)
1198#endif
1199#if PG_MAJORVERSION_NUM >= 15
1200node_dispatch(Integer)
1201node_dispatch(Float)
1202node_dispatch(Boolean)
1203node_dispatch(String)
1204node_dispatch(BitString)
1205#endif
1206node_dispatch(ForeignKeyCacheInfo)
1207 // clang-format on
1208 throw std::runtime_error("unknown node tag");
1209}
1210
1211#undef node_dispatch
1212
1213} // namespace cppgres
Definition: node.hpp:23
Definition: node.hpp:29
Definition: node.hpp:13
Definition: node.hpp:18
Definition: node.hpp:36
Definition: node.hpp:41
Definition: node.hpp:38
Postgres type.
Definition: type.hpp:20