1 /*-------------------------------------------------------------------------
4 * Copy functions for Postgres tree nodes.
6 * NOTE: we currently support copying all node types found in parse and
7 * plan trees. We do not support copying executor state trees; there
8 * is no need for that, and no point in maintaining all the code that
9 * would be needed. We also do not support copying Path trees, mainly
10 * because the circular linkages between RelOptInfo and Path nodes can't
11 * be handled easily in a simple depth-first traversal.
14 * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
18 * src/backend/nodes/copyfuncs.c
20 *-------------------------------------------------------------------------
25 #include "miscadmin.h"
26 #include "nodes/extensible.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
30 #include "utils/rel.h"
34 * Macros to simplify copying of different kinds of fields. Use these
35 * wherever possible to reduce the chance for silly typos. Note that these
36 * hard-wire the convention that the local variables in a Copy routine are
37 * named 'newnode' and 'from'.
40 /* Copy a simple scalar field (int, float, bool, enum, etc) */
41 #define COPY_SCALAR_FIELD(fldname) \
42 (newnode->fldname = from->fldname)
44 /* Copy a field that is a pointer to some kind of Node or Node tree */
45 #define COPY_NODE_FIELD(fldname) \
46 (newnode->fldname = copyObjectImpl(from->fldname))
48 /* Copy a field that is a pointer to a Bitmapset */
49 #define COPY_BITMAPSET_FIELD(fldname) \
50 (newnode->fldname = bms_copy(from->fldname))
52 /* Copy a field that is a pointer to a C string, or perhaps NULL */
53 #define COPY_STRING_FIELD(fldname) \
54 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
56 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
57 #define COPY_POINTER_FIELD(fldname, sz) \
60 newnode->fldname = palloc(_size); \
61 memcpy(newnode->fldname, from->fldname, _size); \
64 /* Copy a parse location field (for Copy, this is same as scalar case) */
65 #define COPY_LOCATION_FIELD(fldname) \
66 (newnode->fldname = from->fldname)
69 /* ****************************************************************
70 * plannodes.h copy functions
71 * ****************************************************************
78 _copyPlannedStmt(const PlannedStmt *from)
80 PlannedStmt *newnode = makeNode(PlannedStmt);
82 COPY_SCALAR_FIELD(commandType);
83 COPY_SCALAR_FIELD(queryId);
84 COPY_SCALAR_FIELD(hasReturning);
85 COPY_SCALAR_FIELD(hasModifyingCTE);
86 COPY_SCALAR_FIELD(canSetTag);
87 COPY_SCALAR_FIELD(transientPlan);
88 COPY_SCALAR_FIELD(dependsOnRole);
89 COPY_SCALAR_FIELD(parallelModeNeeded);
90 COPY_SCALAR_FIELD(jitFlags);
91 COPY_NODE_FIELD(planTree);
92 COPY_NODE_FIELD(rtable);
93 COPY_NODE_FIELD(resultRelations);
94 COPY_NODE_FIELD(nonleafResultRelations);
95 COPY_NODE_FIELD(rootResultRelations);
96 COPY_NODE_FIELD(subplans);
97 COPY_BITMAPSET_FIELD(rewindPlanIDs);
98 COPY_NODE_FIELD(rowMarks);
99 COPY_NODE_FIELD(relationOids);
100 COPY_NODE_FIELD(invalItems);
101 COPY_NODE_FIELD(paramExecTypes);
102 COPY_NODE_FIELD(utilityStmt);
103 COPY_LOCATION_FIELD(stmt_location);
104 COPY_LOCATION_FIELD(stmt_len);
112 * This function copies the fields of the Plan node. It is used by
113 * all the copy functions for classes which inherit from Plan.
116 CopyPlanFields(const Plan *from, Plan *newnode)
118 COPY_SCALAR_FIELD(startup_cost);
119 COPY_SCALAR_FIELD(total_cost);
120 COPY_SCALAR_FIELD(plan_rows);
121 COPY_SCALAR_FIELD(plan_width);
122 COPY_SCALAR_FIELD(parallel_aware);
123 COPY_SCALAR_FIELD(parallel_safe);
124 COPY_SCALAR_FIELD(plan_node_id);
125 COPY_NODE_FIELD(targetlist);
126 COPY_NODE_FIELD(qual);
127 COPY_NODE_FIELD(lefttree);
128 COPY_NODE_FIELD(righttree);
129 COPY_NODE_FIELD(initPlan);
130 COPY_BITMAPSET_FIELD(extParam);
131 COPY_BITMAPSET_FIELD(allParam);
138 _copyPlan(const Plan *from)
140 Plan *newnode = makeNode(Plan);
143 * copy node superclass fields
145 CopyPlanFields(from, newnode);
155 _copyResult(const Result *from)
157 Result *newnode = makeNode(Result);
160 * copy node superclass fields
162 CopyPlanFields((const Plan *) from, (Plan *) newnode);
165 * copy remainder of node
167 COPY_NODE_FIELD(resconstantqual);
176 _copyProjectSet(const ProjectSet *from)
178 ProjectSet *newnode = makeNode(ProjectSet);
181 * copy node superclass fields
183 CopyPlanFields((const Plan *) from, (Plan *) newnode);
192 _copyModifyTable(const ModifyTable *from)
194 ModifyTable *newnode = makeNode(ModifyTable);
197 * copy node superclass fields
199 CopyPlanFields((const Plan *) from, (Plan *) newnode);
202 * copy remainder of node
204 COPY_SCALAR_FIELD(operation);
205 COPY_SCALAR_FIELD(canSetTag);
206 COPY_SCALAR_FIELD(nominalRelation);
207 COPY_NODE_FIELD(partitioned_rels);
208 COPY_SCALAR_FIELD(partColsUpdated);
209 COPY_NODE_FIELD(resultRelations);
210 COPY_SCALAR_FIELD(mergeTargetRelation);
211 COPY_SCALAR_FIELD(resultRelIndex);
212 COPY_SCALAR_FIELD(rootResultRelIndex);
213 COPY_NODE_FIELD(plans);
214 COPY_NODE_FIELD(withCheckOptionLists);
215 COPY_NODE_FIELD(returningLists);
216 COPY_NODE_FIELD(fdwPrivLists);
217 COPY_BITMAPSET_FIELD(fdwDirectModifyPlans);
218 COPY_NODE_FIELD(rowMarks);
219 COPY_SCALAR_FIELD(epqParam);
220 COPY_SCALAR_FIELD(onConflictAction);
221 COPY_NODE_FIELD(arbiterIndexes);
222 COPY_NODE_FIELD(onConflictSet);
223 COPY_NODE_FIELD(onConflictWhere);
224 COPY_SCALAR_FIELD(exclRelRTI);
225 COPY_NODE_FIELD(exclRelTlist);
226 COPY_NODE_FIELD(mergeSourceTargetList);
227 COPY_NODE_FIELD(mergeActionList);
236 _copyAppend(const Append *from)
238 Append *newnode = makeNode(Append);
241 * copy node superclass fields
243 CopyPlanFields((const Plan *) from, (Plan *) newnode);
246 * copy remainder of node
248 COPY_NODE_FIELD(partitioned_rels);
249 COPY_NODE_FIELD(appendplans);
250 COPY_SCALAR_FIELD(first_partial_plan);
259 _copyMergeAppend(const MergeAppend *from)
261 MergeAppend *newnode = makeNode(MergeAppend);
264 * copy node superclass fields
266 CopyPlanFields((const Plan *) from, (Plan *) newnode);
269 * copy remainder of node
271 COPY_NODE_FIELD(partitioned_rels);
272 COPY_NODE_FIELD(mergeplans);
273 COPY_SCALAR_FIELD(numCols);
274 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
275 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
276 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
277 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
283 * _copyRecursiveUnion
285 static RecursiveUnion *
286 _copyRecursiveUnion(const RecursiveUnion *from)
288 RecursiveUnion *newnode = makeNode(RecursiveUnion);
291 * copy node superclass fields
293 CopyPlanFields((const Plan *) from, (Plan *) newnode);
296 * copy remainder of node
298 COPY_SCALAR_FIELD(wtParam);
299 COPY_SCALAR_FIELD(numCols);
300 if (from->numCols > 0)
302 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
303 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
305 COPY_SCALAR_FIELD(numGroups);
314 _copyBitmapAnd(const BitmapAnd *from)
316 BitmapAnd *newnode = makeNode(BitmapAnd);
319 * copy node superclass fields
321 CopyPlanFields((const Plan *) from, (Plan *) newnode);
324 * copy remainder of node
326 COPY_NODE_FIELD(bitmapplans);
335 _copyBitmapOr(const BitmapOr *from)
337 BitmapOr *newnode = makeNode(BitmapOr);
340 * copy node superclass fields
342 CopyPlanFields((const Plan *) from, (Plan *) newnode);
345 * copy remainder of node
347 COPY_SCALAR_FIELD(isshared);
348 COPY_NODE_FIELD(bitmapplans);
357 _copyGather(const Gather *from)
359 Gather *newnode = makeNode(Gather);
362 * copy node superclass fields
364 CopyPlanFields((const Plan *) from, (Plan *) newnode);
367 * copy remainder of node
369 COPY_SCALAR_FIELD(num_workers);
370 COPY_SCALAR_FIELD(rescan_param);
371 COPY_SCALAR_FIELD(single_copy);
372 COPY_SCALAR_FIELD(invisible);
373 COPY_BITMAPSET_FIELD(initParam);
382 _copyGatherMerge(const GatherMerge *from)
384 GatherMerge *newnode = makeNode(GatherMerge);
387 * copy node superclass fields
389 CopyPlanFields((const Plan *) from, (Plan *) newnode);
392 * copy remainder of node
394 COPY_SCALAR_FIELD(num_workers);
395 COPY_SCALAR_FIELD(rescan_param);
396 COPY_SCALAR_FIELD(numCols);
397 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
398 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
399 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
400 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
401 COPY_BITMAPSET_FIELD(initParam);
409 * This function copies the fields of the Scan node. It is used by
410 * all the copy functions for classes which inherit from Scan.
413 CopyScanFields(const Scan *from, Scan *newnode)
415 CopyPlanFields((const Plan *) from, (Plan *) newnode);
417 COPY_SCALAR_FIELD(scanrelid);
424 _copyScan(const Scan *from)
426 Scan *newnode = makeNode(Scan);
429 * copy node superclass fields
431 CopyScanFields((const Scan *) from, (Scan *) newnode);
440 _copySeqScan(const SeqScan *from)
442 SeqScan *newnode = makeNode(SeqScan);
445 * copy node superclass fields
447 CopyScanFields((const Scan *) from, (Scan *) newnode);
456 _copySampleScan(const SampleScan *from)
458 SampleScan *newnode = makeNode(SampleScan);
461 * copy node superclass fields
463 CopyScanFields((const Scan *) from, (Scan *) newnode);
466 * copy remainder of node
468 COPY_NODE_FIELD(tablesample);
477 _copyIndexScan(const IndexScan *from)
479 IndexScan *newnode = makeNode(IndexScan);
482 * copy node superclass fields
484 CopyScanFields((const Scan *) from, (Scan *) newnode);
487 * copy remainder of node
489 COPY_SCALAR_FIELD(indexid);
490 COPY_NODE_FIELD(indexqual);
491 COPY_NODE_FIELD(indexqualorig);
492 COPY_NODE_FIELD(indexorderby);
493 COPY_NODE_FIELD(indexorderbyorig);
494 COPY_NODE_FIELD(indexorderbyops);
495 COPY_SCALAR_FIELD(indexorderdir);
503 static IndexOnlyScan *
504 _copyIndexOnlyScan(const IndexOnlyScan *from)
506 IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
509 * copy node superclass fields
511 CopyScanFields((const Scan *) from, (Scan *) newnode);
514 * copy remainder of node
516 COPY_SCALAR_FIELD(indexid);
517 COPY_NODE_FIELD(indexqual);
518 COPY_NODE_FIELD(indexorderby);
519 COPY_NODE_FIELD(indextlist);
520 COPY_SCALAR_FIELD(indexorderdir);
526 * _copyBitmapIndexScan
528 static BitmapIndexScan *
529 _copyBitmapIndexScan(const BitmapIndexScan *from)
531 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
534 * copy node superclass fields
536 CopyScanFields((const Scan *) from, (Scan *) newnode);
539 * copy remainder of node
541 COPY_SCALAR_FIELD(indexid);
542 COPY_SCALAR_FIELD(isshared);
543 COPY_NODE_FIELD(indexqual);
544 COPY_NODE_FIELD(indexqualorig);
550 * _copyBitmapHeapScan
552 static BitmapHeapScan *
553 _copyBitmapHeapScan(const BitmapHeapScan *from)
555 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
558 * copy node superclass fields
560 CopyScanFields((const Scan *) from, (Scan *) newnode);
563 * copy remainder of node
565 COPY_NODE_FIELD(bitmapqualorig);
574 _copyTidScan(const TidScan *from)
576 TidScan *newnode = makeNode(TidScan);
579 * copy node superclass fields
581 CopyScanFields((const Scan *) from, (Scan *) newnode);
584 * copy remainder of node
586 COPY_NODE_FIELD(tidquals);
594 static SubqueryScan *
595 _copySubqueryScan(const SubqueryScan *from)
597 SubqueryScan *newnode = makeNode(SubqueryScan);
600 * copy node superclass fields
602 CopyScanFields((const Scan *) from, (Scan *) newnode);
605 * copy remainder of node
607 COPY_NODE_FIELD(subplan);
615 static FunctionScan *
616 _copyFunctionScan(const FunctionScan *from)
618 FunctionScan *newnode = makeNode(FunctionScan);
621 * copy node superclass fields
623 CopyScanFields((const Scan *) from, (Scan *) newnode);
626 * copy remainder of node
628 COPY_NODE_FIELD(functions);
629 COPY_SCALAR_FIELD(funcordinality);
637 static TableFuncScan *
638 _copyTableFuncScan(const TableFuncScan *from)
640 TableFuncScan *newnode = makeNode(TableFuncScan);
643 * copy node superclass fields
645 CopyScanFields((const Scan *) from, (Scan *) newnode);
648 * copy remainder of node
650 COPY_NODE_FIELD(tablefunc);
659 _copyValuesScan(const ValuesScan *from)
661 ValuesScan *newnode = makeNode(ValuesScan);
664 * copy node superclass fields
666 CopyScanFields((const Scan *) from, (Scan *) newnode);
669 * copy remainder of node
671 COPY_NODE_FIELD(values_lists);
680 _copyCteScan(const CteScan *from)
682 CteScan *newnode = makeNode(CteScan);
685 * copy node superclass fields
687 CopyScanFields((const Scan *) from, (Scan *) newnode);
690 * copy remainder of node
692 COPY_SCALAR_FIELD(ctePlanId);
693 COPY_SCALAR_FIELD(cteParam);
699 * _copyNamedTuplestoreScan
701 static NamedTuplestoreScan *
702 _copyNamedTuplestoreScan(const NamedTuplestoreScan *from)
704 NamedTuplestoreScan *newnode = makeNode(NamedTuplestoreScan);
707 * copy node superclass fields
709 CopyScanFields((const Scan *) from, (Scan *) newnode);
712 * copy remainder of node
714 COPY_STRING_FIELD(enrname);
722 static WorkTableScan *
723 _copyWorkTableScan(const WorkTableScan *from)
725 WorkTableScan *newnode = makeNode(WorkTableScan);
728 * copy node superclass fields
730 CopyScanFields((const Scan *) from, (Scan *) newnode);
733 * copy remainder of node
735 COPY_SCALAR_FIELD(wtParam);
744 _copyForeignScan(const ForeignScan *from)
746 ForeignScan *newnode = makeNode(ForeignScan);
749 * copy node superclass fields
751 CopyScanFields((const Scan *) from, (Scan *) newnode);
754 * copy remainder of node
756 COPY_SCALAR_FIELD(operation);
757 COPY_SCALAR_FIELD(fs_server);
758 COPY_NODE_FIELD(fdw_exprs);
759 COPY_NODE_FIELD(fdw_private);
760 COPY_NODE_FIELD(fdw_scan_tlist);
761 COPY_NODE_FIELD(fdw_recheck_quals);
762 COPY_BITMAPSET_FIELD(fs_relids);
763 COPY_SCALAR_FIELD(fsSystemCol);
772 _copyCustomScan(const CustomScan *from)
774 CustomScan *newnode = makeNode(CustomScan);
777 * copy node superclass fields
779 CopyScanFields((const Scan *) from, (Scan *) newnode);
782 * copy remainder of node
784 COPY_SCALAR_FIELD(flags);
785 COPY_NODE_FIELD(custom_plans);
786 COPY_NODE_FIELD(custom_exprs);
787 COPY_NODE_FIELD(custom_private);
788 COPY_NODE_FIELD(custom_scan_tlist);
789 COPY_BITMAPSET_FIELD(custom_relids);
792 * NOTE: The method field of CustomScan is required to be a pointer to a
793 * static table of callback functions. So we don't copy the table itself,
794 * just reference the original one.
796 COPY_SCALAR_FIELD(methods);
804 * This function copies the fields of the Join node. It is used by
805 * all the copy functions for classes which inherit from Join.
808 CopyJoinFields(const Join *from, Join *newnode)
810 CopyPlanFields((const Plan *) from, (Plan *) newnode);
812 COPY_SCALAR_FIELD(jointype);
813 COPY_SCALAR_FIELD(inner_unique);
814 COPY_NODE_FIELD(joinqual);
822 _copyJoin(const Join *from)
824 Join *newnode = makeNode(Join);
827 * copy node superclass fields
829 CopyJoinFields(from, newnode);
839 _copyNestLoop(const NestLoop *from)
841 NestLoop *newnode = makeNode(NestLoop);
844 * copy node superclass fields
846 CopyJoinFields((const Join *) from, (Join *) newnode);
849 * copy remainder of node
851 COPY_NODE_FIELD(nestParams);
861 _copyMergeJoin(const MergeJoin *from)
863 MergeJoin *newnode = makeNode(MergeJoin);
867 * copy node superclass fields
869 CopyJoinFields((const Join *) from, (Join *) newnode);
872 * copy remainder of node
874 COPY_SCALAR_FIELD(skip_mark_restore);
875 COPY_NODE_FIELD(mergeclauses);
876 numCols = list_length(from->mergeclauses);
879 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
880 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
881 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
882 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
892 _copyHashJoin(const HashJoin *from)
894 HashJoin *newnode = makeNode(HashJoin);
897 * copy node superclass fields
899 CopyJoinFields((const Join *) from, (Join *) newnode);
902 * copy remainder of node
904 COPY_NODE_FIELD(hashclauses);
914 _copyMaterial(const Material *from)
916 Material *newnode = makeNode(Material);
919 * copy node superclass fields
921 CopyPlanFields((const Plan *) from, (Plan *) newnode);
931 _copySort(const Sort *from)
933 Sort *newnode = makeNode(Sort);
936 * copy node superclass fields
938 CopyPlanFields((const Plan *) from, (Plan *) newnode);
940 COPY_SCALAR_FIELD(numCols);
941 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
942 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
943 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
944 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
954 _copyGroup(const Group *from)
956 Group *newnode = makeNode(Group);
958 CopyPlanFields((const Plan *) from, (Plan *) newnode);
960 COPY_SCALAR_FIELD(numCols);
961 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
962 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
971 _copyAgg(const Agg *from)
973 Agg *newnode = makeNode(Agg);
975 CopyPlanFields((const Plan *) from, (Plan *) newnode);
977 COPY_SCALAR_FIELD(aggstrategy);
978 COPY_SCALAR_FIELD(aggsplit);
979 COPY_SCALAR_FIELD(numCols);
980 if (from->numCols > 0)
982 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
983 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
985 COPY_SCALAR_FIELD(numGroups);
986 COPY_BITMAPSET_FIELD(aggParams);
987 COPY_NODE_FIELD(groupingSets);
988 COPY_NODE_FIELD(chain);
997 _copyWindowAgg(const WindowAgg *from)
999 WindowAgg *newnode = makeNode(WindowAgg);
1001 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1003 COPY_SCALAR_FIELD(winref);
1004 COPY_SCALAR_FIELD(partNumCols);
1005 if (from->partNumCols > 0)
1007 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
1008 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
1010 COPY_SCALAR_FIELD(ordNumCols);
1011 if (from->ordNumCols > 0)
1013 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
1014 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
1016 COPY_SCALAR_FIELD(frameOptions);
1017 COPY_NODE_FIELD(startOffset);
1018 COPY_NODE_FIELD(endOffset);
1019 COPY_SCALAR_FIELD(startInRangeFunc);
1020 COPY_SCALAR_FIELD(endInRangeFunc);
1021 COPY_SCALAR_FIELD(inRangeColl);
1022 COPY_SCALAR_FIELD(inRangeAsc);
1023 COPY_SCALAR_FIELD(inRangeNullsFirst);
1032 _copyUnique(const Unique *from)
1034 Unique *newnode = makeNode(Unique);
1037 * copy node superclass fields
1039 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1042 * copy remainder of node
1044 COPY_SCALAR_FIELD(numCols);
1045 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
1046 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
1055 _copyHash(const Hash *from)
1057 Hash *newnode = makeNode(Hash);
1060 * copy node superclass fields
1062 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1065 * copy remainder of node
1067 COPY_SCALAR_FIELD(skewTable);
1068 COPY_SCALAR_FIELD(skewColumn);
1069 COPY_SCALAR_FIELD(skewInherit);
1070 COPY_SCALAR_FIELD(rows_total);
1079 _copySetOp(const SetOp *from)
1081 SetOp *newnode = makeNode(SetOp);
1084 * copy node superclass fields
1086 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1089 * copy remainder of node
1091 COPY_SCALAR_FIELD(cmd);
1092 COPY_SCALAR_FIELD(strategy);
1093 COPY_SCALAR_FIELD(numCols);
1094 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
1095 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
1096 COPY_SCALAR_FIELD(flagColIdx);
1097 COPY_SCALAR_FIELD(firstFlag);
1098 COPY_SCALAR_FIELD(numGroups);
1107 _copyLockRows(const LockRows *from)
1109 LockRows *newnode = makeNode(LockRows);
1112 * copy node superclass fields
1114 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1117 * copy remainder of node
1119 COPY_NODE_FIELD(rowMarks);
1120 COPY_SCALAR_FIELD(epqParam);
1129 _copyLimit(const Limit *from)
1131 Limit *newnode = makeNode(Limit);
1134 * copy node superclass fields
1136 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1139 * copy remainder of node
1141 COPY_NODE_FIELD(limitOffset);
1142 COPY_NODE_FIELD(limitCount);
1148 * _copyNestLoopParam
1150 static NestLoopParam *
1151 _copyNestLoopParam(const NestLoopParam *from)
1153 NestLoopParam *newnode = makeNode(NestLoopParam);
1155 COPY_SCALAR_FIELD(paramno);
1156 COPY_NODE_FIELD(paramval);
1164 static PlanRowMark *
1165 _copyPlanRowMark(const PlanRowMark *from)
1167 PlanRowMark *newnode = makeNode(PlanRowMark);
1169 COPY_SCALAR_FIELD(rti);
1170 COPY_SCALAR_FIELD(prti);
1171 COPY_SCALAR_FIELD(rowmarkId);
1172 COPY_SCALAR_FIELD(markType);
1173 COPY_SCALAR_FIELD(allMarkTypes);
1174 COPY_SCALAR_FIELD(strength);
1175 COPY_SCALAR_FIELD(waitPolicy);
1176 COPY_SCALAR_FIELD(isParent);
1182 * _copyPlanInvalItem
1184 static PlanInvalItem *
1185 _copyPlanInvalItem(const PlanInvalItem *from)
1187 PlanInvalItem *newnode = makeNode(PlanInvalItem);
1189 COPY_SCALAR_FIELD(cacheId);
1190 COPY_SCALAR_FIELD(hashValue);
1195 /* ****************************************************************
1196 * primnodes.h copy functions
1197 * ****************************************************************
1204 _copyAlias(const Alias *from)
1206 Alias *newnode = makeNode(Alias);
1208 COPY_STRING_FIELD(aliasname);
1209 COPY_NODE_FIELD(colnames);
1218 _copyRangeVar(const RangeVar *from)
1220 RangeVar *newnode = makeNode(RangeVar);
1222 COPY_STRING_FIELD(catalogname);
1223 COPY_STRING_FIELD(schemaname);
1224 COPY_STRING_FIELD(relname);
1225 COPY_SCALAR_FIELD(inh);
1226 COPY_SCALAR_FIELD(relpersistence);
1227 COPY_NODE_FIELD(alias);
1228 COPY_LOCATION_FIELD(location);
1237 _copyTableFunc(const TableFunc *from)
1239 TableFunc *newnode = makeNode(TableFunc);
1241 COPY_NODE_FIELD(ns_uris);
1242 COPY_NODE_FIELD(ns_names);
1243 COPY_NODE_FIELD(docexpr);
1244 COPY_NODE_FIELD(rowexpr);
1245 COPY_NODE_FIELD(colnames);
1246 COPY_NODE_FIELD(coltypes);
1247 COPY_NODE_FIELD(coltypmods);
1248 COPY_NODE_FIELD(colcollations);
1249 COPY_NODE_FIELD(colexprs);
1250 COPY_NODE_FIELD(coldefexprs);
1251 COPY_BITMAPSET_FIELD(notnulls);
1252 COPY_SCALAR_FIELD(ordinalitycol);
1253 COPY_LOCATION_FIELD(location);
1262 _copyIntoClause(const IntoClause *from)
1264 IntoClause *newnode = makeNode(IntoClause);
1266 COPY_NODE_FIELD(rel);
1267 COPY_NODE_FIELD(colNames);
1268 COPY_NODE_FIELD(options);
1269 COPY_SCALAR_FIELD(onCommit);
1270 COPY_STRING_FIELD(tableSpaceName);
1271 COPY_NODE_FIELD(viewQuery);
1272 COPY_SCALAR_FIELD(skipData);
1278 * We don't need a _copyExpr because Expr is an abstract supertype which
1279 * should never actually get instantiated. Also, since it has no common
1280 * fields except NodeTag, there's no need for a helper routine to factor
1281 * out copying the common fields...
1288 _copyVar(const Var *from)
1290 Var *newnode = makeNode(Var);
1292 COPY_SCALAR_FIELD(varno);
1293 COPY_SCALAR_FIELD(varattno);
1294 COPY_SCALAR_FIELD(vartype);
1295 COPY_SCALAR_FIELD(vartypmod);
1296 COPY_SCALAR_FIELD(varcollid);
1297 COPY_SCALAR_FIELD(varlevelsup);
1298 COPY_SCALAR_FIELD(varnoold);
1299 COPY_SCALAR_FIELD(varoattno);
1300 COPY_LOCATION_FIELD(location);
1309 _copyConst(const Const *from)
1311 Const *newnode = makeNode(Const);
1313 COPY_SCALAR_FIELD(consttype);
1314 COPY_SCALAR_FIELD(consttypmod);
1315 COPY_SCALAR_FIELD(constcollid);
1316 COPY_SCALAR_FIELD(constlen);
1318 if (from->constbyval || from->constisnull)
1321 * passed by value so just copy the datum. Also, don't try to copy
1322 * struct when value is null!
1324 newnode->constvalue = from->constvalue;
1329 * passed by reference. We need a palloc'd copy.
1331 newnode->constvalue = datumCopy(from->constvalue,
1336 COPY_SCALAR_FIELD(constisnull);
1337 COPY_SCALAR_FIELD(constbyval);
1338 COPY_LOCATION_FIELD(location);
1347 _copyParam(const Param *from)
1349 Param *newnode = makeNode(Param);
1351 COPY_SCALAR_FIELD(paramkind);
1352 COPY_SCALAR_FIELD(paramid);
1353 COPY_SCALAR_FIELD(paramtype);
1354 COPY_SCALAR_FIELD(paramtypmod);
1355 COPY_SCALAR_FIELD(paramcollid);
1356 COPY_LOCATION_FIELD(location);
1365 _copyAggref(const Aggref *from)
1367 Aggref *newnode = makeNode(Aggref);
1369 COPY_SCALAR_FIELD(aggfnoid);
1370 COPY_SCALAR_FIELD(aggtype);
1371 COPY_SCALAR_FIELD(aggcollid);
1372 COPY_SCALAR_FIELD(inputcollid);
1373 COPY_SCALAR_FIELD(aggtranstype);
1374 COPY_NODE_FIELD(aggargtypes);
1375 COPY_NODE_FIELD(aggdirectargs);
1376 COPY_NODE_FIELD(args);
1377 COPY_NODE_FIELD(aggorder);
1378 COPY_NODE_FIELD(aggdistinct);
1379 COPY_NODE_FIELD(aggfilter);
1380 COPY_SCALAR_FIELD(aggstar);
1381 COPY_SCALAR_FIELD(aggvariadic);
1382 COPY_SCALAR_FIELD(aggkind);
1383 COPY_SCALAR_FIELD(agglevelsup);
1384 COPY_SCALAR_FIELD(aggsplit);
1385 COPY_LOCATION_FIELD(location);
1393 static GroupingFunc *
1394 _copyGroupingFunc(const GroupingFunc *from)
1396 GroupingFunc *newnode = makeNode(GroupingFunc);
1398 COPY_NODE_FIELD(args);
1399 COPY_NODE_FIELD(refs);
1400 COPY_NODE_FIELD(cols);
1401 COPY_SCALAR_FIELD(agglevelsup);
1402 COPY_LOCATION_FIELD(location);
1411 _copyWindowFunc(const WindowFunc *from)
1413 WindowFunc *newnode = makeNode(WindowFunc);
1415 COPY_SCALAR_FIELD(winfnoid);
1416 COPY_SCALAR_FIELD(wintype);
1417 COPY_SCALAR_FIELD(wincollid);
1418 COPY_SCALAR_FIELD(inputcollid);
1419 COPY_NODE_FIELD(args);
1420 COPY_NODE_FIELD(aggfilter);
1421 COPY_SCALAR_FIELD(winref);
1422 COPY_SCALAR_FIELD(winstar);
1423 COPY_SCALAR_FIELD(winagg);
1424 COPY_LOCATION_FIELD(location);
1433 _copyArrayRef(const ArrayRef *from)
1435 ArrayRef *newnode = makeNode(ArrayRef);
1437 COPY_SCALAR_FIELD(refarraytype);
1438 COPY_SCALAR_FIELD(refelemtype);
1439 COPY_SCALAR_FIELD(reftypmod);
1440 COPY_SCALAR_FIELD(refcollid);
1441 COPY_NODE_FIELD(refupperindexpr);
1442 COPY_NODE_FIELD(reflowerindexpr);
1443 COPY_NODE_FIELD(refexpr);
1444 COPY_NODE_FIELD(refassgnexpr);
1453 _copyFuncExpr(const FuncExpr *from)
1455 FuncExpr *newnode = makeNode(FuncExpr);
1457 COPY_SCALAR_FIELD(funcid);
1458 COPY_SCALAR_FIELD(funcresulttype);
1459 COPY_SCALAR_FIELD(funcretset);
1460 COPY_SCALAR_FIELD(funcvariadic);
1461 COPY_SCALAR_FIELD(funcformat);
1462 COPY_SCALAR_FIELD(funccollid);
1463 COPY_SCALAR_FIELD(inputcollid);
1464 COPY_NODE_FIELD(args);
1465 COPY_LOCATION_FIELD(location);
1471 * _copyNamedArgExpr *
1473 static NamedArgExpr *
1474 _copyNamedArgExpr(const NamedArgExpr *from)
1476 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1478 COPY_NODE_FIELD(arg);
1479 COPY_STRING_FIELD(name);
1480 COPY_SCALAR_FIELD(argnumber);
1481 COPY_LOCATION_FIELD(location);
1490 _copyOpExpr(const OpExpr *from)
1492 OpExpr *newnode = makeNode(OpExpr);
1494 COPY_SCALAR_FIELD(opno);
1495 COPY_SCALAR_FIELD(opfuncid);
1496 COPY_SCALAR_FIELD(opresulttype);
1497 COPY_SCALAR_FIELD(opretset);
1498 COPY_SCALAR_FIELD(opcollid);
1499 COPY_SCALAR_FIELD(inputcollid);
1500 COPY_NODE_FIELD(args);
1501 COPY_LOCATION_FIELD(location);
1507 * _copyDistinctExpr (same as OpExpr)
1509 static DistinctExpr *
1510 _copyDistinctExpr(const DistinctExpr *from)
1512 DistinctExpr *newnode = makeNode(DistinctExpr);
1514 COPY_SCALAR_FIELD(opno);
1515 COPY_SCALAR_FIELD(opfuncid);
1516 COPY_SCALAR_FIELD(opresulttype);
1517 COPY_SCALAR_FIELD(opretset);
1518 COPY_SCALAR_FIELD(opcollid);
1519 COPY_SCALAR_FIELD(inputcollid);
1520 COPY_NODE_FIELD(args);
1521 COPY_LOCATION_FIELD(location);
1527 * _copyNullIfExpr (same as OpExpr)
1530 _copyNullIfExpr(const NullIfExpr *from)
1532 NullIfExpr *newnode = makeNode(NullIfExpr);
1534 COPY_SCALAR_FIELD(opno);
1535 COPY_SCALAR_FIELD(opfuncid);
1536 COPY_SCALAR_FIELD(opresulttype);
1537 COPY_SCALAR_FIELD(opretset);
1538 COPY_SCALAR_FIELD(opcollid);
1539 COPY_SCALAR_FIELD(inputcollid);
1540 COPY_NODE_FIELD(args);
1541 COPY_LOCATION_FIELD(location);
1547 * _copyScalarArrayOpExpr
1549 static ScalarArrayOpExpr *
1550 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
1552 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1554 COPY_SCALAR_FIELD(opno);
1555 COPY_SCALAR_FIELD(opfuncid);
1556 COPY_SCALAR_FIELD(useOr);
1557 COPY_SCALAR_FIELD(inputcollid);
1558 COPY_NODE_FIELD(args);
1559 COPY_LOCATION_FIELD(location);
1568 _copyBoolExpr(const BoolExpr *from)
1570 BoolExpr *newnode = makeNode(BoolExpr);
1572 COPY_SCALAR_FIELD(boolop);
1573 COPY_NODE_FIELD(args);
1574 COPY_LOCATION_FIELD(location);
1583 _copySubLink(const SubLink *from)
1585 SubLink *newnode = makeNode(SubLink);
1587 COPY_SCALAR_FIELD(subLinkType);
1588 COPY_SCALAR_FIELD(subLinkId);
1589 COPY_NODE_FIELD(testexpr);
1590 COPY_NODE_FIELD(operName);
1591 COPY_NODE_FIELD(subselect);
1592 COPY_LOCATION_FIELD(location);
1601 _copySubPlan(const SubPlan *from)
1603 SubPlan *newnode = makeNode(SubPlan);
1605 COPY_SCALAR_FIELD(subLinkType);
1606 COPY_NODE_FIELD(testexpr);
1607 COPY_NODE_FIELD(paramIds);
1608 COPY_SCALAR_FIELD(plan_id);
1609 COPY_STRING_FIELD(plan_name);
1610 COPY_SCALAR_FIELD(firstColType);
1611 COPY_SCALAR_FIELD(firstColTypmod);
1612 COPY_SCALAR_FIELD(firstColCollation);
1613 COPY_SCALAR_FIELD(useHashTable);
1614 COPY_SCALAR_FIELD(unknownEqFalse);
1615 COPY_SCALAR_FIELD(parallel_safe);
1616 COPY_NODE_FIELD(setParam);
1617 COPY_NODE_FIELD(parParam);
1618 COPY_NODE_FIELD(args);
1619 COPY_SCALAR_FIELD(startup_cost);
1620 COPY_SCALAR_FIELD(per_call_cost);
1626 * _copyAlternativeSubPlan
1628 static AlternativeSubPlan *
1629 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
1631 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1633 COPY_NODE_FIELD(subplans);
1641 static FieldSelect *
1642 _copyFieldSelect(const FieldSelect *from)
1644 FieldSelect *newnode = makeNode(FieldSelect);
1646 COPY_NODE_FIELD(arg);
1647 COPY_SCALAR_FIELD(fieldnum);
1648 COPY_SCALAR_FIELD(resulttype);
1649 COPY_SCALAR_FIELD(resulttypmod);
1650 COPY_SCALAR_FIELD(resultcollid);
1659 _copyFieldStore(const FieldStore *from)
1661 FieldStore *newnode = makeNode(FieldStore);
1663 COPY_NODE_FIELD(arg);
1664 COPY_NODE_FIELD(newvals);
1665 COPY_NODE_FIELD(fieldnums);
1666 COPY_SCALAR_FIELD(resulttype);
1674 static RelabelType *
1675 _copyRelabelType(const RelabelType *from)
1677 RelabelType *newnode = makeNode(RelabelType);
1679 COPY_NODE_FIELD(arg);
1680 COPY_SCALAR_FIELD(resulttype);
1681 COPY_SCALAR_FIELD(resulttypmod);
1682 COPY_SCALAR_FIELD(resultcollid);
1683 COPY_SCALAR_FIELD(relabelformat);
1684 COPY_LOCATION_FIELD(location);
1692 static CoerceViaIO *
1693 _copyCoerceViaIO(const CoerceViaIO *from)
1695 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1697 COPY_NODE_FIELD(arg);
1698 COPY_SCALAR_FIELD(resulttype);
1699 COPY_SCALAR_FIELD(resultcollid);
1700 COPY_SCALAR_FIELD(coerceformat);
1701 COPY_LOCATION_FIELD(location);
1707 * _copyArrayCoerceExpr
1709 static ArrayCoerceExpr *
1710 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
1712 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1714 COPY_NODE_FIELD(arg);
1715 COPY_NODE_FIELD(elemexpr);
1716 COPY_SCALAR_FIELD(resulttype);
1717 COPY_SCALAR_FIELD(resulttypmod);
1718 COPY_SCALAR_FIELD(resultcollid);
1719 COPY_SCALAR_FIELD(coerceformat);
1720 COPY_LOCATION_FIELD(location);
1726 * _copyConvertRowtypeExpr
1728 static ConvertRowtypeExpr *
1729 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
1731 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1733 COPY_NODE_FIELD(arg);
1734 COPY_SCALAR_FIELD(resulttype);
1735 COPY_SCALAR_FIELD(convertformat);
1736 COPY_LOCATION_FIELD(location);
1744 static CollateExpr *
1745 _copyCollateExpr(const CollateExpr *from)
1747 CollateExpr *newnode = makeNode(CollateExpr);
1749 COPY_NODE_FIELD(arg);
1750 COPY_SCALAR_FIELD(collOid);
1751 COPY_LOCATION_FIELD(location);
1760 _copyCaseExpr(const CaseExpr *from)
1762 CaseExpr *newnode = makeNode(CaseExpr);
1764 COPY_SCALAR_FIELD(casetype);
1765 COPY_SCALAR_FIELD(casecollid);
1766 COPY_NODE_FIELD(arg);
1767 COPY_NODE_FIELD(args);
1768 COPY_NODE_FIELD(defresult);
1769 COPY_LOCATION_FIELD(location);
1778 _copyCaseWhen(const CaseWhen *from)
1780 CaseWhen *newnode = makeNode(CaseWhen);
1782 COPY_NODE_FIELD(expr);
1783 COPY_NODE_FIELD(result);
1784 COPY_LOCATION_FIELD(location);
1792 static CaseTestExpr *
1793 _copyCaseTestExpr(const CaseTestExpr *from)
1795 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1797 COPY_SCALAR_FIELD(typeId);
1798 COPY_SCALAR_FIELD(typeMod);
1799 COPY_SCALAR_FIELD(collation);
1808 _copyArrayExpr(const ArrayExpr *from)
1810 ArrayExpr *newnode = makeNode(ArrayExpr);
1812 COPY_SCALAR_FIELD(array_typeid);
1813 COPY_SCALAR_FIELD(array_collid);
1814 COPY_SCALAR_FIELD(element_typeid);
1815 COPY_NODE_FIELD(elements);
1816 COPY_SCALAR_FIELD(multidims);
1817 COPY_LOCATION_FIELD(location);
1826 _copyRowExpr(const RowExpr *from)
1828 RowExpr *newnode = makeNode(RowExpr);
1830 COPY_NODE_FIELD(args);
1831 COPY_SCALAR_FIELD(row_typeid);
1832 COPY_SCALAR_FIELD(row_format);
1833 COPY_NODE_FIELD(colnames);
1834 COPY_LOCATION_FIELD(location);
1840 * _copyRowCompareExpr
1842 static RowCompareExpr *
1843 _copyRowCompareExpr(const RowCompareExpr *from)
1845 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1847 COPY_SCALAR_FIELD(rctype);
1848 COPY_NODE_FIELD(opnos);
1849 COPY_NODE_FIELD(opfamilies);
1850 COPY_NODE_FIELD(inputcollids);
1851 COPY_NODE_FIELD(largs);
1852 COPY_NODE_FIELD(rargs);
1860 static CoalesceExpr *
1861 _copyCoalesceExpr(const CoalesceExpr *from)
1863 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1865 COPY_SCALAR_FIELD(coalescetype);
1866 COPY_SCALAR_FIELD(coalescecollid);
1867 COPY_NODE_FIELD(args);
1868 COPY_LOCATION_FIELD(location);
1877 _copyMinMaxExpr(const MinMaxExpr *from)
1879 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1881 COPY_SCALAR_FIELD(minmaxtype);
1882 COPY_SCALAR_FIELD(minmaxcollid);
1883 COPY_SCALAR_FIELD(inputcollid);
1884 COPY_SCALAR_FIELD(op);
1885 COPY_NODE_FIELD(args);
1886 COPY_LOCATION_FIELD(location);
1892 * _copySQLValueFunction
1894 static SQLValueFunction *
1895 _copySQLValueFunction(const SQLValueFunction *from)
1897 SQLValueFunction *newnode = makeNode(SQLValueFunction);
1899 COPY_SCALAR_FIELD(op);
1900 COPY_SCALAR_FIELD(type);
1901 COPY_SCALAR_FIELD(typmod);
1902 COPY_LOCATION_FIELD(location);
1911 _copyXmlExpr(const XmlExpr *from)
1913 XmlExpr *newnode = makeNode(XmlExpr);
1915 COPY_SCALAR_FIELD(op);
1916 COPY_STRING_FIELD(name);
1917 COPY_NODE_FIELD(named_args);
1918 COPY_NODE_FIELD(arg_names);
1919 COPY_NODE_FIELD(args);
1920 COPY_SCALAR_FIELD(xmloption);
1921 COPY_SCALAR_FIELD(type);
1922 COPY_SCALAR_FIELD(typmod);
1923 COPY_LOCATION_FIELD(location);
1932 _copyNullTest(const NullTest *from)
1934 NullTest *newnode = makeNode(NullTest);
1936 COPY_NODE_FIELD(arg);
1937 COPY_SCALAR_FIELD(nulltesttype);
1938 COPY_SCALAR_FIELD(argisrow);
1939 COPY_LOCATION_FIELD(location);
1947 static BooleanTest *
1948 _copyBooleanTest(const BooleanTest *from)
1950 BooleanTest *newnode = makeNode(BooleanTest);
1952 COPY_NODE_FIELD(arg);
1953 COPY_SCALAR_FIELD(booltesttype);
1954 COPY_LOCATION_FIELD(location);
1960 * _copyCoerceToDomain
1962 static CoerceToDomain *
1963 _copyCoerceToDomain(const CoerceToDomain *from)
1965 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1967 COPY_NODE_FIELD(arg);
1968 COPY_SCALAR_FIELD(resulttype);
1969 COPY_SCALAR_FIELD(resulttypmod);
1970 COPY_SCALAR_FIELD(resultcollid);
1971 COPY_SCALAR_FIELD(coercionformat);
1972 COPY_LOCATION_FIELD(location);
1978 * _copyCoerceToDomainValue
1980 static CoerceToDomainValue *
1981 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
1983 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1985 COPY_SCALAR_FIELD(typeId);
1986 COPY_SCALAR_FIELD(typeMod);
1987 COPY_SCALAR_FIELD(collation);
1988 COPY_LOCATION_FIELD(location);
1996 static SetToDefault *
1997 _copySetToDefault(const SetToDefault *from)
1999 SetToDefault *newnode = makeNode(SetToDefault);
2001 COPY_SCALAR_FIELD(typeId);
2002 COPY_SCALAR_FIELD(typeMod);
2003 COPY_SCALAR_FIELD(collation);
2004 COPY_LOCATION_FIELD(location);
2010 * _copyCurrentOfExpr
2012 static CurrentOfExpr *
2013 _copyCurrentOfExpr(const CurrentOfExpr *from)
2015 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
2017 COPY_SCALAR_FIELD(cvarno);
2018 COPY_STRING_FIELD(cursor_name);
2019 COPY_SCALAR_FIELD(cursor_param);
2025 * _copyNextValueExpr
2027 static NextValueExpr *
2028 _copyNextValueExpr(const NextValueExpr *from)
2030 NextValueExpr *newnode = makeNode(NextValueExpr);
2032 COPY_SCALAR_FIELD(seqid);
2033 COPY_SCALAR_FIELD(typeId);
2039 * _copyInferenceElem
2041 static InferenceElem *
2042 _copyInferenceElem(const InferenceElem *from)
2044 InferenceElem *newnode = makeNode(InferenceElem);
2046 COPY_NODE_FIELD(expr);
2047 COPY_SCALAR_FIELD(infercollid);
2048 COPY_SCALAR_FIELD(inferopclass);
2056 static TargetEntry *
2057 _copyTargetEntry(const TargetEntry *from)
2059 TargetEntry *newnode = makeNode(TargetEntry);
2061 COPY_NODE_FIELD(expr);
2062 COPY_SCALAR_FIELD(resno);
2063 COPY_STRING_FIELD(resname);
2064 COPY_SCALAR_FIELD(ressortgroupref);
2065 COPY_SCALAR_FIELD(resorigtbl);
2066 COPY_SCALAR_FIELD(resorigcol);
2067 COPY_SCALAR_FIELD(resjunk);
2075 static RangeTblRef *
2076 _copyRangeTblRef(const RangeTblRef *from)
2078 RangeTblRef *newnode = makeNode(RangeTblRef);
2080 COPY_SCALAR_FIELD(rtindex);
2089 _copyJoinExpr(const JoinExpr *from)
2091 JoinExpr *newnode = makeNode(JoinExpr);
2093 COPY_SCALAR_FIELD(jointype);
2094 COPY_SCALAR_FIELD(isNatural);
2095 COPY_NODE_FIELD(larg);
2096 COPY_NODE_FIELD(rarg);
2097 COPY_NODE_FIELD(usingClause);
2098 COPY_NODE_FIELD(quals);
2099 COPY_NODE_FIELD(alias);
2100 COPY_SCALAR_FIELD(rtindex);
2109 _copyFromExpr(const FromExpr *from)
2111 FromExpr *newnode = makeNode(FromExpr);
2113 COPY_NODE_FIELD(fromlist);
2114 COPY_NODE_FIELD(quals);
2120 * _copyOnConflictExpr
2122 static OnConflictExpr *
2123 _copyOnConflictExpr(const OnConflictExpr *from)
2125 OnConflictExpr *newnode = makeNode(OnConflictExpr);
2127 COPY_SCALAR_FIELD(action);
2128 COPY_NODE_FIELD(arbiterElems);
2129 COPY_NODE_FIELD(arbiterWhere);
2130 COPY_SCALAR_FIELD(constraint);
2131 COPY_NODE_FIELD(onConflictSet);
2132 COPY_NODE_FIELD(onConflictWhere);
2133 COPY_SCALAR_FIELD(exclRelIndex);
2134 COPY_NODE_FIELD(exclRelTlist);
2139 static MergeAction *
2140 _copyMergeAction(const MergeAction *from)
2142 MergeAction *newnode = makeNode(MergeAction);
2144 COPY_SCALAR_FIELD(matched);
2145 COPY_SCALAR_FIELD(commandType);
2146 COPY_SCALAR_FIELD(override);
2147 COPY_NODE_FIELD(qual);
2148 COPY_NODE_FIELD(targetList);
2153 /* ****************************************************************
2154 * relation.h copy functions
2156 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
2157 * There are some subsidiary structs that are useful to copy, though.
2158 * ****************************************************************
2165 _copyPathKey(const PathKey *from)
2167 PathKey *newnode = makeNode(PathKey);
2169 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
2170 COPY_SCALAR_FIELD(pk_eclass);
2171 COPY_SCALAR_FIELD(pk_opfamily);
2172 COPY_SCALAR_FIELD(pk_strategy);
2173 COPY_SCALAR_FIELD(pk_nulls_first);
2181 static RestrictInfo *
2182 _copyRestrictInfo(const RestrictInfo *from)
2184 RestrictInfo *newnode = makeNode(RestrictInfo);
2186 COPY_NODE_FIELD(clause);
2187 COPY_SCALAR_FIELD(is_pushed_down);
2188 COPY_SCALAR_FIELD(outerjoin_delayed);
2189 COPY_SCALAR_FIELD(can_join);
2190 COPY_SCALAR_FIELD(pseudoconstant);
2191 COPY_SCALAR_FIELD(leakproof);
2192 COPY_SCALAR_FIELD(security_level);
2193 COPY_BITMAPSET_FIELD(clause_relids);
2194 COPY_BITMAPSET_FIELD(required_relids);
2195 COPY_BITMAPSET_FIELD(outer_relids);
2196 COPY_BITMAPSET_FIELD(nullable_relids);
2197 COPY_BITMAPSET_FIELD(left_relids);
2198 COPY_BITMAPSET_FIELD(right_relids);
2199 COPY_NODE_FIELD(orclause);
2200 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2201 COPY_SCALAR_FIELD(parent_ec);
2202 COPY_SCALAR_FIELD(eval_cost);
2203 COPY_SCALAR_FIELD(norm_selec);
2204 COPY_SCALAR_FIELD(outer_selec);
2205 COPY_NODE_FIELD(mergeopfamilies);
2206 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2207 COPY_SCALAR_FIELD(left_ec);
2208 COPY_SCALAR_FIELD(right_ec);
2209 COPY_SCALAR_FIELD(left_em);
2210 COPY_SCALAR_FIELD(right_em);
2211 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
2212 newnode->scansel_cache = NIL;
2213 COPY_SCALAR_FIELD(outer_is_left);
2214 COPY_SCALAR_FIELD(hashjoinoperator);
2215 COPY_SCALAR_FIELD(left_bucketsize);
2216 COPY_SCALAR_FIELD(right_bucketsize);
2217 COPY_SCALAR_FIELD(left_mcvfreq);
2218 COPY_SCALAR_FIELD(right_mcvfreq);
2224 * _copyPlaceHolderVar
2226 static PlaceHolderVar *
2227 _copyPlaceHolderVar(const PlaceHolderVar *from)
2229 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
2231 COPY_NODE_FIELD(phexpr);
2232 COPY_BITMAPSET_FIELD(phrels);
2233 COPY_SCALAR_FIELD(phid);
2234 COPY_SCALAR_FIELD(phlevelsup);
2240 * _copySpecialJoinInfo
2242 static SpecialJoinInfo *
2243 _copySpecialJoinInfo(const SpecialJoinInfo *from)
2245 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
2247 COPY_BITMAPSET_FIELD(min_lefthand);
2248 COPY_BITMAPSET_FIELD(min_righthand);
2249 COPY_BITMAPSET_FIELD(syn_lefthand);
2250 COPY_BITMAPSET_FIELD(syn_righthand);
2251 COPY_SCALAR_FIELD(jointype);
2252 COPY_SCALAR_FIELD(lhs_strict);
2253 COPY_SCALAR_FIELD(delay_upper_joins);
2254 COPY_SCALAR_FIELD(semi_can_btree);
2255 COPY_SCALAR_FIELD(semi_can_hash);
2256 COPY_NODE_FIELD(semi_operators);
2257 COPY_NODE_FIELD(semi_rhs_exprs);
2263 * _copyAppendRelInfo
2265 static AppendRelInfo *
2266 _copyAppendRelInfo(const AppendRelInfo *from)
2268 AppendRelInfo *newnode = makeNode(AppendRelInfo);
2270 COPY_SCALAR_FIELD(parent_relid);
2271 COPY_SCALAR_FIELD(child_relid);
2272 COPY_SCALAR_FIELD(parent_reltype);
2273 COPY_SCALAR_FIELD(child_reltype);
2274 COPY_NODE_FIELD(translated_vars);
2275 COPY_SCALAR_FIELD(parent_reloid);
2281 * _copyPartitionedChildRelInfo
2283 static PartitionedChildRelInfo *
2284 _copyPartitionedChildRelInfo(const PartitionedChildRelInfo *from)
2286 PartitionedChildRelInfo *newnode = makeNode(PartitionedChildRelInfo);
2288 COPY_SCALAR_FIELD(parent_relid);
2289 COPY_NODE_FIELD(child_rels);
2290 COPY_SCALAR_FIELD(part_cols_updated);
2296 * _copyPlaceHolderInfo
2298 static PlaceHolderInfo *
2299 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
2301 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
2303 COPY_SCALAR_FIELD(phid);
2304 COPY_NODE_FIELD(ph_var);
2305 COPY_BITMAPSET_FIELD(ph_eval_at);
2306 COPY_BITMAPSET_FIELD(ph_lateral);
2307 COPY_BITMAPSET_FIELD(ph_needed);
2308 COPY_SCALAR_FIELD(ph_width);
2313 /* ****************************************************************
2314 * parsenodes.h copy functions
2315 * ****************************************************************
2318 static RangeTblEntry *
2319 _copyRangeTblEntry(const RangeTblEntry *from)
2321 RangeTblEntry *newnode = makeNode(RangeTblEntry);
2323 COPY_SCALAR_FIELD(rtekind);
2324 COPY_SCALAR_FIELD(relid);
2325 COPY_SCALAR_FIELD(relkind);
2326 COPY_NODE_FIELD(tablesample);
2327 COPY_NODE_FIELD(subquery);
2328 COPY_SCALAR_FIELD(security_barrier);
2329 COPY_SCALAR_FIELD(jointype);
2330 COPY_NODE_FIELD(joinaliasvars);
2331 COPY_NODE_FIELD(functions);
2332 COPY_SCALAR_FIELD(funcordinality);
2333 COPY_NODE_FIELD(tablefunc);
2334 COPY_NODE_FIELD(values_lists);
2335 COPY_STRING_FIELD(ctename);
2336 COPY_SCALAR_FIELD(ctelevelsup);
2337 COPY_SCALAR_FIELD(self_reference);
2338 COPY_NODE_FIELD(coltypes);
2339 COPY_NODE_FIELD(coltypmods);
2340 COPY_NODE_FIELD(colcollations);
2341 COPY_STRING_FIELD(enrname);
2342 COPY_SCALAR_FIELD(enrtuples);
2343 COPY_NODE_FIELD(alias);
2344 COPY_NODE_FIELD(eref);
2345 COPY_SCALAR_FIELD(lateral);
2346 COPY_SCALAR_FIELD(inh);
2347 COPY_SCALAR_FIELD(inFromCl);
2348 COPY_SCALAR_FIELD(requiredPerms);
2349 COPY_SCALAR_FIELD(checkAsUser);
2350 COPY_BITMAPSET_FIELD(selectedCols);
2351 COPY_BITMAPSET_FIELD(insertedCols);
2352 COPY_BITMAPSET_FIELD(updatedCols);
2353 COPY_NODE_FIELD(securityQuals);
2358 static RangeTblFunction *
2359 _copyRangeTblFunction(const RangeTblFunction *from)
2361 RangeTblFunction *newnode = makeNode(RangeTblFunction);
2363 COPY_NODE_FIELD(funcexpr);
2364 COPY_SCALAR_FIELD(funccolcount);
2365 COPY_NODE_FIELD(funccolnames);
2366 COPY_NODE_FIELD(funccoltypes);
2367 COPY_NODE_FIELD(funccoltypmods);
2368 COPY_NODE_FIELD(funccolcollations);
2369 COPY_BITMAPSET_FIELD(funcparams);
2374 static TableSampleClause *
2375 _copyTableSampleClause(const TableSampleClause *from)
2377 TableSampleClause *newnode = makeNode(TableSampleClause);
2379 COPY_SCALAR_FIELD(tsmhandler);
2380 COPY_NODE_FIELD(args);
2381 COPY_NODE_FIELD(repeatable);
2386 static WithCheckOption *
2387 _copyWithCheckOption(const WithCheckOption *from)
2389 WithCheckOption *newnode = makeNode(WithCheckOption);
2391 COPY_SCALAR_FIELD(kind);
2392 COPY_STRING_FIELD(relname);
2393 COPY_STRING_FIELD(polname);
2394 COPY_NODE_FIELD(qual);
2395 COPY_SCALAR_FIELD(cascaded);
2400 static SortGroupClause *
2401 _copySortGroupClause(const SortGroupClause *from)
2403 SortGroupClause *newnode = makeNode(SortGroupClause);
2405 COPY_SCALAR_FIELD(tleSortGroupRef);
2406 COPY_SCALAR_FIELD(eqop);
2407 COPY_SCALAR_FIELD(sortop);
2408 COPY_SCALAR_FIELD(nulls_first);
2409 COPY_SCALAR_FIELD(hashable);
2414 static GroupingSet *
2415 _copyGroupingSet(const GroupingSet *from)
2417 GroupingSet *newnode = makeNode(GroupingSet);
2419 COPY_SCALAR_FIELD(kind);
2420 COPY_NODE_FIELD(content);
2421 COPY_LOCATION_FIELD(location);
2426 static WindowClause *
2427 _copyWindowClause(const WindowClause *from)
2429 WindowClause *newnode = makeNode(WindowClause);
2431 COPY_STRING_FIELD(name);
2432 COPY_STRING_FIELD(refname);
2433 COPY_NODE_FIELD(partitionClause);
2434 COPY_NODE_FIELD(orderClause);
2435 COPY_SCALAR_FIELD(frameOptions);
2436 COPY_NODE_FIELD(startOffset);
2437 COPY_NODE_FIELD(endOffset);
2438 COPY_SCALAR_FIELD(startInRangeFunc);
2439 COPY_SCALAR_FIELD(endInRangeFunc);
2440 COPY_SCALAR_FIELD(inRangeColl);
2441 COPY_SCALAR_FIELD(inRangeAsc);
2442 COPY_SCALAR_FIELD(inRangeNullsFirst);
2443 COPY_SCALAR_FIELD(winref);
2444 COPY_SCALAR_FIELD(copiedOrder);
2449 static RowMarkClause *
2450 _copyRowMarkClause(const RowMarkClause *from)
2452 RowMarkClause *newnode = makeNode(RowMarkClause);
2454 COPY_SCALAR_FIELD(rti);
2455 COPY_SCALAR_FIELD(strength);
2456 COPY_SCALAR_FIELD(waitPolicy);
2457 COPY_SCALAR_FIELD(pushedDown);
2463 _copyWithClause(const WithClause *from)
2465 WithClause *newnode = makeNode(WithClause);
2467 COPY_NODE_FIELD(ctes);
2468 COPY_SCALAR_FIELD(recursive);
2469 COPY_LOCATION_FIELD(location);
2474 static InferClause *
2475 _copyInferClause(const InferClause *from)
2477 InferClause *newnode = makeNode(InferClause);
2479 COPY_NODE_FIELD(indexElems);
2480 COPY_NODE_FIELD(whereClause);
2481 COPY_STRING_FIELD(conname);
2482 COPY_LOCATION_FIELD(location);
2487 static OnConflictClause *
2488 _copyOnConflictClause(const OnConflictClause *from)
2490 OnConflictClause *newnode = makeNode(OnConflictClause);
2492 COPY_SCALAR_FIELD(action);
2493 COPY_NODE_FIELD(infer);
2494 COPY_NODE_FIELD(targetList);
2495 COPY_NODE_FIELD(whereClause);
2496 COPY_LOCATION_FIELD(location);
2501 static CommonTableExpr *
2502 _copyCommonTableExpr(const CommonTableExpr *from)
2504 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2506 COPY_STRING_FIELD(ctename);
2507 COPY_NODE_FIELD(aliascolnames);
2508 COPY_NODE_FIELD(ctequery);
2509 COPY_LOCATION_FIELD(location);
2510 COPY_SCALAR_FIELD(cterecursive);
2511 COPY_SCALAR_FIELD(cterefcount);
2512 COPY_NODE_FIELD(ctecolnames);
2513 COPY_NODE_FIELD(ctecoltypes);
2514 COPY_NODE_FIELD(ctecoltypmods);
2515 COPY_NODE_FIELD(ctecolcollations);
2521 _copyAExpr(const A_Expr *from)
2523 A_Expr *newnode = makeNode(A_Expr);
2525 COPY_SCALAR_FIELD(kind);
2526 COPY_NODE_FIELD(name);
2527 COPY_NODE_FIELD(lexpr);
2528 COPY_NODE_FIELD(rexpr);
2529 COPY_LOCATION_FIELD(location);
2535 _copyColumnRef(const ColumnRef *from)
2537 ColumnRef *newnode = makeNode(ColumnRef);
2539 COPY_NODE_FIELD(fields);
2540 COPY_LOCATION_FIELD(location);
2546 _copyParamRef(const ParamRef *from)
2548 ParamRef *newnode = makeNode(ParamRef);
2550 COPY_SCALAR_FIELD(number);
2551 COPY_LOCATION_FIELD(location);
2557 _copyAConst(const A_Const *from)
2559 A_Const *newnode = makeNode(A_Const);
2561 /* This part must duplicate _copyValue */
2562 COPY_SCALAR_FIELD(val.type);
2563 switch (from->val.type)
2566 COPY_SCALAR_FIELD(val.val.ival);
2571 COPY_STRING_FIELD(val.val.str);
2577 elog(ERROR, "unrecognized node type: %d",
2578 (int) from->val.type);
2582 COPY_LOCATION_FIELD(location);
2588 _copyFuncCall(const FuncCall *from)
2590 FuncCall *newnode = makeNode(FuncCall);
2592 COPY_NODE_FIELD(funcname);
2593 COPY_NODE_FIELD(args);
2594 COPY_NODE_FIELD(agg_order);
2595 COPY_NODE_FIELD(agg_filter);
2596 COPY_SCALAR_FIELD(agg_within_group);
2597 COPY_SCALAR_FIELD(agg_star);
2598 COPY_SCALAR_FIELD(agg_distinct);
2599 COPY_SCALAR_FIELD(func_variadic);
2600 COPY_NODE_FIELD(over);
2601 COPY_LOCATION_FIELD(location);
2607 _copyAStar(const A_Star *from)
2609 A_Star *newnode = makeNode(A_Star);
2615 _copyAIndices(const A_Indices *from)
2617 A_Indices *newnode = makeNode(A_Indices);
2619 COPY_SCALAR_FIELD(is_slice);
2620 COPY_NODE_FIELD(lidx);
2621 COPY_NODE_FIELD(uidx);
2626 static A_Indirection *
2627 _copyA_Indirection(const A_Indirection *from)
2629 A_Indirection *newnode = makeNode(A_Indirection);
2631 COPY_NODE_FIELD(arg);
2632 COPY_NODE_FIELD(indirection);
2637 static A_ArrayExpr *
2638 _copyA_ArrayExpr(const A_ArrayExpr *from)
2640 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2642 COPY_NODE_FIELD(elements);
2643 COPY_LOCATION_FIELD(location);
2649 _copyResTarget(const ResTarget *from)
2651 ResTarget *newnode = makeNode(ResTarget);
2653 COPY_STRING_FIELD(name);
2654 COPY_NODE_FIELD(indirection);
2655 COPY_NODE_FIELD(val);
2656 COPY_LOCATION_FIELD(location);
2661 static MultiAssignRef *
2662 _copyMultiAssignRef(const MultiAssignRef *from)
2664 MultiAssignRef *newnode = makeNode(MultiAssignRef);
2666 COPY_NODE_FIELD(source);
2667 COPY_SCALAR_FIELD(colno);
2668 COPY_SCALAR_FIELD(ncolumns);
2674 _copyTypeName(const TypeName *from)
2676 TypeName *newnode = makeNode(TypeName);
2678 COPY_NODE_FIELD(names);
2679 COPY_SCALAR_FIELD(typeOid);
2680 COPY_SCALAR_FIELD(setof);
2681 COPY_SCALAR_FIELD(pct_type);
2682 COPY_NODE_FIELD(typmods);
2683 COPY_SCALAR_FIELD(typemod);
2684 COPY_NODE_FIELD(arrayBounds);
2685 COPY_LOCATION_FIELD(location);
2691 _copySortBy(const SortBy *from)
2693 SortBy *newnode = makeNode(SortBy);
2695 COPY_NODE_FIELD(node);
2696 COPY_SCALAR_FIELD(sortby_dir);
2697 COPY_SCALAR_FIELD(sortby_nulls);
2698 COPY_NODE_FIELD(useOp);
2699 COPY_LOCATION_FIELD(location);
2705 _copyWindowDef(const WindowDef *from)
2707 WindowDef *newnode = makeNode(WindowDef);
2709 COPY_STRING_FIELD(name);
2710 COPY_STRING_FIELD(refname);
2711 COPY_NODE_FIELD(partitionClause);
2712 COPY_NODE_FIELD(orderClause);
2713 COPY_SCALAR_FIELD(frameOptions);
2714 COPY_NODE_FIELD(startOffset);
2715 COPY_NODE_FIELD(endOffset);
2716 COPY_LOCATION_FIELD(location);
2721 static RangeSubselect *
2722 _copyRangeSubselect(const RangeSubselect *from)
2724 RangeSubselect *newnode = makeNode(RangeSubselect);
2726 COPY_SCALAR_FIELD(lateral);
2727 COPY_NODE_FIELD(subquery);
2728 COPY_NODE_FIELD(alias);
2733 static RangeFunction *
2734 _copyRangeFunction(const RangeFunction *from)
2736 RangeFunction *newnode = makeNode(RangeFunction);
2738 COPY_SCALAR_FIELD(lateral);
2739 COPY_SCALAR_FIELD(ordinality);
2740 COPY_SCALAR_FIELD(is_rowsfrom);
2741 COPY_NODE_FIELD(functions);
2742 COPY_NODE_FIELD(alias);
2743 COPY_NODE_FIELD(coldeflist);
2748 static RangeTableSample *
2749 _copyRangeTableSample(const RangeTableSample *from)
2751 RangeTableSample *newnode = makeNode(RangeTableSample);
2753 COPY_NODE_FIELD(relation);
2754 COPY_NODE_FIELD(method);
2755 COPY_NODE_FIELD(args);
2756 COPY_NODE_FIELD(repeatable);
2757 COPY_LOCATION_FIELD(location);
2762 static RangeTableFunc *
2763 _copyRangeTableFunc(const RangeTableFunc *from)
2765 RangeTableFunc *newnode = makeNode(RangeTableFunc);
2767 COPY_SCALAR_FIELD(lateral);
2768 COPY_NODE_FIELD(docexpr);
2769 COPY_NODE_FIELD(rowexpr);
2770 COPY_NODE_FIELD(namespaces);
2771 COPY_NODE_FIELD(columns);
2772 COPY_NODE_FIELD(alias);
2773 COPY_LOCATION_FIELD(location);
2778 static RangeTableFuncCol *
2779 _copyRangeTableFuncCol(const RangeTableFuncCol *from)
2781 RangeTableFuncCol *newnode = makeNode(RangeTableFuncCol);
2783 COPY_STRING_FIELD(colname);
2784 COPY_NODE_FIELD(typeName);
2785 COPY_SCALAR_FIELD(for_ordinality);
2786 COPY_SCALAR_FIELD(is_not_null);
2787 COPY_NODE_FIELD(colexpr);
2788 COPY_NODE_FIELD(coldefexpr);
2789 COPY_LOCATION_FIELD(location);
2795 _copyTypeCast(const TypeCast *from)
2797 TypeCast *newnode = makeNode(TypeCast);
2799 COPY_NODE_FIELD(arg);
2800 COPY_NODE_FIELD(typeName);
2801 COPY_LOCATION_FIELD(location);
2806 static CollateClause *
2807 _copyCollateClause(const CollateClause *from)
2809 CollateClause *newnode = makeNode(CollateClause);
2811 COPY_NODE_FIELD(arg);
2812 COPY_NODE_FIELD(collname);
2813 COPY_LOCATION_FIELD(location);
2819 _copyIndexElem(const IndexElem *from)
2821 IndexElem *newnode = makeNode(IndexElem);
2823 COPY_STRING_FIELD(name);
2824 COPY_NODE_FIELD(expr);
2825 COPY_STRING_FIELD(indexcolname);
2826 COPY_NODE_FIELD(collation);
2827 COPY_NODE_FIELD(opclass);
2828 COPY_SCALAR_FIELD(ordering);
2829 COPY_SCALAR_FIELD(nulls_ordering);
2835 _copyColumnDef(const ColumnDef *from)
2837 ColumnDef *newnode = makeNode(ColumnDef);
2839 COPY_STRING_FIELD(colname);
2840 COPY_NODE_FIELD(typeName);
2841 COPY_SCALAR_FIELD(inhcount);
2842 COPY_SCALAR_FIELD(is_local);
2843 COPY_SCALAR_FIELD(is_not_null);
2844 COPY_SCALAR_FIELD(is_from_type);
2845 COPY_SCALAR_FIELD(is_from_parent);
2846 COPY_SCALAR_FIELD(storage);
2847 COPY_NODE_FIELD(raw_default);
2848 COPY_NODE_FIELD(cooked_default);
2849 COPY_SCALAR_FIELD(identity);
2850 COPY_NODE_FIELD(identitySequence);
2851 COPY_NODE_FIELD(collClause);
2852 COPY_SCALAR_FIELD(collOid);
2853 COPY_NODE_FIELD(constraints);
2854 COPY_NODE_FIELD(fdwoptions);
2855 COPY_LOCATION_FIELD(location);
2861 _copyConstraint(const Constraint *from)
2863 Constraint *newnode = makeNode(Constraint);
2865 COPY_SCALAR_FIELD(contype);
2866 COPY_STRING_FIELD(conname);
2867 COPY_SCALAR_FIELD(deferrable);
2868 COPY_SCALAR_FIELD(initdeferred);
2869 COPY_LOCATION_FIELD(location);
2870 COPY_SCALAR_FIELD(is_no_inherit);
2871 COPY_NODE_FIELD(raw_expr);
2872 COPY_STRING_FIELD(cooked_expr);
2873 COPY_SCALAR_FIELD(generated_when);
2874 COPY_NODE_FIELD(keys);
2875 COPY_NODE_FIELD(exclusions);
2876 COPY_NODE_FIELD(options);
2877 COPY_STRING_FIELD(indexname);
2878 COPY_STRING_FIELD(indexspace);
2879 COPY_STRING_FIELD(access_method);
2880 COPY_NODE_FIELD(where_clause);
2881 COPY_NODE_FIELD(pktable);
2882 COPY_NODE_FIELD(fk_attrs);
2883 COPY_NODE_FIELD(pk_attrs);
2884 COPY_SCALAR_FIELD(fk_matchtype);
2885 COPY_SCALAR_FIELD(fk_upd_action);
2886 COPY_SCALAR_FIELD(fk_del_action);
2887 COPY_NODE_FIELD(old_conpfeqop);
2888 COPY_SCALAR_FIELD(old_pktable_oid);
2889 COPY_SCALAR_FIELD(skip_validation);
2890 COPY_SCALAR_FIELD(initially_valid);
2896 _copyDefElem(const DefElem *from)
2898 DefElem *newnode = makeNode(DefElem);
2900 COPY_STRING_FIELD(defnamespace);
2901 COPY_STRING_FIELD(defname);
2902 COPY_NODE_FIELD(arg);
2903 COPY_SCALAR_FIELD(defaction);
2904 COPY_LOCATION_FIELD(location);
2909 static LockingClause *
2910 _copyLockingClause(const LockingClause *from)
2912 LockingClause *newnode = makeNode(LockingClause);
2914 COPY_NODE_FIELD(lockedRels);
2915 COPY_SCALAR_FIELD(strength);
2916 COPY_SCALAR_FIELD(waitPolicy);
2921 static XmlSerialize *
2922 _copyXmlSerialize(const XmlSerialize *from)
2924 XmlSerialize *newnode = makeNode(XmlSerialize);
2926 COPY_SCALAR_FIELD(xmloption);
2927 COPY_NODE_FIELD(expr);
2928 COPY_NODE_FIELD(typeName);
2929 COPY_LOCATION_FIELD(location);
2935 _copyRoleSpec(const RoleSpec *from)
2937 RoleSpec *newnode = makeNode(RoleSpec);
2939 COPY_SCALAR_FIELD(roletype);
2940 COPY_STRING_FIELD(rolename);
2941 COPY_LOCATION_FIELD(location);
2946 static TriggerTransition *
2947 _copyTriggerTransition(const TriggerTransition *from)
2949 TriggerTransition *newnode = makeNode(TriggerTransition);
2951 COPY_STRING_FIELD(name);
2952 COPY_SCALAR_FIELD(isNew);
2953 COPY_SCALAR_FIELD(isTable);
2959 _copyQuery(const Query *from)
2961 Query *newnode = makeNode(Query);
2963 COPY_SCALAR_FIELD(commandType);
2964 COPY_SCALAR_FIELD(querySource);
2965 COPY_SCALAR_FIELD(queryId);
2966 COPY_SCALAR_FIELD(canSetTag);
2967 COPY_NODE_FIELD(utilityStmt);
2968 COPY_SCALAR_FIELD(resultRelation);
2969 COPY_SCALAR_FIELD(hasAggs);
2970 COPY_SCALAR_FIELD(hasWindowFuncs);
2971 COPY_SCALAR_FIELD(hasTargetSRFs);
2972 COPY_SCALAR_FIELD(hasSubLinks);
2973 COPY_SCALAR_FIELD(hasDistinctOn);
2974 COPY_SCALAR_FIELD(hasRecursive);
2975 COPY_SCALAR_FIELD(hasModifyingCTE);
2976 COPY_SCALAR_FIELD(hasForUpdate);
2977 COPY_SCALAR_FIELD(hasRowSecurity);
2978 COPY_NODE_FIELD(cteList);
2979 COPY_NODE_FIELD(rtable);
2980 COPY_NODE_FIELD(jointree);
2981 COPY_NODE_FIELD(targetList);
2982 COPY_SCALAR_FIELD(override);
2983 COPY_NODE_FIELD(onConflict);
2984 COPY_NODE_FIELD(returningList);
2985 COPY_NODE_FIELD(groupClause);
2986 COPY_NODE_FIELD(groupingSets);
2987 COPY_NODE_FIELD(havingQual);
2988 COPY_NODE_FIELD(windowClause);
2989 COPY_NODE_FIELD(distinctClause);
2990 COPY_NODE_FIELD(sortClause);
2991 COPY_NODE_FIELD(limitOffset);
2992 COPY_NODE_FIELD(limitCount);
2993 COPY_NODE_FIELD(rowMarks);
2994 COPY_NODE_FIELD(setOperations);
2995 COPY_NODE_FIELD(constraintDeps);
2996 COPY_NODE_FIELD(withCheckOptions);
2997 COPY_SCALAR_FIELD(mergeTarget_relation);
2998 COPY_NODE_FIELD(mergeSourceTargetList);
2999 COPY_NODE_FIELD(mergeActionList);
3000 COPY_LOCATION_FIELD(stmt_location);
3001 COPY_LOCATION_FIELD(stmt_len);
3007 _copyRawStmt(const RawStmt *from)
3009 RawStmt *newnode = makeNode(RawStmt);
3011 COPY_NODE_FIELD(stmt);
3012 COPY_LOCATION_FIELD(stmt_location);
3013 COPY_LOCATION_FIELD(stmt_len);
3019 _copyInsertStmt(const InsertStmt *from)
3021 InsertStmt *newnode = makeNode(InsertStmt);
3023 COPY_NODE_FIELD(relation);
3024 COPY_NODE_FIELD(cols);
3025 COPY_NODE_FIELD(selectStmt);
3026 COPY_NODE_FIELD(onConflictClause);
3027 COPY_NODE_FIELD(returningList);
3028 COPY_NODE_FIELD(withClause);
3029 COPY_SCALAR_FIELD(override);
3035 _copyDeleteStmt(const DeleteStmt *from)
3037 DeleteStmt *newnode = makeNode(DeleteStmt);
3039 COPY_NODE_FIELD(relation);
3040 COPY_NODE_FIELD(usingClause);
3041 COPY_NODE_FIELD(whereClause);
3042 COPY_NODE_FIELD(returningList);
3043 COPY_NODE_FIELD(withClause);
3049 _copyUpdateStmt(const UpdateStmt *from)
3051 UpdateStmt *newnode = makeNode(UpdateStmt);
3053 COPY_NODE_FIELD(relation);
3054 COPY_NODE_FIELD(targetList);
3055 COPY_NODE_FIELD(whereClause);
3056 COPY_NODE_FIELD(fromClause);
3057 COPY_NODE_FIELD(returningList);
3058 COPY_NODE_FIELD(withClause);
3064 _copyMergeStmt(const MergeStmt *from)
3066 MergeStmt *newnode = makeNode(MergeStmt);
3068 COPY_NODE_FIELD(relation);
3069 COPY_NODE_FIELD(source_relation);
3070 COPY_NODE_FIELD(join_condition);
3071 COPY_NODE_FIELD(mergeWhenClauses);
3072 COPY_NODE_FIELD(withClause);
3077 static MergeWhenClause *
3078 _copyMergeWhenClause(const MergeWhenClause *from)
3080 MergeWhenClause *newnode = makeNode(MergeWhenClause);
3082 COPY_SCALAR_FIELD(matched);
3083 COPY_SCALAR_FIELD(commandType);
3084 COPY_NODE_FIELD(condition);
3085 COPY_NODE_FIELD(targetList);
3086 COPY_NODE_FIELD(cols);
3087 COPY_NODE_FIELD(values);
3088 COPY_SCALAR_FIELD(override);
3093 _copySelectStmt(const SelectStmt *from)
3095 SelectStmt *newnode = makeNode(SelectStmt);
3097 COPY_NODE_FIELD(distinctClause);
3098 COPY_NODE_FIELD(intoClause);
3099 COPY_NODE_FIELD(targetList);
3100 COPY_NODE_FIELD(fromClause);
3101 COPY_NODE_FIELD(whereClause);
3102 COPY_NODE_FIELD(groupClause);
3103 COPY_NODE_FIELD(havingClause);
3104 COPY_NODE_FIELD(windowClause);
3105 COPY_NODE_FIELD(valuesLists);
3106 COPY_NODE_FIELD(sortClause);
3107 COPY_NODE_FIELD(limitOffset);
3108 COPY_NODE_FIELD(limitCount);
3109 COPY_NODE_FIELD(lockingClause);
3110 COPY_NODE_FIELD(withClause);
3111 COPY_SCALAR_FIELD(op);
3112 COPY_SCALAR_FIELD(all);
3113 COPY_NODE_FIELD(larg);
3114 COPY_NODE_FIELD(rarg);
3119 static SetOperationStmt *
3120 _copySetOperationStmt(const SetOperationStmt *from)
3122 SetOperationStmt *newnode = makeNode(SetOperationStmt);
3124 COPY_SCALAR_FIELD(op);
3125 COPY_SCALAR_FIELD(all);
3126 COPY_NODE_FIELD(larg);
3127 COPY_NODE_FIELD(rarg);
3128 COPY_NODE_FIELD(colTypes);
3129 COPY_NODE_FIELD(colTypmods);
3130 COPY_NODE_FIELD(colCollations);
3131 COPY_NODE_FIELD(groupClauses);
3136 static AlterTableStmt *
3137 _copyAlterTableStmt(const AlterTableStmt *from)
3139 AlterTableStmt *newnode = makeNode(AlterTableStmt);
3141 COPY_NODE_FIELD(relation);
3142 COPY_NODE_FIELD(cmds);
3143 COPY_SCALAR_FIELD(relkind);
3144 COPY_SCALAR_FIELD(missing_ok);
3149 static AlterTableCmd *
3150 _copyAlterTableCmd(const AlterTableCmd *from)
3152 AlterTableCmd *newnode = makeNode(AlterTableCmd);
3154 COPY_SCALAR_FIELD(subtype);
3155 COPY_STRING_FIELD(name);
3156 COPY_SCALAR_FIELD(num);
3157 COPY_NODE_FIELD(newowner);
3158 COPY_NODE_FIELD(def);
3159 COPY_SCALAR_FIELD(behavior);
3160 COPY_SCALAR_FIELD(missing_ok);
3165 static AlterCollationStmt *
3166 _copyAlterCollationStmt(const AlterCollationStmt *from)
3168 AlterCollationStmt *newnode = makeNode(AlterCollationStmt);
3170 COPY_NODE_FIELD(collname);
3175 static AlterDomainStmt *
3176 _copyAlterDomainStmt(const AlterDomainStmt *from)
3178 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
3180 COPY_SCALAR_FIELD(subtype);
3181 COPY_NODE_FIELD(typeName);
3182 COPY_STRING_FIELD(name);
3183 COPY_NODE_FIELD(def);
3184 COPY_SCALAR_FIELD(behavior);
3185 COPY_SCALAR_FIELD(missing_ok);
3191 _copyGrantStmt(const GrantStmt *from)
3193 GrantStmt *newnode = makeNode(GrantStmt);
3195 COPY_SCALAR_FIELD(is_grant);
3196 COPY_SCALAR_FIELD(targtype);
3197 COPY_SCALAR_FIELD(objtype);
3198 COPY_NODE_FIELD(objects);
3199 COPY_NODE_FIELD(privileges);
3200 COPY_NODE_FIELD(grantees);
3201 COPY_SCALAR_FIELD(grant_option);
3202 COPY_SCALAR_FIELD(behavior);
3207 static ObjectWithArgs *
3208 _copyObjectWithArgs(const ObjectWithArgs *from)
3210 ObjectWithArgs *newnode = makeNode(ObjectWithArgs);
3212 COPY_NODE_FIELD(objname);
3213 COPY_NODE_FIELD(objargs);
3214 COPY_SCALAR_FIELD(args_unspecified);
3220 _copyAccessPriv(const AccessPriv *from)
3222 AccessPriv *newnode = makeNode(AccessPriv);
3224 COPY_STRING_FIELD(priv_name);
3225 COPY_NODE_FIELD(cols);
3230 static GrantRoleStmt *
3231 _copyGrantRoleStmt(const GrantRoleStmt *from)
3233 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
3235 COPY_NODE_FIELD(granted_roles);
3236 COPY_NODE_FIELD(grantee_roles);
3237 COPY_SCALAR_FIELD(is_grant);
3238 COPY_SCALAR_FIELD(admin_opt);
3239 COPY_NODE_FIELD(grantor);
3240 COPY_SCALAR_FIELD(behavior);
3245 static AlterDefaultPrivilegesStmt *
3246 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
3248 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
3250 COPY_NODE_FIELD(options);
3251 COPY_NODE_FIELD(action);
3256 static DeclareCursorStmt *
3257 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
3259 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
3261 COPY_STRING_FIELD(portalname);
3262 COPY_SCALAR_FIELD(options);
3263 COPY_NODE_FIELD(query);
3268 static ClosePortalStmt *
3269 _copyClosePortalStmt(const ClosePortalStmt *from)
3271 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
3273 COPY_STRING_FIELD(portalname);
3279 _copyCallStmt(const CallStmt *from)
3281 CallStmt *newnode = makeNode(CallStmt);
3283 COPY_NODE_FIELD(funccall);
3284 COPY_NODE_FIELD(funcexpr);
3289 static ClusterStmt *
3290 _copyClusterStmt(const ClusterStmt *from)
3292 ClusterStmt *newnode = makeNode(ClusterStmt);
3294 COPY_NODE_FIELD(relation);
3295 COPY_STRING_FIELD(indexname);
3296 COPY_SCALAR_FIELD(verbose);
3302 _copyCopyStmt(const CopyStmt *from)
3304 CopyStmt *newnode = makeNode(CopyStmt);
3306 COPY_NODE_FIELD(relation);
3307 COPY_NODE_FIELD(query);
3308 COPY_NODE_FIELD(attlist);
3309 COPY_SCALAR_FIELD(is_from);
3310 COPY_SCALAR_FIELD(is_program);
3311 COPY_STRING_FIELD(filename);
3312 COPY_NODE_FIELD(options);
3318 * CopyCreateStmtFields
3320 * This function copies the fields of the CreateStmt node. It is used by
3321 * copy functions for classes which inherit from CreateStmt.
3324 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
3326 COPY_NODE_FIELD(relation);
3327 COPY_NODE_FIELD(tableElts);
3328 COPY_NODE_FIELD(inhRelations);
3329 COPY_NODE_FIELD(partspec);
3330 COPY_NODE_FIELD(partbound);
3331 COPY_NODE_FIELD(ofTypename);
3332 COPY_NODE_FIELD(constraints);
3333 COPY_NODE_FIELD(options);
3334 COPY_SCALAR_FIELD(oncommit);
3335 COPY_STRING_FIELD(tablespacename);
3336 COPY_SCALAR_FIELD(if_not_exists);
3340 _copyCreateStmt(const CreateStmt *from)
3342 CreateStmt *newnode = makeNode(CreateStmt);
3344 CopyCreateStmtFields(from, newnode);
3349 static TableLikeClause *
3350 _copyTableLikeClause(const TableLikeClause *from)
3352 TableLikeClause *newnode = makeNode(TableLikeClause);
3354 COPY_NODE_FIELD(relation);
3355 COPY_SCALAR_FIELD(options);
3361 _copyDefineStmt(const DefineStmt *from)
3363 DefineStmt *newnode = makeNode(DefineStmt);
3365 COPY_SCALAR_FIELD(kind);
3366 COPY_SCALAR_FIELD(oldstyle);
3367 COPY_NODE_FIELD(defnames);
3368 COPY_NODE_FIELD(args);
3369 COPY_NODE_FIELD(definition);
3370 COPY_SCALAR_FIELD(if_not_exists);
3376 _copyDropStmt(const DropStmt *from)
3378 DropStmt *newnode = makeNode(DropStmt);
3380 COPY_NODE_FIELD(objects);
3381 COPY_SCALAR_FIELD(removeType);
3382 COPY_SCALAR_FIELD(behavior);
3383 COPY_SCALAR_FIELD(missing_ok);
3384 COPY_SCALAR_FIELD(concurrent);
3389 static TruncateStmt *
3390 _copyTruncateStmt(const TruncateStmt *from)
3392 TruncateStmt *newnode = makeNode(TruncateStmt);
3394 COPY_NODE_FIELD(relations);
3395 COPY_SCALAR_FIELD(restart_seqs);
3396 COPY_SCALAR_FIELD(behavior);
3401 static CommentStmt *
3402 _copyCommentStmt(const CommentStmt *from)
3404 CommentStmt *newnode = makeNode(CommentStmt);
3406 COPY_SCALAR_FIELD(objtype);
3407 COPY_NODE_FIELD(object);
3408 COPY_STRING_FIELD(comment);
3413 static SecLabelStmt *
3414 _copySecLabelStmt(const SecLabelStmt *from)
3416 SecLabelStmt *newnode = makeNode(SecLabelStmt);
3418 COPY_SCALAR_FIELD(objtype);
3419 COPY_NODE_FIELD(object);
3420 COPY_STRING_FIELD(provider);
3421 COPY_STRING_FIELD(label);
3427 _copyFetchStmt(const FetchStmt *from)
3429 FetchStmt *newnode = makeNode(FetchStmt);
3431 COPY_SCALAR_FIELD(direction);
3432 COPY_SCALAR_FIELD(howMany);
3433 COPY_STRING_FIELD(portalname);
3434 COPY_SCALAR_FIELD(ismove);
3440 _copyIndexStmt(const IndexStmt *from)
3442 IndexStmt *newnode = makeNode(IndexStmt);
3444 COPY_STRING_FIELD(idxname);
3445 COPY_NODE_FIELD(relation);
3446 COPY_SCALAR_FIELD(relationId);
3447 COPY_STRING_FIELD(accessMethod);
3448 COPY_STRING_FIELD(tableSpace);
3449 COPY_NODE_FIELD(indexParams);
3450 COPY_NODE_FIELD(options);
3451 COPY_NODE_FIELD(whereClause);
3452 COPY_NODE_FIELD(excludeOpNames);
3453 COPY_STRING_FIELD(idxcomment);
3454 COPY_SCALAR_FIELD(indexOid);
3455 COPY_SCALAR_FIELD(oldNode);
3456 COPY_SCALAR_FIELD(unique);
3457 COPY_SCALAR_FIELD(primary);
3458 COPY_SCALAR_FIELD(isconstraint);
3459 COPY_SCALAR_FIELD(deferrable);
3460 COPY_SCALAR_FIELD(initdeferred);
3461 COPY_SCALAR_FIELD(transformed);
3462 COPY_SCALAR_FIELD(concurrent);
3463 COPY_SCALAR_FIELD(if_not_exists);
3468 static CreateStatsStmt *
3469 _copyCreateStatsStmt(const CreateStatsStmt *from)
3471 CreateStatsStmt *newnode = makeNode(CreateStatsStmt);
3473 COPY_NODE_FIELD(defnames);
3474 COPY_NODE_FIELD(stat_types);
3475 COPY_NODE_FIELD(exprs);
3476 COPY_NODE_FIELD(relations);
3477 COPY_STRING_FIELD(stxcomment);
3478 COPY_SCALAR_FIELD(if_not_exists);
3483 static CreateFunctionStmt *
3484 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
3486 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
3488 COPY_SCALAR_FIELD(is_procedure);
3489 COPY_SCALAR_FIELD(replace);
3490 COPY_NODE_FIELD(funcname);
3491 COPY_NODE_FIELD(parameters);
3492 COPY_NODE_FIELD(returnType);
3493 COPY_NODE_FIELD(options);
3498 static FunctionParameter *
3499 _copyFunctionParameter(const FunctionParameter *from)
3501 FunctionParameter *newnode = makeNode(FunctionParameter);
3503 COPY_STRING_FIELD(name);
3504 COPY_NODE_FIELD(argType);
3505 COPY_SCALAR_FIELD(mode);
3506 COPY_NODE_FIELD(defexpr);
3511 static AlterFunctionStmt *
3512 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
3514 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
3516 COPY_SCALAR_FIELD(objtype);
3517 COPY_NODE_FIELD(func);
3518 COPY_NODE_FIELD(actions);
3524 _copyDoStmt(const DoStmt *from)
3526 DoStmt *newnode = makeNode(DoStmt);
3528 COPY_NODE_FIELD(args);
3534 _copyRenameStmt(const RenameStmt *from)
3536 RenameStmt *newnode = makeNode(RenameStmt);
3538 COPY_SCALAR_FIELD(renameType);
3539 COPY_SCALAR_FIELD(relationType);
3540 COPY_NODE_FIELD(relation);
3541 COPY_NODE_FIELD(object);
3542 COPY_STRING_FIELD(subname);
3543 COPY_STRING_FIELD(newname);
3544 COPY_SCALAR_FIELD(behavior);
3545 COPY_SCALAR_FIELD(missing_ok);
3550 static AlterObjectDependsStmt *
3551 _copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from)
3553 AlterObjectDependsStmt *newnode = makeNode(AlterObjectDependsStmt);
3555 COPY_SCALAR_FIELD(objectType);
3556 COPY_NODE_FIELD(relation);
3557 COPY_NODE_FIELD(object);
3558 COPY_NODE_FIELD(extname);
3563 static AlterObjectSchemaStmt *
3564 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
3566 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
3568 COPY_SCALAR_FIELD(objectType);
3569 COPY_NODE_FIELD(relation);
3570 COPY_NODE_FIELD(object);
3571 COPY_STRING_FIELD(newschema);
3572 COPY_SCALAR_FIELD(missing_ok);
3577 static AlterOwnerStmt *
3578 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
3580 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
3582 COPY_SCALAR_FIELD(objectType);
3583 COPY_NODE_FIELD(relation);
3584 COPY_NODE_FIELD(object);
3585 COPY_NODE_FIELD(newowner);
3590 static AlterOperatorStmt *
3591 _copyAlterOperatorStmt(const AlterOperatorStmt *from)
3593 AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt);
3595 COPY_NODE_FIELD(opername);
3596 COPY_NODE_FIELD(options);
3602 _copyRuleStmt(const RuleStmt *from)
3604 RuleStmt *newnode = makeNode(RuleStmt);
3606 COPY_NODE_FIELD(relation);
3607 COPY_STRING_FIELD(rulename);
3608 COPY_NODE_FIELD(whereClause);
3609 COPY_SCALAR_FIELD(event);
3610 COPY_SCALAR_FIELD(instead);
3611 COPY_NODE_FIELD(actions);
3612 COPY_SCALAR_FIELD(replace);
3618 _copyNotifyStmt(const NotifyStmt *from)
3620 NotifyStmt *newnode = makeNode(NotifyStmt);
3622 COPY_STRING_FIELD(conditionname);
3623 COPY_STRING_FIELD(payload);
3629 _copyListenStmt(const ListenStmt *from)
3631 ListenStmt *newnode = makeNode(ListenStmt);
3633 COPY_STRING_FIELD(conditionname);
3638 static UnlistenStmt *
3639 _copyUnlistenStmt(const UnlistenStmt *from)
3641 UnlistenStmt *newnode = makeNode(UnlistenStmt);
3643 COPY_STRING_FIELD(conditionname);
3648 static TransactionStmt *
3649 _copyTransactionStmt(const TransactionStmt *from)
3651 TransactionStmt *newnode = makeNode(TransactionStmt);
3653 COPY_SCALAR_FIELD(kind);
3654 COPY_NODE_FIELD(options);
3655 COPY_STRING_FIELD(savepoint_name);
3656 COPY_STRING_FIELD(gid);
3661 static CompositeTypeStmt *
3662 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3664 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3666 COPY_NODE_FIELD(typevar);
3667 COPY_NODE_FIELD(coldeflist);
3672 static CreateEnumStmt *
3673 _copyCreateEnumStmt(const CreateEnumStmt *from)
3675 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3677 COPY_NODE_FIELD(typeName);
3678 COPY_NODE_FIELD(vals);
3683 static CreateRangeStmt *
3684 _copyCreateRangeStmt(const CreateRangeStmt *from)
3686 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3688 COPY_NODE_FIELD(typeName);
3689 COPY_NODE_FIELD(params);
3694 static AlterEnumStmt *
3695 _copyAlterEnumStmt(const AlterEnumStmt *from)
3697 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3699 COPY_NODE_FIELD(typeName);
3700 COPY_STRING_FIELD(oldVal);
3701 COPY_STRING_FIELD(newVal);
3702 COPY_STRING_FIELD(newValNeighbor);
3703 COPY_SCALAR_FIELD(newValIsAfter);
3704 COPY_SCALAR_FIELD(skipIfNewValExists);
3710 _copyViewStmt(const ViewStmt *from)
3712 ViewStmt *newnode = makeNode(ViewStmt);
3714 COPY_NODE_FIELD(view);
3715 COPY_NODE_FIELD(aliases);
3716 COPY_NODE_FIELD(query);
3717 COPY_SCALAR_FIELD(replace);
3718 COPY_NODE_FIELD(options);
3719 COPY_SCALAR_FIELD(withCheckOption);
3725 _copyLoadStmt(const LoadStmt *from)
3727 LoadStmt *newnode = makeNode(LoadStmt);
3729 COPY_STRING_FIELD(filename);
3734 static CreateDomainStmt *
3735 _copyCreateDomainStmt(const CreateDomainStmt *from)
3737 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3739 COPY_NODE_FIELD(domainname);
3740 COPY_NODE_FIELD(typeName);
3741 COPY_NODE_FIELD(collClause);
3742 COPY_NODE_FIELD(constraints);
3747 static CreateOpClassStmt *
3748 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3750 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3752 COPY_NODE_FIELD(opclassname);
3753 COPY_NODE_FIELD(opfamilyname);
3754 COPY_STRING_FIELD(amname);
3755 COPY_NODE_FIELD(datatype);
3756 COPY_NODE_FIELD(items);
3757 COPY_SCALAR_FIELD(isDefault);
3762 static CreateOpClassItem *
3763 _copyCreateOpClassItem(const CreateOpClassItem *from)
3765 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3767 COPY_SCALAR_FIELD(itemtype);
3768 COPY_NODE_FIELD(name);
3769 COPY_SCALAR_FIELD(number);
3770 COPY_NODE_FIELD(order_family);
3771 COPY_NODE_FIELD(class_args);
3772 COPY_NODE_FIELD(storedtype);
3777 static CreateOpFamilyStmt *
3778 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3780 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3782 COPY_NODE_FIELD(opfamilyname);
3783 COPY_STRING_FIELD(amname);
3788 static AlterOpFamilyStmt *
3789 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3791 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3793 COPY_NODE_FIELD(opfamilyname);
3794 COPY_STRING_FIELD(amname);
3795 COPY_SCALAR_FIELD(isDrop);
3796 COPY_NODE_FIELD(items);
3801 static CreatedbStmt *
3802 _copyCreatedbStmt(const CreatedbStmt *from)
3804 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3806 COPY_STRING_FIELD(dbname);
3807 COPY_NODE_FIELD(options);
3812 static AlterDatabaseStmt *
3813 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3815 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3817 COPY_STRING_FIELD(dbname);
3818 COPY_NODE_FIELD(options);
3823 static AlterDatabaseSetStmt *
3824 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3826 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3828 COPY_STRING_FIELD(dbname);
3829 COPY_NODE_FIELD(setstmt);
3835 _copyDropdbStmt(const DropdbStmt *from)
3837 DropdbStmt *newnode = makeNode(DropdbStmt);
3839 COPY_STRING_FIELD(dbname);
3840 COPY_SCALAR_FIELD(missing_ok);
3846 _copyVacuumStmt(const VacuumStmt *from)
3848 VacuumStmt *newnode = makeNode(VacuumStmt);
3850 COPY_SCALAR_FIELD(options);
3851 COPY_NODE_FIELD(rels);
3856 static VacuumRelation *
3857 _copyVacuumRelation(const VacuumRelation *from)
3859 VacuumRelation *newnode = makeNode(VacuumRelation);
3861 COPY_NODE_FIELD(relation);
3862 COPY_SCALAR_FIELD(oid);
3863 COPY_NODE_FIELD(va_cols);
3868 static ExplainStmt *
3869 _copyExplainStmt(const ExplainStmt *from)
3871 ExplainStmt *newnode = makeNode(ExplainStmt);
3873 COPY_NODE_FIELD(query);
3874 COPY_NODE_FIELD(options);
3879 static CreateTableAsStmt *
3880 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3882 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3884 COPY_NODE_FIELD(query);
3885 COPY_NODE_FIELD(into);
3886 COPY_SCALAR_FIELD(relkind);
3887 COPY_SCALAR_FIELD(is_select_into);
3888 COPY_SCALAR_FIELD(if_not_exists);
3893 static RefreshMatViewStmt *
3894 _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
3896 RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
3898 COPY_SCALAR_FIELD(concurrent);
3899 COPY_SCALAR_FIELD(skipData);
3900 COPY_NODE_FIELD(relation);
3905 static ReplicaIdentityStmt *
3906 _copyReplicaIdentityStmt(const ReplicaIdentityStmt *from)
3908 ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt);
3910 COPY_SCALAR_FIELD(identity_type);
3911 COPY_STRING_FIELD(name);
3916 static AlterSystemStmt *
3917 _copyAlterSystemStmt(const AlterSystemStmt *from)
3919 AlterSystemStmt *newnode = makeNode(AlterSystemStmt);
3921 COPY_NODE_FIELD(setstmt);
3926 static CreateSeqStmt *
3927 _copyCreateSeqStmt(const CreateSeqStmt *from)
3929 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3931 COPY_NODE_FIELD(sequence);
3932 COPY_NODE_FIELD(options);
3933 COPY_SCALAR_FIELD(ownerId);
3934 COPY_SCALAR_FIELD(for_identity);
3935 COPY_SCALAR_FIELD(if_not_exists);
3940 static AlterSeqStmt *
3941 _copyAlterSeqStmt(const AlterSeqStmt *from)
3943 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3945 COPY_NODE_FIELD(sequence);
3946 COPY_NODE_FIELD(options);
3947 COPY_SCALAR_FIELD(for_identity);
3948 COPY_SCALAR_FIELD(missing_ok);
3953 static VariableSetStmt *
3954 _copyVariableSetStmt(const VariableSetStmt *from)
3956 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3958 COPY_SCALAR_FIELD(kind);
3959 COPY_STRING_FIELD(name);
3960 COPY_NODE_FIELD(args);
3961 COPY_SCALAR_FIELD(is_local);
3966 static VariableShowStmt *
3967 _copyVariableShowStmt(const VariableShowStmt *from)
3969 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3971 COPY_STRING_FIELD(name);
3976 static DiscardStmt *
3977 _copyDiscardStmt(const DiscardStmt *from)
3979 DiscardStmt *newnode = makeNode(DiscardStmt);
3981 COPY_SCALAR_FIELD(target);
3986 static CreateTableSpaceStmt *
3987 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3989 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3991 COPY_STRING_FIELD(tablespacename);
3992 COPY_NODE_FIELD(owner);
3993 COPY_STRING_FIELD(location);
3994 COPY_NODE_FIELD(options);
3999 static DropTableSpaceStmt *
4000 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
4002 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
4004 COPY_STRING_FIELD(tablespacename);
4005 COPY_SCALAR_FIELD(missing_ok);
4010 static AlterTableSpaceOptionsStmt *
4011 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
4013 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
4015 COPY_STRING_FIELD(tablespacename);
4016 COPY_NODE_FIELD(options);
4017 COPY_SCALAR_FIELD(isReset);
4022 static AlterTableMoveAllStmt *
4023 _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
4025 AlterTableMoveAllStmt *newnode = makeNode(AlterTableMoveAllStmt);
4027 COPY_STRING_FIELD(orig_tablespacename);
4028 COPY_SCALAR_FIELD(objtype);
4029 COPY_NODE_FIELD(roles);
4030 COPY_STRING_FIELD(new_tablespacename);
4031 COPY_SCALAR_FIELD(nowait);
4036 static CreateExtensionStmt *
4037 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
4039 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
4041 COPY_STRING_FIELD(extname);
4042 COPY_SCALAR_FIELD(if_not_exists);
4043 COPY_NODE_FIELD(options);
4048 static AlterExtensionStmt *
4049 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
4051 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
4053 COPY_STRING_FIELD(extname);
4054 COPY_NODE_FIELD(options);
4059 static AlterExtensionContentsStmt *
4060 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
4062 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
4064 COPY_STRING_FIELD(extname);
4065 COPY_SCALAR_FIELD(action);
4066 COPY_SCALAR_FIELD(objtype);
4067 COPY_NODE_FIELD(object);
4072 static CreateFdwStmt *
4073 _copyCreateFdwStmt(const CreateFdwStmt *from)
4075 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
4077 COPY_STRING_FIELD(fdwname);
4078 COPY_NODE_FIELD(func_options);
4079 COPY_NODE_FIELD(options);
4084 static AlterFdwStmt *
4085 _copyAlterFdwStmt(const AlterFdwStmt *from)
4087 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
4089 COPY_STRING_FIELD(fdwname);
4090 COPY_NODE_FIELD(func_options);
4091 COPY_NODE_FIELD(options);
4096 static CreateForeignServerStmt *
4097 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
4099 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
4101 COPY_STRING_FIELD(servername);
4102 COPY_STRING_FIELD(servertype);
4103 COPY_STRING_FIELD(version);
4104 COPY_STRING_FIELD(fdwname);
4105 COPY_SCALAR_FIELD(if_not_exists);
4106 COPY_NODE_FIELD(options);
4111 static AlterForeignServerStmt *
4112 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
4114 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
4116 COPY_STRING_FIELD(servername);
4117 COPY_STRING_FIELD(version);
4118 COPY_NODE_FIELD(options);
4119 COPY_SCALAR_FIELD(has_version);
4124 static CreateUserMappingStmt *
4125 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
4127 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
4129 COPY_NODE_FIELD(user);
4130 COPY_STRING_FIELD(servername);
4131 COPY_SCALAR_FIELD(if_not_exists);
4132 COPY_NODE_FIELD(options);
4137 static AlterUserMappingStmt *
4138 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
4140 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
4142 COPY_NODE_FIELD(user);
4143 COPY_STRING_FIELD(servername);
4144 COPY_NODE_FIELD(options);
4149 static DropUserMappingStmt *
4150 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
4152 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
4154 COPY_NODE_FIELD(user);
4155 COPY_STRING_FIELD(servername);
4156 COPY_SCALAR_FIELD(missing_ok);
4161 static CreateForeignTableStmt *
4162 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
4164 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
4166 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
4168 COPY_STRING_FIELD(servername);
4169 COPY_NODE_FIELD(options);
4174 static ImportForeignSchemaStmt *
4175 _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
4177 ImportForeignSchemaStmt *newnode = makeNode(ImportForeignSchemaStmt);
4179 COPY_STRING_FIELD(server_name);
4180 COPY_STRING_FIELD(remote_schema);
4181 COPY_STRING_FIELD(local_schema);
4182 COPY_SCALAR_FIELD(list_type);
4183 COPY_NODE_FIELD(table_list);
4184 COPY_NODE_FIELD(options);
4189 static CreateTransformStmt *
4190 _copyCreateTransformStmt(const CreateTransformStmt *from)
4192 CreateTransformStmt *newnode = makeNode(CreateTransformStmt);
4194 COPY_SCALAR_FIELD(replace);
4195 COPY_NODE_FIELD(type_name);
4196 COPY_STRING_FIELD(lang);
4197 COPY_NODE_FIELD(fromsql);
4198 COPY_NODE_FIELD(tosql);
4203 static CreateAmStmt *
4204 _copyCreateAmStmt(const CreateAmStmt *from)
4206 CreateAmStmt *newnode = makeNode(CreateAmStmt);
4208 COPY_STRING_FIELD(amname);
4209 COPY_NODE_FIELD(handler_name);
4210 COPY_SCALAR_FIELD(amtype);
4215 static CreateTrigStmt *
4216 _copyCreateTrigStmt(const CreateTrigStmt *from)
4218 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
4220 COPY_STRING_FIELD(trigname);
4221 COPY_NODE_FIELD(relation);
4222 COPY_NODE_FIELD(funcname);
4223 COPY_NODE_FIELD(args);
4224 COPY_SCALAR_FIELD(row);
4225 COPY_SCALAR_FIELD(timing);
4226 COPY_SCALAR_FIELD(events);
4227 COPY_NODE_FIELD(columns);
4228 COPY_NODE_FIELD(whenClause);
4229 COPY_SCALAR_FIELD(isconstraint);
4230 COPY_NODE_FIELD(transitionRels);
4231 COPY_SCALAR_FIELD(deferrable);
4232 COPY_SCALAR_FIELD(initdeferred);
4233 COPY_NODE_FIELD(constrrel);
4238 static CreateEventTrigStmt *
4239 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
4241 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
4243 COPY_STRING_FIELD(trigname);
4244 COPY_STRING_FIELD(eventname);
4245 COPY_NODE_FIELD(whenclause);
4246 COPY_NODE_FIELD(funcname);
4251 static AlterEventTrigStmt *
4252 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
4254 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
4256 COPY_STRING_FIELD(trigname);
4257 COPY_SCALAR_FIELD(tgenabled);
4262 static CreatePLangStmt *
4263 _copyCreatePLangStmt(const CreatePLangStmt *from)
4265 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
4267 COPY_SCALAR_FIELD(replace);
4268 COPY_STRING_FIELD(plname);
4269 COPY_NODE_FIELD(plhandler);
4270 COPY_NODE_FIELD(plinline);
4271 COPY_NODE_FIELD(plvalidator);
4272 COPY_SCALAR_FIELD(pltrusted);
4277 static CreateRoleStmt *
4278 _copyCreateRoleStmt(const CreateRoleStmt *from)
4280 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
4282 COPY_SCALAR_FIELD(stmt_type);
4283 COPY_STRING_FIELD(role);
4284 COPY_NODE_FIELD(options);
4289 static AlterRoleStmt *
4290 _copyAlterRoleStmt(const AlterRoleStmt *from)
4292 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
4294 COPY_NODE_FIELD(role);
4295 COPY_NODE_FIELD(options);
4296 COPY_SCALAR_FIELD(action);
4301 static AlterRoleSetStmt *
4302 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
4304 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
4306 COPY_NODE_FIELD(role);
4307 COPY_STRING_FIELD(database);
4308 COPY_NODE_FIELD(setstmt);
4313 static DropRoleStmt *
4314 _copyDropRoleStmt(const DropRoleStmt *from)
4316 DropRoleStmt *newnode = makeNode(DropRoleStmt);
4318 COPY_NODE_FIELD(roles);
4319 COPY_SCALAR_FIELD(missing_ok);
4325 _copyLockStmt(const LockStmt *from)
4327 LockStmt *newnode = makeNode(LockStmt);
4329 COPY_NODE_FIELD(relations);
4330 COPY_SCALAR_FIELD(mode);
4331 COPY_SCALAR_FIELD(nowait);
4336 static ConstraintsSetStmt *
4337 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
4339 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
4341 COPY_NODE_FIELD(constraints);
4342 COPY_SCALAR_FIELD(deferred);
4347 static ReindexStmt *
4348 _copyReindexStmt(const ReindexStmt *from)
4350 ReindexStmt *newnode = makeNode(ReindexStmt);
4352 COPY_SCALAR_FIELD(kind);
4353 COPY_NODE_FIELD(relation);
4354 COPY_STRING_FIELD(name);
4355 COPY_SCALAR_FIELD(options);
4360 static CreateSchemaStmt *
4361 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
4363 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
4365 COPY_STRING_FIELD(schemaname);
4366 COPY_NODE_FIELD(authrole);
4367 COPY_NODE_FIELD(schemaElts);
4368 COPY_SCALAR_FIELD(if_not_exists);
4373 static CreateConversionStmt *
4374 _copyCreateConversionStmt(const CreateConversionStmt *from)
4376 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
4378 COPY_NODE_FIELD(conversion_name);
4379 COPY_STRING_FIELD(for_encoding_name);
4380 COPY_STRING_FIELD(to_encoding_name);
4381 COPY_NODE_FIELD(func_name);
4382 COPY_SCALAR_FIELD(def);
4387 static CreateCastStmt *
4388 _copyCreateCastStmt(const CreateCastStmt *from)
4390 CreateCastStmt *newnode = makeNode(CreateCastStmt);
4392 COPY_NODE_FIELD(sourcetype);
4393 COPY_NODE_FIELD(targettype);
4394 COPY_NODE_FIELD(func);
4395 COPY_SCALAR_FIELD(context);
4396 COPY_SCALAR_FIELD(inout);
4401 static PrepareStmt *
4402 _copyPrepareStmt(const PrepareStmt *from)
4404 PrepareStmt *newnode = makeNode(PrepareStmt);
4406 COPY_STRING_FIELD(name);
4407 COPY_NODE_FIELD(argtypes);
4408 COPY_NODE_FIELD(query);
4413 static ExecuteStmt *
4414 _copyExecuteStmt(const ExecuteStmt *from)
4416 ExecuteStmt *newnode = makeNode(ExecuteStmt);
4418 COPY_STRING_FIELD(name);
4419 COPY_NODE_FIELD(params);
4424 static DeallocateStmt *
4425 _copyDeallocateStmt(const DeallocateStmt *from)
4427 DeallocateStmt *newnode = makeNode(DeallocateStmt);
4429 COPY_STRING_FIELD(name);
4434 static DropOwnedStmt *
4435 _copyDropOwnedStmt(const DropOwnedStmt *from)
4437 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
4439 COPY_NODE_FIELD(roles);
4440 COPY_SCALAR_FIELD(behavior);
4445 static ReassignOwnedStmt *
4446 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
4448 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
4450 COPY_NODE_FIELD(roles);
4451 COPY_NODE_FIELD(newrole);
4456 static AlterTSDictionaryStmt *
4457 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
4459 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
4461 COPY_NODE_FIELD(dictname);
4462 COPY_NODE_FIELD(options);
4467 static AlterTSConfigurationStmt *
4468 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
4470 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
4472 COPY_SCALAR_FIELD(kind);
4473 COPY_NODE_FIELD(cfgname);
4474 COPY_NODE_FIELD(tokentype);
4475 COPY_NODE_FIELD(dicts);
4476 COPY_SCALAR_FIELD(override);
4477 COPY_SCALAR_FIELD(replace);
4478 COPY_SCALAR_FIELD(missing_ok);
4483 static CreatePolicyStmt *
4484 _copyCreatePolicyStmt(const CreatePolicyStmt *from)
4486 CreatePolicyStmt *newnode = makeNode(CreatePolicyStmt);
4488 COPY_STRING_FIELD(policy_name);
4489 COPY_NODE_FIELD(table);
4490 COPY_STRING_FIELD(cmd_name);
4491 COPY_SCALAR_FIELD(permissive);
4492 COPY_NODE_FIELD(roles);
4493 COPY_NODE_FIELD(qual);
4494 COPY_NODE_FIELD(with_check);
4499 static AlterPolicyStmt *
4500 _copyAlterPolicyStmt(const AlterPolicyStmt *from)
4502 AlterPolicyStmt *newnode = makeNode(AlterPolicyStmt);
4504 COPY_STRING_FIELD(policy_name);
4505 COPY_NODE_FIELD(table);
4506 COPY_NODE_FIELD(roles);
4507 COPY_NODE_FIELD(qual);
4508 COPY_NODE_FIELD(with_check);
4513 static PartitionElem *
4514 _copyPartitionElem(const PartitionElem *from)
4516 PartitionElem *newnode = makeNode(PartitionElem);
4518 COPY_STRING_FIELD(name);
4519 COPY_NODE_FIELD(expr);
4520 COPY_NODE_FIELD(collation);
4521 COPY_NODE_FIELD(opclass);
4522 COPY_LOCATION_FIELD(location);
4527 static PartitionSpec *
4528 _copyPartitionSpec(const PartitionSpec *from)
4530 PartitionSpec *newnode = makeNode(PartitionSpec);
4532 COPY_STRING_FIELD(strategy);
4533 COPY_NODE_FIELD(partParams);
4534 COPY_LOCATION_FIELD(location);
4539 static PartitionBoundSpec *
4540 _copyPartitionBoundSpec(const PartitionBoundSpec *from)
4542 PartitionBoundSpec *newnode = makeNode(PartitionBoundSpec);
4544 COPY_SCALAR_FIELD(strategy);
4545 COPY_SCALAR_FIELD(is_default);
4546 COPY_SCALAR_FIELD(modulus);
4547 COPY_SCALAR_FIELD(remainder);
4548 COPY_NODE_FIELD(listdatums);
4549 COPY_NODE_FIELD(lowerdatums);
4550 COPY_NODE_FIELD(upperdatums);
4551 COPY_LOCATION_FIELD(location);
4556 static PartitionRangeDatum *
4557 _copyPartitionRangeDatum(const PartitionRangeDatum *from)
4559 PartitionRangeDatum *newnode = makeNode(PartitionRangeDatum);
4561 COPY_SCALAR_FIELD(kind);
4562 COPY_NODE_FIELD(value);
4563 COPY_LOCATION_FIELD(location);
4568 static PartitionCmd *
4569 _copyPartitionCmd(const PartitionCmd *from)
4571 PartitionCmd *newnode = makeNode(PartitionCmd);
4573 COPY_NODE_FIELD(name);
4574 COPY_NODE_FIELD(bound);
4579 static CreatePublicationStmt *
4580 _copyCreatePublicationStmt(const CreatePublicationStmt *from)
4582 CreatePublicationStmt *newnode = makeNode(CreatePublicationStmt);
4584 COPY_STRING_FIELD(pubname);
4585 COPY_NODE_FIELD(options);
4586 COPY_NODE_FIELD(tables);
4587 COPY_SCALAR_FIELD(for_all_tables);
4592 static AlterPublicationStmt *
4593 _copyAlterPublicationStmt(const AlterPublicationStmt *from)
4595 AlterPublicationStmt *newnode = makeNode(AlterPublicationStmt);
4597 COPY_STRING_FIELD(pubname);
4598 COPY_NODE_FIELD(options);
4599 COPY_NODE_FIELD(tables);
4600 COPY_SCALAR_FIELD(for_all_tables);
4601 COPY_SCALAR_FIELD(tableAction);
4606 static CreateSubscriptionStmt *
4607 _copyCreateSubscriptionStmt(const CreateSubscriptionStmt *from)
4609 CreateSubscriptionStmt *newnode = makeNode(CreateSubscriptionStmt);
4611 COPY_STRING_FIELD(subname);
4612 COPY_STRING_FIELD(conninfo);
4613 COPY_NODE_FIELD(publication);
4614 COPY_NODE_FIELD(options);
4619 static AlterSubscriptionStmt *
4620 _copyAlterSubscriptionStmt(const AlterSubscriptionStmt *from)
4622 AlterSubscriptionStmt *newnode = makeNode(AlterSubscriptionStmt);
4624 COPY_SCALAR_FIELD(kind);
4625 COPY_STRING_FIELD(subname);
4626 COPY_STRING_FIELD(conninfo);
4627 COPY_NODE_FIELD(publication);
4628 COPY_NODE_FIELD(options);
4633 static DropSubscriptionStmt *
4634 _copyDropSubscriptionStmt(const DropSubscriptionStmt *from)
4636 DropSubscriptionStmt *newnode = makeNode(DropSubscriptionStmt);
4638 COPY_STRING_FIELD(subname);
4639 COPY_SCALAR_FIELD(missing_ok);
4640 COPY_SCALAR_FIELD(behavior);
4645 /* ****************************************************************
4646 * pg_list.h copy functions
4647 * ****************************************************************
4651 * Perform a deep copy of the specified list, using copyObject(). The
4652 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
4653 * need deep copies, so they should be copied via list_copy()
4655 #define COPY_NODE_CELL(new, old) \
4656 (new) = (ListCell *) palloc(sizeof(ListCell)); \
4657 lfirst(new) = copyObjectImpl(lfirst(old));
4660 _copyList(const List *from)
4666 Assert(list_length(from) >= 1);
4668 new = makeNode(List);
4669 new->length = from->length;
4671 COPY_NODE_CELL(new->head, from->head);
4672 prev_new = new->head;
4673 curr_old = lnext(from->head);
4677 COPY_NODE_CELL(prev_new->next, curr_old);
4678 prev_new = prev_new->next;
4679 curr_old = curr_old->next;
4681 prev_new->next = NULL;
4682 new->tail = prev_new;
4687 /* ****************************************************************
4688 * extensible.h copy functions
4689 * ****************************************************************
4691 static ExtensibleNode *
4692 _copyExtensibleNode(const ExtensibleNode *from)
4694 ExtensibleNode *newnode;
4695 const ExtensibleNodeMethods *methods;
4697 methods = GetExtensibleNodeMethods(from->extnodename, false);
4698 newnode = (ExtensibleNode *) newNode(methods->node_size,
4700 COPY_STRING_FIELD(extnodename);
4702 /* copy the private fields */
4703 methods->nodeCopy(newnode, from);
4708 /* ****************************************************************
4709 * value.h copy functions
4710 * ****************************************************************
4713 _copyValue(const Value *from)
4715 Value *newnode = makeNode(Value);
4717 /* See also _copyAConst when changing this code! */
4719 COPY_SCALAR_FIELD(type);
4723 COPY_SCALAR_FIELD(val.ival);
4728 COPY_STRING_FIELD(val.str);
4734 elog(ERROR, "unrecognized node type: %d",
4742 static ForeignKeyCacheInfo *
4743 _copyForeignKeyCacheInfo(const ForeignKeyCacheInfo *from)
4745 ForeignKeyCacheInfo *newnode = makeNode(ForeignKeyCacheInfo);
4747 COPY_SCALAR_FIELD(conrelid);
4748 COPY_SCALAR_FIELD(confrelid);
4749 COPY_SCALAR_FIELD(nkeys);
4750 /* COPY_SCALAR_FIELD might work for these, but let's not assume that */
4751 memcpy(newnode->conkey, from->conkey, sizeof(newnode->conkey));
4752 memcpy(newnode->confkey, from->confkey, sizeof(newnode->confkey));
4753 memcpy(newnode->conpfeqop, from->conpfeqop, sizeof(newnode->conpfeqop));
4760 * copyObjectImpl -- implementation of copyObject(); see nodes/nodes.h
4762 * Create a copy of a Node tree or list. This is a "deep" copy: all
4763 * substructure is copied too, recursively.
4766 copyObjectImpl(const void *from)
4773 /* Guard against stack overflow due to overly complex expressions */
4774 check_stack_depth();
4776 switch (nodeTag(from))
4782 retval = _copyPlannedStmt(from);
4785 retval = _copyPlan(from);
4788 retval = _copyResult(from);
4791 retval = _copyProjectSet(from);
4794 retval = _copyModifyTable(from);
4797 retval = _copyAppend(from);
4800 retval = _copyMergeAppend(from);
4802 case T_RecursiveUnion:
4803 retval = _copyRecursiveUnion(from);
4806 retval = _copyBitmapAnd(from);
4809 retval = _copyBitmapOr(from);
4812 retval = _copyScan(from);
4815 retval = _copyGather(from);
4818 retval = _copyGatherMerge(from);
4821 retval = _copySeqScan(from);
4824 retval = _copySampleScan(from);
4827 retval = _copyIndexScan(from);
4829 case T_IndexOnlyScan:
4830 retval = _copyIndexOnlyScan(from);
4832 case T_BitmapIndexScan:
4833 retval = _copyBitmapIndexScan(from);
4835 case T_BitmapHeapScan:
4836 retval = _copyBitmapHeapScan(from);
4839 retval = _copyTidScan(from);
4841 case T_SubqueryScan:
4842 retval = _copySubqueryScan(from);
4844 case T_FunctionScan:
4845 retval = _copyFunctionScan(from);
4847 case T_TableFuncScan:
4848 retval = _copyTableFuncScan(from);
4851 retval = _copyValuesScan(from);
4854 retval = _copyCteScan(from);
4856 case T_NamedTuplestoreScan:
4857 retval = _copyNamedTuplestoreScan(from);
4859 case T_WorkTableScan:
4860 retval = _copyWorkTableScan(from);
4863 retval = _copyForeignScan(from);
4866 retval = _copyCustomScan(from);
4869 retval = _copyJoin(from);
4872 retval = _copyNestLoop(from);
4875 retval = _copyMergeJoin(from);
4878 retval = _copyHashJoin(from);
4881 retval = _copyMaterial(from);
4884 retval = _copySort(from);
4887 retval = _copyGroup(from);
4890 retval = _copyAgg(from);
4893 retval = _copyWindowAgg(from);
4896 retval = _copyUnique(from);
4899 retval = _copyHash(from);
4902 retval = _copySetOp(from);
4905 retval = _copyLockRows(from);
4908 retval = _copyLimit(from);
4910 case T_NestLoopParam:
4911 retval = _copyNestLoopParam(from);
4914 retval = _copyPlanRowMark(from);
4916 case T_PlanInvalItem:
4917 retval = _copyPlanInvalItem(from);
4924 retval = _copyAlias(from);
4927 retval = _copyRangeVar(from);
4930 retval = _copyTableFunc(from);
4933 retval = _copyIntoClause(from);
4936 retval = _copyVar(from);
4939 retval = _copyConst(from);
4942 retval = _copyParam(from);
4945 retval = _copyAggref(from);
4947 case T_GroupingFunc:
4948 retval = _copyGroupingFunc(from);
4951 retval = _copyWindowFunc(from);
4954 retval = _copyArrayRef(from);
4957 retval = _copyFuncExpr(from);
4959 case T_NamedArgExpr:
4960 retval = _copyNamedArgExpr(from);
4963 retval = _copyOpExpr(from);
4965 case T_DistinctExpr:
4966 retval = _copyDistinctExpr(from);
4969 retval = _copyNullIfExpr(from);
4971 case T_ScalarArrayOpExpr:
4972 retval = _copyScalarArrayOpExpr(from);
4975 retval = _copyBoolExpr(from);
4978 retval = _copySubLink(from);
4981 retval = _copySubPlan(from);
4983 case T_AlternativeSubPlan:
4984 retval = _copyAlternativeSubPlan(from);
4987 retval = _copyFieldSelect(from);
4990 retval = _copyFieldStore(from);
4993 retval = _copyRelabelType(from);
4996 retval = _copyCoerceViaIO(from);
4998 case T_ArrayCoerceExpr:
4999 retval = _copyArrayCoerceExpr(from);
5001 case T_ConvertRowtypeExpr:
5002 retval = _copyConvertRowtypeExpr(from);
5005 retval = _copyCollateExpr(from);
5008 retval = _copyCaseExpr(from);
5011 retval = _copyCaseWhen(from);
5013 case T_CaseTestExpr:
5014 retval = _copyCaseTestExpr(from);
5017 retval = _copyArrayExpr(from);
5020 retval = _copyRowExpr(from);
5022 case T_RowCompareExpr:
5023 retval = _copyRowCompareExpr(from);
5025 case T_CoalesceExpr:
5026 retval = _copyCoalesceExpr(from);
5029 retval = _copyMinMaxExpr(from);
5031 case T_SQLValueFunction:
5032 retval = _copySQLValueFunction(from);
5035 retval = _copyXmlExpr(from);
5038 retval = _copyNullTest(from);
5041 retval = _copyBooleanTest(from);
5043 case T_CoerceToDomain:
5044 retval = _copyCoerceToDomain(from);
5046 case T_CoerceToDomainValue:
5047 retval = _copyCoerceToDomainValue(from);
5049 case T_SetToDefault:
5050 retval = _copySetToDefault(from);
5052 case T_CurrentOfExpr:
5053 retval = _copyCurrentOfExpr(from);
5055 case T_NextValueExpr:
5056 retval = _copyNextValueExpr(from);
5058 case T_InferenceElem:
5059 retval = _copyInferenceElem(from);
5062 retval = _copyTargetEntry(from);
5065 retval = _copyRangeTblRef(from);
5068 retval = _copyJoinExpr(from);
5071 retval = _copyFromExpr(from);
5073 case T_OnConflictExpr:
5074 retval = _copyOnConflictExpr(from);
5077 retval = _copyMergeAction(from);
5084 retval = _copyPathKey(from);
5086 case T_RestrictInfo:
5087 retval = _copyRestrictInfo(from);
5089 case T_PlaceHolderVar:
5090 retval = _copyPlaceHolderVar(from);
5092 case T_SpecialJoinInfo:
5093 retval = _copySpecialJoinInfo(from);
5095 case T_AppendRelInfo:
5096 retval = _copyAppendRelInfo(from);
5098 case T_PartitionedChildRelInfo:
5099 retval = _copyPartitionedChildRelInfo(from);
5101 case T_PlaceHolderInfo:
5102 retval = _copyPlaceHolderInfo(from);
5113 retval = _copyValue(from);
5120 retval = _copyList(from);
5124 * Lists of integers and OIDs don't need to be deep-copied, so we
5125 * perform a shallow copy via list_copy()
5129 retval = list_copy(from);
5135 case T_ExtensibleNode:
5136 retval = _copyExtensibleNode(from);
5143 retval = _copyQuery(from);
5146 retval = _copyRawStmt(from);
5149 retval = _copyInsertStmt(from);
5152 retval = _copyDeleteStmt(from);
5155 retval = _copyUpdateStmt(from);
5158 retval = _copyMergeStmt(from);
5160 case T_MergeWhenClause:
5161 retval = _copyMergeWhenClause(from);
5164 retval = _copySelectStmt(from);
5166 case T_SetOperationStmt:
5167 retval = _copySetOperationStmt(from);
5169 case T_AlterTableStmt:
5170 retval = _copyAlterTableStmt(from);
5172 case T_AlterTableCmd:
5173 retval = _copyAlterTableCmd(from);
5175 case T_AlterCollationStmt:
5176 retval = _copyAlterCollationStmt(from);
5178 case T_AlterDomainStmt:
5179 retval = _copyAlterDomainStmt(from);
5182 retval = _copyGrantStmt(from);
5184 case T_GrantRoleStmt:
5185 retval = _copyGrantRoleStmt(from);
5187 case T_AlterDefaultPrivilegesStmt:
5188 retval = _copyAlterDefaultPrivilegesStmt(from);
5190 case T_DeclareCursorStmt:
5191 retval = _copyDeclareCursorStmt(from);
5193 case T_ClosePortalStmt:
5194 retval = _copyClosePortalStmt(from);
5197 retval = _copyCallStmt(from);
5200 retval = _copyClusterStmt(from);
5203 retval = _copyCopyStmt(from);
5206 retval = _copyCreateStmt(from);
5208 case T_TableLikeClause:
5209 retval = _copyTableLikeClause(from);
5212 retval = _copyDefineStmt(from);
5215 retval = _copyDropStmt(from);
5217 case T_TruncateStmt:
5218 retval = _copyTruncateStmt(from);
5221 retval = _copyCommentStmt(from);
5223 case T_SecLabelStmt:
5224 retval = _copySecLabelStmt(from);
5227 retval = _copyFetchStmt(from);
5230 retval = _copyIndexStmt(from);
5232 case T_CreateStatsStmt:
5233 retval = _copyCreateStatsStmt(from);
5235 case T_CreateFunctionStmt:
5236 retval = _copyCreateFunctionStmt(from);
5238 case T_FunctionParameter:
5239 retval = _copyFunctionParameter(from);
5241 case T_AlterFunctionStmt:
5242 retval = _copyAlterFunctionStmt(from);
5245 retval = _copyDoStmt(from);
5248 retval = _copyRenameStmt(from);
5250 case T_AlterObjectDependsStmt:
5251 retval = _copyAlterObjectDependsStmt(from);
5253 case T_AlterObjectSchemaStmt:
5254 retval = _copyAlterObjectSchemaStmt(from);
5256 case T_AlterOwnerStmt:
5257 retval = _copyAlterOwnerStmt(from);
5259 case T_AlterOperatorStmt:
5260 retval = _copyAlterOperatorStmt(from);
5263 retval = _copyRuleStmt(from);
5266 retval = _copyNotifyStmt(from);
5269 retval = _copyListenStmt(from);
5271 case T_UnlistenStmt:
5272 retval = _copyUnlistenStmt(from);
5274 case T_TransactionStmt:
5275 retval = _copyTransactionStmt(from);
5277 case T_CompositeTypeStmt:
5278 retval = _copyCompositeTypeStmt(from);
5280 case T_CreateEnumStmt:
5281 retval = _copyCreateEnumStmt(from);
5283 case T_CreateRangeStmt:
5284 retval = _copyCreateRangeStmt(from);
5286 case T_AlterEnumStmt:
5287 retval = _copyAlterEnumStmt(from);
5290 retval = _copyViewStmt(from);
5293 retval = _copyLoadStmt(from);
5295 case T_CreateDomainStmt:
5296 retval = _copyCreateDomainStmt(from);
5298 case T_CreateOpClassStmt:
5299 retval = _copyCreateOpClassStmt(from);
5301 case T_CreateOpClassItem:
5302 retval = _copyCreateOpClassItem(from);
5304 case T_CreateOpFamilyStmt:
5305 retval = _copyCreateOpFamilyStmt(from);
5307 case T_AlterOpFamilyStmt:
5308 retval = _copyAlterOpFamilyStmt(from);
5310 case T_CreatedbStmt:
5311 retval = _copyCreatedbStmt(from);
5313 case T_AlterDatabaseStmt:
5314 retval = _copyAlterDatabaseStmt(from);
5316 case T_AlterDatabaseSetStmt:
5317 retval = _copyAlterDatabaseSetStmt(from);
5320 retval = _copyDropdbStmt(from);
5323 retval = _copyVacuumStmt(from);
5325 case T_VacuumRelation:
5326 retval = _copyVacuumRelation(from);
5329 retval = _copyExplainStmt(from);
5331 case T_CreateTableAsStmt:
5332 retval = _copyCreateTableAsStmt(from);
5334 case T_RefreshMatViewStmt:
5335 retval = _copyRefreshMatViewStmt(from);
5337 case T_ReplicaIdentityStmt:
5338 retval = _copyReplicaIdentityStmt(from);
5340 case T_AlterSystemStmt:
5341 retval = _copyAlterSystemStmt(from);
5343 case T_CreateSeqStmt:
5344 retval = _copyCreateSeqStmt(from);
5346 case T_AlterSeqStmt:
5347 retval = _copyAlterSeqStmt(from);
5349 case T_VariableSetStmt:
5350 retval = _copyVariableSetStmt(from);
5352 case T_VariableShowStmt:
5353 retval = _copyVariableShowStmt(from);
5356 retval = _copyDiscardStmt(from);
5358 case T_CreateTableSpaceStmt:
5359 retval = _copyCreateTableSpaceStmt(from);
5361 case T_DropTableSpaceStmt:
5362 retval = _copyDropTableSpaceStmt(from);
5364 case T_AlterTableSpaceOptionsStmt:
5365 retval = _copyAlterTableSpaceOptionsStmt(from);
5367 case T_AlterTableMoveAllStmt:
5368 retval = _copyAlterTableMoveAllStmt(from);
5370 case T_CreateExtensionStmt:
5371 retval = _copyCreateExtensionStmt(from);
5373 case T_AlterExtensionStmt:
5374 retval = _copyAlterExtensionStmt(from);
5376 case T_AlterExtensionContentsStmt:
5377 retval = _copyAlterExtensionContentsStmt(from);
5379 case T_CreateFdwStmt:
5380 retval = _copyCreateFdwStmt(from);
5382 case T_AlterFdwStmt:
5383 retval = _copyAlterFdwStmt(from);
5385 case T_CreateForeignServerStmt:
5386 retval = _copyCreateForeignServerStmt(from);
5388 case T_AlterForeignServerStmt:
5389 retval = _copyAlterForeignServerStmt(from);
5391 case T_CreateUserMappingStmt:
5392 retval = _copyCreateUserMappingStmt(from);
5394 case T_AlterUserMappingStmt:
5395 retval = _copyAlterUserMappingStmt(from);
5397 case T_DropUserMappingStmt:
5398 retval = _copyDropUserMappingStmt(from);
5400 case T_CreateForeignTableStmt:
5401 retval = _copyCreateForeignTableStmt(from);
5403 case T_ImportForeignSchemaStmt:
5404 retval = _copyImportForeignSchemaStmt(from);
5406 case T_CreateTransformStmt:
5407 retval = _copyCreateTransformStmt(from);
5409 case T_CreateAmStmt:
5410 retval = _copyCreateAmStmt(from);
5412 case T_CreateTrigStmt:
5413 retval = _copyCreateTrigStmt(from);
5415 case T_CreateEventTrigStmt:
5416 retval = _copyCreateEventTrigStmt(from);
5418 case T_AlterEventTrigStmt:
5419 retval = _copyAlterEventTrigStmt(from);
5421 case T_CreatePLangStmt:
5422 retval = _copyCreatePLangStmt(from);
5424 case T_CreateRoleStmt:
5425 retval = _copyCreateRoleStmt(from);
5427 case T_AlterRoleStmt:
5428 retval = _copyAlterRoleStmt(from);
5430 case T_AlterRoleSetStmt:
5431 retval = _copyAlterRoleSetStmt(from);
5433 case T_DropRoleStmt:
5434 retval = _copyDropRoleStmt(from);
5437 retval = _copyLockStmt(from);
5439 case T_ConstraintsSetStmt:
5440 retval = _copyConstraintsSetStmt(from);
5443 retval = _copyReindexStmt(from);
5445 case T_CheckPointStmt:
5446 retval = (void *) makeNode(CheckPointStmt);
5448 case T_CreateSchemaStmt:
5449 retval = _copyCreateSchemaStmt(from);
5451 case T_CreateConversionStmt:
5452 retval = _copyCreateConversionStmt(from);
5454 case T_CreateCastStmt:
5455 retval = _copyCreateCastStmt(from);
5458 retval = _copyPrepareStmt(from);
5461 retval = _copyExecuteStmt(from);
5463 case T_DeallocateStmt:
5464 retval = _copyDeallocateStmt(from);
5466 case T_DropOwnedStmt:
5467 retval = _copyDropOwnedStmt(from);
5469 case T_ReassignOwnedStmt:
5470 retval = _copyReassignOwnedStmt(from);
5472 case T_AlterTSDictionaryStmt:
5473 retval = _copyAlterTSDictionaryStmt(from);
5475 case T_AlterTSConfigurationStmt:
5476 retval = _copyAlterTSConfigurationStmt(from);
5478 case T_CreatePolicyStmt:
5479 retval = _copyCreatePolicyStmt(from);
5481 case T_AlterPolicyStmt:
5482 retval = _copyAlterPolicyStmt(from);
5484 case T_CreatePublicationStmt:
5485 retval = _copyCreatePublicationStmt(from);
5487 case T_AlterPublicationStmt:
5488 retval = _copyAlterPublicationStmt(from);
5490 case T_CreateSubscriptionStmt:
5491 retval = _copyCreateSubscriptionStmt(from);
5493 case T_AlterSubscriptionStmt:
5494 retval = _copyAlterSubscriptionStmt(from);
5496 case T_DropSubscriptionStmt:
5497 retval = _copyDropSubscriptionStmt(from);
5500 retval = _copyAExpr(from);
5503 retval = _copyColumnRef(from);
5506 retval = _copyParamRef(from);
5509 retval = _copyAConst(from);
5512 retval = _copyFuncCall(from);
5515 retval = _copyAStar(from);
5518 retval = _copyAIndices(from);
5520 case T_A_Indirection:
5521 retval = _copyA_Indirection(from);
5524 retval = _copyA_ArrayExpr(from);
5527 retval = _copyResTarget(from);
5529 case T_MultiAssignRef:
5530 retval = _copyMultiAssignRef(from);
5533 retval = _copyTypeCast(from);
5535 case T_CollateClause:
5536 retval = _copyCollateClause(from);
5539 retval = _copySortBy(from);
5542 retval = _copyWindowDef(from);
5544 case T_RangeSubselect:
5545 retval = _copyRangeSubselect(from);
5547 case T_RangeFunction:
5548 retval = _copyRangeFunction(from);
5550 case T_RangeTableSample:
5551 retval = _copyRangeTableSample(from);
5553 case T_RangeTableFunc:
5554 retval = _copyRangeTableFunc(from);
5556 case T_RangeTableFuncCol:
5557 retval = _copyRangeTableFuncCol(from);
5560 retval = _copyTypeName(from);
5563 retval = _copyIndexElem(from);
5566 retval = _copyColumnDef(from);
5569 retval = _copyConstraint(from);
5572 retval = _copyDefElem(from);
5574 case T_LockingClause:
5575 retval = _copyLockingClause(from);
5577 case T_RangeTblEntry:
5578 retval = _copyRangeTblEntry(from);
5580 case T_RangeTblFunction:
5581 retval = _copyRangeTblFunction(from);
5583 case T_TableSampleClause:
5584 retval = _copyTableSampleClause(from);
5586 case T_WithCheckOption:
5587 retval = _copyWithCheckOption(from);
5589 case T_SortGroupClause:
5590 retval = _copySortGroupClause(from);
5593 retval = _copyGroupingSet(from);
5595 case T_WindowClause:
5596 retval = _copyWindowClause(from);
5598 case T_RowMarkClause:
5599 retval = _copyRowMarkClause(from);
5602 retval = _copyWithClause(from);
5605 retval = _copyInferClause(from);
5607 case T_OnConflictClause:
5608 retval = _copyOnConflictClause(from);
5610 case T_CommonTableExpr:
5611 retval = _copyCommonTableExpr(from);
5613 case T_ObjectWithArgs:
5614 retval = _copyObjectWithArgs(from);
5617 retval = _copyAccessPriv(from);
5619 case T_XmlSerialize:
5620 retval = _copyXmlSerialize(from);
5623 retval = _copyRoleSpec(from);
5625 case T_TriggerTransition:
5626 retval = _copyTriggerTransition(from);
5628 case T_PartitionElem:
5629 retval = _copyPartitionElem(from);
5631 case T_PartitionSpec:
5632 retval = _copyPartitionSpec(from);
5634 case T_PartitionBoundSpec:
5635 retval = _copyPartitionBoundSpec(from);
5637 case T_PartitionRangeDatum:
5638 retval = _copyPartitionRangeDatum(from);
5640 case T_PartitionCmd:
5641 retval = _copyPartitionCmd(from);
5645 * MISCELLANEOUS NODES
5647 case T_ForeignKeyCacheInfo:
5648 retval = _copyForeignKeyCacheInfo(from);
5652 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
5653 retval = 0; /* keep compiler quiet */