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-2015, 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/plannodes.h"
27 #include "nodes/relation.h"
28 #include "utils/datum.h"
32 * Macros to simplify copying of different kinds of fields. Use these
33 * wherever possible to reduce the chance for silly typos. Note that these
34 * hard-wire the convention that the local variables in a Copy routine are
35 * named 'newnode' and 'from'.
38 /* Copy a simple scalar field (int, float, bool, enum, etc) */
39 #define COPY_SCALAR_FIELD(fldname) \
40 (newnode->fldname = from->fldname)
42 /* Copy a field that is a pointer to some kind of Node or Node tree */
43 #define COPY_NODE_FIELD(fldname) \
44 (newnode->fldname = copyObject(from->fldname))
46 /* Copy a field that is a pointer to a Bitmapset */
47 #define COPY_BITMAPSET_FIELD(fldname) \
48 (newnode->fldname = bms_copy(from->fldname))
50 /* Copy a field that is a pointer to a C string, or perhaps NULL */
51 #define COPY_STRING_FIELD(fldname) \
52 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
54 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
55 #define COPY_POINTER_FIELD(fldname, sz) \
58 newnode->fldname = palloc(_size); \
59 memcpy(newnode->fldname, from->fldname, _size); \
62 /* Copy a parse location field (for Copy, this is same as scalar case) */
63 #define COPY_LOCATION_FIELD(fldname) \
64 (newnode->fldname = from->fldname)
67 /* ****************************************************************
68 * plannodes.h copy functions
69 * ****************************************************************
76 _copyPlannedStmt(const PlannedStmt *from)
78 PlannedStmt *newnode = makeNode(PlannedStmt);
80 COPY_SCALAR_FIELD(commandType);
81 COPY_SCALAR_FIELD(queryId);
82 COPY_SCALAR_FIELD(hasReturning);
83 COPY_SCALAR_FIELD(hasModifyingCTE);
84 COPY_SCALAR_FIELD(isUpsert);
85 COPY_SCALAR_FIELD(canSetTag);
86 COPY_SCALAR_FIELD(transientPlan);
87 COPY_NODE_FIELD(planTree);
88 COPY_NODE_FIELD(rtable);
89 COPY_NODE_FIELD(resultRelations);
90 COPY_NODE_FIELD(utilityStmt);
91 COPY_NODE_FIELD(subplans);
92 COPY_BITMAPSET_FIELD(rewindPlanIDs);
93 COPY_NODE_FIELD(rowMarks);
94 COPY_NODE_FIELD(relationOids);
95 COPY_NODE_FIELD(invalItems);
96 COPY_SCALAR_FIELD(nParamExec);
97 COPY_SCALAR_FIELD(hasRowSecurity);
105 * This function copies the fields of the Plan node. It is used by
106 * all the copy functions for classes which inherit from Plan.
109 CopyPlanFields(const Plan *from, Plan *newnode)
111 COPY_SCALAR_FIELD(startup_cost);
112 COPY_SCALAR_FIELD(total_cost);
113 COPY_SCALAR_FIELD(plan_rows);
114 COPY_SCALAR_FIELD(plan_width);
115 COPY_NODE_FIELD(targetlist);
116 COPY_NODE_FIELD(qual);
117 COPY_NODE_FIELD(lefttree);
118 COPY_NODE_FIELD(righttree);
119 COPY_NODE_FIELD(initPlan);
120 COPY_BITMAPSET_FIELD(extParam);
121 COPY_BITMAPSET_FIELD(allParam);
128 _copyPlan(const Plan *from)
130 Plan *newnode = makeNode(Plan);
133 * copy node superclass fields
135 CopyPlanFields(from, newnode);
145 _copyResult(const Result *from)
147 Result *newnode = makeNode(Result);
150 * copy node superclass fields
152 CopyPlanFields((const Plan *) from, (Plan *) newnode);
155 * copy remainder of node
157 COPY_NODE_FIELD(resconstantqual);
166 _copyModifyTable(const ModifyTable *from)
168 ModifyTable *newnode = makeNode(ModifyTable);
171 * copy node superclass fields
173 CopyPlanFields((const Plan *) from, (Plan *) newnode);
176 * copy remainder of node
178 COPY_SCALAR_FIELD(operation);
179 COPY_SCALAR_FIELD(canSetTag);
180 COPY_SCALAR_FIELD(nominalRelation);
181 COPY_NODE_FIELD(resultRelations);
182 COPY_SCALAR_FIELD(resultRelIndex);
183 COPY_NODE_FIELD(plans);
184 COPY_NODE_FIELD(withCheckOptionLists);
185 COPY_NODE_FIELD(returningLists);
186 COPY_NODE_FIELD(fdwPrivLists);
187 COPY_NODE_FIELD(rowMarks);
188 COPY_SCALAR_FIELD(epqParam);
189 COPY_SCALAR_FIELD(onConflictAction);
190 COPY_NODE_FIELD(arbiterIndexes);
191 COPY_NODE_FIELD(onConflictSet);
192 COPY_NODE_FIELD(onConflictWhere);
193 COPY_SCALAR_FIELD(exclRelRTI);
194 COPY_NODE_FIELD(exclRelTlist);
203 _copyAppend(const Append *from)
205 Append *newnode = makeNode(Append);
208 * copy node superclass fields
210 CopyPlanFields((const Plan *) from, (Plan *) newnode);
213 * copy remainder of node
215 COPY_NODE_FIELD(appendplans);
224 _copyMergeAppend(const MergeAppend *from)
226 MergeAppend *newnode = makeNode(MergeAppend);
229 * copy node superclass fields
231 CopyPlanFields((const Plan *) from, (Plan *) newnode);
234 * copy remainder of node
236 COPY_NODE_FIELD(mergeplans);
237 COPY_SCALAR_FIELD(numCols);
238 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
239 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
240 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
241 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
247 * _copyRecursiveUnion
249 static RecursiveUnion *
250 _copyRecursiveUnion(const RecursiveUnion *from)
252 RecursiveUnion *newnode = makeNode(RecursiveUnion);
255 * copy node superclass fields
257 CopyPlanFields((const Plan *) from, (Plan *) newnode);
260 * copy remainder of node
262 COPY_SCALAR_FIELD(wtParam);
263 COPY_SCALAR_FIELD(numCols);
264 if (from->numCols > 0)
266 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
267 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
269 COPY_SCALAR_FIELD(numGroups);
278 _copyBitmapAnd(const BitmapAnd *from)
280 BitmapAnd *newnode = makeNode(BitmapAnd);
283 * copy node superclass fields
285 CopyPlanFields((const Plan *) from, (Plan *) newnode);
288 * copy remainder of node
290 COPY_NODE_FIELD(bitmapplans);
299 _copyBitmapOr(const BitmapOr *from)
301 BitmapOr *newnode = makeNode(BitmapOr);
304 * copy node superclass fields
306 CopyPlanFields((const Plan *) from, (Plan *) newnode);
309 * copy remainder of node
311 COPY_NODE_FIELD(bitmapplans);
320 * This function copies the fields of the Scan node. It is used by
321 * all the copy functions for classes which inherit from Scan.
324 CopyScanFields(const Scan *from, Scan *newnode)
326 CopyPlanFields((const Plan *) from, (Plan *) newnode);
328 COPY_SCALAR_FIELD(scanrelid);
335 _copyScan(const Scan *from)
337 Scan *newnode = makeNode(Scan);
340 * copy node superclass fields
342 CopyScanFields((const Scan *) from, (Scan *) newnode);
351 _copySeqScan(const SeqScan *from)
353 SeqScan *newnode = makeNode(SeqScan);
356 * copy node superclass fields
358 CopyScanFields((const Scan *) from, (Scan *) newnode);
367 _copyIndexScan(const IndexScan *from)
369 IndexScan *newnode = makeNode(IndexScan);
372 * copy node superclass fields
374 CopyScanFields((const Scan *) from, (Scan *) newnode);
377 * copy remainder of node
379 COPY_SCALAR_FIELD(indexid);
380 COPY_NODE_FIELD(indexqual);
381 COPY_NODE_FIELD(indexqualorig);
382 COPY_NODE_FIELD(indexorderby);
383 COPY_NODE_FIELD(indexorderbyorig);
384 COPY_SCALAR_FIELD(indexorderdir);
392 static IndexOnlyScan *
393 _copyIndexOnlyScan(const IndexOnlyScan *from)
395 IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
398 * copy node superclass fields
400 CopyScanFields((const Scan *) from, (Scan *) newnode);
403 * copy remainder of node
405 COPY_SCALAR_FIELD(indexid);
406 COPY_NODE_FIELD(indexqual);
407 COPY_NODE_FIELD(indexorderby);
408 COPY_NODE_FIELD(indextlist);
409 COPY_SCALAR_FIELD(indexorderdir);
415 * _copyBitmapIndexScan
417 static BitmapIndexScan *
418 _copyBitmapIndexScan(const BitmapIndexScan *from)
420 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
423 * copy node superclass fields
425 CopyScanFields((const Scan *) from, (Scan *) newnode);
428 * copy remainder of node
430 COPY_SCALAR_FIELD(indexid);
431 COPY_NODE_FIELD(indexqual);
432 COPY_NODE_FIELD(indexqualorig);
438 * _copyBitmapHeapScan
440 static BitmapHeapScan *
441 _copyBitmapHeapScan(const BitmapHeapScan *from)
443 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
446 * copy node superclass fields
448 CopyScanFields((const Scan *) from, (Scan *) newnode);
451 * copy remainder of node
453 COPY_NODE_FIELD(bitmapqualorig);
462 _copyTidScan(const TidScan *from)
464 TidScan *newnode = makeNode(TidScan);
467 * copy node superclass fields
469 CopyScanFields((const Scan *) from, (Scan *) newnode);
472 * copy remainder of node
474 COPY_NODE_FIELD(tidquals);
482 static SubqueryScan *
483 _copySubqueryScan(const SubqueryScan *from)
485 SubqueryScan *newnode = makeNode(SubqueryScan);
488 * copy node superclass fields
490 CopyScanFields((const Scan *) from, (Scan *) newnode);
493 * copy remainder of node
495 COPY_NODE_FIELD(subplan);
503 static FunctionScan *
504 _copyFunctionScan(const FunctionScan *from)
506 FunctionScan *newnode = makeNode(FunctionScan);
509 * copy node superclass fields
511 CopyScanFields((const Scan *) from, (Scan *) newnode);
514 * copy remainder of node
516 COPY_NODE_FIELD(functions);
517 COPY_SCALAR_FIELD(funcordinality);
526 _copyValuesScan(const ValuesScan *from)
528 ValuesScan *newnode = makeNode(ValuesScan);
531 * copy node superclass fields
533 CopyScanFields((const Scan *) from, (Scan *) newnode);
536 * copy remainder of node
538 COPY_NODE_FIELD(values_lists);
547 _copyCteScan(const CteScan *from)
549 CteScan *newnode = makeNode(CteScan);
552 * copy node superclass fields
554 CopyScanFields((const Scan *) from, (Scan *) newnode);
557 * copy remainder of node
559 COPY_SCALAR_FIELD(ctePlanId);
560 COPY_SCALAR_FIELD(cteParam);
568 static WorkTableScan *
569 _copyWorkTableScan(const WorkTableScan *from)
571 WorkTableScan *newnode = makeNode(WorkTableScan);
574 * copy node superclass fields
576 CopyScanFields((const Scan *) from, (Scan *) newnode);
579 * copy remainder of node
581 COPY_SCALAR_FIELD(wtParam);
590 _copyForeignScan(const ForeignScan *from)
592 ForeignScan *newnode = makeNode(ForeignScan);
595 * copy node superclass fields
597 CopyScanFields((const Scan *) from, (Scan *) newnode);
600 * copy remainder of node
602 COPY_SCALAR_FIELD(fs_server);
603 COPY_NODE_FIELD(fdw_exprs);
604 COPY_NODE_FIELD(fdw_private);
605 COPY_NODE_FIELD(fdw_scan_tlist);
606 COPY_BITMAPSET_FIELD(fs_relids);
607 COPY_SCALAR_FIELD(fsSystemCol);
616 _copyCustomScan(const CustomScan *from)
618 CustomScan *newnode = makeNode(CustomScan);
621 * copy node superclass fields
623 CopyScanFields((const Scan *) from, (Scan *) newnode);
626 * copy remainder of node
628 COPY_SCALAR_FIELD(flags);
629 COPY_NODE_FIELD(custom_exprs);
630 COPY_NODE_FIELD(custom_private);
631 COPY_NODE_FIELD(custom_scan_tlist);
632 COPY_BITMAPSET_FIELD(custom_relids);
635 * NOTE: The method field of CustomScan is required to be a pointer to a
636 * static table of callback functions. So we don't copy the table itself,
637 * just reference the original one.
639 COPY_SCALAR_FIELD(methods);
648 _copySampleScan(const SampleScan *from)
650 SampleScan *newnode = makeNode(SampleScan);
653 * copy node superclass fields
655 CopyScanFields((const Scan *) from, (Scan *) newnode);
663 * This function copies the fields of the Join node. It is used by
664 * all the copy functions for classes which inherit from Join.
667 CopyJoinFields(const Join *from, Join *newnode)
669 CopyPlanFields((const Plan *) from, (Plan *) newnode);
671 COPY_SCALAR_FIELD(jointype);
672 COPY_NODE_FIELD(joinqual);
680 _copyJoin(const Join *from)
682 Join *newnode = makeNode(Join);
685 * copy node superclass fields
687 CopyJoinFields(from, newnode);
697 _copyNestLoop(const NestLoop *from)
699 NestLoop *newnode = makeNode(NestLoop);
702 * copy node superclass fields
704 CopyJoinFields((const Join *) from, (Join *) newnode);
707 * copy remainder of node
709 COPY_NODE_FIELD(nestParams);
719 _copyMergeJoin(const MergeJoin *from)
721 MergeJoin *newnode = makeNode(MergeJoin);
725 * copy node superclass fields
727 CopyJoinFields((const Join *) from, (Join *) newnode);
730 * copy remainder of node
732 COPY_NODE_FIELD(mergeclauses);
733 numCols = list_length(from->mergeclauses);
736 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
737 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
738 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
739 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
749 _copyHashJoin(const HashJoin *from)
751 HashJoin *newnode = makeNode(HashJoin);
754 * copy node superclass fields
756 CopyJoinFields((const Join *) from, (Join *) newnode);
759 * copy remainder of node
761 COPY_NODE_FIELD(hashclauses);
771 _copyMaterial(const Material *from)
773 Material *newnode = makeNode(Material);
776 * copy node superclass fields
778 CopyPlanFields((const Plan *) from, (Plan *) newnode);
788 _copySort(const Sort *from)
790 Sort *newnode = makeNode(Sort);
793 * copy node superclass fields
795 CopyPlanFields((const Plan *) from, (Plan *) newnode);
797 COPY_SCALAR_FIELD(numCols);
798 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
799 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
800 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
801 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
811 _copyGroup(const Group *from)
813 Group *newnode = makeNode(Group);
815 CopyPlanFields((const Plan *) from, (Plan *) newnode);
817 COPY_SCALAR_FIELD(numCols);
818 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
819 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
828 _copyAgg(const Agg *from)
830 Agg *newnode = makeNode(Agg);
832 CopyPlanFields((const Plan *) from, (Plan *) newnode);
834 COPY_SCALAR_FIELD(aggstrategy);
835 COPY_SCALAR_FIELD(numCols);
836 if (from->numCols > 0)
838 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
839 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
841 COPY_SCALAR_FIELD(numGroups);
842 COPY_NODE_FIELD(groupingSets);
843 COPY_NODE_FIELD(chain);
852 _copyWindowAgg(const WindowAgg *from)
854 WindowAgg *newnode = makeNode(WindowAgg);
856 CopyPlanFields((const Plan *) from, (Plan *) newnode);
858 COPY_SCALAR_FIELD(winref);
859 COPY_SCALAR_FIELD(partNumCols);
860 if (from->partNumCols > 0)
862 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
863 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
865 COPY_SCALAR_FIELD(ordNumCols);
866 if (from->ordNumCols > 0)
868 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
869 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
871 COPY_SCALAR_FIELD(frameOptions);
872 COPY_NODE_FIELD(startOffset);
873 COPY_NODE_FIELD(endOffset);
882 _copyUnique(const Unique *from)
884 Unique *newnode = makeNode(Unique);
887 * copy node superclass fields
889 CopyPlanFields((const Plan *) from, (Plan *) newnode);
892 * copy remainder of node
894 COPY_SCALAR_FIELD(numCols);
895 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
896 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
905 _copyHash(const Hash *from)
907 Hash *newnode = makeNode(Hash);
910 * copy node superclass fields
912 CopyPlanFields((const Plan *) from, (Plan *) newnode);
915 * copy remainder of node
917 COPY_SCALAR_FIELD(skewTable);
918 COPY_SCALAR_FIELD(skewColumn);
919 COPY_SCALAR_FIELD(skewInherit);
920 COPY_SCALAR_FIELD(skewColType);
921 COPY_SCALAR_FIELD(skewColTypmod);
930 _copySetOp(const SetOp *from)
932 SetOp *newnode = makeNode(SetOp);
935 * copy node superclass fields
937 CopyPlanFields((const Plan *) from, (Plan *) newnode);
940 * copy remainder of node
942 COPY_SCALAR_FIELD(cmd);
943 COPY_SCALAR_FIELD(strategy);
944 COPY_SCALAR_FIELD(numCols);
945 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
946 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
947 COPY_SCALAR_FIELD(flagColIdx);
948 COPY_SCALAR_FIELD(firstFlag);
949 COPY_SCALAR_FIELD(numGroups);
958 _copyLockRows(const LockRows *from)
960 LockRows *newnode = makeNode(LockRows);
963 * copy node superclass fields
965 CopyPlanFields((const Plan *) from, (Plan *) newnode);
968 * copy remainder of node
970 COPY_NODE_FIELD(rowMarks);
971 COPY_SCALAR_FIELD(epqParam);
980 _copyLimit(const Limit *from)
982 Limit *newnode = makeNode(Limit);
985 * copy node superclass fields
987 CopyPlanFields((const Plan *) from, (Plan *) newnode);
990 * copy remainder of node
992 COPY_NODE_FIELD(limitOffset);
993 COPY_NODE_FIELD(limitCount);
1001 static NestLoopParam *
1002 _copyNestLoopParam(const NestLoopParam *from)
1004 NestLoopParam *newnode = makeNode(NestLoopParam);
1006 COPY_SCALAR_FIELD(paramno);
1007 COPY_NODE_FIELD(paramval);
1015 static PlanRowMark *
1016 _copyPlanRowMark(const PlanRowMark *from)
1018 PlanRowMark *newnode = makeNode(PlanRowMark);
1020 COPY_SCALAR_FIELD(rti);
1021 COPY_SCALAR_FIELD(prti);
1022 COPY_SCALAR_FIELD(rowmarkId);
1023 COPY_SCALAR_FIELD(markType);
1024 COPY_SCALAR_FIELD(allMarkTypes);
1025 COPY_SCALAR_FIELD(strength);
1026 COPY_SCALAR_FIELD(waitPolicy);
1027 COPY_SCALAR_FIELD(isParent);
1033 * _copyPlanInvalItem
1035 static PlanInvalItem *
1036 _copyPlanInvalItem(const PlanInvalItem *from)
1038 PlanInvalItem *newnode = makeNode(PlanInvalItem);
1040 COPY_SCALAR_FIELD(cacheId);
1041 COPY_SCALAR_FIELD(hashValue);
1046 /* ****************************************************************
1047 * primnodes.h copy functions
1048 * ****************************************************************
1055 _copyAlias(const Alias *from)
1057 Alias *newnode = makeNode(Alias);
1059 COPY_STRING_FIELD(aliasname);
1060 COPY_NODE_FIELD(colnames);
1069 _copyRangeVar(const RangeVar *from)
1071 RangeVar *newnode = makeNode(RangeVar);
1073 COPY_STRING_FIELD(catalogname);
1074 COPY_STRING_FIELD(schemaname);
1075 COPY_STRING_FIELD(relname);
1076 COPY_SCALAR_FIELD(inhOpt);
1077 COPY_SCALAR_FIELD(relpersistence);
1078 COPY_NODE_FIELD(alias);
1079 COPY_LOCATION_FIELD(location);
1088 _copyIntoClause(const IntoClause *from)
1090 IntoClause *newnode = makeNode(IntoClause);
1092 COPY_NODE_FIELD(rel);
1093 COPY_NODE_FIELD(colNames);
1094 COPY_NODE_FIELD(options);
1095 COPY_SCALAR_FIELD(onCommit);
1096 COPY_STRING_FIELD(tableSpaceName);
1097 COPY_NODE_FIELD(viewQuery);
1098 COPY_SCALAR_FIELD(skipData);
1104 * We don't need a _copyExpr because Expr is an abstract supertype which
1105 * should never actually get instantiated. Also, since it has no common
1106 * fields except NodeTag, there's no need for a helper routine to factor
1107 * out copying the common fields...
1114 _copyVar(const Var *from)
1116 Var *newnode = makeNode(Var);
1118 COPY_SCALAR_FIELD(varno);
1119 COPY_SCALAR_FIELD(varattno);
1120 COPY_SCALAR_FIELD(vartype);
1121 COPY_SCALAR_FIELD(vartypmod);
1122 COPY_SCALAR_FIELD(varcollid);
1123 COPY_SCALAR_FIELD(varlevelsup);
1124 COPY_SCALAR_FIELD(varnoold);
1125 COPY_SCALAR_FIELD(varoattno);
1126 COPY_LOCATION_FIELD(location);
1135 _copyConst(const Const *from)
1137 Const *newnode = makeNode(Const);
1139 COPY_SCALAR_FIELD(consttype);
1140 COPY_SCALAR_FIELD(consttypmod);
1141 COPY_SCALAR_FIELD(constcollid);
1142 COPY_SCALAR_FIELD(constlen);
1144 if (from->constbyval || from->constisnull)
1147 * passed by value so just copy the datum. Also, don't try to copy
1148 * struct when value is null!
1150 newnode->constvalue = from->constvalue;
1155 * passed by reference. We need a palloc'd copy.
1157 newnode->constvalue = datumCopy(from->constvalue,
1162 COPY_SCALAR_FIELD(constisnull);
1163 COPY_SCALAR_FIELD(constbyval);
1164 COPY_LOCATION_FIELD(location);
1173 _copyParam(const Param *from)
1175 Param *newnode = makeNode(Param);
1177 COPY_SCALAR_FIELD(paramkind);
1178 COPY_SCALAR_FIELD(paramid);
1179 COPY_SCALAR_FIELD(paramtype);
1180 COPY_SCALAR_FIELD(paramtypmod);
1181 COPY_SCALAR_FIELD(paramcollid);
1182 COPY_LOCATION_FIELD(location);
1191 _copyAggref(const Aggref *from)
1193 Aggref *newnode = makeNode(Aggref);
1195 COPY_SCALAR_FIELD(aggfnoid);
1196 COPY_SCALAR_FIELD(aggtype);
1197 COPY_SCALAR_FIELD(aggcollid);
1198 COPY_SCALAR_FIELD(inputcollid);
1199 COPY_NODE_FIELD(aggdirectargs);
1200 COPY_NODE_FIELD(args);
1201 COPY_NODE_FIELD(aggorder);
1202 COPY_NODE_FIELD(aggdistinct);
1203 COPY_NODE_FIELD(aggfilter);
1204 COPY_SCALAR_FIELD(aggstar);
1205 COPY_SCALAR_FIELD(aggvariadic);
1206 COPY_SCALAR_FIELD(aggkind);
1207 COPY_SCALAR_FIELD(agglevelsup);
1208 COPY_LOCATION_FIELD(location);
1216 static GroupingFunc *
1217 _copyGroupingFunc(const GroupingFunc *from)
1219 GroupingFunc *newnode = makeNode(GroupingFunc);
1221 COPY_NODE_FIELD(args);
1222 COPY_NODE_FIELD(refs);
1223 COPY_NODE_FIELD(cols);
1224 COPY_SCALAR_FIELD(agglevelsup);
1225 COPY_LOCATION_FIELD(location);
1234 _copyWindowFunc(const WindowFunc *from)
1236 WindowFunc *newnode = makeNode(WindowFunc);
1238 COPY_SCALAR_FIELD(winfnoid);
1239 COPY_SCALAR_FIELD(wintype);
1240 COPY_SCALAR_FIELD(wincollid);
1241 COPY_SCALAR_FIELD(inputcollid);
1242 COPY_NODE_FIELD(args);
1243 COPY_NODE_FIELD(aggfilter);
1244 COPY_SCALAR_FIELD(winref);
1245 COPY_SCALAR_FIELD(winstar);
1246 COPY_SCALAR_FIELD(winagg);
1247 COPY_LOCATION_FIELD(location);
1256 _copyArrayRef(const ArrayRef *from)
1258 ArrayRef *newnode = makeNode(ArrayRef);
1260 COPY_SCALAR_FIELD(refarraytype);
1261 COPY_SCALAR_FIELD(refelemtype);
1262 COPY_SCALAR_FIELD(reftypmod);
1263 COPY_SCALAR_FIELD(refcollid);
1264 COPY_NODE_FIELD(refupperindexpr);
1265 COPY_NODE_FIELD(reflowerindexpr);
1266 COPY_NODE_FIELD(refexpr);
1267 COPY_NODE_FIELD(refassgnexpr);
1276 _copyFuncExpr(const FuncExpr *from)
1278 FuncExpr *newnode = makeNode(FuncExpr);
1280 COPY_SCALAR_FIELD(funcid);
1281 COPY_SCALAR_FIELD(funcresulttype);
1282 COPY_SCALAR_FIELD(funcretset);
1283 COPY_SCALAR_FIELD(funcvariadic);
1284 COPY_SCALAR_FIELD(funcformat);
1285 COPY_SCALAR_FIELD(funccollid);
1286 COPY_SCALAR_FIELD(inputcollid);
1287 COPY_NODE_FIELD(args);
1288 COPY_LOCATION_FIELD(location);
1294 * _copyNamedArgExpr *
1296 static NamedArgExpr *
1297 _copyNamedArgExpr(const NamedArgExpr *from)
1299 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1301 COPY_NODE_FIELD(arg);
1302 COPY_STRING_FIELD(name);
1303 COPY_SCALAR_FIELD(argnumber);
1304 COPY_LOCATION_FIELD(location);
1313 _copyOpExpr(const OpExpr *from)
1315 OpExpr *newnode = makeNode(OpExpr);
1317 COPY_SCALAR_FIELD(opno);
1318 COPY_SCALAR_FIELD(opfuncid);
1319 COPY_SCALAR_FIELD(opresulttype);
1320 COPY_SCALAR_FIELD(opretset);
1321 COPY_SCALAR_FIELD(opcollid);
1322 COPY_SCALAR_FIELD(inputcollid);
1323 COPY_NODE_FIELD(args);
1324 COPY_LOCATION_FIELD(location);
1330 * _copyDistinctExpr (same as OpExpr)
1332 static DistinctExpr *
1333 _copyDistinctExpr(const DistinctExpr *from)
1335 DistinctExpr *newnode = makeNode(DistinctExpr);
1337 COPY_SCALAR_FIELD(opno);
1338 COPY_SCALAR_FIELD(opfuncid);
1339 COPY_SCALAR_FIELD(opresulttype);
1340 COPY_SCALAR_FIELD(opretset);
1341 COPY_SCALAR_FIELD(opcollid);
1342 COPY_SCALAR_FIELD(inputcollid);
1343 COPY_NODE_FIELD(args);
1344 COPY_LOCATION_FIELD(location);
1350 * _copyNullIfExpr (same as OpExpr)
1353 _copyNullIfExpr(const NullIfExpr *from)
1355 NullIfExpr *newnode = makeNode(NullIfExpr);
1357 COPY_SCALAR_FIELD(opno);
1358 COPY_SCALAR_FIELD(opfuncid);
1359 COPY_SCALAR_FIELD(opresulttype);
1360 COPY_SCALAR_FIELD(opretset);
1361 COPY_SCALAR_FIELD(opcollid);
1362 COPY_SCALAR_FIELD(inputcollid);
1363 COPY_NODE_FIELD(args);
1364 COPY_LOCATION_FIELD(location);
1370 * _copyScalarArrayOpExpr
1372 static ScalarArrayOpExpr *
1373 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
1375 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1377 COPY_SCALAR_FIELD(opno);
1378 COPY_SCALAR_FIELD(opfuncid);
1379 COPY_SCALAR_FIELD(useOr);
1380 COPY_SCALAR_FIELD(inputcollid);
1381 COPY_NODE_FIELD(args);
1382 COPY_LOCATION_FIELD(location);
1391 _copyBoolExpr(const BoolExpr *from)
1393 BoolExpr *newnode = makeNode(BoolExpr);
1395 COPY_SCALAR_FIELD(boolop);
1396 COPY_NODE_FIELD(args);
1397 COPY_LOCATION_FIELD(location);
1406 _copySubLink(const SubLink *from)
1408 SubLink *newnode = makeNode(SubLink);
1410 COPY_SCALAR_FIELD(subLinkType);
1411 COPY_SCALAR_FIELD(subLinkId);
1412 COPY_NODE_FIELD(testexpr);
1413 COPY_NODE_FIELD(operName);
1414 COPY_NODE_FIELD(subselect);
1415 COPY_LOCATION_FIELD(location);
1424 _copySubPlan(const SubPlan *from)
1426 SubPlan *newnode = makeNode(SubPlan);
1428 COPY_SCALAR_FIELD(subLinkType);
1429 COPY_NODE_FIELD(testexpr);
1430 COPY_NODE_FIELD(paramIds);
1431 COPY_SCALAR_FIELD(plan_id);
1432 COPY_STRING_FIELD(plan_name);
1433 COPY_SCALAR_FIELD(firstColType);
1434 COPY_SCALAR_FIELD(firstColTypmod);
1435 COPY_SCALAR_FIELD(firstColCollation);
1436 COPY_SCALAR_FIELD(useHashTable);
1437 COPY_SCALAR_FIELD(unknownEqFalse);
1438 COPY_NODE_FIELD(setParam);
1439 COPY_NODE_FIELD(parParam);
1440 COPY_NODE_FIELD(args);
1441 COPY_SCALAR_FIELD(startup_cost);
1442 COPY_SCALAR_FIELD(per_call_cost);
1448 * _copyAlternativeSubPlan
1450 static AlternativeSubPlan *
1451 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
1453 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1455 COPY_NODE_FIELD(subplans);
1463 static FieldSelect *
1464 _copyFieldSelect(const FieldSelect *from)
1466 FieldSelect *newnode = makeNode(FieldSelect);
1468 COPY_NODE_FIELD(arg);
1469 COPY_SCALAR_FIELD(fieldnum);
1470 COPY_SCALAR_FIELD(resulttype);
1471 COPY_SCALAR_FIELD(resulttypmod);
1472 COPY_SCALAR_FIELD(resultcollid);
1481 _copyFieldStore(const FieldStore *from)
1483 FieldStore *newnode = makeNode(FieldStore);
1485 COPY_NODE_FIELD(arg);
1486 COPY_NODE_FIELD(newvals);
1487 COPY_NODE_FIELD(fieldnums);
1488 COPY_SCALAR_FIELD(resulttype);
1496 static RelabelType *
1497 _copyRelabelType(const RelabelType *from)
1499 RelabelType *newnode = makeNode(RelabelType);
1501 COPY_NODE_FIELD(arg);
1502 COPY_SCALAR_FIELD(resulttype);
1503 COPY_SCALAR_FIELD(resulttypmod);
1504 COPY_SCALAR_FIELD(resultcollid);
1505 COPY_SCALAR_FIELD(relabelformat);
1506 COPY_LOCATION_FIELD(location);
1514 static CoerceViaIO *
1515 _copyCoerceViaIO(const CoerceViaIO *from)
1517 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1519 COPY_NODE_FIELD(arg);
1520 COPY_SCALAR_FIELD(resulttype);
1521 COPY_SCALAR_FIELD(resultcollid);
1522 COPY_SCALAR_FIELD(coerceformat);
1523 COPY_LOCATION_FIELD(location);
1529 * _copyArrayCoerceExpr
1531 static ArrayCoerceExpr *
1532 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
1534 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1536 COPY_NODE_FIELD(arg);
1537 COPY_SCALAR_FIELD(elemfuncid);
1538 COPY_SCALAR_FIELD(resulttype);
1539 COPY_SCALAR_FIELD(resulttypmod);
1540 COPY_SCALAR_FIELD(resultcollid);
1541 COPY_SCALAR_FIELD(isExplicit);
1542 COPY_SCALAR_FIELD(coerceformat);
1543 COPY_LOCATION_FIELD(location);
1549 * _copyConvertRowtypeExpr
1551 static ConvertRowtypeExpr *
1552 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
1554 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1556 COPY_NODE_FIELD(arg);
1557 COPY_SCALAR_FIELD(resulttype);
1558 COPY_SCALAR_FIELD(convertformat);
1559 COPY_LOCATION_FIELD(location);
1567 static CollateExpr *
1568 _copyCollateExpr(const CollateExpr *from)
1570 CollateExpr *newnode = makeNode(CollateExpr);
1572 COPY_NODE_FIELD(arg);
1573 COPY_SCALAR_FIELD(collOid);
1574 COPY_LOCATION_FIELD(location);
1583 _copyCaseExpr(const CaseExpr *from)
1585 CaseExpr *newnode = makeNode(CaseExpr);
1587 COPY_SCALAR_FIELD(casetype);
1588 COPY_SCALAR_FIELD(casecollid);
1589 COPY_NODE_FIELD(arg);
1590 COPY_NODE_FIELD(args);
1591 COPY_NODE_FIELD(defresult);
1592 COPY_LOCATION_FIELD(location);
1601 _copyCaseWhen(const CaseWhen *from)
1603 CaseWhen *newnode = makeNode(CaseWhen);
1605 COPY_NODE_FIELD(expr);
1606 COPY_NODE_FIELD(result);
1607 COPY_LOCATION_FIELD(location);
1615 static CaseTestExpr *
1616 _copyCaseTestExpr(const CaseTestExpr *from)
1618 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1620 COPY_SCALAR_FIELD(typeId);
1621 COPY_SCALAR_FIELD(typeMod);
1622 COPY_SCALAR_FIELD(collation);
1631 _copyArrayExpr(const ArrayExpr *from)
1633 ArrayExpr *newnode = makeNode(ArrayExpr);
1635 COPY_SCALAR_FIELD(array_typeid);
1636 COPY_SCALAR_FIELD(array_collid);
1637 COPY_SCALAR_FIELD(element_typeid);
1638 COPY_NODE_FIELD(elements);
1639 COPY_SCALAR_FIELD(multidims);
1640 COPY_LOCATION_FIELD(location);
1649 _copyRowExpr(const RowExpr *from)
1651 RowExpr *newnode = makeNode(RowExpr);
1653 COPY_NODE_FIELD(args);
1654 COPY_SCALAR_FIELD(row_typeid);
1655 COPY_SCALAR_FIELD(row_format);
1656 COPY_NODE_FIELD(colnames);
1657 COPY_LOCATION_FIELD(location);
1663 * _copyRowCompareExpr
1665 static RowCompareExpr *
1666 _copyRowCompareExpr(const RowCompareExpr *from)
1668 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1670 COPY_SCALAR_FIELD(rctype);
1671 COPY_NODE_FIELD(opnos);
1672 COPY_NODE_FIELD(opfamilies);
1673 COPY_NODE_FIELD(inputcollids);
1674 COPY_NODE_FIELD(largs);
1675 COPY_NODE_FIELD(rargs);
1683 static CoalesceExpr *
1684 _copyCoalesceExpr(const CoalesceExpr *from)
1686 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1688 COPY_SCALAR_FIELD(coalescetype);
1689 COPY_SCALAR_FIELD(coalescecollid);
1690 COPY_NODE_FIELD(args);
1691 COPY_LOCATION_FIELD(location);
1700 _copyMinMaxExpr(const MinMaxExpr *from)
1702 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1704 COPY_SCALAR_FIELD(minmaxtype);
1705 COPY_SCALAR_FIELD(minmaxcollid);
1706 COPY_SCALAR_FIELD(inputcollid);
1707 COPY_SCALAR_FIELD(op);
1708 COPY_NODE_FIELD(args);
1709 COPY_LOCATION_FIELD(location);
1718 _copyXmlExpr(const XmlExpr *from)
1720 XmlExpr *newnode = makeNode(XmlExpr);
1722 COPY_SCALAR_FIELD(op);
1723 COPY_STRING_FIELD(name);
1724 COPY_NODE_FIELD(named_args);
1725 COPY_NODE_FIELD(arg_names);
1726 COPY_NODE_FIELD(args);
1727 COPY_SCALAR_FIELD(xmloption);
1728 COPY_SCALAR_FIELD(type);
1729 COPY_SCALAR_FIELD(typmod);
1730 COPY_LOCATION_FIELD(location);
1739 _copyNullTest(const NullTest *from)
1741 NullTest *newnode = makeNode(NullTest);
1743 COPY_NODE_FIELD(arg);
1744 COPY_SCALAR_FIELD(nulltesttype);
1745 COPY_SCALAR_FIELD(argisrow);
1746 COPY_LOCATION_FIELD(location);
1754 static BooleanTest *
1755 _copyBooleanTest(const BooleanTest *from)
1757 BooleanTest *newnode = makeNode(BooleanTest);
1759 COPY_NODE_FIELD(arg);
1760 COPY_SCALAR_FIELD(booltesttype);
1761 COPY_LOCATION_FIELD(location);
1767 * _copyCoerceToDomain
1769 static CoerceToDomain *
1770 _copyCoerceToDomain(const CoerceToDomain *from)
1772 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1774 COPY_NODE_FIELD(arg);
1775 COPY_SCALAR_FIELD(resulttype);
1776 COPY_SCALAR_FIELD(resulttypmod);
1777 COPY_SCALAR_FIELD(resultcollid);
1778 COPY_SCALAR_FIELD(coercionformat);
1779 COPY_LOCATION_FIELD(location);
1785 * _copyCoerceToDomainValue
1787 static CoerceToDomainValue *
1788 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
1790 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1792 COPY_SCALAR_FIELD(typeId);
1793 COPY_SCALAR_FIELD(typeMod);
1794 COPY_SCALAR_FIELD(collation);
1795 COPY_LOCATION_FIELD(location);
1803 static SetToDefault *
1804 _copySetToDefault(const SetToDefault *from)
1806 SetToDefault *newnode = makeNode(SetToDefault);
1808 COPY_SCALAR_FIELD(typeId);
1809 COPY_SCALAR_FIELD(typeMod);
1810 COPY_SCALAR_FIELD(collation);
1811 COPY_LOCATION_FIELD(location);
1817 * _copyCurrentOfExpr
1819 static CurrentOfExpr *
1820 _copyCurrentOfExpr(const CurrentOfExpr *from)
1822 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1824 COPY_SCALAR_FIELD(cvarno);
1825 COPY_STRING_FIELD(cursor_name);
1826 COPY_SCALAR_FIELD(cursor_param);
1832 * _copyInferenceElem
1834 static InferenceElem *
1835 _copyInferenceElem(const InferenceElem *from)
1837 InferenceElem *newnode = makeNode(InferenceElem);
1839 COPY_NODE_FIELD(expr);
1840 COPY_SCALAR_FIELD(infercollid);
1841 COPY_SCALAR_FIELD(inferopfamily);
1842 COPY_SCALAR_FIELD(inferopcinputtype);
1850 static TargetEntry *
1851 _copyTargetEntry(const TargetEntry *from)
1853 TargetEntry *newnode = makeNode(TargetEntry);
1855 COPY_NODE_FIELD(expr);
1856 COPY_SCALAR_FIELD(resno);
1857 COPY_STRING_FIELD(resname);
1858 COPY_SCALAR_FIELD(ressortgroupref);
1859 COPY_SCALAR_FIELD(resorigtbl);
1860 COPY_SCALAR_FIELD(resorigcol);
1861 COPY_SCALAR_FIELD(resjunk);
1869 static RangeTblRef *
1870 _copyRangeTblRef(const RangeTblRef *from)
1872 RangeTblRef *newnode = makeNode(RangeTblRef);
1874 COPY_SCALAR_FIELD(rtindex);
1883 _copyJoinExpr(const JoinExpr *from)
1885 JoinExpr *newnode = makeNode(JoinExpr);
1887 COPY_SCALAR_FIELD(jointype);
1888 COPY_SCALAR_FIELD(isNatural);
1889 COPY_NODE_FIELD(larg);
1890 COPY_NODE_FIELD(rarg);
1891 COPY_NODE_FIELD(usingClause);
1892 COPY_NODE_FIELD(quals);
1893 COPY_NODE_FIELD(alias);
1894 COPY_SCALAR_FIELD(rtindex);
1903 _copyFromExpr(const FromExpr *from)
1905 FromExpr *newnode = makeNode(FromExpr);
1907 COPY_NODE_FIELD(fromlist);
1908 COPY_NODE_FIELD(quals);
1914 * _copyOnConflictExpr
1916 static OnConflictExpr *
1917 _copyOnConflictExpr(const OnConflictExpr *from)
1919 OnConflictExpr *newnode = makeNode(OnConflictExpr);
1921 COPY_SCALAR_FIELD(action);
1922 COPY_NODE_FIELD(arbiterElems);
1923 COPY_NODE_FIELD(arbiterWhere);
1924 COPY_NODE_FIELD(onConflictSet);
1925 COPY_NODE_FIELD(onConflictWhere);
1926 COPY_SCALAR_FIELD(constraint);
1927 COPY_SCALAR_FIELD(exclRelIndex);
1928 COPY_NODE_FIELD(exclRelTlist);
1933 /* ****************************************************************
1934 * relation.h copy functions
1936 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1937 * There are some subsidiary structs that are useful to copy, though.
1938 * ****************************************************************
1945 _copyPathKey(const PathKey *from)
1947 PathKey *newnode = makeNode(PathKey);
1949 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1950 COPY_SCALAR_FIELD(pk_eclass);
1951 COPY_SCALAR_FIELD(pk_opfamily);
1952 COPY_SCALAR_FIELD(pk_strategy);
1953 COPY_SCALAR_FIELD(pk_nulls_first);
1961 static RestrictInfo *
1962 _copyRestrictInfo(const RestrictInfo *from)
1964 RestrictInfo *newnode = makeNode(RestrictInfo);
1966 COPY_NODE_FIELD(clause);
1967 COPY_SCALAR_FIELD(is_pushed_down);
1968 COPY_SCALAR_FIELD(outerjoin_delayed);
1969 COPY_SCALAR_FIELD(can_join);
1970 COPY_SCALAR_FIELD(pseudoconstant);
1971 COPY_BITMAPSET_FIELD(clause_relids);
1972 COPY_BITMAPSET_FIELD(required_relids);
1973 COPY_BITMAPSET_FIELD(outer_relids);
1974 COPY_BITMAPSET_FIELD(nullable_relids);
1975 COPY_BITMAPSET_FIELD(left_relids);
1976 COPY_BITMAPSET_FIELD(right_relids);
1977 COPY_NODE_FIELD(orclause);
1978 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1979 COPY_SCALAR_FIELD(parent_ec);
1980 COPY_SCALAR_FIELD(eval_cost);
1981 COPY_SCALAR_FIELD(norm_selec);
1982 COPY_SCALAR_FIELD(outer_selec);
1983 COPY_NODE_FIELD(mergeopfamilies);
1984 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1985 COPY_SCALAR_FIELD(left_ec);
1986 COPY_SCALAR_FIELD(right_ec);
1987 COPY_SCALAR_FIELD(left_em);
1988 COPY_SCALAR_FIELD(right_em);
1989 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1990 newnode->scansel_cache = NIL;
1991 COPY_SCALAR_FIELD(outer_is_left);
1992 COPY_SCALAR_FIELD(hashjoinoperator);
1993 COPY_SCALAR_FIELD(left_bucketsize);
1994 COPY_SCALAR_FIELD(right_bucketsize);
2000 * _copyPlaceHolderVar
2002 static PlaceHolderVar *
2003 _copyPlaceHolderVar(const PlaceHolderVar *from)
2005 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
2007 COPY_NODE_FIELD(phexpr);
2008 COPY_BITMAPSET_FIELD(phrels);
2009 COPY_SCALAR_FIELD(phid);
2010 COPY_SCALAR_FIELD(phlevelsup);
2016 * _copySpecialJoinInfo
2018 static SpecialJoinInfo *
2019 _copySpecialJoinInfo(const SpecialJoinInfo *from)
2021 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
2023 COPY_BITMAPSET_FIELD(min_lefthand);
2024 COPY_BITMAPSET_FIELD(min_righthand);
2025 COPY_BITMAPSET_FIELD(syn_lefthand);
2026 COPY_BITMAPSET_FIELD(syn_righthand);
2027 COPY_SCALAR_FIELD(jointype);
2028 COPY_SCALAR_FIELD(lhs_strict);
2029 COPY_SCALAR_FIELD(delay_upper_joins);
2030 COPY_SCALAR_FIELD(semi_can_btree);
2031 COPY_SCALAR_FIELD(semi_can_hash);
2032 COPY_NODE_FIELD(semi_operators);
2033 COPY_NODE_FIELD(semi_rhs_exprs);
2039 * _copyLateralJoinInfo
2041 static LateralJoinInfo *
2042 _copyLateralJoinInfo(const LateralJoinInfo *from)
2044 LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
2046 COPY_BITMAPSET_FIELD(lateral_lhs);
2047 COPY_BITMAPSET_FIELD(lateral_rhs);
2053 * _copyAppendRelInfo
2055 static AppendRelInfo *
2056 _copyAppendRelInfo(const AppendRelInfo *from)
2058 AppendRelInfo *newnode = makeNode(AppendRelInfo);
2060 COPY_SCALAR_FIELD(parent_relid);
2061 COPY_SCALAR_FIELD(child_relid);
2062 COPY_SCALAR_FIELD(parent_reltype);
2063 COPY_SCALAR_FIELD(child_reltype);
2064 COPY_NODE_FIELD(translated_vars);
2065 COPY_SCALAR_FIELD(parent_reloid);
2071 * _copyPlaceHolderInfo
2073 static PlaceHolderInfo *
2074 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
2076 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
2078 COPY_SCALAR_FIELD(phid);
2079 COPY_NODE_FIELD(ph_var);
2080 COPY_BITMAPSET_FIELD(ph_eval_at);
2081 COPY_BITMAPSET_FIELD(ph_lateral);
2082 COPY_BITMAPSET_FIELD(ph_needed);
2083 COPY_SCALAR_FIELD(ph_width);
2088 /* ****************************************************************
2089 * parsenodes.h copy functions
2090 * ****************************************************************
2093 static RangeTblEntry *
2094 _copyRangeTblEntry(const RangeTblEntry *from)
2096 RangeTblEntry *newnode = makeNode(RangeTblEntry);
2098 COPY_SCALAR_FIELD(rtekind);
2099 COPY_SCALAR_FIELD(relid);
2100 COPY_SCALAR_FIELD(relkind);
2101 COPY_NODE_FIELD(tablesample);
2102 COPY_NODE_FIELD(subquery);
2103 COPY_SCALAR_FIELD(security_barrier);
2104 COPY_SCALAR_FIELD(jointype);
2105 COPY_NODE_FIELD(joinaliasvars);
2106 COPY_NODE_FIELD(functions);
2107 COPY_SCALAR_FIELD(funcordinality);
2108 COPY_NODE_FIELD(values_lists);
2109 COPY_NODE_FIELD(values_collations);
2110 COPY_STRING_FIELD(ctename);
2111 COPY_SCALAR_FIELD(ctelevelsup);
2112 COPY_SCALAR_FIELD(self_reference);
2113 COPY_NODE_FIELD(ctecoltypes);
2114 COPY_NODE_FIELD(ctecoltypmods);
2115 COPY_NODE_FIELD(ctecolcollations);
2116 COPY_NODE_FIELD(alias);
2117 COPY_NODE_FIELD(eref);
2118 COPY_SCALAR_FIELD(lateral);
2119 COPY_SCALAR_FIELD(inh);
2120 COPY_SCALAR_FIELD(inFromCl);
2121 COPY_SCALAR_FIELD(requiredPerms);
2122 COPY_SCALAR_FIELD(checkAsUser);
2123 COPY_BITMAPSET_FIELD(selectedCols);
2124 COPY_BITMAPSET_FIELD(insertedCols);
2125 COPY_BITMAPSET_FIELD(updatedCols);
2126 COPY_NODE_FIELD(securityQuals);
2131 static RangeTblFunction *
2132 _copyRangeTblFunction(const RangeTblFunction *from)
2134 RangeTblFunction *newnode = makeNode(RangeTblFunction);
2136 COPY_NODE_FIELD(funcexpr);
2137 COPY_SCALAR_FIELD(funccolcount);
2138 COPY_NODE_FIELD(funccolnames);
2139 COPY_NODE_FIELD(funccoltypes);
2140 COPY_NODE_FIELD(funccoltypmods);
2141 COPY_NODE_FIELD(funccolcollations);
2142 COPY_BITMAPSET_FIELD(funcparams);
2147 static WithCheckOption *
2148 _copyWithCheckOption(const WithCheckOption *from)
2150 WithCheckOption *newnode = makeNode(WithCheckOption);
2152 COPY_SCALAR_FIELD(kind);
2153 COPY_STRING_FIELD(relname);
2154 COPY_NODE_FIELD(qual);
2155 COPY_SCALAR_FIELD(cascaded);
2160 static SortGroupClause *
2161 _copySortGroupClause(const SortGroupClause *from)
2163 SortGroupClause *newnode = makeNode(SortGroupClause);
2165 COPY_SCALAR_FIELD(tleSortGroupRef);
2166 COPY_SCALAR_FIELD(eqop);
2167 COPY_SCALAR_FIELD(sortop);
2168 COPY_SCALAR_FIELD(nulls_first);
2169 COPY_SCALAR_FIELD(hashable);
2174 static GroupingSet *
2175 _copyGroupingSet(const GroupingSet *from)
2177 GroupingSet *newnode = makeNode(GroupingSet);
2179 COPY_SCALAR_FIELD(kind);
2180 COPY_NODE_FIELD(content);
2181 COPY_LOCATION_FIELD(location);
2186 static WindowClause *
2187 _copyWindowClause(const WindowClause *from)
2189 WindowClause *newnode = makeNode(WindowClause);
2191 COPY_STRING_FIELD(name);
2192 COPY_STRING_FIELD(refname);
2193 COPY_NODE_FIELD(partitionClause);
2194 COPY_NODE_FIELD(orderClause);
2195 COPY_SCALAR_FIELD(frameOptions);
2196 COPY_NODE_FIELD(startOffset);
2197 COPY_NODE_FIELD(endOffset);
2198 COPY_SCALAR_FIELD(winref);
2199 COPY_SCALAR_FIELD(copiedOrder);
2204 static RowMarkClause *
2205 _copyRowMarkClause(const RowMarkClause *from)
2207 RowMarkClause *newnode = makeNode(RowMarkClause);
2209 COPY_SCALAR_FIELD(rti);
2210 COPY_SCALAR_FIELD(strength);
2211 COPY_SCALAR_FIELD(waitPolicy);
2212 COPY_SCALAR_FIELD(pushedDown);
2218 _copyWithClause(const WithClause *from)
2220 WithClause *newnode = makeNode(WithClause);
2222 COPY_NODE_FIELD(ctes);
2223 COPY_SCALAR_FIELD(recursive);
2224 COPY_LOCATION_FIELD(location);
2229 static InferClause *
2230 _copyInferClause(const InferClause *from)
2232 InferClause *newnode = makeNode(InferClause);
2234 COPY_NODE_FIELD(indexElems);
2235 COPY_NODE_FIELD(whereClause);
2236 COPY_STRING_FIELD(conname);
2237 COPY_LOCATION_FIELD(location);
2242 static OnConflictClause *
2243 _copyOnConflictClause(const OnConflictClause *from)
2245 OnConflictClause *newnode = makeNode(OnConflictClause);
2247 COPY_SCALAR_FIELD(action);
2248 COPY_NODE_FIELD(infer);
2249 COPY_NODE_FIELD(targetList);
2250 COPY_NODE_FIELD(whereClause);
2251 COPY_LOCATION_FIELD(location);
2256 static CommonTableExpr *
2257 _copyCommonTableExpr(const CommonTableExpr *from)
2259 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2261 COPY_STRING_FIELD(ctename);
2262 COPY_NODE_FIELD(aliascolnames);
2263 COPY_NODE_FIELD(ctequery);
2264 COPY_LOCATION_FIELD(location);
2265 COPY_SCALAR_FIELD(cterecursive);
2266 COPY_SCALAR_FIELD(cterefcount);
2267 COPY_NODE_FIELD(ctecolnames);
2268 COPY_NODE_FIELD(ctecoltypes);
2269 COPY_NODE_FIELD(ctecoltypmods);
2270 COPY_NODE_FIELD(ctecolcollations);
2275 static RangeTableSample *
2276 _copyRangeTableSample(const RangeTableSample *from)
2278 RangeTableSample *newnode = makeNode(RangeTableSample);
2280 COPY_NODE_FIELD(relation);
2281 COPY_STRING_FIELD(method);
2282 COPY_NODE_FIELD(repeatable);
2283 COPY_NODE_FIELD(args);
2288 static TableSampleClause *
2289 _copyTableSampleClause(const TableSampleClause *from)
2291 TableSampleClause *newnode = makeNode(TableSampleClause);
2293 COPY_SCALAR_FIELD(tsmid);
2294 COPY_SCALAR_FIELD(tsmseqscan);
2295 COPY_SCALAR_FIELD(tsmpagemode);
2296 COPY_SCALAR_FIELD(tsminit);
2297 COPY_SCALAR_FIELD(tsmnextblock);
2298 COPY_SCALAR_FIELD(tsmnexttuple);
2299 COPY_SCALAR_FIELD(tsmexaminetuple);
2300 COPY_SCALAR_FIELD(tsmend);
2301 COPY_SCALAR_FIELD(tsmreset);
2302 COPY_SCALAR_FIELD(tsmcost);
2303 COPY_NODE_FIELD(repeatable);
2304 COPY_NODE_FIELD(args);
2310 _copyAExpr(const A_Expr *from)
2312 A_Expr *newnode = makeNode(A_Expr);
2314 COPY_SCALAR_FIELD(kind);
2315 COPY_NODE_FIELD(name);
2316 COPY_NODE_FIELD(lexpr);
2317 COPY_NODE_FIELD(rexpr);
2318 COPY_LOCATION_FIELD(location);
2324 _copyColumnRef(const ColumnRef *from)
2326 ColumnRef *newnode = makeNode(ColumnRef);
2328 COPY_NODE_FIELD(fields);
2329 COPY_LOCATION_FIELD(location);
2335 _copyParamRef(const ParamRef *from)
2337 ParamRef *newnode = makeNode(ParamRef);
2339 COPY_SCALAR_FIELD(number);
2340 COPY_LOCATION_FIELD(location);
2346 _copyAConst(const A_Const *from)
2348 A_Const *newnode = makeNode(A_Const);
2350 /* This part must duplicate _copyValue */
2351 COPY_SCALAR_FIELD(val.type);
2352 switch (from->val.type)
2355 COPY_SCALAR_FIELD(val.val.ival);
2360 COPY_STRING_FIELD(val.val.str);
2366 elog(ERROR, "unrecognized node type: %d",
2367 (int) from->val.type);
2371 COPY_LOCATION_FIELD(location);
2377 _copyFuncCall(const FuncCall *from)
2379 FuncCall *newnode = makeNode(FuncCall);
2381 COPY_NODE_FIELD(funcname);
2382 COPY_NODE_FIELD(args);
2383 COPY_NODE_FIELD(agg_order);
2384 COPY_NODE_FIELD(agg_filter);
2385 COPY_SCALAR_FIELD(agg_within_group);
2386 COPY_SCALAR_FIELD(agg_star);
2387 COPY_SCALAR_FIELD(agg_distinct);
2388 COPY_SCALAR_FIELD(func_variadic);
2389 COPY_NODE_FIELD(over);
2390 COPY_LOCATION_FIELD(location);
2396 _copyAStar(const A_Star *from)
2398 A_Star *newnode = makeNode(A_Star);
2404 _copyAIndices(const A_Indices *from)
2406 A_Indices *newnode = makeNode(A_Indices);
2408 COPY_NODE_FIELD(lidx);
2409 COPY_NODE_FIELD(uidx);
2414 static A_Indirection *
2415 _copyA_Indirection(const A_Indirection *from)
2417 A_Indirection *newnode = makeNode(A_Indirection);
2419 COPY_NODE_FIELD(arg);
2420 COPY_NODE_FIELD(indirection);
2425 static A_ArrayExpr *
2426 _copyA_ArrayExpr(const A_ArrayExpr *from)
2428 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2430 COPY_NODE_FIELD(elements);
2431 COPY_LOCATION_FIELD(location);
2437 _copyResTarget(const ResTarget *from)
2439 ResTarget *newnode = makeNode(ResTarget);
2441 COPY_STRING_FIELD(name);
2442 COPY_NODE_FIELD(indirection);
2443 COPY_NODE_FIELD(val);
2444 COPY_LOCATION_FIELD(location);
2449 static MultiAssignRef *
2450 _copyMultiAssignRef(const MultiAssignRef *from)
2452 MultiAssignRef *newnode = makeNode(MultiAssignRef);
2454 COPY_NODE_FIELD(source);
2455 COPY_SCALAR_FIELD(colno);
2456 COPY_SCALAR_FIELD(ncolumns);
2462 _copyTypeName(const TypeName *from)
2464 TypeName *newnode = makeNode(TypeName);
2466 COPY_NODE_FIELD(names);
2467 COPY_SCALAR_FIELD(typeOid);
2468 COPY_SCALAR_FIELD(setof);
2469 COPY_SCALAR_FIELD(pct_type);
2470 COPY_NODE_FIELD(typmods);
2471 COPY_SCALAR_FIELD(typemod);
2472 COPY_NODE_FIELD(arrayBounds);
2473 COPY_LOCATION_FIELD(location);
2479 _copySortBy(const SortBy *from)
2481 SortBy *newnode = makeNode(SortBy);
2483 COPY_NODE_FIELD(node);
2484 COPY_SCALAR_FIELD(sortby_dir);
2485 COPY_SCALAR_FIELD(sortby_nulls);
2486 COPY_NODE_FIELD(useOp);
2487 COPY_LOCATION_FIELD(location);
2493 _copyWindowDef(const WindowDef *from)
2495 WindowDef *newnode = makeNode(WindowDef);
2497 COPY_STRING_FIELD(name);
2498 COPY_STRING_FIELD(refname);
2499 COPY_NODE_FIELD(partitionClause);
2500 COPY_NODE_FIELD(orderClause);
2501 COPY_SCALAR_FIELD(frameOptions);
2502 COPY_NODE_FIELD(startOffset);
2503 COPY_NODE_FIELD(endOffset);
2504 COPY_LOCATION_FIELD(location);
2509 static RangeSubselect *
2510 _copyRangeSubselect(const RangeSubselect *from)
2512 RangeSubselect *newnode = makeNode(RangeSubselect);
2514 COPY_SCALAR_FIELD(lateral);
2515 COPY_NODE_FIELD(subquery);
2516 COPY_NODE_FIELD(alias);
2521 static RangeFunction *
2522 _copyRangeFunction(const RangeFunction *from)
2524 RangeFunction *newnode = makeNode(RangeFunction);
2526 COPY_SCALAR_FIELD(lateral);
2527 COPY_SCALAR_FIELD(ordinality);
2528 COPY_SCALAR_FIELD(is_rowsfrom);
2529 COPY_NODE_FIELD(functions);
2530 COPY_NODE_FIELD(alias);
2531 COPY_NODE_FIELD(coldeflist);
2537 _copyTypeCast(const TypeCast *from)
2539 TypeCast *newnode = makeNode(TypeCast);
2541 COPY_NODE_FIELD(arg);
2542 COPY_NODE_FIELD(typeName);
2543 COPY_LOCATION_FIELD(location);
2548 static CollateClause *
2549 _copyCollateClause(const CollateClause *from)
2551 CollateClause *newnode = makeNode(CollateClause);
2553 COPY_NODE_FIELD(arg);
2554 COPY_NODE_FIELD(collname);
2555 COPY_LOCATION_FIELD(location);
2561 _copyIndexElem(const IndexElem *from)
2563 IndexElem *newnode = makeNode(IndexElem);
2565 COPY_STRING_FIELD(name);
2566 COPY_NODE_FIELD(expr);
2567 COPY_STRING_FIELD(indexcolname);
2568 COPY_NODE_FIELD(collation);
2569 COPY_NODE_FIELD(opclass);
2570 COPY_SCALAR_FIELD(ordering);
2571 COPY_SCALAR_FIELD(nulls_ordering);
2577 _copyColumnDef(const ColumnDef *from)
2579 ColumnDef *newnode = makeNode(ColumnDef);
2581 COPY_STRING_FIELD(colname);
2582 COPY_NODE_FIELD(typeName);
2583 COPY_SCALAR_FIELD(inhcount);
2584 COPY_SCALAR_FIELD(is_local);
2585 COPY_SCALAR_FIELD(is_not_null);
2586 COPY_SCALAR_FIELD(is_from_type);
2587 COPY_SCALAR_FIELD(storage);
2588 COPY_NODE_FIELD(raw_default);
2589 COPY_NODE_FIELD(cooked_default);
2590 COPY_NODE_FIELD(collClause);
2591 COPY_SCALAR_FIELD(collOid);
2592 COPY_NODE_FIELD(constraints);
2593 COPY_NODE_FIELD(fdwoptions);
2594 COPY_LOCATION_FIELD(location);
2600 _copyConstraint(const Constraint *from)
2602 Constraint *newnode = makeNode(Constraint);
2604 COPY_SCALAR_FIELD(contype);
2605 COPY_STRING_FIELD(conname);
2606 COPY_SCALAR_FIELD(deferrable);
2607 COPY_SCALAR_FIELD(initdeferred);
2608 COPY_LOCATION_FIELD(location);
2609 COPY_SCALAR_FIELD(is_no_inherit);
2610 COPY_NODE_FIELD(raw_expr);
2611 COPY_STRING_FIELD(cooked_expr);
2612 COPY_NODE_FIELD(keys);
2613 COPY_NODE_FIELD(exclusions);
2614 COPY_NODE_FIELD(options);
2615 COPY_STRING_FIELD(indexname);
2616 COPY_STRING_FIELD(indexspace);
2617 COPY_STRING_FIELD(access_method);
2618 COPY_NODE_FIELD(where_clause);
2619 COPY_NODE_FIELD(pktable);
2620 COPY_NODE_FIELD(fk_attrs);
2621 COPY_NODE_FIELD(pk_attrs);
2622 COPY_SCALAR_FIELD(fk_matchtype);
2623 COPY_SCALAR_FIELD(fk_upd_action);
2624 COPY_SCALAR_FIELD(fk_del_action);
2625 COPY_NODE_FIELD(old_conpfeqop);
2626 COPY_SCALAR_FIELD(old_pktable_oid);
2627 COPY_SCALAR_FIELD(skip_validation);
2628 COPY_SCALAR_FIELD(initially_valid);
2634 _copyDefElem(const DefElem *from)
2636 DefElem *newnode = makeNode(DefElem);
2638 COPY_STRING_FIELD(defnamespace);
2639 COPY_STRING_FIELD(defname);
2640 COPY_NODE_FIELD(arg);
2641 COPY_SCALAR_FIELD(defaction);
2646 static LockingClause *
2647 _copyLockingClause(const LockingClause *from)
2649 LockingClause *newnode = makeNode(LockingClause);
2651 COPY_NODE_FIELD(lockedRels);
2652 COPY_SCALAR_FIELD(strength);
2653 COPY_SCALAR_FIELD(waitPolicy);
2658 static XmlSerialize *
2659 _copyXmlSerialize(const XmlSerialize *from)
2661 XmlSerialize *newnode = makeNode(XmlSerialize);
2663 COPY_SCALAR_FIELD(xmloption);
2664 COPY_NODE_FIELD(expr);
2665 COPY_NODE_FIELD(typeName);
2666 COPY_LOCATION_FIELD(location);
2672 _copyRoleSpec(const RoleSpec *from)
2674 RoleSpec *newnode = makeNode(RoleSpec);
2676 COPY_SCALAR_FIELD(roletype);
2677 COPY_STRING_FIELD(rolename);
2678 COPY_LOCATION_FIELD(location);
2684 _copyQuery(const Query *from)
2686 Query *newnode = makeNode(Query);
2688 COPY_SCALAR_FIELD(commandType);
2689 COPY_SCALAR_FIELD(querySource);
2690 COPY_SCALAR_FIELD(queryId);
2691 COPY_SCALAR_FIELD(canSetTag);
2692 COPY_NODE_FIELD(utilityStmt);
2693 COPY_SCALAR_FIELD(resultRelation);
2694 COPY_SCALAR_FIELD(hasAggs);
2695 COPY_SCALAR_FIELD(hasWindowFuncs);
2696 COPY_SCALAR_FIELD(hasSubLinks);
2697 COPY_SCALAR_FIELD(hasDistinctOn);
2698 COPY_SCALAR_FIELD(hasRecursive);
2699 COPY_SCALAR_FIELD(hasModifyingCTE);
2700 COPY_SCALAR_FIELD(hasForUpdate);
2701 COPY_SCALAR_FIELD(hasRowSecurity);
2702 COPY_NODE_FIELD(cteList);
2703 COPY_NODE_FIELD(rtable);
2704 COPY_NODE_FIELD(jointree);
2705 COPY_NODE_FIELD(targetList);
2706 COPY_NODE_FIELD(withCheckOptions);
2707 COPY_NODE_FIELD(onConflict);
2708 COPY_NODE_FIELD(returningList);
2709 COPY_NODE_FIELD(groupClause);
2710 COPY_NODE_FIELD(groupingSets);
2711 COPY_NODE_FIELD(havingQual);
2712 COPY_NODE_FIELD(windowClause);
2713 COPY_NODE_FIELD(distinctClause);
2714 COPY_NODE_FIELD(sortClause);
2715 COPY_NODE_FIELD(limitOffset);
2716 COPY_NODE_FIELD(limitCount);
2717 COPY_NODE_FIELD(rowMarks);
2718 COPY_NODE_FIELD(setOperations);
2719 COPY_NODE_FIELD(constraintDeps);
2725 _copyInsertStmt(const InsertStmt *from)
2727 InsertStmt *newnode = makeNode(InsertStmt);
2729 COPY_NODE_FIELD(relation);
2730 COPY_NODE_FIELD(cols);
2731 COPY_NODE_FIELD(selectStmt);
2732 COPY_NODE_FIELD(onConflictClause);
2733 COPY_NODE_FIELD(returningList);
2734 COPY_NODE_FIELD(withClause);
2740 _copyDeleteStmt(const DeleteStmt *from)
2742 DeleteStmt *newnode = makeNode(DeleteStmt);
2744 COPY_NODE_FIELD(relation);
2745 COPY_NODE_FIELD(usingClause);
2746 COPY_NODE_FIELD(whereClause);
2747 COPY_NODE_FIELD(returningList);
2748 COPY_NODE_FIELD(withClause);
2754 _copyUpdateStmt(const UpdateStmt *from)
2756 UpdateStmt *newnode = makeNode(UpdateStmt);
2758 COPY_NODE_FIELD(relation);
2759 COPY_NODE_FIELD(targetList);
2760 COPY_NODE_FIELD(whereClause);
2761 COPY_NODE_FIELD(fromClause);
2762 COPY_NODE_FIELD(returningList);
2763 COPY_NODE_FIELD(withClause);
2769 _copySelectStmt(const SelectStmt *from)
2771 SelectStmt *newnode = makeNode(SelectStmt);
2773 COPY_NODE_FIELD(distinctClause);
2774 COPY_NODE_FIELD(intoClause);
2775 COPY_NODE_FIELD(targetList);
2776 COPY_NODE_FIELD(fromClause);
2777 COPY_NODE_FIELD(whereClause);
2778 COPY_NODE_FIELD(groupClause);
2779 COPY_NODE_FIELD(havingClause);
2780 COPY_NODE_FIELD(windowClause);
2781 COPY_NODE_FIELD(valuesLists);
2782 COPY_NODE_FIELD(sortClause);
2783 COPY_NODE_FIELD(limitOffset);
2784 COPY_NODE_FIELD(limitCount);
2785 COPY_NODE_FIELD(lockingClause);
2786 COPY_NODE_FIELD(withClause);
2787 COPY_SCALAR_FIELD(op);
2788 COPY_SCALAR_FIELD(all);
2789 COPY_NODE_FIELD(larg);
2790 COPY_NODE_FIELD(rarg);
2795 static SetOperationStmt *
2796 _copySetOperationStmt(const SetOperationStmt *from)
2798 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2800 COPY_SCALAR_FIELD(op);
2801 COPY_SCALAR_FIELD(all);
2802 COPY_NODE_FIELD(larg);
2803 COPY_NODE_FIELD(rarg);
2804 COPY_NODE_FIELD(colTypes);
2805 COPY_NODE_FIELD(colTypmods);
2806 COPY_NODE_FIELD(colCollations);
2807 COPY_NODE_FIELD(groupClauses);
2812 static AlterTableStmt *
2813 _copyAlterTableStmt(const AlterTableStmt *from)
2815 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2817 COPY_NODE_FIELD(relation);
2818 COPY_NODE_FIELD(cmds);
2819 COPY_SCALAR_FIELD(relkind);
2820 COPY_SCALAR_FIELD(missing_ok);
2825 static AlterTableCmd *
2826 _copyAlterTableCmd(const AlterTableCmd *from)
2828 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2830 COPY_SCALAR_FIELD(subtype);
2831 COPY_STRING_FIELD(name);
2832 COPY_NODE_FIELD(newowner);
2833 COPY_NODE_FIELD(def);
2834 COPY_SCALAR_FIELD(behavior);
2835 COPY_SCALAR_FIELD(missing_ok);
2840 static AlterDomainStmt *
2841 _copyAlterDomainStmt(const AlterDomainStmt *from)
2843 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2845 COPY_SCALAR_FIELD(subtype);
2846 COPY_NODE_FIELD(typeName);
2847 COPY_STRING_FIELD(name);
2848 COPY_NODE_FIELD(def);
2849 COPY_SCALAR_FIELD(behavior);
2850 COPY_SCALAR_FIELD(missing_ok);
2856 _copyGrantStmt(const GrantStmt *from)
2858 GrantStmt *newnode = makeNode(GrantStmt);
2860 COPY_SCALAR_FIELD(is_grant);
2861 COPY_SCALAR_FIELD(targtype);
2862 COPY_SCALAR_FIELD(objtype);
2863 COPY_NODE_FIELD(objects);
2864 COPY_NODE_FIELD(privileges);
2865 COPY_NODE_FIELD(grantees);
2866 COPY_SCALAR_FIELD(grant_option);
2867 COPY_SCALAR_FIELD(behavior);
2872 static FuncWithArgs *
2873 _copyFuncWithArgs(const FuncWithArgs *from)
2875 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2877 COPY_NODE_FIELD(funcname);
2878 COPY_NODE_FIELD(funcargs);
2884 _copyAccessPriv(const AccessPriv *from)
2886 AccessPriv *newnode = makeNode(AccessPriv);
2888 COPY_STRING_FIELD(priv_name);
2889 COPY_NODE_FIELD(cols);
2894 static GrantRoleStmt *
2895 _copyGrantRoleStmt(const GrantRoleStmt *from)
2897 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2899 COPY_NODE_FIELD(granted_roles);
2900 COPY_NODE_FIELD(grantee_roles);
2901 COPY_SCALAR_FIELD(is_grant);
2902 COPY_SCALAR_FIELD(admin_opt);
2903 COPY_NODE_FIELD(grantor);
2904 COPY_SCALAR_FIELD(behavior);
2909 static AlterDefaultPrivilegesStmt *
2910 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
2912 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2914 COPY_NODE_FIELD(options);
2915 COPY_NODE_FIELD(action);
2920 static DeclareCursorStmt *
2921 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
2923 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2925 COPY_STRING_FIELD(portalname);
2926 COPY_SCALAR_FIELD(options);
2927 COPY_NODE_FIELD(query);
2932 static ClosePortalStmt *
2933 _copyClosePortalStmt(const ClosePortalStmt *from)
2935 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2937 COPY_STRING_FIELD(portalname);
2942 static ClusterStmt *
2943 _copyClusterStmt(const ClusterStmt *from)
2945 ClusterStmt *newnode = makeNode(ClusterStmt);
2947 COPY_NODE_FIELD(relation);
2948 COPY_STRING_FIELD(indexname);
2949 COPY_SCALAR_FIELD(verbose);
2955 _copyCopyStmt(const CopyStmt *from)
2957 CopyStmt *newnode = makeNode(CopyStmt);
2959 COPY_NODE_FIELD(relation);
2960 COPY_NODE_FIELD(query);
2961 COPY_NODE_FIELD(attlist);
2962 COPY_SCALAR_FIELD(is_from);
2963 COPY_SCALAR_FIELD(is_program);
2964 COPY_STRING_FIELD(filename);
2965 COPY_NODE_FIELD(options);
2971 * CopyCreateStmtFields
2973 * This function copies the fields of the CreateStmt node. It is used by
2974 * copy functions for classes which inherit from CreateStmt.
2977 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
2979 COPY_NODE_FIELD(relation);
2980 COPY_NODE_FIELD(tableElts);
2981 COPY_NODE_FIELD(inhRelations);
2982 COPY_NODE_FIELD(ofTypename);
2983 COPY_NODE_FIELD(constraints);
2984 COPY_NODE_FIELD(options);
2985 COPY_SCALAR_FIELD(oncommit);
2986 COPY_STRING_FIELD(tablespacename);
2987 COPY_SCALAR_FIELD(if_not_exists);
2991 _copyCreateStmt(const CreateStmt *from)
2993 CreateStmt *newnode = makeNode(CreateStmt);
2995 CopyCreateStmtFields(from, newnode);
3000 static TableLikeClause *
3001 _copyTableLikeClause(const TableLikeClause *from)
3003 TableLikeClause *newnode = makeNode(TableLikeClause);
3005 COPY_NODE_FIELD(relation);
3006 COPY_SCALAR_FIELD(options);
3012 _copyDefineStmt(const DefineStmt *from)
3014 DefineStmt *newnode = makeNode(DefineStmt);
3016 COPY_SCALAR_FIELD(kind);
3017 COPY_SCALAR_FIELD(oldstyle);
3018 COPY_NODE_FIELD(defnames);
3019 COPY_NODE_FIELD(args);
3020 COPY_NODE_FIELD(definition);
3026 _copyDropStmt(const DropStmt *from)
3028 DropStmt *newnode = makeNode(DropStmt);
3030 COPY_NODE_FIELD(objects);
3031 COPY_NODE_FIELD(arguments);
3032 COPY_SCALAR_FIELD(removeType);
3033 COPY_SCALAR_FIELD(behavior);
3034 COPY_SCALAR_FIELD(missing_ok);
3035 COPY_SCALAR_FIELD(concurrent);
3040 static TruncateStmt *
3041 _copyTruncateStmt(const TruncateStmt *from)
3043 TruncateStmt *newnode = makeNode(TruncateStmt);
3045 COPY_NODE_FIELD(relations);
3046 COPY_SCALAR_FIELD(restart_seqs);
3047 COPY_SCALAR_FIELD(behavior);
3052 static CommentStmt *
3053 _copyCommentStmt(const CommentStmt *from)
3055 CommentStmt *newnode = makeNode(CommentStmt);
3057 COPY_SCALAR_FIELD(objtype);
3058 COPY_NODE_FIELD(objname);
3059 COPY_NODE_FIELD(objargs);
3060 COPY_STRING_FIELD(comment);
3065 static SecLabelStmt *
3066 _copySecLabelStmt(const SecLabelStmt *from)
3068 SecLabelStmt *newnode = makeNode(SecLabelStmt);
3070 COPY_SCALAR_FIELD(objtype);
3071 COPY_NODE_FIELD(objname);
3072 COPY_NODE_FIELD(objargs);
3073 COPY_STRING_FIELD(provider);
3074 COPY_STRING_FIELD(label);
3080 _copyFetchStmt(const FetchStmt *from)
3082 FetchStmt *newnode = makeNode(FetchStmt);
3084 COPY_SCALAR_FIELD(direction);
3085 COPY_SCALAR_FIELD(howMany);
3086 COPY_STRING_FIELD(portalname);
3087 COPY_SCALAR_FIELD(ismove);
3093 _copyIndexStmt(const IndexStmt *from)
3095 IndexStmt *newnode = makeNode(IndexStmt);
3097 COPY_STRING_FIELD(idxname);
3098 COPY_NODE_FIELD(relation);
3099 COPY_STRING_FIELD(accessMethod);
3100 COPY_STRING_FIELD(tableSpace);
3101 COPY_NODE_FIELD(indexParams);
3102 COPY_NODE_FIELD(options);
3103 COPY_NODE_FIELD(whereClause);
3104 COPY_NODE_FIELD(excludeOpNames);
3105 COPY_STRING_FIELD(idxcomment);
3106 COPY_SCALAR_FIELD(indexOid);
3107 COPY_SCALAR_FIELD(oldNode);
3108 COPY_SCALAR_FIELD(unique);
3109 COPY_SCALAR_FIELD(primary);
3110 COPY_SCALAR_FIELD(isconstraint);
3111 COPY_SCALAR_FIELD(deferrable);
3112 COPY_SCALAR_FIELD(initdeferred);
3113 COPY_SCALAR_FIELD(transformed);
3114 COPY_SCALAR_FIELD(concurrent);
3115 COPY_SCALAR_FIELD(if_not_exists);
3120 static CreateFunctionStmt *
3121 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
3123 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
3125 COPY_SCALAR_FIELD(replace);
3126 COPY_NODE_FIELD(funcname);
3127 COPY_NODE_FIELD(parameters);
3128 COPY_NODE_FIELD(returnType);
3129 COPY_NODE_FIELD(options);
3130 COPY_NODE_FIELD(withClause);
3135 static FunctionParameter *
3136 _copyFunctionParameter(const FunctionParameter *from)
3138 FunctionParameter *newnode = makeNode(FunctionParameter);
3140 COPY_STRING_FIELD(name);
3141 COPY_NODE_FIELD(argType);
3142 COPY_SCALAR_FIELD(mode);
3143 COPY_NODE_FIELD(defexpr);
3148 static AlterFunctionStmt *
3149 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
3151 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
3153 COPY_NODE_FIELD(func);
3154 COPY_NODE_FIELD(actions);
3160 _copyDoStmt(const DoStmt *from)
3162 DoStmt *newnode = makeNode(DoStmt);
3164 COPY_NODE_FIELD(args);
3170 _copyRenameStmt(const RenameStmt *from)
3172 RenameStmt *newnode = makeNode(RenameStmt);
3174 COPY_SCALAR_FIELD(renameType);
3175 COPY_SCALAR_FIELD(relationType);
3176 COPY_NODE_FIELD(relation);
3177 COPY_NODE_FIELD(object);
3178 COPY_NODE_FIELD(objarg);
3179 COPY_STRING_FIELD(subname);
3180 COPY_STRING_FIELD(newname);
3181 COPY_SCALAR_FIELD(behavior);
3182 COPY_SCALAR_FIELD(missing_ok);
3187 static AlterObjectSchemaStmt *
3188 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
3190 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
3192 COPY_SCALAR_FIELD(objectType);
3193 COPY_NODE_FIELD(relation);
3194 COPY_NODE_FIELD(object);
3195 COPY_NODE_FIELD(objarg);
3196 COPY_STRING_FIELD(newschema);
3197 COPY_SCALAR_FIELD(missing_ok);
3202 static AlterOwnerStmt *
3203 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
3205 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
3207 COPY_SCALAR_FIELD(objectType);
3208 COPY_NODE_FIELD(relation);
3209 COPY_NODE_FIELD(object);
3210 COPY_NODE_FIELD(objarg);
3211 COPY_NODE_FIELD(newowner);
3217 _copyRuleStmt(const RuleStmt *from)
3219 RuleStmt *newnode = makeNode(RuleStmt);
3221 COPY_NODE_FIELD(relation);
3222 COPY_STRING_FIELD(rulename);
3223 COPY_NODE_FIELD(whereClause);
3224 COPY_SCALAR_FIELD(event);
3225 COPY_SCALAR_FIELD(instead);
3226 COPY_NODE_FIELD(actions);
3227 COPY_SCALAR_FIELD(replace);
3233 _copyNotifyStmt(const NotifyStmt *from)
3235 NotifyStmt *newnode = makeNode(NotifyStmt);
3237 COPY_STRING_FIELD(conditionname);
3238 COPY_STRING_FIELD(payload);
3244 _copyListenStmt(const ListenStmt *from)
3246 ListenStmt *newnode = makeNode(ListenStmt);
3248 COPY_STRING_FIELD(conditionname);
3253 static UnlistenStmt *
3254 _copyUnlistenStmt(const UnlistenStmt *from)
3256 UnlistenStmt *newnode = makeNode(UnlistenStmt);
3258 COPY_STRING_FIELD(conditionname);
3263 static TransactionStmt *
3264 _copyTransactionStmt(const TransactionStmt *from)
3266 TransactionStmt *newnode = makeNode(TransactionStmt);
3268 COPY_SCALAR_FIELD(kind);
3269 COPY_NODE_FIELD(options);
3270 COPY_STRING_FIELD(gid);
3275 static CompositeTypeStmt *
3276 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3278 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3280 COPY_NODE_FIELD(typevar);
3281 COPY_NODE_FIELD(coldeflist);
3286 static CreateEnumStmt *
3287 _copyCreateEnumStmt(const CreateEnumStmt *from)
3289 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3291 COPY_NODE_FIELD(typeName);
3292 COPY_NODE_FIELD(vals);
3297 static CreateRangeStmt *
3298 _copyCreateRangeStmt(const CreateRangeStmt *from)
3300 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3302 COPY_NODE_FIELD(typeName);
3303 COPY_NODE_FIELD(params);
3308 static AlterEnumStmt *
3309 _copyAlterEnumStmt(const AlterEnumStmt *from)
3311 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3313 COPY_NODE_FIELD(typeName);
3314 COPY_STRING_FIELD(newVal);
3315 COPY_STRING_FIELD(newValNeighbor);
3316 COPY_SCALAR_FIELD(newValIsAfter);
3317 COPY_SCALAR_FIELD(skipIfExists);
3323 _copyViewStmt(const ViewStmt *from)
3325 ViewStmt *newnode = makeNode(ViewStmt);
3327 COPY_NODE_FIELD(view);
3328 COPY_NODE_FIELD(aliases);
3329 COPY_NODE_FIELD(query);
3330 COPY_SCALAR_FIELD(replace);
3331 COPY_NODE_FIELD(options);
3332 COPY_SCALAR_FIELD(withCheckOption);
3338 _copyLoadStmt(const LoadStmt *from)
3340 LoadStmt *newnode = makeNode(LoadStmt);
3342 COPY_STRING_FIELD(filename);
3347 static CreateDomainStmt *
3348 _copyCreateDomainStmt(const CreateDomainStmt *from)
3350 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3352 COPY_NODE_FIELD(domainname);
3353 COPY_NODE_FIELD(typeName);
3354 COPY_NODE_FIELD(collClause);
3355 COPY_NODE_FIELD(constraints);
3360 static CreateOpClassStmt *
3361 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3363 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3365 COPY_NODE_FIELD(opclassname);
3366 COPY_NODE_FIELD(opfamilyname);
3367 COPY_STRING_FIELD(amname);
3368 COPY_NODE_FIELD(datatype);
3369 COPY_NODE_FIELD(items);
3370 COPY_SCALAR_FIELD(isDefault);
3375 static CreateOpClassItem *
3376 _copyCreateOpClassItem(const CreateOpClassItem *from)
3378 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3380 COPY_SCALAR_FIELD(itemtype);
3381 COPY_NODE_FIELD(name);
3382 COPY_NODE_FIELD(args);
3383 COPY_SCALAR_FIELD(number);
3384 COPY_NODE_FIELD(order_family);
3385 COPY_NODE_FIELD(class_args);
3386 COPY_NODE_FIELD(storedtype);
3391 static CreateOpFamilyStmt *
3392 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3394 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3396 COPY_NODE_FIELD(opfamilyname);
3397 COPY_STRING_FIELD(amname);
3402 static AlterOpFamilyStmt *
3403 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3405 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3407 COPY_NODE_FIELD(opfamilyname);
3408 COPY_STRING_FIELD(amname);
3409 COPY_SCALAR_FIELD(isDrop);
3410 COPY_NODE_FIELD(items);
3415 static CreatedbStmt *
3416 _copyCreatedbStmt(const CreatedbStmt *from)
3418 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3420 COPY_STRING_FIELD(dbname);
3421 COPY_NODE_FIELD(options);
3426 static AlterDatabaseStmt *
3427 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3429 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3431 COPY_STRING_FIELD(dbname);
3432 COPY_NODE_FIELD(options);
3437 static AlterDatabaseSetStmt *
3438 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3440 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3442 COPY_STRING_FIELD(dbname);
3443 COPY_NODE_FIELD(setstmt);
3449 _copyDropdbStmt(const DropdbStmt *from)
3451 DropdbStmt *newnode = makeNode(DropdbStmt);
3453 COPY_STRING_FIELD(dbname);
3454 COPY_SCALAR_FIELD(missing_ok);
3460 _copyVacuumStmt(const VacuumStmt *from)
3462 VacuumStmt *newnode = makeNode(VacuumStmt);
3464 COPY_SCALAR_FIELD(options);
3465 COPY_NODE_FIELD(relation);
3466 COPY_NODE_FIELD(va_cols);
3471 static ExplainStmt *
3472 _copyExplainStmt(const ExplainStmt *from)
3474 ExplainStmt *newnode = makeNode(ExplainStmt);
3476 COPY_NODE_FIELD(query);
3477 COPY_NODE_FIELD(options);
3482 static CreateTableAsStmt *
3483 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3485 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3487 COPY_NODE_FIELD(query);
3488 COPY_NODE_FIELD(into);
3489 COPY_SCALAR_FIELD(relkind);
3490 COPY_SCALAR_FIELD(is_select_into);
3491 COPY_SCALAR_FIELD(if_not_exists);
3496 static RefreshMatViewStmt *
3497 _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
3499 RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
3501 COPY_SCALAR_FIELD(concurrent);
3502 COPY_SCALAR_FIELD(skipData);
3503 COPY_NODE_FIELD(relation);
3508 static ReplicaIdentityStmt *
3509 _copyReplicaIdentityStmt(const ReplicaIdentityStmt *from)
3511 ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt);
3513 COPY_SCALAR_FIELD(identity_type);
3514 COPY_STRING_FIELD(name);
3519 static AlterSystemStmt *
3520 _copyAlterSystemStmt(const AlterSystemStmt *from)
3522 AlterSystemStmt *newnode = makeNode(AlterSystemStmt);
3524 COPY_NODE_FIELD(setstmt);
3529 static CreateSeqStmt *
3530 _copyCreateSeqStmt(const CreateSeqStmt *from)
3532 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3534 COPY_NODE_FIELD(sequence);
3535 COPY_NODE_FIELD(options);
3536 COPY_SCALAR_FIELD(ownerId);
3537 COPY_SCALAR_FIELD(if_not_exists);
3542 static AlterSeqStmt *
3543 _copyAlterSeqStmt(const AlterSeqStmt *from)
3545 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3547 COPY_NODE_FIELD(sequence);
3548 COPY_NODE_FIELD(options);
3549 COPY_SCALAR_FIELD(missing_ok);
3554 static VariableSetStmt *
3555 _copyVariableSetStmt(const VariableSetStmt *from)
3557 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3559 COPY_SCALAR_FIELD(kind);
3560 COPY_STRING_FIELD(name);
3561 COPY_NODE_FIELD(args);
3562 COPY_SCALAR_FIELD(is_local);
3567 static VariableShowStmt *
3568 _copyVariableShowStmt(const VariableShowStmt *from)
3570 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3572 COPY_STRING_FIELD(name);
3577 static DiscardStmt *
3578 _copyDiscardStmt(const DiscardStmt *from)
3580 DiscardStmt *newnode = makeNode(DiscardStmt);
3582 COPY_SCALAR_FIELD(target);
3587 static CreateTableSpaceStmt *
3588 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3590 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3592 COPY_STRING_FIELD(tablespacename);
3593 COPY_NODE_FIELD(owner);
3594 COPY_STRING_FIELD(location);
3595 COPY_NODE_FIELD(options);
3600 static DropTableSpaceStmt *
3601 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
3603 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3605 COPY_STRING_FIELD(tablespacename);
3606 COPY_SCALAR_FIELD(missing_ok);
3611 static AlterTableSpaceOptionsStmt *
3612 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
3614 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3616 COPY_STRING_FIELD(tablespacename);
3617 COPY_NODE_FIELD(options);
3618 COPY_SCALAR_FIELD(isReset);
3623 static AlterTableMoveAllStmt *
3624 _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
3626 AlterTableMoveAllStmt *newnode = makeNode(AlterTableMoveAllStmt);
3628 COPY_STRING_FIELD(orig_tablespacename);
3629 COPY_SCALAR_FIELD(objtype);
3630 COPY_NODE_FIELD(roles);
3631 COPY_STRING_FIELD(new_tablespacename);
3632 COPY_SCALAR_FIELD(nowait);
3637 static CreateExtensionStmt *
3638 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
3640 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3642 COPY_STRING_FIELD(extname);
3643 COPY_SCALAR_FIELD(if_not_exists);
3644 COPY_NODE_FIELD(options);
3649 static AlterExtensionStmt *
3650 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
3652 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3654 COPY_STRING_FIELD(extname);
3655 COPY_NODE_FIELD(options);
3660 static AlterExtensionContentsStmt *
3661 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
3663 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3665 COPY_STRING_FIELD(extname);
3666 COPY_SCALAR_FIELD(action);
3667 COPY_SCALAR_FIELD(objtype);
3668 COPY_NODE_FIELD(objname);
3669 COPY_NODE_FIELD(objargs);
3674 static CreateFdwStmt *
3675 _copyCreateFdwStmt(const CreateFdwStmt *from)
3677 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3679 COPY_STRING_FIELD(fdwname);
3680 COPY_NODE_FIELD(func_options);
3681 COPY_NODE_FIELD(options);
3686 static AlterFdwStmt *
3687 _copyAlterFdwStmt(const AlterFdwStmt *from)
3689 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3691 COPY_STRING_FIELD(fdwname);
3692 COPY_NODE_FIELD(func_options);
3693 COPY_NODE_FIELD(options);
3698 static CreateForeignServerStmt *
3699 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
3701 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3703 COPY_STRING_FIELD(servername);
3704 COPY_STRING_FIELD(servertype);
3705 COPY_STRING_FIELD(version);
3706 COPY_STRING_FIELD(fdwname);
3707 COPY_NODE_FIELD(options);
3712 static AlterForeignServerStmt *
3713 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
3715 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3717 COPY_STRING_FIELD(servername);
3718 COPY_STRING_FIELD(version);
3719 COPY_NODE_FIELD(options);
3720 COPY_SCALAR_FIELD(has_version);
3725 static CreateUserMappingStmt *
3726 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
3728 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3730 COPY_NODE_FIELD(user);
3731 COPY_STRING_FIELD(servername);
3732 COPY_NODE_FIELD(options);
3737 static AlterUserMappingStmt *
3738 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
3740 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3742 COPY_NODE_FIELD(user);
3743 COPY_STRING_FIELD(servername);
3744 COPY_NODE_FIELD(options);
3749 static DropUserMappingStmt *
3750 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
3752 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3754 COPY_NODE_FIELD(user);
3755 COPY_STRING_FIELD(servername);
3756 COPY_SCALAR_FIELD(missing_ok);
3761 static CreateForeignTableStmt *
3762 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
3764 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3766 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
3768 COPY_STRING_FIELD(servername);
3769 COPY_NODE_FIELD(options);
3774 static ImportForeignSchemaStmt *
3775 _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
3777 ImportForeignSchemaStmt *newnode = makeNode(ImportForeignSchemaStmt);
3779 COPY_STRING_FIELD(server_name);
3780 COPY_STRING_FIELD(remote_schema);
3781 COPY_STRING_FIELD(local_schema);
3782 COPY_SCALAR_FIELD(list_type);
3783 COPY_NODE_FIELD(table_list);
3784 COPY_NODE_FIELD(options);
3789 static CreateTransformStmt *
3790 _copyCreateTransformStmt(const CreateTransformStmt *from)
3792 CreateTransformStmt *newnode = makeNode(CreateTransformStmt);
3794 COPY_SCALAR_FIELD(replace);
3795 COPY_NODE_FIELD(type_name);
3796 COPY_STRING_FIELD(lang);
3797 COPY_NODE_FIELD(fromsql);
3798 COPY_NODE_FIELD(tosql);
3803 static CreateTrigStmt *
3804 _copyCreateTrigStmt(const CreateTrigStmt *from)
3806 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3808 COPY_STRING_FIELD(trigname);
3809 COPY_NODE_FIELD(relation);
3810 COPY_NODE_FIELD(funcname);
3811 COPY_NODE_FIELD(args);
3812 COPY_SCALAR_FIELD(row);
3813 COPY_SCALAR_FIELD(timing);
3814 COPY_SCALAR_FIELD(events);
3815 COPY_NODE_FIELD(columns);
3816 COPY_NODE_FIELD(whenClause);
3817 COPY_SCALAR_FIELD(isconstraint);
3818 COPY_SCALAR_FIELD(deferrable);
3819 COPY_SCALAR_FIELD(initdeferred);
3820 COPY_NODE_FIELD(constrrel);
3825 static CreateEventTrigStmt *
3826 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
3828 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
3830 COPY_STRING_FIELD(trigname);
3831 COPY_STRING_FIELD(eventname);
3832 COPY_NODE_FIELD(whenclause);
3833 COPY_NODE_FIELD(funcname);
3838 static AlterEventTrigStmt *
3839 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
3841 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
3843 COPY_STRING_FIELD(trigname);
3844 COPY_SCALAR_FIELD(tgenabled);
3849 static CreatePLangStmt *
3850 _copyCreatePLangStmt(const CreatePLangStmt *from)
3852 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3854 COPY_SCALAR_FIELD(replace);
3855 COPY_STRING_FIELD(plname);
3856 COPY_NODE_FIELD(plhandler);
3857 COPY_NODE_FIELD(plinline);
3858 COPY_NODE_FIELD(plvalidator);
3859 COPY_SCALAR_FIELD(pltrusted);
3864 static CreateRoleStmt *
3865 _copyCreateRoleStmt(const CreateRoleStmt *from)
3867 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3869 COPY_SCALAR_FIELD(stmt_type);
3870 COPY_STRING_FIELD(role);
3871 COPY_NODE_FIELD(options);
3876 static AlterRoleStmt *
3877 _copyAlterRoleStmt(const AlterRoleStmt *from)
3879 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3881 COPY_NODE_FIELD(role);
3882 COPY_NODE_FIELD(options);
3883 COPY_SCALAR_FIELD(action);
3888 static AlterRoleSetStmt *
3889 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
3891 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3893 COPY_NODE_FIELD(role);
3894 COPY_STRING_FIELD(database);
3895 COPY_NODE_FIELD(setstmt);
3900 static DropRoleStmt *
3901 _copyDropRoleStmt(const DropRoleStmt *from)
3903 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3905 COPY_NODE_FIELD(roles);
3906 COPY_SCALAR_FIELD(missing_ok);
3912 _copyLockStmt(const LockStmt *from)
3914 LockStmt *newnode = makeNode(LockStmt);
3916 COPY_NODE_FIELD(relations);
3917 COPY_SCALAR_FIELD(mode);
3918 COPY_SCALAR_FIELD(nowait);
3923 static ConstraintsSetStmt *
3924 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
3926 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3928 COPY_NODE_FIELD(constraints);
3929 COPY_SCALAR_FIELD(deferred);
3934 static ReindexStmt *
3935 _copyReindexStmt(const ReindexStmt *from)
3937 ReindexStmt *newnode = makeNode(ReindexStmt);
3939 COPY_SCALAR_FIELD(kind);
3940 COPY_NODE_FIELD(relation);
3941 COPY_STRING_FIELD(name);
3942 COPY_SCALAR_FIELD(options);
3947 static CreateSchemaStmt *
3948 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
3950 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3952 COPY_STRING_FIELD(schemaname);
3953 COPY_NODE_FIELD(authrole);
3954 COPY_NODE_FIELD(schemaElts);
3955 COPY_SCALAR_FIELD(if_not_exists);
3960 static CreateConversionStmt *
3961 _copyCreateConversionStmt(const CreateConversionStmt *from)
3963 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3965 COPY_NODE_FIELD(conversion_name);
3966 COPY_STRING_FIELD(for_encoding_name);
3967 COPY_STRING_FIELD(to_encoding_name);
3968 COPY_NODE_FIELD(func_name);
3969 COPY_SCALAR_FIELD(def);
3974 static CreateCastStmt *
3975 _copyCreateCastStmt(const CreateCastStmt *from)
3977 CreateCastStmt *newnode = makeNode(CreateCastStmt);
3979 COPY_NODE_FIELD(sourcetype);
3980 COPY_NODE_FIELD(targettype);
3981 COPY_NODE_FIELD(func);
3982 COPY_SCALAR_FIELD(context);
3983 COPY_SCALAR_FIELD(inout);
3988 static PrepareStmt *
3989 _copyPrepareStmt(const PrepareStmt *from)
3991 PrepareStmt *newnode = makeNode(PrepareStmt);
3993 COPY_STRING_FIELD(name);
3994 COPY_NODE_FIELD(argtypes);
3995 COPY_NODE_FIELD(query);
4000 static ExecuteStmt *
4001 _copyExecuteStmt(const ExecuteStmt *from)
4003 ExecuteStmt *newnode = makeNode(ExecuteStmt);
4005 COPY_STRING_FIELD(name);
4006 COPY_NODE_FIELD(params);
4011 static DeallocateStmt *
4012 _copyDeallocateStmt(const DeallocateStmt *from)
4014 DeallocateStmt *newnode = makeNode(DeallocateStmt);
4016 COPY_STRING_FIELD(name);
4021 static DropOwnedStmt *
4022 _copyDropOwnedStmt(const DropOwnedStmt *from)
4024 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
4026 COPY_NODE_FIELD(roles);
4027 COPY_SCALAR_FIELD(behavior);
4032 static ReassignOwnedStmt *
4033 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
4035 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
4037 COPY_NODE_FIELD(roles);
4038 COPY_NODE_FIELD(newrole);
4043 static AlterTSDictionaryStmt *
4044 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
4046 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
4048 COPY_NODE_FIELD(dictname);
4049 COPY_NODE_FIELD(options);
4054 static AlterTSConfigurationStmt *
4055 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
4057 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
4059 COPY_SCALAR_FIELD(kind);
4060 COPY_NODE_FIELD(cfgname);
4061 COPY_NODE_FIELD(tokentype);
4062 COPY_NODE_FIELD(dicts);
4063 COPY_SCALAR_FIELD(override);
4064 COPY_SCALAR_FIELD(replace);
4065 COPY_SCALAR_FIELD(missing_ok);
4070 static CreatePolicyStmt *
4071 _copyCreatePolicyStmt(const CreatePolicyStmt *from)
4073 CreatePolicyStmt *newnode = makeNode(CreatePolicyStmt);
4075 COPY_STRING_FIELD(policy_name);
4076 COPY_NODE_FIELD(table);
4077 COPY_SCALAR_FIELD(cmd);
4078 COPY_NODE_FIELD(roles);
4079 COPY_NODE_FIELD(qual);
4080 COPY_NODE_FIELD(with_check);
4085 static AlterPolicyStmt *
4086 _copyAlterPolicyStmt(const AlterPolicyStmt *from)
4088 AlterPolicyStmt *newnode = makeNode(AlterPolicyStmt);
4090 COPY_STRING_FIELD(policy_name);
4091 COPY_NODE_FIELD(table);
4092 COPY_NODE_FIELD(roles);
4093 COPY_NODE_FIELD(qual);
4094 COPY_NODE_FIELD(with_check);
4099 /* ****************************************************************
4100 * pg_list.h copy functions
4101 * ****************************************************************
4105 * Perform a deep copy of the specified list, using copyObject(). The
4106 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
4107 * need deep copies, so they should be copied via list_copy()
4109 #define COPY_NODE_CELL(new, old) \
4110 (new) = (ListCell *) palloc(sizeof(ListCell)); \
4111 lfirst(new) = copyObject(lfirst(old));
4114 _copyList(const List *from)
4120 Assert(list_length(from) >= 1);
4122 new = makeNode(List);
4123 new->length = from->length;
4125 COPY_NODE_CELL(new->head, from->head);
4126 prev_new = new->head;
4127 curr_old = lnext(from->head);
4131 COPY_NODE_CELL(prev_new->next, curr_old);
4132 prev_new = prev_new->next;
4133 curr_old = curr_old->next;
4135 prev_new->next = NULL;
4136 new->tail = prev_new;
4141 /* ****************************************************************
4142 * value.h copy functions
4143 * ****************************************************************
4146 _copyValue(const Value *from)
4148 Value *newnode = makeNode(Value);
4150 /* See also _copyAConst when changing this code! */
4152 COPY_SCALAR_FIELD(type);
4156 COPY_SCALAR_FIELD(val.ival);
4161 COPY_STRING_FIELD(val.str);
4167 elog(ERROR, "unrecognized node type: %d",
4177 * Create a copy of a Node tree or list. This is a "deep" copy: all
4178 * substructure is copied too, recursively.
4181 copyObject(const void *from)
4188 /* Guard against stack overflow due to overly complex expressions */
4189 check_stack_depth();
4191 switch (nodeTag(from))
4197 retval = _copyPlannedStmt(from);
4200 retval = _copyPlan(from);
4203 retval = _copyResult(from);
4206 retval = _copyModifyTable(from);
4209 retval = _copyAppend(from);
4212 retval = _copyMergeAppend(from);
4214 case T_RecursiveUnion:
4215 retval = _copyRecursiveUnion(from);
4218 retval = _copyBitmapAnd(from);
4221 retval = _copyBitmapOr(from);
4224 retval = _copyScan(from);
4227 retval = _copySeqScan(from);
4230 retval = _copyIndexScan(from);
4232 case T_IndexOnlyScan:
4233 retval = _copyIndexOnlyScan(from);
4235 case T_BitmapIndexScan:
4236 retval = _copyBitmapIndexScan(from);
4238 case T_BitmapHeapScan:
4239 retval = _copyBitmapHeapScan(from);
4242 retval = _copyTidScan(from);
4244 case T_SubqueryScan:
4245 retval = _copySubqueryScan(from);
4247 case T_FunctionScan:
4248 retval = _copyFunctionScan(from);
4251 retval = _copyValuesScan(from);
4254 retval = _copyCteScan(from);
4256 case T_WorkTableScan:
4257 retval = _copyWorkTableScan(from);
4260 retval = _copyForeignScan(from);
4263 retval = _copyCustomScan(from);
4266 retval = _copySampleScan(from);
4269 retval = _copyJoin(from);
4272 retval = _copyNestLoop(from);
4275 retval = _copyMergeJoin(from);
4278 retval = _copyHashJoin(from);
4281 retval = _copyMaterial(from);
4284 retval = _copySort(from);
4287 retval = _copyGroup(from);
4290 retval = _copyAgg(from);
4293 retval = _copyWindowAgg(from);
4296 retval = _copyUnique(from);
4299 retval = _copyHash(from);
4302 retval = _copySetOp(from);
4305 retval = _copyLockRows(from);
4308 retval = _copyLimit(from);
4310 case T_NestLoopParam:
4311 retval = _copyNestLoopParam(from);
4314 retval = _copyPlanRowMark(from);
4316 case T_PlanInvalItem:
4317 retval = _copyPlanInvalItem(from);
4324 retval = _copyAlias(from);
4327 retval = _copyRangeVar(from);
4330 retval = _copyIntoClause(from);
4333 retval = _copyVar(from);
4336 retval = _copyConst(from);
4339 retval = _copyParam(from);
4342 retval = _copyAggref(from);
4344 case T_GroupingFunc:
4345 retval = _copyGroupingFunc(from);
4348 retval = _copyWindowFunc(from);
4351 retval = _copyArrayRef(from);
4354 retval = _copyFuncExpr(from);
4356 case T_NamedArgExpr:
4357 retval = _copyNamedArgExpr(from);
4360 retval = _copyOpExpr(from);
4362 case T_DistinctExpr:
4363 retval = _copyDistinctExpr(from);
4366 retval = _copyNullIfExpr(from);
4368 case T_ScalarArrayOpExpr:
4369 retval = _copyScalarArrayOpExpr(from);
4372 retval = _copyBoolExpr(from);
4375 retval = _copySubLink(from);
4378 retval = _copySubPlan(from);
4380 case T_AlternativeSubPlan:
4381 retval = _copyAlternativeSubPlan(from);
4384 retval = _copyFieldSelect(from);
4387 retval = _copyFieldStore(from);
4390 retval = _copyRelabelType(from);
4393 retval = _copyCoerceViaIO(from);
4395 case T_ArrayCoerceExpr:
4396 retval = _copyArrayCoerceExpr(from);
4398 case T_ConvertRowtypeExpr:
4399 retval = _copyConvertRowtypeExpr(from);
4402 retval = _copyCollateExpr(from);
4405 retval = _copyCaseExpr(from);
4408 retval = _copyCaseWhen(from);
4410 case T_CaseTestExpr:
4411 retval = _copyCaseTestExpr(from);
4414 retval = _copyArrayExpr(from);
4417 retval = _copyRowExpr(from);
4419 case T_RowCompareExpr:
4420 retval = _copyRowCompareExpr(from);
4422 case T_CoalesceExpr:
4423 retval = _copyCoalesceExpr(from);
4426 retval = _copyMinMaxExpr(from);
4429 retval = _copyXmlExpr(from);
4432 retval = _copyNullTest(from);
4435 retval = _copyBooleanTest(from);
4437 case T_CoerceToDomain:
4438 retval = _copyCoerceToDomain(from);
4440 case T_CoerceToDomainValue:
4441 retval = _copyCoerceToDomainValue(from);
4443 case T_SetToDefault:
4444 retval = _copySetToDefault(from);
4446 case T_CurrentOfExpr:
4447 retval = _copyCurrentOfExpr(from);
4449 case T_InferenceElem:
4450 retval = _copyInferenceElem(from);
4453 retval = _copyTargetEntry(from);
4456 retval = _copyRangeTblRef(from);
4459 retval = _copyJoinExpr(from);
4462 retval = _copyFromExpr(from);
4464 case T_OnConflictExpr:
4465 retval = _copyOnConflictExpr(from);
4472 retval = _copyPathKey(from);
4474 case T_RestrictInfo:
4475 retval = _copyRestrictInfo(from);
4477 case T_PlaceHolderVar:
4478 retval = _copyPlaceHolderVar(from);
4480 case T_SpecialJoinInfo:
4481 retval = _copySpecialJoinInfo(from);
4483 case T_LateralJoinInfo:
4484 retval = _copyLateralJoinInfo(from);
4486 case T_AppendRelInfo:
4487 retval = _copyAppendRelInfo(from);
4489 case T_PlaceHolderInfo:
4490 retval = _copyPlaceHolderInfo(from);
4501 retval = _copyValue(from);
4508 retval = _copyList(from);
4512 * Lists of integers and OIDs don't need to be deep-copied, so we
4513 * perform a shallow copy via list_copy()
4517 retval = list_copy(from);
4524 retval = _copyQuery(from);
4527 retval = _copyInsertStmt(from);
4530 retval = _copyDeleteStmt(from);
4533 retval = _copyUpdateStmt(from);
4536 retval = _copySelectStmt(from);
4538 case T_SetOperationStmt:
4539 retval = _copySetOperationStmt(from);
4541 case T_AlterTableStmt:
4542 retval = _copyAlterTableStmt(from);
4544 case T_AlterTableCmd:
4545 retval = _copyAlterTableCmd(from);
4547 case T_AlterDomainStmt:
4548 retval = _copyAlterDomainStmt(from);
4551 retval = _copyGrantStmt(from);
4553 case T_GrantRoleStmt:
4554 retval = _copyGrantRoleStmt(from);
4556 case T_AlterDefaultPrivilegesStmt:
4557 retval = _copyAlterDefaultPrivilegesStmt(from);
4559 case T_DeclareCursorStmt:
4560 retval = _copyDeclareCursorStmt(from);
4562 case T_ClosePortalStmt:
4563 retval = _copyClosePortalStmt(from);
4566 retval = _copyClusterStmt(from);
4569 retval = _copyCopyStmt(from);
4572 retval = _copyCreateStmt(from);
4574 case T_TableLikeClause:
4575 retval = _copyTableLikeClause(from);
4578 retval = _copyDefineStmt(from);
4581 retval = _copyDropStmt(from);
4583 case T_TruncateStmt:
4584 retval = _copyTruncateStmt(from);
4587 retval = _copyCommentStmt(from);
4589 case T_SecLabelStmt:
4590 retval = _copySecLabelStmt(from);
4593 retval = _copyFetchStmt(from);
4596 retval = _copyIndexStmt(from);
4598 case T_CreateFunctionStmt:
4599 retval = _copyCreateFunctionStmt(from);
4601 case T_FunctionParameter:
4602 retval = _copyFunctionParameter(from);
4604 case T_AlterFunctionStmt:
4605 retval = _copyAlterFunctionStmt(from);
4608 retval = _copyDoStmt(from);
4611 retval = _copyRenameStmt(from);
4613 case T_AlterObjectSchemaStmt:
4614 retval = _copyAlterObjectSchemaStmt(from);
4616 case T_AlterOwnerStmt:
4617 retval = _copyAlterOwnerStmt(from);
4620 retval = _copyRuleStmt(from);
4623 retval = _copyNotifyStmt(from);
4626 retval = _copyListenStmt(from);
4628 case T_UnlistenStmt:
4629 retval = _copyUnlistenStmt(from);
4631 case T_TransactionStmt:
4632 retval = _copyTransactionStmt(from);
4634 case T_CompositeTypeStmt:
4635 retval = _copyCompositeTypeStmt(from);
4637 case T_CreateEnumStmt:
4638 retval = _copyCreateEnumStmt(from);
4640 case T_CreateRangeStmt:
4641 retval = _copyCreateRangeStmt(from);
4643 case T_AlterEnumStmt:
4644 retval = _copyAlterEnumStmt(from);
4647 retval = _copyViewStmt(from);
4650 retval = _copyLoadStmt(from);
4652 case T_CreateDomainStmt:
4653 retval = _copyCreateDomainStmt(from);
4655 case T_CreateOpClassStmt:
4656 retval = _copyCreateOpClassStmt(from);
4658 case T_CreateOpClassItem:
4659 retval = _copyCreateOpClassItem(from);
4661 case T_CreateOpFamilyStmt:
4662 retval = _copyCreateOpFamilyStmt(from);
4664 case T_AlterOpFamilyStmt:
4665 retval = _copyAlterOpFamilyStmt(from);
4667 case T_CreatedbStmt:
4668 retval = _copyCreatedbStmt(from);
4670 case T_AlterDatabaseStmt:
4671 retval = _copyAlterDatabaseStmt(from);
4673 case T_AlterDatabaseSetStmt:
4674 retval = _copyAlterDatabaseSetStmt(from);
4677 retval = _copyDropdbStmt(from);
4680 retval = _copyVacuumStmt(from);
4683 retval = _copyExplainStmt(from);
4685 case T_CreateTableAsStmt:
4686 retval = _copyCreateTableAsStmt(from);
4688 case T_RefreshMatViewStmt:
4689 retval = _copyRefreshMatViewStmt(from);
4691 case T_ReplicaIdentityStmt:
4692 retval = _copyReplicaIdentityStmt(from);
4694 case T_AlterSystemStmt:
4695 retval = _copyAlterSystemStmt(from);
4697 case T_CreateSeqStmt:
4698 retval = _copyCreateSeqStmt(from);
4700 case T_AlterSeqStmt:
4701 retval = _copyAlterSeqStmt(from);
4703 case T_VariableSetStmt:
4704 retval = _copyVariableSetStmt(from);
4706 case T_VariableShowStmt:
4707 retval = _copyVariableShowStmt(from);
4710 retval = _copyDiscardStmt(from);
4712 case T_CreateTableSpaceStmt:
4713 retval = _copyCreateTableSpaceStmt(from);
4715 case T_DropTableSpaceStmt:
4716 retval = _copyDropTableSpaceStmt(from);
4718 case T_AlterTableSpaceOptionsStmt:
4719 retval = _copyAlterTableSpaceOptionsStmt(from);
4721 case T_AlterTableMoveAllStmt:
4722 retval = _copyAlterTableMoveAllStmt(from);
4724 case T_CreateExtensionStmt:
4725 retval = _copyCreateExtensionStmt(from);
4727 case T_AlterExtensionStmt:
4728 retval = _copyAlterExtensionStmt(from);
4730 case T_AlterExtensionContentsStmt:
4731 retval = _copyAlterExtensionContentsStmt(from);
4733 case T_CreateFdwStmt:
4734 retval = _copyCreateFdwStmt(from);
4736 case T_AlterFdwStmt:
4737 retval = _copyAlterFdwStmt(from);
4739 case T_CreateForeignServerStmt:
4740 retval = _copyCreateForeignServerStmt(from);
4742 case T_AlterForeignServerStmt:
4743 retval = _copyAlterForeignServerStmt(from);
4745 case T_CreateUserMappingStmt:
4746 retval = _copyCreateUserMappingStmt(from);
4748 case T_AlterUserMappingStmt:
4749 retval = _copyAlterUserMappingStmt(from);
4751 case T_DropUserMappingStmt:
4752 retval = _copyDropUserMappingStmt(from);
4754 case T_CreateForeignTableStmt:
4755 retval = _copyCreateForeignTableStmt(from);
4757 case T_ImportForeignSchemaStmt:
4758 retval = _copyImportForeignSchemaStmt(from);
4760 case T_CreateTransformStmt:
4761 retval = _copyCreateTransformStmt(from);
4763 case T_CreateTrigStmt:
4764 retval = _copyCreateTrigStmt(from);
4766 case T_CreateEventTrigStmt:
4767 retval = _copyCreateEventTrigStmt(from);
4769 case T_AlterEventTrigStmt:
4770 retval = _copyAlterEventTrigStmt(from);
4772 case T_CreatePLangStmt:
4773 retval = _copyCreatePLangStmt(from);
4775 case T_CreateRoleStmt:
4776 retval = _copyCreateRoleStmt(from);
4778 case T_AlterRoleStmt:
4779 retval = _copyAlterRoleStmt(from);
4781 case T_AlterRoleSetStmt:
4782 retval = _copyAlterRoleSetStmt(from);
4784 case T_DropRoleStmt:
4785 retval = _copyDropRoleStmt(from);
4788 retval = _copyLockStmt(from);
4790 case T_ConstraintsSetStmt:
4791 retval = _copyConstraintsSetStmt(from);
4794 retval = _copyReindexStmt(from);
4796 case T_CheckPointStmt:
4797 retval = (void *) makeNode(CheckPointStmt);
4799 case T_CreateSchemaStmt:
4800 retval = _copyCreateSchemaStmt(from);
4802 case T_CreateConversionStmt:
4803 retval = _copyCreateConversionStmt(from);
4805 case T_CreateCastStmt:
4806 retval = _copyCreateCastStmt(from);
4809 retval = _copyPrepareStmt(from);
4812 retval = _copyExecuteStmt(from);
4814 case T_DeallocateStmt:
4815 retval = _copyDeallocateStmt(from);
4817 case T_DropOwnedStmt:
4818 retval = _copyDropOwnedStmt(from);
4820 case T_ReassignOwnedStmt:
4821 retval = _copyReassignOwnedStmt(from);
4823 case T_AlterTSDictionaryStmt:
4824 retval = _copyAlterTSDictionaryStmt(from);
4826 case T_AlterTSConfigurationStmt:
4827 retval = _copyAlterTSConfigurationStmt(from);
4829 case T_CreatePolicyStmt:
4830 retval = _copyCreatePolicyStmt(from);
4832 case T_AlterPolicyStmt:
4833 retval = _copyAlterPolicyStmt(from);
4836 retval = _copyAExpr(from);
4839 retval = _copyColumnRef(from);
4842 retval = _copyParamRef(from);
4845 retval = _copyAConst(from);
4848 retval = _copyFuncCall(from);
4851 retval = _copyAStar(from);
4854 retval = _copyAIndices(from);
4856 case T_A_Indirection:
4857 retval = _copyA_Indirection(from);
4860 retval = _copyA_ArrayExpr(from);
4863 retval = _copyResTarget(from);
4865 case T_MultiAssignRef:
4866 retval = _copyMultiAssignRef(from);
4869 retval = _copyTypeCast(from);
4871 case T_CollateClause:
4872 retval = _copyCollateClause(from);
4875 retval = _copySortBy(from);
4878 retval = _copyWindowDef(from);
4880 case T_RangeSubselect:
4881 retval = _copyRangeSubselect(from);
4883 case T_RangeFunction:
4884 retval = _copyRangeFunction(from);
4887 retval = _copyTypeName(from);
4890 retval = _copyIndexElem(from);
4893 retval = _copyColumnDef(from);
4896 retval = _copyConstraint(from);
4899 retval = _copyDefElem(from);
4901 case T_LockingClause:
4902 retval = _copyLockingClause(from);
4904 case T_RangeTblEntry:
4905 retval = _copyRangeTblEntry(from);
4907 case T_RangeTblFunction:
4908 retval = _copyRangeTblFunction(from);
4910 case T_WithCheckOption:
4911 retval = _copyWithCheckOption(from);
4913 case T_SortGroupClause:
4914 retval = _copySortGroupClause(from);
4917 retval = _copyGroupingSet(from);
4919 case T_WindowClause:
4920 retval = _copyWindowClause(from);
4922 case T_RowMarkClause:
4923 retval = _copyRowMarkClause(from);
4926 retval = _copyWithClause(from);
4929 retval = _copyInferClause(from);
4931 case T_OnConflictClause:
4932 retval = _copyOnConflictClause(from);
4934 case T_CommonTableExpr:
4935 retval = _copyCommonTableExpr(from);
4937 case T_RangeTableSample:
4938 retval = _copyRangeTableSample(from);
4940 case T_TableSampleClause:
4941 retval = _copyTableSampleClause(from);
4943 case T_FuncWithArgs:
4944 retval = _copyFuncWithArgs(from);
4947 retval = _copyAccessPriv(from);
4949 case T_XmlSerialize:
4950 retval = _copyXmlSerialize(from);
4953 retval = _copyRoleSpec(from);
4957 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4958 retval = 0; /* keep compiler quiet */