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);
647 * This function copies the fields of the Join node. It is used by
648 * all the copy functions for classes which inherit from Join.
651 CopyJoinFields(const Join *from, Join *newnode)
653 CopyPlanFields((const Plan *) from, (Plan *) newnode);
655 COPY_SCALAR_FIELD(jointype);
656 COPY_NODE_FIELD(joinqual);
664 _copyJoin(const Join *from)
666 Join *newnode = makeNode(Join);
669 * copy node superclass fields
671 CopyJoinFields(from, newnode);
681 _copyNestLoop(const NestLoop *from)
683 NestLoop *newnode = makeNode(NestLoop);
686 * copy node superclass fields
688 CopyJoinFields((const Join *) from, (Join *) newnode);
691 * copy remainder of node
693 COPY_NODE_FIELD(nestParams);
703 _copyMergeJoin(const MergeJoin *from)
705 MergeJoin *newnode = makeNode(MergeJoin);
709 * copy node superclass fields
711 CopyJoinFields((const Join *) from, (Join *) newnode);
714 * copy remainder of node
716 COPY_NODE_FIELD(mergeclauses);
717 numCols = list_length(from->mergeclauses);
720 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
721 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
722 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
723 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
733 _copyHashJoin(const HashJoin *from)
735 HashJoin *newnode = makeNode(HashJoin);
738 * copy node superclass fields
740 CopyJoinFields((const Join *) from, (Join *) newnode);
743 * copy remainder of node
745 COPY_NODE_FIELD(hashclauses);
755 _copyMaterial(const Material *from)
757 Material *newnode = makeNode(Material);
760 * copy node superclass fields
762 CopyPlanFields((const Plan *) from, (Plan *) newnode);
772 _copySort(const Sort *from)
774 Sort *newnode = makeNode(Sort);
777 * copy node superclass fields
779 CopyPlanFields((const Plan *) from, (Plan *) newnode);
781 COPY_SCALAR_FIELD(numCols);
782 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
783 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
784 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
785 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
795 _copyGroup(const Group *from)
797 Group *newnode = makeNode(Group);
799 CopyPlanFields((const Plan *) from, (Plan *) newnode);
801 COPY_SCALAR_FIELD(numCols);
802 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
803 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
812 _copyAgg(const Agg *from)
814 Agg *newnode = makeNode(Agg);
816 CopyPlanFields((const Plan *) from, (Plan *) newnode);
818 COPY_SCALAR_FIELD(aggstrategy);
819 COPY_SCALAR_FIELD(numCols);
820 if (from->numCols > 0)
822 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
823 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
825 COPY_SCALAR_FIELD(numGroups);
834 _copyWindowAgg(const WindowAgg *from)
836 WindowAgg *newnode = makeNode(WindowAgg);
838 CopyPlanFields((const Plan *) from, (Plan *) newnode);
840 COPY_SCALAR_FIELD(winref);
841 COPY_SCALAR_FIELD(partNumCols);
842 if (from->partNumCols > 0)
844 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
845 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
847 COPY_SCALAR_FIELD(ordNumCols);
848 if (from->ordNumCols > 0)
850 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
851 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
853 COPY_SCALAR_FIELD(frameOptions);
854 COPY_NODE_FIELD(startOffset);
855 COPY_NODE_FIELD(endOffset);
864 _copyUnique(const Unique *from)
866 Unique *newnode = makeNode(Unique);
869 * copy node superclass fields
871 CopyPlanFields((const Plan *) from, (Plan *) newnode);
874 * copy remainder of node
876 COPY_SCALAR_FIELD(numCols);
877 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
878 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
887 _copyHash(const Hash *from)
889 Hash *newnode = makeNode(Hash);
892 * copy node superclass fields
894 CopyPlanFields((const Plan *) from, (Plan *) newnode);
897 * copy remainder of node
899 COPY_SCALAR_FIELD(skewTable);
900 COPY_SCALAR_FIELD(skewColumn);
901 COPY_SCALAR_FIELD(skewInherit);
902 COPY_SCALAR_FIELD(skewColType);
903 COPY_SCALAR_FIELD(skewColTypmod);
912 _copySetOp(const SetOp *from)
914 SetOp *newnode = makeNode(SetOp);
917 * copy node superclass fields
919 CopyPlanFields((const Plan *) from, (Plan *) newnode);
922 * copy remainder of node
924 COPY_SCALAR_FIELD(cmd);
925 COPY_SCALAR_FIELD(strategy);
926 COPY_SCALAR_FIELD(numCols);
927 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
928 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
929 COPY_SCALAR_FIELD(flagColIdx);
930 COPY_SCALAR_FIELD(firstFlag);
931 COPY_SCALAR_FIELD(numGroups);
940 _copyLockRows(const LockRows *from)
942 LockRows *newnode = makeNode(LockRows);
945 * copy node superclass fields
947 CopyPlanFields((const Plan *) from, (Plan *) newnode);
950 * copy remainder of node
952 COPY_NODE_FIELD(rowMarks);
953 COPY_SCALAR_FIELD(epqParam);
962 _copyLimit(const Limit *from)
964 Limit *newnode = makeNode(Limit);
967 * copy node superclass fields
969 CopyPlanFields((const Plan *) from, (Plan *) newnode);
972 * copy remainder of node
974 COPY_NODE_FIELD(limitOffset);
975 COPY_NODE_FIELD(limitCount);
983 static NestLoopParam *
984 _copyNestLoopParam(const NestLoopParam *from)
986 NestLoopParam *newnode = makeNode(NestLoopParam);
988 COPY_SCALAR_FIELD(paramno);
989 COPY_NODE_FIELD(paramval);
998 _copyPlanRowMark(const PlanRowMark *from)
1000 PlanRowMark *newnode = makeNode(PlanRowMark);
1002 COPY_SCALAR_FIELD(rti);
1003 COPY_SCALAR_FIELD(prti);
1004 COPY_SCALAR_FIELD(rowmarkId);
1005 COPY_SCALAR_FIELD(markType);
1006 COPY_SCALAR_FIELD(allMarkTypes);
1007 COPY_SCALAR_FIELD(strength);
1008 COPY_SCALAR_FIELD(waitPolicy);
1009 COPY_SCALAR_FIELD(isParent);
1015 * _copyPlanInvalItem
1017 static PlanInvalItem *
1018 _copyPlanInvalItem(const PlanInvalItem *from)
1020 PlanInvalItem *newnode = makeNode(PlanInvalItem);
1022 COPY_SCALAR_FIELD(cacheId);
1023 COPY_SCALAR_FIELD(hashValue);
1028 /* ****************************************************************
1029 * primnodes.h copy functions
1030 * ****************************************************************
1037 _copyAlias(const Alias *from)
1039 Alias *newnode = makeNode(Alias);
1041 COPY_STRING_FIELD(aliasname);
1042 COPY_NODE_FIELD(colnames);
1051 _copyRangeVar(const RangeVar *from)
1053 RangeVar *newnode = makeNode(RangeVar);
1055 COPY_STRING_FIELD(catalogname);
1056 COPY_STRING_FIELD(schemaname);
1057 COPY_STRING_FIELD(relname);
1058 COPY_SCALAR_FIELD(inhOpt);
1059 COPY_SCALAR_FIELD(relpersistence);
1060 COPY_NODE_FIELD(alias);
1061 COPY_LOCATION_FIELD(location);
1070 _copyIntoClause(const IntoClause *from)
1072 IntoClause *newnode = makeNode(IntoClause);
1074 COPY_NODE_FIELD(rel);
1075 COPY_NODE_FIELD(colNames);
1076 COPY_NODE_FIELD(options);
1077 COPY_SCALAR_FIELD(onCommit);
1078 COPY_STRING_FIELD(tableSpaceName);
1079 COPY_NODE_FIELD(viewQuery);
1080 COPY_SCALAR_FIELD(skipData);
1086 * We don't need a _copyExpr because Expr is an abstract supertype which
1087 * should never actually get instantiated. Also, since it has no common
1088 * fields except NodeTag, there's no need for a helper routine to factor
1089 * out copying the common fields...
1096 _copyVar(const Var *from)
1098 Var *newnode = makeNode(Var);
1100 COPY_SCALAR_FIELD(varno);
1101 COPY_SCALAR_FIELD(varattno);
1102 COPY_SCALAR_FIELD(vartype);
1103 COPY_SCALAR_FIELD(vartypmod);
1104 COPY_SCALAR_FIELD(varcollid);
1105 COPY_SCALAR_FIELD(varlevelsup);
1106 COPY_SCALAR_FIELD(varnoold);
1107 COPY_SCALAR_FIELD(varoattno);
1108 COPY_LOCATION_FIELD(location);
1117 _copyConst(const Const *from)
1119 Const *newnode = makeNode(Const);
1121 COPY_SCALAR_FIELD(consttype);
1122 COPY_SCALAR_FIELD(consttypmod);
1123 COPY_SCALAR_FIELD(constcollid);
1124 COPY_SCALAR_FIELD(constlen);
1126 if (from->constbyval || from->constisnull)
1129 * passed by value so just copy the datum. Also, don't try to copy
1130 * struct when value is null!
1132 newnode->constvalue = from->constvalue;
1137 * passed by reference. We need a palloc'd copy.
1139 newnode->constvalue = datumCopy(from->constvalue,
1144 COPY_SCALAR_FIELD(constisnull);
1145 COPY_SCALAR_FIELD(constbyval);
1146 COPY_LOCATION_FIELD(location);
1155 _copyParam(const Param *from)
1157 Param *newnode = makeNode(Param);
1159 COPY_SCALAR_FIELD(paramkind);
1160 COPY_SCALAR_FIELD(paramid);
1161 COPY_SCALAR_FIELD(paramtype);
1162 COPY_SCALAR_FIELD(paramtypmod);
1163 COPY_SCALAR_FIELD(paramcollid);
1164 COPY_LOCATION_FIELD(location);
1173 _copyAggref(const Aggref *from)
1175 Aggref *newnode = makeNode(Aggref);
1177 COPY_SCALAR_FIELD(aggfnoid);
1178 COPY_SCALAR_FIELD(aggtype);
1179 COPY_SCALAR_FIELD(aggcollid);
1180 COPY_SCALAR_FIELD(inputcollid);
1181 COPY_NODE_FIELD(aggdirectargs);
1182 COPY_NODE_FIELD(args);
1183 COPY_NODE_FIELD(aggorder);
1184 COPY_NODE_FIELD(aggdistinct);
1185 COPY_NODE_FIELD(aggfilter);
1186 COPY_SCALAR_FIELD(aggstar);
1187 COPY_SCALAR_FIELD(aggvariadic);
1188 COPY_SCALAR_FIELD(aggkind);
1189 COPY_SCALAR_FIELD(agglevelsup);
1190 COPY_LOCATION_FIELD(location);
1199 _copyWindowFunc(const WindowFunc *from)
1201 WindowFunc *newnode = makeNode(WindowFunc);
1203 COPY_SCALAR_FIELD(winfnoid);
1204 COPY_SCALAR_FIELD(wintype);
1205 COPY_SCALAR_FIELD(wincollid);
1206 COPY_SCALAR_FIELD(inputcollid);
1207 COPY_NODE_FIELD(args);
1208 COPY_NODE_FIELD(aggfilter);
1209 COPY_SCALAR_FIELD(winref);
1210 COPY_SCALAR_FIELD(winstar);
1211 COPY_SCALAR_FIELD(winagg);
1212 COPY_LOCATION_FIELD(location);
1221 _copyArrayRef(const ArrayRef *from)
1223 ArrayRef *newnode = makeNode(ArrayRef);
1225 COPY_SCALAR_FIELD(refarraytype);
1226 COPY_SCALAR_FIELD(refelemtype);
1227 COPY_SCALAR_FIELD(reftypmod);
1228 COPY_SCALAR_FIELD(refcollid);
1229 COPY_NODE_FIELD(refupperindexpr);
1230 COPY_NODE_FIELD(reflowerindexpr);
1231 COPY_NODE_FIELD(refexpr);
1232 COPY_NODE_FIELD(refassgnexpr);
1241 _copyFuncExpr(const FuncExpr *from)
1243 FuncExpr *newnode = makeNode(FuncExpr);
1245 COPY_SCALAR_FIELD(funcid);
1246 COPY_SCALAR_FIELD(funcresulttype);
1247 COPY_SCALAR_FIELD(funcretset);
1248 COPY_SCALAR_FIELD(funcvariadic);
1249 COPY_SCALAR_FIELD(funcformat);
1250 COPY_SCALAR_FIELD(funccollid);
1251 COPY_SCALAR_FIELD(inputcollid);
1252 COPY_NODE_FIELD(args);
1253 COPY_LOCATION_FIELD(location);
1259 * _copyNamedArgExpr *
1261 static NamedArgExpr *
1262 _copyNamedArgExpr(const NamedArgExpr *from)
1264 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1266 COPY_NODE_FIELD(arg);
1267 COPY_STRING_FIELD(name);
1268 COPY_SCALAR_FIELD(argnumber);
1269 COPY_LOCATION_FIELD(location);
1278 _copyOpExpr(const OpExpr *from)
1280 OpExpr *newnode = makeNode(OpExpr);
1282 COPY_SCALAR_FIELD(opno);
1283 COPY_SCALAR_FIELD(opfuncid);
1284 COPY_SCALAR_FIELD(opresulttype);
1285 COPY_SCALAR_FIELD(opretset);
1286 COPY_SCALAR_FIELD(opcollid);
1287 COPY_SCALAR_FIELD(inputcollid);
1288 COPY_NODE_FIELD(args);
1289 COPY_LOCATION_FIELD(location);
1295 * _copyDistinctExpr (same as OpExpr)
1297 static DistinctExpr *
1298 _copyDistinctExpr(const DistinctExpr *from)
1300 DistinctExpr *newnode = makeNode(DistinctExpr);
1302 COPY_SCALAR_FIELD(opno);
1303 COPY_SCALAR_FIELD(opfuncid);
1304 COPY_SCALAR_FIELD(opresulttype);
1305 COPY_SCALAR_FIELD(opretset);
1306 COPY_SCALAR_FIELD(opcollid);
1307 COPY_SCALAR_FIELD(inputcollid);
1308 COPY_NODE_FIELD(args);
1309 COPY_LOCATION_FIELD(location);
1315 * _copyNullIfExpr (same as OpExpr)
1318 _copyNullIfExpr(const NullIfExpr *from)
1320 NullIfExpr *newnode = makeNode(NullIfExpr);
1322 COPY_SCALAR_FIELD(opno);
1323 COPY_SCALAR_FIELD(opfuncid);
1324 COPY_SCALAR_FIELD(opresulttype);
1325 COPY_SCALAR_FIELD(opretset);
1326 COPY_SCALAR_FIELD(opcollid);
1327 COPY_SCALAR_FIELD(inputcollid);
1328 COPY_NODE_FIELD(args);
1329 COPY_LOCATION_FIELD(location);
1335 * _copyScalarArrayOpExpr
1337 static ScalarArrayOpExpr *
1338 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
1340 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1342 COPY_SCALAR_FIELD(opno);
1343 COPY_SCALAR_FIELD(opfuncid);
1344 COPY_SCALAR_FIELD(useOr);
1345 COPY_SCALAR_FIELD(inputcollid);
1346 COPY_NODE_FIELD(args);
1347 COPY_LOCATION_FIELD(location);
1356 _copyBoolExpr(const BoolExpr *from)
1358 BoolExpr *newnode = makeNode(BoolExpr);
1360 COPY_SCALAR_FIELD(boolop);
1361 COPY_NODE_FIELD(args);
1362 COPY_LOCATION_FIELD(location);
1371 _copySubLink(const SubLink *from)
1373 SubLink *newnode = makeNode(SubLink);
1375 COPY_SCALAR_FIELD(subLinkType);
1376 COPY_SCALAR_FIELD(subLinkId);
1377 COPY_NODE_FIELD(testexpr);
1378 COPY_NODE_FIELD(operName);
1379 COPY_NODE_FIELD(subselect);
1380 COPY_LOCATION_FIELD(location);
1389 _copySubPlan(const SubPlan *from)
1391 SubPlan *newnode = makeNode(SubPlan);
1393 COPY_SCALAR_FIELD(subLinkType);
1394 COPY_NODE_FIELD(testexpr);
1395 COPY_NODE_FIELD(paramIds);
1396 COPY_SCALAR_FIELD(plan_id);
1397 COPY_STRING_FIELD(plan_name);
1398 COPY_SCALAR_FIELD(firstColType);
1399 COPY_SCALAR_FIELD(firstColTypmod);
1400 COPY_SCALAR_FIELD(firstColCollation);
1401 COPY_SCALAR_FIELD(useHashTable);
1402 COPY_SCALAR_FIELD(unknownEqFalse);
1403 COPY_NODE_FIELD(setParam);
1404 COPY_NODE_FIELD(parParam);
1405 COPY_NODE_FIELD(args);
1406 COPY_SCALAR_FIELD(startup_cost);
1407 COPY_SCALAR_FIELD(per_call_cost);
1413 * _copyAlternativeSubPlan
1415 static AlternativeSubPlan *
1416 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
1418 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1420 COPY_NODE_FIELD(subplans);
1428 static FieldSelect *
1429 _copyFieldSelect(const FieldSelect *from)
1431 FieldSelect *newnode = makeNode(FieldSelect);
1433 COPY_NODE_FIELD(arg);
1434 COPY_SCALAR_FIELD(fieldnum);
1435 COPY_SCALAR_FIELD(resulttype);
1436 COPY_SCALAR_FIELD(resulttypmod);
1437 COPY_SCALAR_FIELD(resultcollid);
1446 _copyFieldStore(const FieldStore *from)
1448 FieldStore *newnode = makeNode(FieldStore);
1450 COPY_NODE_FIELD(arg);
1451 COPY_NODE_FIELD(newvals);
1452 COPY_NODE_FIELD(fieldnums);
1453 COPY_SCALAR_FIELD(resulttype);
1461 static RelabelType *
1462 _copyRelabelType(const RelabelType *from)
1464 RelabelType *newnode = makeNode(RelabelType);
1466 COPY_NODE_FIELD(arg);
1467 COPY_SCALAR_FIELD(resulttype);
1468 COPY_SCALAR_FIELD(resulttypmod);
1469 COPY_SCALAR_FIELD(resultcollid);
1470 COPY_SCALAR_FIELD(relabelformat);
1471 COPY_LOCATION_FIELD(location);
1479 static CoerceViaIO *
1480 _copyCoerceViaIO(const CoerceViaIO *from)
1482 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1484 COPY_NODE_FIELD(arg);
1485 COPY_SCALAR_FIELD(resulttype);
1486 COPY_SCALAR_FIELD(resultcollid);
1487 COPY_SCALAR_FIELD(coerceformat);
1488 COPY_LOCATION_FIELD(location);
1494 * _copyArrayCoerceExpr
1496 static ArrayCoerceExpr *
1497 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
1499 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1501 COPY_NODE_FIELD(arg);
1502 COPY_SCALAR_FIELD(elemfuncid);
1503 COPY_SCALAR_FIELD(resulttype);
1504 COPY_SCALAR_FIELD(resulttypmod);
1505 COPY_SCALAR_FIELD(resultcollid);
1506 COPY_SCALAR_FIELD(isExplicit);
1507 COPY_SCALAR_FIELD(coerceformat);
1508 COPY_LOCATION_FIELD(location);
1514 * _copyConvertRowtypeExpr
1516 static ConvertRowtypeExpr *
1517 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
1519 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1521 COPY_NODE_FIELD(arg);
1522 COPY_SCALAR_FIELD(resulttype);
1523 COPY_SCALAR_FIELD(convertformat);
1524 COPY_LOCATION_FIELD(location);
1532 static CollateExpr *
1533 _copyCollateExpr(const CollateExpr *from)
1535 CollateExpr *newnode = makeNode(CollateExpr);
1537 COPY_NODE_FIELD(arg);
1538 COPY_SCALAR_FIELD(collOid);
1539 COPY_LOCATION_FIELD(location);
1548 _copyCaseExpr(const CaseExpr *from)
1550 CaseExpr *newnode = makeNode(CaseExpr);
1552 COPY_SCALAR_FIELD(casetype);
1553 COPY_SCALAR_FIELD(casecollid);
1554 COPY_NODE_FIELD(arg);
1555 COPY_NODE_FIELD(args);
1556 COPY_NODE_FIELD(defresult);
1557 COPY_LOCATION_FIELD(location);
1566 _copyCaseWhen(const CaseWhen *from)
1568 CaseWhen *newnode = makeNode(CaseWhen);
1570 COPY_NODE_FIELD(expr);
1571 COPY_NODE_FIELD(result);
1572 COPY_LOCATION_FIELD(location);
1580 static CaseTestExpr *
1581 _copyCaseTestExpr(const CaseTestExpr *from)
1583 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1585 COPY_SCALAR_FIELD(typeId);
1586 COPY_SCALAR_FIELD(typeMod);
1587 COPY_SCALAR_FIELD(collation);
1596 _copyArrayExpr(const ArrayExpr *from)
1598 ArrayExpr *newnode = makeNode(ArrayExpr);
1600 COPY_SCALAR_FIELD(array_typeid);
1601 COPY_SCALAR_FIELD(array_collid);
1602 COPY_SCALAR_FIELD(element_typeid);
1603 COPY_NODE_FIELD(elements);
1604 COPY_SCALAR_FIELD(multidims);
1605 COPY_LOCATION_FIELD(location);
1614 _copyRowExpr(const RowExpr *from)
1616 RowExpr *newnode = makeNode(RowExpr);
1618 COPY_NODE_FIELD(args);
1619 COPY_SCALAR_FIELD(row_typeid);
1620 COPY_SCALAR_FIELD(row_format);
1621 COPY_NODE_FIELD(colnames);
1622 COPY_LOCATION_FIELD(location);
1628 * _copyRowCompareExpr
1630 static RowCompareExpr *
1631 _copyRowCompareExpr(const RowCompareExpr *from)
1633 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1635 COPY_SCALAR_FIELD(rctype);
1636 COPY_NODE_FIELD(opnos);
1637 COPY_NODE_FIELD(opfamilies);
1638 COPY_NODE_FIELD(inputcollids);
1639 COPY_NODE_FIELD(largs);
1640 COPY_NODE_FIELD(rargs);
1648 static CoalesceExpr *
1649 _copyCoalesceExpr(const CoalesceExpr *from)
1651 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1653 COPY_SCALAR_FIELD(coalescetype);
1654 COPY_SCALAR_FIELD(coalescecollid);
1655 COPY_NODE_FIELD(args);
1656 COPY_LOCATION_FIELD(location);
1665 _copyMinMaxExpr(const MinMaxExpr *from)
1667 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1669 COPY_SCALAR_FIELD(minmaxtype);
1670 COPY_SCALAR_FIELD(minmaxcollid);
1671 COPY_SCALAR_FIELD(inputcollid);
1672 COPY_SCALAR_FIELD(op);
1673 COPY_NODE_FIELD(args);
1674 COPY_LOCATION_FIELD(location);
1683 _copyXmlExpr(const XmlExpr *from)
1685 XmlExpr *newnode = makeNode(XmlExpr);
1687 COPY_SCALAR_FIELD(op);
1688 COPY_STRING_FIELD(name);
1689 COPY_NODE_FIELD(named_args);
1690 COPY_NODE_FIELD(arg_names);
1691 COPY_NODE_FIELD(args);
1692 COPY_SCALAR_FIELD(xmloption);
1693 COPY_SCALAR_FIELD(type);
1694 COPY_SCALAR_FIELD(typmod);
1695 COPY_LOCATION_FIELD(location);
1704 _copyNullTest(const NullTest *from)
1706 NullTest *newnode = makeNode(NullTest);
1708 COPY_NODE_FIELD(arg);
1709 COPY_SCALAR_FIELD(nulltesttype);
1710 COPY_SCALAR_FIELD(argisrow);
1711 COPY_LOCATION_FIELD(location);
1719 static BooleanTest *
1720 _copyBooleanTest(const BooleanTest *from)
1722 BooleanTest *newnode = makeNode(BooleanTest);
1724 COPY_NODE_FIELD(arg);
1725 COPY_SCALAR_FIELD(booltesttype);
1726 COPY_LOCATION_FIELD(location);
1732 * _copyCoerceToDomain
1734 static CoerceToDomain *
1735 _copyCoerceToDomain(const CoerceToDomain *from)
1737 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1739 COPY_NODE_FIELD(arg);
1740 COPY_SCALAR_FIELD(resulttype);
1741 COPY_SCALAR_FIELD(resulttypmod);
1742 COPY_SCALAR_FIELD(resultcollid);
1743 COPY_SCALAR_FIELD(coercionformat);
1744 COPY_LOCATION_FIELD(location);
1750 * _copyCoerceToDomainValue
1752 static CoerceToDomainValue *
1753 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
1755 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1757 COPY_SCALAR_FIELD(typeId);
1758 COPY_SCALAR_FIELD(typeMod);
1759 COPY_SCALAR_FIELD(collation);
1760 COPY_LOCATION_FIELD(location);
1768 static SetToDefault *
1769 _copySetToDefault(const SetToDefault *from)
1771 SetToDefault *newnode = makeNode(SetToDefault);
1773 COPY_SCALAR_FIELD(typeId);
1774 COPY_SCALAR_FIELD(typeMod);
1775 COPY_SCALAR_FIELD(collation);
1776 COPY_LOCATION_FIELD(location);
1782 * _copyCurrentOfExpr
1784 static CurrentOfExpr *
1785 _copyCurrentOfExpr(const CurrentOfExpr *from)
1787 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1789 COPY_SCALAR_FIELD(cvarno);
1790 COPY_STRING_FIELD(cursor_name);
1791 COPY_SCALAR_FIELD(cursor_param);
1797 * _copyInferenceElem
1799 static InferenceElem *
1800 _copyInferenceElem(const InferenceElem *from)
1802 InferenceElem *newnode = makeNode(InferenceElem);
1804 COPY_NODE_FIELD(expr);
1805 COPY_SCALAR_FIELD(infercollid);
1806 COPY_SCALAR_FIELD(inferopfamily);
1807 COPY_SCALAR_FIELD(inferopcinputtype);
1815 static TargetEntry *
1816 _copyTargetEntry(const TargetEntry *from)
1818 TargetEntry *newnode = makeNode(TargetEntry);
1820 COPY_NODE_FIELD(expr);
1821 COPY_SCALAR_FIELD(resno);
1822 COPY_STRING_FIELD(resname);
1823 COPY_SCALAR_FIELD(ressortgroupref);
1824 COPY_SCALAR_FIELD(resorigtbl);
1825 COPY_SCALAR_FIELD(resorigcol);
1826 COPY_SCALAR_FIELD(resjunk);
1834 static RangeTblRef *
1835 _copyRangeTblRef(const RangeTblRef *from)
1837 RangeTblRef *newnode = makeNode(RangeTblRef);
1839 COPY_SCALAR_FIELD(rtindex);
1848 _copyJoinExpr(const JoinExpr *from)
1850 JoinExpr *newnode = makeNode(JoinExpr);
1852 COPY_SCALAR_FIELD(jointype);
1853 COPY_SCALAR_FIELD(isNatural);
1854 COPY_NODE_FIELD(larg);
1855 COPY_NODE_FIELD(rarg);
1856 COPY_NODE_FIELD(usingClause);
1857 COPY_NODE_FIELD(quals);
1858 COPY_NODE_FIELD(alias);
1859 COPY_SCALAR_FIELD(rtindex);
1868 _copyFromExpr(const FromExpr *from)
1870 FromExpr *newnode = makeNode(FromExpr);
1872 COPY_NODE_FIELD(fromlist);
1873 COPY_NODE_FIELD(quals);
1879 * _copyOnConflictExpr
1881 static OnConflictExpr *
1882 _copyOnConflictExpr(const OnConflictExpr *from)
1884 OnConflictExpr *newnode = makeNode(OnConflictExpr);
1886 COPY_SCALAR_FIELD(action);
1887 COPY_NODE_FIELD(arbiterElems);
1888 COPY_NODE_FIELD(arbiterWhere);
1889 COPY_NODE_FIELD(onConflictSet);
1890 COPY_NODE_FIELD(onConflictWhere);
1891 COPY_SCALAR_FIELD(constraint);
1892 COPY_SCALAR_FIELD(exclRelIndex);
1893 COPY_NODE_FIELD(exclRelTlist);
1898 /* ****************************************************************
1899 * relation.h copy functions
1901 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1902 * There are some subsidiary structs that are useful to copy, though.
1903 * ****************************************************************
1910 _copyPathKey(const PathKey *from)
1912 PathKey *newnode = makeNode(PathKey);
1914 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1915 COPY_SCALAR_FIELD(pk_eclass);
1916 COPY_SCALAR_FIELD(pk_opfamily);
1917 COPY_SCALAR_FIELD(pk_strategy);
1918 COPY_SCALAR_FIELD(pk_nulls_first);
1926 static RestrictInfo *
1927 _copyRestrictInfo(const RestrictInfo *from)
1929 RestrictInfo *newnode = makeNode(RestrictInfo);
1931 COPY_NODE_FIELD(clause);
1932 COPY_SCALAR_FIELD(is_pushed_down);
1933 COPY_SCALAR_FIELD(outerjoin_delayed);
1934 COPY_SCALAR_FIELD(can_join);
1935 COPY_SCALAR_FIELD(pseudoconstant);
1936 COPY_BITMAPSET_FIELD(clause_relids);
1937 COPY_BITMAPSET_FIELD(required_relids);
1938 COPY_BITMAPSET_FIELD(outer_relids);
1939 COPY_BITMAPSET_FIELD(nullable_relids);
1940 COPY_BITMAPSET_FIELD(left_relids);
1941 COPY_BITMAPSET_FIELD(right_relids);
1942 COPY_NODE_FIELD(orclause);
1943 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1944 COPY_SCALAR_FIELD(parent_ec);
1945 COPY_SCALAR_FIELD(eval_cost);
1946 COPY_SCALAR_FIELD(norm_selec);
1947 COPY_SCALAR_FIELD(outer_selec);
1948 COPY_NODE_FIELD(mergeopfamilies);
1949 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1950 COPY_SCALAR_FIELD(left_ec);
1951 COPY_SCALAR_FIELD(right_ec);
1952 COPY_SCALAR_FIELD(left_em);
1953 COPY_SCALAR_FIELD(right_em);
1954 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1955 newnode->scansel_cache = NIL;
1956 COPY_SCALAR_FIELD(outer_is_left);
1957 COPY_SCALAR_FIELD(hashjoinoperator);
1958 COPY_SCALAR_FIELD(left_bucketsize);
1959 COPY_SCALAR_FIELD(right_bucketsize);
1965 * _copyPlaceHolderVar
1967 static PlaceHolderVar *
1968 _copyPlaceHolderVar(const PlaceHolderVar *from)
1970 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
1972 COPY_NODE_FIELD(phexpr);
1973 COPY_BITMAPSET_FIELD(phrels);
1974 COPY_SCALAR_FIELD(phid);
1975 COPY_SCALAR_FIELD(phlevelsup);
1981 * _copySpecialJoinInfo
1983 static SpecialJoinInfo *
1984 _copySpecialJoinInfo(const SpecialJoinInfo *from)
1986 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
1988 COPY_BITMAPSET_FIELD(min_lefthand);
1989 COPY_BITMAPSET_FIELD(min_righthand);
1990 COPY_BITMAPSET_FIELD(syn_lefthand);
1991 COPY_BITMAPSET_FIELD(syn_righthand);
1992 COPY_SCALAR_FIELD(jointype);
1993 COPY_SCALAR_FIELD(lhs_strict);
1994 COPY_SCALAR_FIELD(delay_upper_joins);
1995 COPY_SCALAR_FIELD(semi_can_btree);
1996 COPY_SCALAR_FIELD(semi_can_hash);
1997 COPY_NODE_FIELD(semi_operators);
1998 COPY_NODE_FIELD(semi_rhs_exprs);
2004 * _copyLateralJoinInfo
2006 static LateralJoinInfo *
2007 _copyLateralJoinInfo(const LateralJoinInfo *from)
2009 LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
2011 COPY_BITMAPSET_FIELD(lateral_lhs);
2012 COPY_BITMAPSET_FIELD(lateral_rhs);
2018 * _copyAppendRelInfo
2020 static AppendRelInfo *
2021 _copyAppendRelInfo(const AppendRelInfo *from)
2023 AppendRelInfo *newnode = makeNode(AppendRelInfo);
2025 COPY_SCALAR_FIELD(parent_relid);
2026 COPY_SCALAR_FIELD(child_relid);
2027 COPY_SCALAR_FIELD(parent_reltype);
2028 COPY_SCALAR_FIELD(child_reltype);
2029 COPY_NODE_FIELD(translated_vars);
2030 COPY_SCALAR_FIELD(parent_reloid);
2036 * _copyPlaceHolderInfo
2038 static PlaceHolderInfo *
2039 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
2041 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
2043 COPY_SCALAR_FIELD(phid);
2044 COPY_NODE_FIELD(ph_var);
2045 COPY_BITMAPSET_FIELD(ph_eval_at);
2046 COPY_BITMAPSET_FIELD(ph_lateral);
2047 COPY_BITMAPSET_FIELD(ph_needed);
2048 COPY_SCALAR_FIELD(ph_width);
2053 /* ****************************************************************
2054 * parsenodes.h copy functions
2055 * ****************************************************************
2058 static RangeTblEntry *
2059 _copyRangeTblEntry(const RangeTblEntry *from)
2061 RangeTblEntry *newnode = makeNode(RangeTblEntry);
2063 COPY_SCALAR_FIELD(rtekind);
2064 COPY_SCALAR_FIELD(relid);
2065 COPY_SCALAR_FIELD(relkind);
2066 COPY_NODE_FIELD(subquery);
2067 COPY_SCALAR_FIELD(security_barrier);
2068 COPY_SCALAR_FIELD(jointype);
2069 COPY_NODE_FIELD(joinaliasvars);
2070 COPY_NODE_FIELD(functions);
2071 COPY_SCALAR_FIELD(funcordinality);
2072 COPY_NODE_FIELD(values_lists);
2073 COPY_NODE_FIELD(values_collations);
2074 COPY_STRING_FIELD(ctename);
2075 COPY_SCALAR_FIELD(ctelevelsup);
2076 COPY_SCALAR_FIELD(self_reference);
2077 COPY_NODE_FIELD(ctecoltypes);
2078 COPY_NODE_FIELD(ctecoltypmods);
2079 COPY_NODE_FIELD(ctecolcollations);
2080 COPY_NODE_FIELD(alias);
2081 COPY_NODE_FIELD(eref);
2082 COPY_SCALAR_FIELD(lateral);
2083 COPY_SCALAR_FIELD(inh);
2084 COPY_SCALAR_FIELD(inFromCl);
2085 COPY_SCALAR_FIELD(requiredPerms);
2086 COPY_SCALAR_FIELD(checkAsUser);
2087 COPY_BITMAPSET_FIELD(selectedCols);
2088 COPY_BITMAPSET_FIELD(insertedCols);
2089 COPY_BITMAPSET_FIELD(updatedCols);
2090 COPY_NODE_FIELD(securityQuals);
2095 static RangeTblFunction *
2096 _copyRangeTblFunction(const RangeTblFunction *from)
2098 RangeTblFunction *newnode = makeNode(RangeTblFunction);
2100 COPY_NODE_FIELD(funcexpr);
2101 COPY_SCALAR_FIELD(funccolcount);
2102 COPY_NODE_FIELD(funccolnames);
2103 COPY_NODE_FIELD(funccoltypes);
2104 COPY_NODE_FIELD(funccoltypmods);
2105 COPY_NODE_FIELD(funccolcollations);
2106 COPY_BITMAPSET_FIELD(funcparams);
2111 static WithCheckOption *
2112 _copyWithCheckOption(const WithCheckOption *from)
2114 WithCheckOption *newnode = makeNode(WithCheckOption);
2116 COPY_SCALAR_FIELD(kind);
2117 COPY_STRING_FIELD(relname);
2118 COPY_NODE_FIELD(qual);
2119 COPY_SCALAR_FIELD(cascaded);
2124 static SortGroupClause *
2125 _copySortGroupClause(const SortGroupClause *from)
2127 SortGroupClause *newnode = makeNode(SortGroupClause);
2129 COPY_SCALAR_FIELD(tleSortGroupRef);
2130 COPY_SCALAR_FIELD(eqop);
2131 COPY_SCALAR_FIELD(sortop);
2132 COPY_SCALAR_FIELD(nulls_first);
2133 COPY_SCALAR_FIELD(hashable);
2138 static WindowClause *
2139 _copyWindowClause(const WindowClause *from)
2141 WindowClause *newnode = makeNode(WindowClause);
2143 COPY_STRING_FIELD(name);
2144 COPY_STRING_FIELD(refname);
2145 COPY_NODE_FIELD(partitionClause);
2146 COPY_NODE_FIELD(orderClause);
2147 COPY_SCALAR_FIELD(frameOptions);
2148 COPY_NODE_FIELD(startOffset);
2149 COPY_NODE_FIELD(endOffset);
2150 COPY_SCALAR_FIELD(winref);
2151 COPY_SCALAR_FIELD(copiedOrder);
2156 static RowMarkClause *
2157 _copyRowMarkClause(const RowMarkClause *from)
2159 RowMarkClause *newnode = makeNode(RowMarkClause);
2161 COPY_SCALAR_FIELD(rti);
2162 COPY_SCALAR_FIELD(strength);
2163 COPY_SCALAR_FIELD(waitPolicy);
2164 COPY_SCALAR_FIELD(pushedDown);
2170 _copyWithClause(const WithClause *from)
2172 WithClause *newnode = makeNode(WithClause);
2174 COPY_NODE_FIELD(ctes);
2175 COPY_SCALAR_FIELD(recursive);
2176 COPY_LOCATION_FIELD(location);
2181 static InferClause *
2182 _copyInferClause(const InferClause *from)
2184 InferClause *newnode = makeNode(InferClause);
2186 COPY_NODE_FIELD(indexElems);
2187 COPY_NODE_FIELD(whereClause);
2188 COPY_STRING_FIELD(conname);
2189 COPY_LOCATION_FIELD(location);
2194 static OnConflictClause *
2195 _copyOnConflictClause(const OnConflictClause *from)
2197 OnConflictClause *newnode = makeNode(OnConflictClause);
2199 COPY_SCALAR_FIELD(action);
2200 COPY_NODE_FIELD(infer);
2201 COPY_NODE_FIELD(targetList);
2202 COPY_NODE_FIELD(whereClause);
2203 COPY_LOCATION_FIELD(location);
2208 static CommonTableExpr *
2209 _copyCommonTableExpr(const CommonTableExpr *from)
2211 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2213 COPY_STRING_FIELD(ctename);
2214 COPY_NODE_FIELD(aliascolnames);
2215 COPY_NODE_FIELD(ctequery);
2216 COPY_LOCATION_FIELD(location);
2217 COPY_SCALAR_FIELD(cterecursive);
2218 COPY_SCALAR_FIELD(cterefcount);
2219 COPY_NODE_FIELD(ctecolnames);
2220 COPY_NODE_FIELD(ctecoltypes);
2221 COPY_NODE_FIELD(ctecoltypmods);
2222 COPY_NODE_FIELD(ctecolcollations);
2228 _copyAExpr(const A_Expr *from)
2230 A_Expr *newnode = makeNode(A_Expr);
2232 COPY_SCALAR_FIELD(kind);
2233 COPY_NODE_FIELD(name);
2234 COPY_NODE_FIELD(lexpr);
2235 COPY_NODE_FIELD(rexpr);
2236 COPY_LOCATION_FIELD(location);
2242 _copyColumnRef(const ColumnRef *from)
2244 ColumnRef *newnode = makeNode(ColumnRef);
2246 COPY_NODE_FIELD(fields);
2247 COPY_LOCATION_FIELD(location);
2253 _copyParamRef(const ParamRef *from)
2255 ParamRef *newnode = makeNode(ParamRef);
2257 COPY_SCALAR_FIELD(number);
2258 COPY_LOCATION_FIELD(location);
2264 _copyAConst(const A_Const *from)
2266 A_Const *newnode = makeNode(A_Const);
2268 /* This part must duplicate _copyValue */
2269 COPY_SCALAR_FIELD(val.type);
2270 switch (from->val.type)
2273 COPY_SCALAR_FIELD(val.val.ival);
2278 COPY_STRING_FIELD(val.val.str);
2284 elog(ERROR, "unrecognized node type: %d",
2285 (int) from->val.type);
2289 COPY_LOCATION_FIELD(location);
2295 _copyFuncCall(const FuncCall *from)
2297 FuncCall *newnode = makeNode(FuncCall);
2299 COPY_NODE_FIELD(funcname);
2300 COPY_NODE_FIELD(args);
2301 COPY_NODE_FIELD(agg_order);
2302 COPY_NODE_FIELD(agg_filter);
2303 COPY_SCALAR_FIELD(agg_within_group);
2304 COPY_SCALAR_FIELD(agg_star);
2305 COPY_SCALAR_FIELD(agg_distinct);
2306 COPY_SCALAR_FIELD(func_variadic);
2307 COPY_NODE_FIELD(over);
2308 COPY_LOCATION_FIELD(location);
2314 _copyAStar(const A_Star *from)
2316 A_Star *newnode = makeNode(A_Star);
2322 _copyAIndices(const A_Indices *from)
2324 A_Indices *newnode = makeNode(A_Indices);
2326 COPY_NODE_FIELD(lidx);
2327 COPY_NODE_FIELD(uidx);
2332 static A_Indirection *
2333 _copyA_Indirection(const A_Indirection *from)
2335 A_Indirection *newnode = makeNode(A_Indirection);
2337 COPY_NODE_FIELD(arg);
2338 COPY_NODE_FIELD(indirection);
2343 static A_ArrayExpr *
2344 _copyA_ArrayExpr(const A_ArrayExpr *from)
2346 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2348 COPY_NODE_FIELD(elements);
2349 COPY_LOCATION_FIELD(location);
2355 _copyResTarget(const ResTarget *from)
2357 ResTarget *newnode = makeNode(ResTarget);
2359 COPY_STRING_FIELD(name);
2360 COPY_NODE_FIELD(indirection);
2361 COPY_NODE_FIELD(val);
2362 COPY_LOCATION_FIELD(location);
2367 static MultiAssignRef *
2368 _copyMultiAssignRef(const MultiAssignRef *from)
2370 MultiAssignRef *newnode = makeNode(MultiAssignRef);
2372 COPY_NODE_FIELD(source);
2373 COPY_SCALAR_FIELD(colno);
2374 COPY_SCALAR_FIELD(ncolumns);
2380 _copyTypeName(const TypeName *from)
2382 TypeName *newnode = makeNode(TypeName);
2384 COPY_NODE_FIELD(names);
2385 COPY_SCALAR_FIELD(typeOid);
2386 COPY_SCALAR_FIELD(setof);
2387 COPY_SCALAR_FIELD(pct_type);
2388 COPY_NODE_FIELD(typmods);
2389 COPY_SCALAR_FIELD(typemod);
2390 COPY_NODE_FIELD(arrayBounds);
2391 COPY_LOCATION_FIELD(location);
2397 _copySortBy(const SortBy *from)
2399 SortBy *newnode = makeNode(SortBy);
2401 COPY_NODE_FIELD(node);
2402 COPY_SCALAR_FIELD(sortby_dir);
2403 COPY_SCALAR_FIELD(sortby_nulls);
2404 COPY_NODE_FIELD(useOp);
2405 COPY_LOCATION_FIELD(location);
2411 _copyWindowDef(const WindowDef *from)
2413 WindowDef *newnode = makeNode(WindowDef);
2415 COPY_STRING_FIELD(name);
2416 COPY_STRING_FIELD(refname);
2417 COPY_NODE_FIELD(partitionClause);
2418 COPY_NODE_FIELD(orderClause);
2419 COPY_SCALAR_FIELD(frameOptions);
2420 COPY_NODE_FIELD(startOffset);
2421 COPY_NODE_FIELD(endOffset);
2422 COPY_LOCATION_FIELD(location);
2427 static RangeSubselect *
2428 _copyRangeSubselect(const RangeSubselect *from)
2430 RangeSubselect *newnode = makeNode(RangeSubselect);
2432 COPY_SCALAR_FIELD(lateral);
2433 COPY_NODE_FIELD(subquery);
2434 COPY_NODE_FIELD(alias);
2439 static RangeFunction *
2440 _copyRangeFunction(const RangeFunction *from)
2442 RangeFunction *newnode = makeNode(RangeFunction);
2444 COPY_SCALAR_FIELD(lateral);
2445 COPY_SCALAR_FIELD(ordinality);
2446 COPY_SCALAR_FIELD(is_rowsfrom);
2447 COPY_NODE_FIELD(functions);
2448 COPY_NODE_FIELD(alias);
2449 COPY_NODE_FIELD(coldeflist);
2455 _copyTypeCast(const TypeCast *from)
2457 TypeCast *newnode = makeNode(TypeCast);
2459 COPY_NODE_FIELD(arg);
2460 COPY_NODE_FIELD(typeName);
2461 COPY_LOCATION_FIELD(location);
2466 static CollateClause *
2467 _copyCollateClause(const CollateClause *from)
2469 CollateClause *newnode = makeNode(CollateClause);
2471 COPY_NODE_FIELD(arg);
2472 COPY_NODE_FIELD(collname);
2473 COPY_LOCATION_FIELD(location);
2479 _copyIndexElem(const IndexElem *from)
2481 IndexElem *newnode = makeNode(IndexElem);
2483 COPY_STRING_FIELD(name);
2484 COPY_NODE_FIELD(expr);
2485 COPY_STRING_FIELD(indexcolname);
2486 COPY_NODE_FIELD(collation);
2487 COPY_NODE_FIELD(opclass);
2488 COPY_SCALAR_FIELD(ordering);
2489 COPY_SCALAR_FIELD(nulls_ordering);
2495 _copyColumnDef(const ColumnDef *from)
2497 ColumnDef *newnode = makeNode(ColumnDef);
2499 COPY_STRING_FIELD(colname);
2500 COPY_NODE_FIELD(typeName);
2501 COPY_SCALAR_FIELD(inhcount);
2502 COPY_SCALAR_FIELD(is_local);
2503 COPY_SCALAR_FIELD(is_not_null);
2504 COPY_SCALAR_FIELD(is_from_type);
2505 COPY_SCALAR_FIELD(storage);
2506 COPY_NODE_FIELD(raw_default);
2507 COPY_NODE_FIELD(cooked_default);
2508 COPY_NODE_FIELD(collClause);
2509 COPY_SCALAR_FIELD(collOid);
2510 COPY_NODE_FIELD(constraints);
2511 COPY_NODE_FIELD(fdwoptions);
2512 COPY_LOCATION_FIELD(location);
2518 _copyConstraint(const Constraint *from)
2520 Constraint *newnode = makeNode(Constraint);
2522 COPY_SCALAR_FIELD(contype);
2523 COPY_STRING_FIELD(conname);
2524 COPY_SCALAR_FIELD(deferrable);
2525 COPY_SCALAR_FIELD(initdeferred);
2526 COPY_LOCATION_FIELD(location);
2527 COPY_SCALAR_FIELD(is_no_inherit);
2528 COPY_NODE_FIELD(raw_expr);
2529 COPY_STRING_FIELD(cooked_expr);
2530 COPY_NODE_FIELD(keys);
2531 COPY_NODE_FIELD(exclusions);
2532 COPY_NODE_FIELD(options);
2533 COPY_STRING_FIELD(indexname);
2534 COPY_STRING_FIELD(indexspace);
2535 COPY_STRING_FIELD(access_method);
2536 COPY_NODE_FIELD(where_clause);
2537 COPY_NODE_FIELD(pktable);
2538 COPY_NODE_FIELD(fk_attrs);
2539 COPY_NODE_FIELD(pk_attrs);
2540 COPY_SCALAR_FIELD(fk_matchtype);
2541 COPY_SCALAR_FIELD(fk_upd_action);
2542 COPY_SCALAR_FIELD(fk_del_action);
2543 COPY_NODE_FIELD(old_conpfeqop);
2544 COPY_SCALAR_FIELD(old_pktable_oid);
2545 COPY_SCALAR_FIELD(skip_validation);
2546 COPY_SCALAR_FIELD(initially_valid);
2552 _copyDefElem(const DefElem *from)
2554 DefElem *newnode = makeNode(DefElem);
2556 COPY_STRING_FIELD(defnamespace);
2557 COPY_STRING_FIELD(defname);
2558 COPY_NODE_FIELD(arg);
2559 COPY_SCALAR_FIELD(defaction);
2564 static LockingClause *
2565 _copyLockingClause(const LockingClause *from)
2567 LockingClause *newnode = makeNode(LockingClause);
2569 COPY_NODE_FIELD(lockedRels);
2570 COPY_SCALAR_FIELD(strength);
2571 COPY_SCALAR_FIELD(waitPolicy);
2576 static XmlSerialize *
2577 _copyXmlSerialize(const XmlSerialize *from)
2579 XmlSerialize *newnode = makeNode(XmlSerialize);
2581 COPY_SCALAR_FIELD(xmloption);
2582 COPY_NODE_FIELD(expr);
2583 COPY_NODE_FIELD(typeName);
2584 COPY_LOCATION_FIELD(location);
2590 _copyRoleSpec(const RoleSpec *from)
2592 RoleSpec *newnode = makeNode(RoleSpec);
2594 COPY_SCALAR_FIELD(roletype);
2595 COPY_STRING_FIELD(rolename);
2596 COPY_LOCATION_FIELD(location);
2602 _copyQuery(const Query *from)
2604 Query *newnode = makeNode(Query);
2606 COPY_SCALAR_FIELD(commandType);
2607 COPY_SCALAR_FIELD(querySource);
2608 COPY_SCALAR_FIELD(queryId);
2609 COPY_SCALAR_FIELD(canSetTag);
2610 COPY_NODE_FIELD(utilityStmt);
2611 COPY_SCALAR_FIELD(resultRelation);
2612 COPY_SCALAR_FIELD(hasAggs);
2613 COPY_SCALAR_FIELD(hasWindowFuncs);
2614 COPY_SCALAR_FIELD(hasSubLinks);
2615 COPY_SCALAR_FIELD(hasDistinctOn);
2616 COPY_SCALAR_FIELD(hasRecursive);
2617 COPY_SCALAR_FIELD(hasModifyingCTE);
2618 COPY_SCALAR_FIELD(hasForUpdate);
2619 COPY_SCALAR_FIELD(hasRowSecurity);
2620 COPY_NODE_FIELD(cteList);
2621 COPY_NODE_FIELD(rtable);
2622 COPY_NODE_FIELD(jointree);
2623 COPY_NODE_FIELD(targetList);
2624 COPY_NODE_FIELD(withCheckOptions);
2625 COPY_NODE_FIELD(onConflict);
2626 COPY_NODE_FIELD(returningList);
2627 COPY_NODE_FIELD(groupClause);
2628 COPY_NODE_FIELD(havingQual);
2629 COPY_NODE_FIELD(windowClause);
2630 COPY_NODE_FIELD(distinctClause);
2631 COPY_NODE_FIELD(sortClause);
2632 COPY_NODE_FIELD(limitOffset);
2633 COPY_NODE_FIELD(limitCount);
2634 COPY_NODE_FIELD(rowMarks);
2635 COPY_NODE_FIELD(setOperations);
2636 COPY_NODE_FIELD(constraintDeps);
2642 _copyInsertStmt(const InsertStmt *from)
2644 InsertStmt *newnode = makeNode(InsertStmt);
2646 COPY_NODE_FIELD(relation);
2647 COPY_NODE_FIELD(cols);
2648 COPY_NODE_FIELD(selectStmt);
2649 COPY_NODE_FIELD(onConflictClause);
2650 COPY_NODE_FIELD(returningList);
2651 COPY_NODE_FIELD(withClause);
2657 _copyDeleteStmt(const DeleteStmt *from)
2659 DeleteStmt *newnode = makeNode(DeleteStmt);
2661 COPY_NODE_FIELD(relation);
2662 COPY_NODE_FIELD(usingClause);
2663 COPY_NODE_FIELD(whereClause);
2664 COPY_NODE_FIELD(returningList);
2665 COPY_NODE_FIELD(withClause);
2671 _copyUpdateStmt(const UpdateStmt *from)
2673 UpdateStmt *newnode = makeNode(UpdateStmt);
2675 COPY_NODE_FIELD(relation);
2676 COPY_NODE_FIELD(targetList);
2677 COPY_NODE_FIELD(whereClause);
2678 COPY_NODE_FIELD(fromClause);
2679 COPY_NODE_FIELD(returningList);
2680 COPY_NODE_FIELD(withClause);
2686 _copySelectStmt(const SelectStmt *from)
2688 SelectStmt *newnode = makeNode(SelectStmt);
2690 COPY_NODE_FIELD(distinctClause);
2691 COPY_NODE_FIELD(intoClause);
2692 COPY_NODE_FIELD(targetList);
2693 COPY_NODE_FIELD(fromClause);
2694 COPY_NODE_FIELD(whereClause);
2695 COPY_NODE_FIELD(groupClause);
2696 COPY_NODE_FIELD(havingClause);
2697 COPY_NODE_FIELD(windowClause);
2698 COPY_NODE_FIELD(valuesLists);
2699 COPY_NODE_FIELD(sortClause);
2700 COPY_NODE_FIELD(limitOffset);
2701 COPY_NODE_FIELD(limitCount);
2702 COPY_NODE_FIELD(lockingClause);
2703 COPY_NODE_FIELD(withClause);
2704 COPY_SCALAR_FIELD(op);
2705 COPY_SCALAR_FIELD(all);
2706 COPY_NODE_FIELD(larg);
2707 COPY_NODE_FIELD(rarg);
2712 static SetOperationStmt *
2713 _copySetOperationStmt(const SetOperationStmt *from)
2715 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2717 COPY_SCALAR_FIELD(op);
2718 COPY_SCALAR_FIELD(all);
2719 COPY_NODE_FIELD(larg);
2720 COPY_NODE_FIELD(rarg);
2721 COPY_NODE_FIELD(colTypes);
2722 COPY_NODE_FIELD(colTypmods);
2723 COPY_NODE_FIELD(colCollations);
2724 COPY_NODE_FIELD(groupClauses);
2729 static AlterTableStmt *
2730 _copyAlterTableStmt(const AlterTableStmt *from)
2732 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2734 COPY_NODE_FIELD(relation);
2735 COPY_NODE_FIELD(cmds);
2736 COPY_SCALAR_FIELD(relkind);
2737 COPY_SCALAR_FIELD(missing_ok);
2742 static AlterTableCmd *
2743 _copyAlterTableCmd(const AlterTableCmd *from)
2745 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2747 COPY_SCALAR_FIELD(subtype);
2748 COPY_STRING_FIELD(name);
2749 COPY_NODE_FIELD(newowner);
2750 COPY_NODE_FIELD(def);
2751 COPY_SCALAR_FIELD(behavior);
2752 COPY_SCALAR_FIELD(missing_ok);
2757 static AlterDomainStmt *
2758 _copyAlterDomainStmt(const AlterDomainStmt *from)
2760 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2762 COPY_SCALAR_FIELD(subtype);
2763 COPY_NODE_FIELD(typeName);
2764 COPY_STRING_FIELD(name);
2765 COPY_NODE_FIELD(def);
2766 COPY_SCALAR_FIELD(behavior);
2767 COPY_SCALAR_FIELD(missing_ok);
2773 _copyGrantStmt(const GrantStmt *from)
2775 GrantStmt *newnode = makeNode(GrantStmt);
2777 COPY_SCALAR_FIELD(is_grant);
2778 COPY_SCALAR_FIELD(targtype);
2779 COPY_SCALAR_FIELD(objtype);
2780 COPY_NODE_FIELD(objects);
2781 COPY_NODE_FIELD(privileges);
2782 COPY_NODE_FIELD(grantees);
2783 COPY_SCALAR_FIELD(grant_option);
2784 COPY_SCALAR_FIELD(behavior);
2789 static FuncWithArgs *
2790 _copyFuncWithArgs(const FuncWithArgs *from)
2792 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2794 COPY_NODE_FIELD(funcname);
2795 COPY_NODE_FIELD(funcargs);
2801 _copyAccessPriv(const AccessPriv *from)
2803 AccessPriv *newnode = makeNode(AccessPriv);
2805 COPY_STRING_FIELD(priv_name);
2806 COPY_NODE_FIELD(cols);
2811 static GrantRoleStmt *
2812 _copyGrantRoleStmt(const GrantRoleStmt *from)
2814 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2816 COPY_NODE_FIELD(granted_roles);
2817 COPY_NODE_FIELD(grantee_roles);
2818 COPY_SCALAR_FIELD(is_grant);
2819 COPY_SCALAR_FIELD(admin_opt);
2820 COPY_NODE_FIELD(grantor);
2821 COPY_SCALAR_FIELD(behavior);
2826 static AlterDefaultPrivilegesStmt *
2827 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
2829 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2831 COPY_NODE_FIELD(options);
2832 COPY_NODE_FIELD(action);
2837 static DeclareCursorStmt *
2838 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
2840 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2842 COPY_STRING_FIELD(portalname);
2843 COPY_SCALAR_FIELD(options);
2844 COPY_NODE_FIELD(query);
2849 static ClosePortalStmt *
2850 _copyClosePortalStmt(const ClosePortalStmt *from)
2852 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2854 COPY_STRING_FIELD(portalname);
2859 static ClusterStmt *
2860 _copyClusterStmt(const ClusterStmt *from)
2862 ClusterStmt *newnode = makeNode(ClusterStmt);
2864 COPY_NODE_FIELD(relation);
2865 COPY_STRING_FIELD(indexname);
2866 COPY_SCALAR_FIELD(verbose);
2872 _copyCopyStmt(const CopyStmt *from)
2874 CopyStmt *newnode = makeNode(CopyStmt);
2876 COPY_NODE_FIELD(relation);
2877 COPY_NODE_FIELD(query);
2878 COPY_NODE_FIELD(attlist);
2879 COPY_SCALAR_FIELD(is_from);
2880 COPY_SCALAR_FIELD(is_program);
2881 COPY_STRING_FIELD(filename);
2882 COPY_NODE_FIELD(options);
2888 * CopyCreateStmtFields
2890 * This function copies the fields of the CreateStmt node. It is used by
2891 * copy functions for classes which inherit from CreateStmt.
2894 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
2896 COPY_NODE_FIELD(relation);
2897 COPY_NODE_FIELD(tableElts);
2898 COPY_NODE_FIELD(inhRelations);
2899 COPY_NODE_FIELD(ofTypename);
2900 COPY_NODE_FIELD(constraints);
2901 COPY_NODE_FIELD(options);
2902 COPY_SCALAR_FIELD(oncommit);
2903 COPY_STRING_FIELD(tablespacename);
2904 COPY_SCALAR_FIELD(if_not_exists);
2908 _copyCreateStmt(const CreateStmt *from)
2910 CreateStmt *newnode = makeNode(CreateStmt);
2912 CopyCreateStmtFields(from, newnode);
2917 static TableLikeClause *
2918 _copyTableLikeClause(const TableLikeClause *from)
2920 TableLikeClause *newnode = makeNode(TableLikeClause);
2922 COPY_NODE_FIELD(relation);
2923 COPY_SCALAR_FIELD(options);
2929 _copyDefineStmt(const DefineStmt *from)
2931 DefineStmt *newnode = makeNode(DefineStmt);
2933 COPY_SCALAR_FIELD(kind);
2934 COPY_SCALAR_FIELD(oldstyle);
2935 COPY_NODE_FIELD(defnames);
2936 COPY_NODE_FIELD(args);
2937 COPY_NODE_FIELD(definition);
2943 _copyDropStmt(const DropStmt *from)
2945 DropStmt *newnode = makeNode(DropStmt);
2947 COPY_NODE_FIELD(objects);
2948 COPY_NODE_FIELD(arguments);
2949 COPY_SCALAR_FIELD(removeType);
2950 COPY_SCALAR_FIELD(behavior);
2951 COPY_SCALAR_FIELD(missing_ok);
2952 COPY_SCALAR_FIELD(concurrent);
2957 static TruncateStmt *
2958 _copyTruncateStmt(const TruncateStmt *from)
2960 TruncateStmt *newnode = makeNode(TruncateStmt);
2962 COPY_NODE_FIELD(relations);
2963 COPY_SCALAR_FIELD(restart_seqs);
2964 COPY_SCALAR_FIELD(behavior);
2969 static CommentStmt *
2970 _copyCommentStmt(const CommentStmt *from)
2972 CommentStmt *newnode = makeNode(CommentStmt);
2974 COPY_SCALAR_FIELD(objtype);
2975 COPY_NODE_FIELD(objname);
2976 COPY_NODE_FIELD(objargs);
2977 COPY_STRING_FIELD(comment);
2982 static SecLabelStmt *
2983 _copySecLabelStmt(const SecLabelStmt *from)
2985 SecLabelStmt *newnode = makeNode(SecLabelStmt);
2987 COPY_SCALAR_FIELD(objtype);
2988 COPY_NODE_FIELD(objname);
2989 COPY_NODE_FIELD(objargs);
2990 COPY_STRING_FIELD(provider);
2991 COPY_STRING_FIELD(label);
2997 _copyFetchStmt(const FetchStmt *from)
2999 FetchStmt *newnode = makeNode(FetchStmt);
3001 COPY_SCALAR_FIELD(direction);
3002 COPY_SCALAR_FIELD(howMany);
3003 COPY_STRING_FIELD(portalname);
3004 COPY_SCALAR_FIELD(ismove);
3010 _copyIndexStmt(const IndexStmt *from)
3012 IndexStmt *newnode = makeNode(IndexStmt);
3014 COPY_STRING_FIELD(idxname);
3015 COPY_NODE_FIELD(relation);
3016 COPY_STRING_FIELD(accessMethod);
3017 COPY_STRING_FIELD(tableSpace);
3018 COPY_NODE_FIELD(indexParams);
3019 COPY_NODE_FIELD(options);
3020 COPY_NODE_FIELD(whereClause);
3021 COPY_NODE_FIELD(excludeOpNames);
3022 COPY_STRING_FIELD(idxcomment);
3023 COPY_SCALAR_FIELD(indexOid);
3024 COPY_SCALAR_FIELD(oldNode);
3025 COPY_SCALAR_FIELD(unique);
3026 COPY_SCALAR_FIELD(primary);
3027 COPY_SCALAR_FIELD(isconstraint);
3028 COPY_SCALAR_FIELD(deferrable);
3029 COPY_SCALAR_FIELD(initdeferred);
3030 COPY_SCALAR_FIELD(transformed);
3031 COPY_SCALAR_FIELD(concurrent);
3032 COPY_SCALAR_FIELD(if_not_exists);
3037 static CreateFunctionStmt *
3038 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
3040 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
3042 COPY_SCALAR_FIELD(replace);
3043 COPY_NODE_FIELD(funcname);
3044 COPY_NODE_FIELD(parameters);
3045 COPY_NODE_FIELD(returnType);
3046 COPY_NODE_FIELD(options);
3047 COPY_NODE_FIELD(withClause);
3052 static FunctionParameter *
3053 _copyFunctionParameter(const FunctionParameter *from)
3055 FunctionParameter *newnode = makeNode(FunctionParameter);
3057 COPY_STRING_FIELD(name);
3058 COPY_NODE_FIELD(argType);
3059 COPY_SCALAR_FIELD(mode);
3060 COPY_NODE_FIELD(defexpr);
3065 static AlterFunctionStmt *
3066 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
3068 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
3070 COPY_NODE_FIELD(func);
3071 COPY_NODE_FIELD(actions);
3077 _copyDoStmt(const DoStmt *from)
3079 DoStmt *newnode = makeNode(DoStmt);
3081 COPY_NODE_FIELD(args);
3087 _copyRenameStmt(const RenameStmt *from)
3089 RenameStmt *newnode = makeNode(RenameStmt);
3091 COPY_SCALAR_FIELD(renameType);
3092 COPY_SCALAR_FIELD(relationType);
3093 COPY_NODE_FIELD(relation);
3094 COPY_NODE_FIELD(object);
3095 COPY_NODE_FIELD(objarg);
3096 COPY_STRING_FIELD(subname);
3097 COPY_STRING_FIELD(newname);
3098 COPY_SCALAR_FIELD(behavior);
3099 COPY_SCALAR_FIELD(missing_ok);
3104 static AlterObjectSchemaStmt *
3105 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
3107 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
3109 COPY_SCALAR_FIELD(objectType);
3110 COPY_NODE_FIELD(relation);
3111 COPY_NODE_FIELD(object);
3112 COPY_NODE_FIELD(objarg);
3113 COPY_STRING_FIELD(newschema);
3114 COPY_SCALAR_FIELD(missing_ok);
3119 static AlterOwnerStmt *
3120 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
3122 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
3124 COPY_SCALAR_FIELD(objectType);
3125 COPY_NODE_FIELD(relation);
3126 COPY_NODE_FIELD(object);
3127 COPY_NODE_FIELD(objarg);
3128 COPY_NODE_FIELD(newowner);
3134 _copyRuleStmt(const RuleStmt *from)
3136 RuleStmt *newnode = makeNode(RuleStmt);
3138 COPY_NODE_FIELD(relation);
3139 COPY_STRING_FIELD(rulename);
3140 COPY_NODE_FIELD(whereClause);
3141 COPY_SCALAR_FIELD(event);
3142 COPY_SCALAR_FIELD(instead);
3143 COPY_NODE_FIELD(actions);
3144 COPY_SCALAR_FIELD(replace);
3150 _copyNotifyStmt(const NotifyStmt *from)
3152 NotifyStmt *newnode = makeNode(NotifyStmt);
3154 COPY_STRING_FIELD(conditionname);
3155 COPY_STRING_FIELD(payload);
3161 _copyListenStmt(const ListenStmt *from)
3163 ListenStmt *newnode = makeNode(ListenStmt);
3165 COPY_STRING_FIELD(conditionname);
3170 static UnlistenStmt *
3171 _copyUnlistenStmt(const UnlistenStmt *from)
3173 UnlistenStmt *newnode = makeNode(UnlistenStmt);
3175 COPY_STRING_FIELD(conditionname);
3180 static TransactionStmt *
3181 _copyTransactionStmt(const TransactionStmt *from)
3183 TransactionStmt *newnode = makeNode(TransactionStmt);
3185 COPY_SCALAR_FIELD(kind);
3186 COPY_NODE_FIELD(options);
3187 COPY_STRING_FIELD(gid);
3192 static CompositeTypeStmt *
3193 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3195 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3197 COPY_NODE_FIELD(typevar);
3198 COPY_NODE_FIELD(coldeflist);
3203 static CreateEnumStmt *
3204 _copyCreateEnumStmt(const CreateEnumStmt *from)
3206 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3208 COPY_NODE_FIELD(typeName);
3209 COPY_NODE_FIELD(vals);
3214 static CreateRangeStmt *
3215 _copyCreateRangeStmt(const CreateRangeStmt *from)
3217 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3219 COPY_NODE_FIELD(typeName);
3220 COPY_NODE_FIELD(params);
3225 static AlterEnumStmt *
3226 _copyAlterEnumStmt(const AlterEnumStmt *from)
3228 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3230 COPY_NODE_FIELD(typeName);
3231 COPY_STRING_FIELD(newVal);
3232 COPY_STRING_FIELD(newValNeighbor);
3233 COPY_SCALAR_FIELD(newValIsAfter);
3234 COPY_SCALAR_FIELD(skipIfExists);
3240 _copyViewStmt(const ViewStmt *from)
3242 ViewStmt *newnode = makeNode(ViewStmt);
3244 COPY_NODE_FIELD(view);
3245 COPY_NODE_FIELD(aliases);
3246 COPY_NODE_FIELD(query);
3247 COPY_SCALAR_FIELD(replace);
3248 COPY_NODE_FIELD(options);
3249 COPY_SCALAR_FIELD(withCheckOption);
3255 _copyLoadStmt(const LoadStmt *from)
3257 LoadStmt *newnode = makeNode(LoadStmt);
3259 COPY_STRING_FIELD(filename);
3264 static CreateDomainStmt *
3265 _copyCreateDomainStmt(const CreateDomainStmt *from)
3267 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3269 COPY_NODE_FIELD(domainname);
3270 COPY_NODE_FIELD(typeName);
3271 COPY_NODE_FIELD(collClause);
3272 COPY_NODE_FIELD(constraints);
3277 static CreateOpClassStmt *
3278 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3280 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3282 COPY_NODE_FIELD(opclassname);
3283 COPY_NODE_FIELD(opfamilyname);
3284 COPY_STRING_FIELD(amname);
3285 COPY_NODE_FIELD(datatype);
3286 COPY_NODE_FIELD(items);
3287 COPY_SCALAR_FIELD(isDefault);
3292 static CreateOpClassItem *
3293 _copyCreateOpClassItem(const CreateOpClassItem *from)
3295 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3297 COPY_SCALAR_FIELD(itemtype);
3298 COPY_NODE_FIELD(name);
3299 COPY_NODE_FIELD(args);
3300 COPY_SCALAR_FIELD(number);
3301 COPY_NODE_FIELD(order_family);
3302 COPY_NODE_FIELD(class_args);
3303 COPY_NODE_FIELD(storedtype);
3308 static CreateOpFamilyStmt *
3309 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3311 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3313 COPY_NODE_FIELD(opfamilyname);
3314 COPY_STRING_FIELD(amname);
3319 static AlterOpFamilyStmt *
3320 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3322 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3324 COPY_NODE_FIELD(opfamilyname);
3325 COPY_STRING_FIELD(amname);
3326 COPY_SCALAR_FIELD(isDrop);
3327 COPY_NODE_FIELD(items);
3332 static CreatedbStmt *
3333 _copyCreatedbStmt(const CreatedbStmt *from)
3335 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3337 COPY_STRING_FIELD(dbname);
3338 COPY_NODE_FIELD(options);
3343 static AlterDatabaseStmt *
3344 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3346 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3348 COPY_STRING_FIELD(dbname);
3349 COPY_NODE_FIELD(options);
3354 static AlterDatabaseSetStmt *
3355 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3357 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3359 COPY_STRING_FIELD(dbname);
3360 COPY_NODE_FIELD(setstmt);
3366 _copyDropdbStmt(const DropdbStmt *from)
3368 DropdbStmt *newnode = makeNode(DropdbStmt);
3370 COPY_STRING_FIELD(dbname);
3371 COPY_SCALAR_FIELD(missing_ok);
3377 _copyVacuumStmt(const VacuumStmt *from)
3379 VacuumStmt *newnode = makeNode(VacuumStmt);
3381 COPY_SCALAR_FIELD(options);
3382 COPY_NODE_FIELD(relation);
3383 COPY_NODE_FIELD(va_cols);
3388 static ExplainStmt *
3389 _copyExplainStmt(const ExplainStmt *from)
3391 ExplainStmt *newnode = makeNode(ExplainStmt);
3393 COPY_NODE_FIELD(query);
3394 COPY_NODE_FIELD(options);
3399 static CreateTableAsStmt *
3400 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3402 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3404 COPY_NODE_FIELD(query);
3405 COPY_NODE_FIELD(into);
3406 COPY_SCALAR_FIELD(relkind);
3407 COPY_SCALAR_FIELD(is_select_into);
3408 COPY_SCALAR_FIELD(if_not_exists);
3413 static RefreshMatViewStmt *
3414 _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
3416 RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
3418 COPY_SCALAR_FIELD(concurrent);
3419 COPY_SCALAR_FIELD(skipData);
3420 COPY_NODE_FIELD(relation);
3425 static ReplicaIdentityStmt *
3426 _copyReplicaIdentityStmt(const ReplicaIdentityStmt *from)
3428 ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt);
3430 COPY_SCALAR_FIELD(identity_type);
3431 COPY_STRING_FIELD(name);
3436 static AlterSystemStmt *
3437 _copyAlterSystemStmt(const AlterSystemStmt *from)
3439 AlterSystemStmt *newnode = makeNode(AlterSystemStmt);
3441 COPY_NODE_FIELD(setstmt);
3446 static CreateSeqStmt *
3447 _copyCreateSeqStmt(const CreateSeqStmt *from)
3449 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3451 COPY_NODE_FIELD(sequence);
3452 COPY_NODE_FIELD(options);
3453 COPY_SCALAR_FIELD(ownerId);
3454 COPY_SCALAR_FIELD(if_not_exists);
3459 static AlterSeqStmt *
3460 _copyAlterSeqStmt(const AlterSeqStmt *from)
3462 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3464 COPY_NODE_FIELD(sequence);
3465 COPY_NODE_FIELD(options);
3466 COPY_SCALAR_FIELD(missing_ok);
3471 static VariableSetStmt *
3472 _copyVariableSetStmt(const VariableSetStmt *from)
3474 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3476 COPY_SCALAR_FIELD(kind);
3477 COPY_STRING_FIELD(name);
3478 COPY_NODE_FIELD(args);
3479 COPY_SCALAR_FIELD(is_local);
3484 static VariableShowStmt *
3485 _copyVariableShowStmt(const VariableShowStmt *from)
3487 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3489 COPY_STRING_FIELD(name);
3494 static DiscardStmt *
3495 _copyDiscardStmt(const DiscardStmt *from)
3497 DiscardStmt *newnode = makeNode(DiscardStmt);
3499 COPY_SCALAR_FIELD(target);
3504 static CreateTableSpaceStmt *
3505 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3507 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3509 COPY_STRING_FIELD(tablespacename);
3510 COPY_NODE_FIELD(owner);
3511 COPY_STRING_FIELD(location);
3512 COPY_NODE_FIELD(options);
3517 static DropTableSpaceStmt *
3518 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
3520 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3522 COPY_STRING_FIELD(tablespacename);
3523 COPY_SCALAR_FIELD(missing_ok);
3528 static AlterTableSpaceOptionsStmt *
3529 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
3531 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3533 COPY_STRING_FIELD(tablespacename);
3534 COPY_NODE_FIELD(options);
3535 COPY_SCALAR_FIELD(isReset);
3540 static AlterTableMoveAllStmt *
3541 _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
3543 AlterTableMoveAllStmt *newnode = makeNode(AlterTableMoveAllStmt);
3545 COPY_STRING_FIELD(orig_tablespacename);
3546 COPY_SCALAR_FIELD(objtype);
3547 COPY_NODE_FIELD(roles);
3548 COPY_STRING_FIELD(new_tablespacename);
3549 COPY_SCALAR_FIELD(nowait);
3554 static CreateExtensionStmt *
3555 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
3557 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3559 COPY_STRING_FIELD(extname);
3560 COPY_SCALAR_FIELD(if_not_exists);
3561 COPY_NODE_FIELD(options);
3566 static AlterExtensionStmt *
3567 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
3569 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3571 COPY_STRING_FIELD(extname);
3572 COPY_NODE_FIELD(options);
3577 static AlterExtensionContentsStmt *
3578 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
3580 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3582 COPY_STRING_FIELD(extname);
3583 COPY_SCALAR_FIELD(action);
3584 COPY_SCALAR_FIELD(objtype);
3585 COPY_NODE_FIELD(objname);
3586 COPY_NODE_FIELD(objargs);
3591 static CreateFdwStmt *
3592 _copyCreateFdwStmt(const CreateFdwStmt *from)
3594 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3596 COPY_STRING_FIELD(fdwname);
3597 COPY_NODE_FIELD(func_options);
3598 COPY_NODE_FIELD(options);
3603 static AlterFdwStmt *
3604 _copyAlterFdwStmt(const AlterFdwStmt *from)
3606 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3608 COPY_STRING_FIELD(fdwname);
3609 COPY_NODE_FIELD(func_options);
3610 COPY_NODE_FIELD(options);
3615 static CreateForeignServerStmt *
3616 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
3618 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3620 COPY_STRING_FIELD(servername);
3621 COPY_STRING_FIELD(servertype);
3622 COPY_STRING_FIELD(version);
3623 COPY_STRING_FIELD(fdwname);
3624 COPY_NODE_FIELD(options);
3629 static AlterForeignServerStmt *
3630 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
3632 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3634 COPY_STRING_FIELD(servername);
3635 COPY_STRING_FIELD(version);
3636 COPY_NODE_FIELD(options);
3637 COPY_SCALAR_FIELD(has_version);
3642 static CreateUserMappingStmt *
3643 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
3645 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3647 COPY_NODE_FIELD(user);
3648 COPY_STRING_FIELD(servername);
3649 COPY_NODE_FIELD(options);
3654 static AlterUserMappingStmt *
3655 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
3657 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3659 COPY_NODE_FIELD(user);
3660 COPY_STRING_FIELD(servername);
3661 COPY_NODE_FIELD(options);
3666 static DropUserMappingStmt *
3667 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
3669 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3671 COPY_NODE_FIELD(user);
3672 COPY_STRING_FIELD(servername);
3673 COPY_SCALAR_FIELD(missing_ok);
3678 static CreateForeignTableStmt *
3679 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
3681 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3683 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
3685 COPY_STRING_FIELD(servername);
3686 COPY_NODE_FIELD(options);
3691 static ImportForeignSchemaStmt *
3692 _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
3694 ImportForeignSchemaStmt *newnode = makeNode(ImportForeignSchemaStmt);
3696 COPY_STRING_FIELD(server_name);
3697 COPY_STRING_FIELD(remote_schema);
3698 COPY_STRING_FIELD(local_schema);
3699 COPY_SCALAR_FIELD(list_type);
3700 COPY_NODE_FIELD(table_list);
3701 COPY_NODE_FIELD(options);
3706 static CreateTransformStmt *
3707 _copyCreateTransformStmt(const CreateTransformStmt *from)
3709 CreateTransformStmt *newnode = makeNode(CreateTransformStmt);
3711 COPY_SCALAR_FIELD(replace);
3712 COPY_NODE_FIELD(type_name);
3713 COPY_STRING_FIELD(lang);
3714 COPY_NODE_FIELD(fromsql);
3715 COPY_NODE_FIELD(tosql);
3720 static CreateTrigStmt *
3721 _copyCreateTrigStmt(const CreateTrigStmt *from)
3723 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3725 COPY_STRING_FIELD(trigname);
3726 COPY_NODE_FIELD(relation);
3727 COPY_NODE_FIELD(funcname);
3728 COPY_NODE_FIELD(args);
3729 COPY_SCALAR_FIELD(row);
3730 COPY_SCALAR_FIELD(timing);
3731 COPY_SCALAR_FIELD(events);
3732 COPY_NODE_FIELD(columns);
3733 COPY_NODE_FIELD(whenClause);
3734 COPY_SCALAR_FIELD(isconstraint);
3735 COPY_SCALAR_FIELD(deferrable);
3736 COPY_SCALAR_FIELD(initdeferred);
3737 COPY_NODE_FIELD(constrrel);
3742 static CreateEventTrigStmt *
3743 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
3745 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
3747 COPY_STRING_FIELD(trigname);
3748 COPY_STRING_FIELD(eventname);
3749 COPY_NODE_FIELD(whenclause);
3750 COPY_NODE_FIELD(funcname);
3755 static AlterEventTrigStmt *
3756 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
3758 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
3760 COPY_STRING_FIELD(trigname);
3761 COPY_SCALAR_FIELD(tgenabled);
3766 static CreatePLangStmt *
3767 _copyCreatePLangStmt(const CreatePLangStmt *from)
3769 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3771 COPY_SCALAR_FIELD(replace);
3772 COPY_STRING_FIELD(plname);
3773 COPY_NODE_FIELD(plhandler);
3774 COPY_NODE_FIELD(plinline);
3775 COPY_NODE_FIELD(plvalidator);
3776 COPY_SCALAR_FIELD(pltrusted);
3781 static CreateRoleStmt *
3782 _copyCreateRoleStmt(const CreateRoleStmt *from)
3784 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3786 COPY_SCALAR_FIELD(stmt_type);
3787 COPY_STRING_FIELD(role);
3788 COPY_NODE_FIELD(options);
3793 static AlterRoleStmt *
3794 _copyAlterRoleStmt(const AlterRoleStmt *from)
3796 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3798 COPY_NODE_FIELD(role);
3799 COPY_NODE_FIELD(options);
3800 COPY_SCALAR_FIELD(action);
3805 static AlterRoleSetStmt *
3806 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
3808 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3810 COPY_NODE_FIELD(role);
3811 COPY_STRING_FIELD(database);
3812 COPY_NODE_FIELD(setstmt);
3817 static DropRoleStmt *
3818 _copyDropRoleStmt(const DropRoleStmt *from)
3820 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3822 COPY_NODE_FIELD(roles);
3823 COPY_SCALAR_FIELD(missing_ok);
3829 _copyLockStmt(const LockStmt *from)
3831 LockStmt *newnode = makeNode(LockStmt);
3833 COPY_NODE_FIELD(relations);
3834 COPY_SCALAR_FIELD(mode);
3835 COPY_SCALAR_FIELD(nowait);
3840 static ConstraintsSetStmt *
3841 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
3843 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3845 COPY_NODE_FIELD(constraints);
3846 COPY_SCALAR_FIELD(deferred);
3851 static ReindexStmt *
3852 _copyReindexStmt(const ReindexStmt *from)
3854 ReindexStmt *newnode = makeNode(ReindexStmt);
3856 COPY_SCALAR_FIELD(kind);
3857 COPY_NODE_FIELD(relation);
3858 COPY_STRING_FIELD(name);
3863 static CreateSchemaStmt *
3864 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
3866 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3868 COPY_STRING_FIELD(schemaname);
3869 COPY_NODE_FIELD(authrole);
3870 COPY_NODE_FIELD(schemaElts);
3871 COPY_SCALAR_FIELD(if_not_exists);
3876 static CreateConversionStmt *
3877 _copyCreateConversionStmt(const CreateConversionStmt *from)
3879 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3881 COPY_NODE_FIELD(conversion_name);
3882 COPY_STRING_FIELD(for_encoding_name);
3883 COPY_STRING_FIELD(to_encoding_name);
3884 COPY_NODE_FIELD(func_name);
3885 COPY_SCALAR_FIELD(def);
3890 static CreateCastStmt *
3891 _copyCreateCastStmt(const CreateCastStmt *from)
3893 CreateCastStmt *newnode = makeNode(CreateCastStmt);
3895 COPY_NODE_FIELD(sourcetype);
3896 COPY_NODE_FIELD(targettype);
3897 COPY_NODE_FIELD(func);
3898 COPY_SCALAR_FIELD(context);
3899 COPY_SCALAR_FIELD(inout);
3904 static PrepareStmt *
3905 _copyPrepareStmt(const PrepareStmt *from)
3907 PrepareStmt *newnode = makeNode(PrepareStmt);
3909 COPY_STRING_FIELD(name);
3910 COPY_NODE_FIELD(argtypes);
3911 COPY_NODE_FIELD(query);
3916 static ExecuteStmt *
3917 _copyExecuteStmt(const ExecuteStmt *from)
3919 ExecuteStmt *newnode = makeNode(ExecuteStmt);
3921 COPY_STRING_FIELD(name);
3922 COPY_NODE_FIELD(params);
3927 static DeallocateStmt *
3928 _copyDeallocateStmt(const DeallocateStmt *from)
3930 DeallocateStmt *newnode = makeNode(DeallocateStmt);
3932 COPY_STRING_FIELD(name);
3937 static DropOwnedStmt *
3938 _copyDropOwnedStmt(const DropOwnedStmt *from)
3940 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3942 COPY_NODE_FIELD(roles);
3943 COPY_SCALAR_FIELD(behavior);
3948 static ReassignOwnedStmt *
3949 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
3951 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3953 COPY_NODE_FIELD(roles);
3954 COPY_NODE_FIELD(newrole);
3959 static AlterTSDictionaryStmt *
3960 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
3962 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3964 COPY_NODE_FIELD(dictname);
3965 COPY_NODE_FIELD(options);
3970 static AlterTSConfigurationStmt *
3971 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
3973 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3975 COPY_NODE_FIELD(cfgname);
3976 COPY_NODE_FIELD(tokentype);
3977 COPY_NODE_FIELD(dicts);
3978 COPY_SCALAR_FIELD(override);
3979 COPY_SCALAR_FIELD(replace);
3980 COPY_SCALAR_FIELD(missing_ok);
3985 static CreatePolicyStmt *
3986 _copyCreatePolicyStmt(const CreatePolicyStmt *from)
3988 CreatePolicyStmt *newnode = makeNode(CreatePolicyStmt);
3990 COPY_STRING_FIELD(policy_name);
3991 COPY_NODE_FIELD(table);
3992 COPY_SCALAR_FIELD(cmd);
3993 COPY_NODE_FIELD(roles);
3994 COPY_NODE_FIELD(qual);
3995 COPY_NODE_FIELD(with_check);
4000 static AlterPolicyStmt *
4001 _copyAlterPolicyStmt(const AlterPolicyStmt *from)
4003 AlterPolicyStmt *newnode = makeNode(AlterPolicyStmt);
4005 COPY_STRING_FIELD(policy_name);
4006 COPY_NODE_FIELD(table);
4007 COPY_NODE_FIELD(roles);
4008 COPY_NODE_FIELD(qual);
4009 COPY_NODE_FIELD(with_check);
4014 /* ****************************************************************
4015 * pg_list.h copy functions
4016 * ****************************************************************
4020 * Perform a deep copy of the specified list, using copyObject(). The
4021 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
4022 * need deep copies, so they should be copied via list_copy()
4024 #define COPY_NODE_CELL(new, old) \
4025 (new) = (ListCell *) palloc(sizeof(ListCell)); \
4026 lfirst(new) = copyObject(lfirst(old));
4029 _copyList(const List *from)
4035 Assert(list_length(from) >= 1);
4037 new = makeNode(List);
4038 new->length = from->length;
4040 COPY_NODE_CELL(new->head, from->head);
4041 prev_new = new->head;
4042 curr_old = lnext(from->head);
4046 COPY_NODE_CELL(prev_new->next, curr_old);
4047 prev_new = prev_new->next;
4048 curr_old = curr_old->next;
4050 prev_new->next = NULL;
4051 new->tail = prev_new;
4056 /* ****************************************************************
4057 * value.h copy functions
4058 * ****************************************************************
4061 _copyValue(const Value *from)
4063 Value *newnode = makeNode(Value);
4065 /* See also _copyAConst when changing this code! */
4067 COPY_SCALAR_FIELD(type);
4071 COPY_SCALAR_FIELD(val.ival);
4076 COPY_STRING_FIELD(val.str);
4082 elog(ERROR, "unrecognized node type: %d",
4092 * Create a copy of a Node tree or list. This is a "deep" copy: all
4093 * substructure is copied too, recursively.
4096 copyObject(const void *from)
4103 /* Guard against stack overflow due to overly complex expressions */
4104 check_stack_depth();
4106 switch (nodeTag(from))
4112 retval = _copyPlannedStmt(from);
4115 retval = _copyPlan(from);
4118 retval = _copyResult(from);
4121 retval = _copyModifyTable(from);
4124 retval = _copyAppend(from);
4127 retval = _copyMergeAppend(from);
4129 case T_RecursiveUnion:
4130 retval = _copyRecursiveUnion(from);
4133 retval = _copyBitmapAnd(from);
4136 retval = _copyBitmapOr(from);
4139 retval = _copyScan(from);
4142 retval = _copySeqScan(from);
4145 retval = _copyIndexScan(from);
4147 case T_IndexOnlyScan:
4148 retval = _copyIndexOnlyScan(from);
4150 case T_BitmapIndexScan:
4151 retval = _copyBitmapIndexScan(from);
4153 case T_BitmapHeapScan:
4154 retval = _copyBitmapHeapScan(from);
4157 retval = _copyTidScan(from);
4159 case T_SubqueryScan:
4160 retval = _copySubqueryScan(from);
4162 case T_FunctionScan:
4163 retval = _copyFunctionScan(from);
4166 retval = _copyValuesScan(from);
4169 retval = _copyCteScan(from);
4171 case T_WorkTableScan:
4172 retval = _copyWorkTableScan(from);
4175 retval = _copyForeignScan(from);
4178 retval = _copyCustomScan(from);
4181 retval = _copyJoin(from);
4184 retval = _copyNestLoop(from);
4187 retval = _copyMergeJoin(from);
4190 retval = _copyHashJoin(from);
4193 retval = _copyMaterial(from);
4196 retval = _copySort(from);
4199 retval = _copyGroup(from);
4202 retval = _copyAgg(from);
4205 retval = _copyWindowAgg(from);
4208 retval = _copyUnique(from);
4211 retval = _copyHash(from);
4214 retval = _copySetOp(from);
4217 retval = _copyLockRows(from);
4220 retval = _copyLimit(from);
4222 case T_NestLoopParam:
4223 retval = _copyNestLoopParam(from);
4226 retval = _copyPlanRowMark(from);
4228 case T_PlanInvalItem:
4229 retval = _copyPlanInvalItem(from);
4236 retval = _copyAlias(from);
4239 retval = _copyRangeVar(from);
4242 retval = _copyIntoClause(from);
4245 retval = _copyVar(from);
4248 retval = _copyConst(from);
4251 retval = _copyParam(from);
4254 retval = _copyAggref(from);
4257 retval = _copyWindowFunc(from);
4260 retval = _copyArrayRef(from);
4263 retval = _copyFuncExpr(from);
4265 case T_NamedArgExpr:
4266 retval = _copyNamedArgExpr(from);
4269 retval = _copyOpExpr(from);
4271 case T_DistinctExpr:
4272 retval = _copyDistinctExpr(from);
4275 retval = _copyNullIfExpr(from);
4277 case T_ScalarArrayOpExpr:
4278 retval = _copyScalarArrayOpExpr(from);
4281 retval = _copyBoolExpr(from);
4284 retval = _copySubLink(from);
4287 retval = _copySubPlan(from);
4289 case T_AlternativeSubPlan:
4290 retval = _copyAlternativeSubPlan(from);
4293 retval = _copyFieldSelect(from);
4296 retval = _copyFieldStore(from);
4299 retval = _copyRelabelType(from);
4302 retval = _copyCoerceViaIO(from);
4304 case T_ArrayCoerceExpr:
4305 retval = _copyArrayCoerceExpr(from);
4307 case T_ConvertRowtypeExpr:
4308 retval = _copyConvertRowtypeExpr(from);
4311 retval = _copyCollateExpr(from);
4314 retval = _copyCaseExpr(from);
4317 retval = _copyCaseWhen(from);
4319 case T_CaseTestExpr:
4320 retval = _copyCaseTestExpr(from);
4323 retval = _copyArrayExpr(from);
4326 retval = _copyRowExpr(from);
4328 case T_RowCompareExpr:
4329 retval = _copyRowCompareExpr(from);
4331 case T_CoalesceExpr:
4332 retval = _copyCoalesceExpr(from);
4335 retval = _copyMinMaxExpr(from);
4338 retval = _copyXmlExpr(from);
4341 retval = _copyNullTest(from);
4344 retval = _copyBooleanTest(from);
4346 case T_CoerceToDomain:
4347 retval = _copyCoerceToDomain(from);
4349 case T_CoerceToDomainValue:
4350 retval = _copyCoerceToDomainValue(from);
4352 case T_SetToDefault:
4353 retval = _copySetToDefault(from);
4355 case T_CurrentOfExpr:
4356 retval = _copyCurrentOfExpr(from);
4358 case T_InferenceElem:
4359 retval = _copyInferenceElem(from);
4362 retval = _copyTargetEntry(from);
4365 retval = _copyRangeTblRef(from);
4368 retval = _copyJoinExpr(from);
4371 retval = _copyFromExpr(from);
4373 case T_OnConflictExpr:
4374 retval = _copyOnConflictExpr(from);
4381 retval = _copyPathKey(from);
4383 case T_RestrictInfo:
4384 retval = _copyRestrictInfo(from);
4386 case T_PlaceHolderVar:
4387 retval = _copyPlaceHolderVar(from);
4389 case T_SpecialJoinInfo:
4390 retval = _copySpecialJoinInfo(from);
4392 case T_LateralJoinInfo:
4393 retval = _copyLateralJoinInfo(from);
4395 case T_AppendRelInfo:
4396 retval = _copyAppendRelInfo(from);
4398 case T_PlaceHolderInfo:
4399 retval = _copyPlaceHolderInfo(from);
4410 retval = _copyValue(from);
4417 retval = _copyList(from);
4421 * Lists of integers and OIDs don't need to be deep-copied, so we
4422 * perform a shallow copy via list_copy()
4426 retval = list_copy(from);
4433 retval = _copyQuery(from);
4436 retval = _copyInsertStmt(from);
4439 retval = _copyDeleteStmt(from);
4442 retval = _copyUpdateStmt(from);
4445 retval = _copySelectStmt(from);
4447 case T_SetOperationStmt:
4448 retval = _copySetOperationStmt(from);
4450 case T_AlterTableStmt:
4451 retval = _copyAlterTableStmt(from);
4453 case T_AlterTableCmd:
4454 retval = _copyAlterTableCmd(from);
4456 case T_AlterDomainStmt:
4457 retval = _copyAlterDomainStmt(from);
4460 retval = _copyGrantStmt(from);
4462 case T_GrantRoleStmt:
4463 retval = _copyGrantRoleStmt(from);
4465 case T_AlterDefaultPrivilegesStmt:
4466 retval = _copyAlterDefaultPrivilegesStmt(from);
4468 case T_DeclareCursorStmt:
4469 retval = _copyDeclareCursorStmt(from);
4471 case T_ClosePortalStmt:
4472 retval = _copyClosePortalStmt(from);
4475 retval = _copyClusterStmt(from);
4478 retval = _copyCopyStmt(from);
4481 retval = _copyCreateStmt(from);
4483 case T_TableLikeClause:
4484 retval = _copyTableLikeClause(from);
4487 retval = _copyDefineStmt(from);
4490 retval = _copyDropStmt(from);
4492 case T_TruncateStmt:
4493 retval = _copyTruncateStmt(from);
4496 retval = _copyCommentStmt(from);
4498 case T_SecLabelStmt:
4499 retval = _copySecLabelStmt(from);
4502 retval = _copyFetchStmt(from);
4505 retval = _copyIndexStmt(from);
4507 case T_CreateFunctionStmt:
4508 retval = _copyCreateFunctionStmt(from);
4510 case T_FunctionParameter:
4511 retval = _copyFunctionParameter(from);
4513 case T_AlterFunctionStmt:
4514 retval = _copyAlterFunctionStmt(from);
4517 retval = _copyDoStmt(from);
4520 retval = _copyRenameStmt(from);
4522 case T_AlterObjectSchemaStmt:
4523 retval = _copyAlterObjectSchemaStmt(from);
4525 case T_AlterOwnerStmt:
4526 retval = _copyAlterOwnerStmt(from);
4529 retval = _copyRuleStmt(from);
4532 retval = _copyNotifyStmt(from);
4535 retval = _copyListenStmt(from);
4537 case T_UnlistenStmt:
4538 retval = _copyUnlistenStmt(from);
4540 case T_TransactionStmt:
4541 retval = _copyTransactionStmt(from);
4543 case T_CompositeTypeStmt:
4544 retval = _copyCompositeTypeStmt(from);
4546 case T_CreateEnumStmt:
4547 retval = _copyCreateEnumStmt(from);
4549 case T_CreateRangeStmt:
4550 retval = _copyCreateRangeStmt(from);
4552 case T_AlterEnumStmt:
4553 retval = _copyAlterEnumStmt(from);
4556 retval = _copyViewStmt(from);
4559 retval = _copyLoadStmt(from);
4561 case T_CreateDomainStmt:
4562 retval = _copyCreateDomainStmt(from);
4564 case T_CreateOpClassStmt:
4565 retval = _copyCreateOpClassStmt(from);
4567 case T_CreateOpClassItem:
4568 retval = _copyCreateOpClassItem(from);
4570 case T_CreateOpFamilyStmt:
4571 retval = _copyCreateOpFamilyStmt(from);
4573 case T_AlterOpFamilyStmt:
4574 retval = _copyAlterOpFamilyStmt(from);
4576 case T_CreatedbStmt:
4577 retval = _copyCreatedbStmt(from);
4579 case T_AlterDatabaseStmt:
4580 retval = _copyAlterDatabaseStmt(from);
4582 case T_AlterDatabaseSetStmt:
4583 retval = _copyAlterDatabaseSetStmt(from);
4586 retval = _copyDropdbStmt(from);
4589 retval = _copyVacuumStmt(from);
4592 retval = _copyExplainStmt(from);
4594 case T_CreateTableAsStmt:
4595 retval = _copyCreateTableAsStmt(from);
4597 case T_RefreshMatViewStmt:
4598 retval = _copyRefreshMatViewStmt(from);
4600 case T_ReplicaIdentityStmt:
4601 retval = _copyReplicaIdentityStmt(from);
4603 case T_AlterSystemStmt:
4604 retval = _copyAlterSystemStmt(from);
4606 case T_CreateSeqStmt:
4607 retval = _copyCreateSeqStmt(from);
4609 case T_AlterSeqStmt:
4610 retval = _copyAlterSeqStmt(from);
4612 case T_VariableSetStmt:
4613 retval = _copyVariableSetStmt(from);
4615 case T_VariableShowStmt:
4616 retval = _copyVariableShowStmt(from);
4619 retval = _copyDiscardStmt(from);
4621 case T_CreateTableSpaceStmt:
4622 retval = _copyCreateTableSpaceStmt(from);
4624 case T_DropTableSpaceStmt:
4625 retval = _copyDropTableSpaceStmt(from);
4627 case T_AlterTableSpaceOptionsStmt:
4628 retval = _copyAlterTableSpaceOptionsStmt(from);
4630 case T_AlterTableMoveAllStmt:
4631 retval = _copyAlterTableMoveAllStmt(from);
4633 case T_CreateExtensionStmt:
4634 retval = _copyCreateExtensionStmt(from);
4636 case T_AlterExtensionStmt:
4637 retval = _copyAlterExtensionStmt(from);
4639 case T_AlterExtensionContentsStmt:
4640 retval = _copyAlterExtensionContentsStmt(from);
4642 case T_CreateFdwStmt:
4643 retval = _copyCreateFdwStmt(from);
4645 case T_AlterFdwStmt:
4646 retval = _copyAlterFdwStmt(from);
4648 case T_CreateForeignServerStmt:
4649 retval = _copyCreateForeignServerStmt(from);
4651 case T_AlterForeignServerStmt:
4652 retval = _copyAlterForeignServerStmt(from);
4654 case T_CreateUserMappingStmt:
4655 retval = _copyCreateUserMappingStmt(from);
4657 case T_AlterUserMappingStmt:
4658 retval = _copyAlterUserMappingStmt(from);
4660 case T_DropUserMappingStmt:
4661 retval = _copyDropUserMappingStmt(from);
4663 case T_CreateForeignTableStmt:
4664 retval = _copyCreateForeignTableStmt(from);
4666 case T_ImportForeignSchemaStmt:
4667 retval = _copyImportForeignSchemaStmt(from);
4669 case T_CreateTransformStmt:
4670 retval = _copyCreateTransformStmt(from);
4672 case T_CreateTrigStmt:
4673 retval = _copyCreateTrigStmt(from);
4675 case T_CreateEventTrigStmt:
4676 retval = _copyCreateEventTrigStmt(from);
4678 case T_AlterEventTrigStmt:
4679 retval = _copyAlterEventTrigStmt(from);
4681 case T_CreatePLangStmt:
4682 retval = _copyCreatePLangStmt(from);
4684 case T_CreateRoleStmt:
4685 retval = _copyCreateRoleStmt(from);
4687 case T_AlterRoleStmt:
4688 retval = _copyAlterRoleStmt(from);
4690 case T_AlterRoleSetStmt:
4691 retval = _copyAlterRoleSetStmt(from);
4693 case T_DropRoleStmt:
4694 retval = _copyDropRoleStmt(from);
4697 retval = _copyLockStmt(from);
4699 case T_ConstraintsSetStmt:
4700 retval = _copyConstraintsSetStmt(from);
4703 retval = _copyReindexStmt(from);
4705 case T_CheckPointStmt:
4706 retval = (void *) makeNode(CheckPointStmt);
4708 case T_CreateSchemaStmt:
4709 retval = _copyCreateSchemaStmt(from);
4711 case T_CreateConversionStmt:
4712 retval = _copyCreateConversionStmt(from);
4714 case T_CreateCastStmt:
4715 retval = _copyCreateCastStmt(from);
4718 retval = _copyPrepareStmt(from);
4721 retval = _copyExecuteStmt(from);
4723 case T_DeallocateStmt:
4724 retval = _copyDeallocateStmt(from);
4726 case T_DropOwnedStmt:
4727 retval = _copyDropOwnedStmt(from);
4729 case T_ReassignOwnedStmt:
4730 retval = _copyReassignOwnedStmt(from);
4732 case T_AlterTSDictionaryStmt:
4733 retval = _copyAlterTSDictionaryStmt(from);
4735 case T_AlterTSConfigurationStmt:
4736 retval = _copyAlterTSConfigurationStmt(from);
4738 case T_CreatePolicyStmt:
4739 retval = _copyCreatePolicyStmt(from);
4741 case T_AlterPolicyStmt:
4742 retval = _copyAlterPolicyStmt(from);
4745 retval = _copyAExpr(from);
4748 retval = _copyColumnRef(from);
4751 retval = _copyParamRef(from);
4754 retval = _copyAConst(from);
4757 retval = _copyFuncCall(from);
4760 retval = _copyAStar(from);
4763 retval = _copyAIndices(from);
4765 case T_A_Indirection:
4766 retval = _copyA_Indirection(from);
4769 retval = _copyA_ArrayExpr(from);
4772 retval = _copyResTarget(from);
4774 case T_MultiAssignRef:
4775 retval = _copyMultiAssignRef(from);
4778 retval = _copyTypeCast(from);
4780 case T_CollateClause:
4781 retval = _copyCollateClause(from);
4784 retval = _copySortBy(from);
4787 retval = _copyWindowDef(from);
4789 case T_RangeSubselect:
4790 retval = _copyRangeSubselect(from);
4792 case T_RangeFunction:
4793 retval = _copyRangeFunction(from);
4796 retval = _copyTypeName(from);
4799 retval = _copyIndexElem(from);
4802 retval = _copyColumnDef(from);
4805 retval = _copyConstraint(from);
4808 retval = _copyDefElem(from);
4810 case T_LockingClause:
4811 retval = _copyLockingClause(from);
4813 case T_RangeTblEntry:
4814 retval = _copyRangeTblEntry(from);
4816 case T_RangeTblFunction:
4817 retval = _copyRangeTblFunction(from);
4819 case T_WithCheckOption:
4820 retval = _copyWithCheckOption(from);
4822 case T_SortGroupClause:
4823 retval = _copySortGroupClause(from);
4825 case T_WindowClause:
4826 retval = _copyWindowClause(from);
4828 case T_RowMarkClause:
4829 retval = _copyRowMarkClause(from);
4832 retval = _copyWithClause(from);
4835 retval = _copyInferClause(from);
4837 case T_OnConflictClause:
4838 retval = _copyOnConflictClause(from);
4840 case T_CommonTableExpr:
4841 retval = _copyCommonTableExpr(from);
4843 case T_FuncWithArgs:
4844 retval = _copyFuncWithArgs(from);
4847 retval = _copyAccessPriv(from);
4849 case T_XmlSerialize:
4850 retval = _copyXmlSerialize(from);
4853 retval = _copyRoleSpec(from);
4857 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4858 retval = 0; /* keep compiler quiet */