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-2017, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
18 * src/backend/nodes/copyfuncs.c
20 *-------------------------------------------------------------------------
25 #include "miscadmin.h"
26 #include "nodes/extensible.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
30 #include "utils/rel.h"
34 * Macros to simplify copying of different kinds of fields. Use these
35 * wherever possible to reduce the chance for silly typos. Note that these
36 * hard-wire the convention that the local variables in a Copy routine are
37 * named 'newnode' and 'from'.
40 /* Copy a simple scalar field (int, float, bool, enum, etc) */
41 #define COPY_SCALAR_FIELD(fldname) \
42 (newnode->fldname = from->fldname)
44 /* Copy a field that is a pointer to some kind of Node or Node tree */
45 #define COPY_NODE_FIELD(fldname) \
46 (newnode->fldname = copyObject(from->fldname))
48 /* Copy a field that is a pointer to a Bitmapset */
49 #define COPY_BITMAPSET_FIELD(fldname) \
50 (newnode->fldname = bms_copy(from->fldname))
52 /* Copy a field that is a pointer to a C string, or perhaps NULL */
53 #define COPY_STRING_FIELD(fldname) \
54 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
56 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
57 #define COPY_POINTER_FIELD(fldname, sz) \
60 newnode->fldname = palloc(_size); \
61 memcpy(newnode->fldname, from->fldname, _size); \
64 /* Copy a parse location field (for Copy, this is same as scalar case) */
65 #define COPY_LOCATION_FIELD(fldname) \
66 (newnode->fldname = from->fldname)
69 /* ****************************************************************
70 * plannodes.h copy functions
71 * ****************************************************************
78 _copyPlannedStmt(const PlannedStmt *from)
80 PlannedStmt *newnode = makeNode(PlannedStmt);
82 COPY_SCALAR_FIELD(commandType);
83 COPY_SCALAR_FIELD(queryId);
84 COPY_SCALAR_FIELD(hasReturning);
85 COPY_SCALAR_FIELD(hasModifyingCTE);
86 COPY_SCALAR_FIELD(canSetTag);
87 COPY_SCALAR_FIELD(transientPlan);
88 COPY_SCALAR_FIELD(dependsOnRole);
89 COPY_SCALAR_FIELD(parallelModeNeeded);
90 COPY_NODE_FIELD(planTree);
91 COPY_NODE_FIELD(rtable);
92 COPY_NODE_FIELD(resultRelations);
93 COPY_NODE_FIELD(subplans);
94 COPY_BITMAPSET_FIELD(rewindPlanIDs);
95 COPY_NODE_FIELD(rowMarks);
96 COPY_NODE_FIELD(relationOids);
97 COPY_NODE_FIELD(invalItems);
98 COPY_SCALAR_FIELD(nParamExec);
99 COPY_NODE_FIELD(utilityStmt);
100 COPY_LOCATION_FIELD(stmt_location);
101 COPY_LOCATION_FIELD(stmt_len);
109 * This function copies the fields of the Plan node. It is used by
110 * all the copy functions for classes which inherit from Plan.
113 CopyPlanFields(const Plan *from, Plan *newnode)
115 COPY_SCALAR_FIELD(startup_cost);
116 COPY_SCALAR_FIELD(total_cost);
117 COPY_SCALAR_FIELD(plan_rows);
118 COPY_SCALAR_FIELD(plan_width);
119 COPY_SCALAR_FIELD(parallel_aware);
120 COPY_SCALAR_FIELD(plan_node_id);
121 COPY_NODE_FIELD(targetlist);
122 COPY_NODE_FIELD(qual);
123 COPY_NODE_FIELD(lefttree);
124 COPY_NODE_FIELD(righttree);
125 COPY_NODE_FIELD(initPlan);
126 COPY_BITMAPSET_FIELD(extParam);
127 COPY_BITMAPSET_FIELD(allParam);
134 _copyPlan(const Plan *from)
136 Plan *newnode = makeNode(Plan);
139 * copy node superclass fields
141 CopyPlanFields(from, newnode);
151 _copyResult(const Result *from)
153 Result *newnode = makeNode(Result);
156 * copy node superclass fields
158 CopyPlanFields((const Plan *) from, (Plan *) newnode);
161 * copy remainder of node
163 COPY_NODE_FIELD(resconstantqual);
172 _copyModifyTable(const ModifyTable *from)
174 ModifyTable *newnode = makeNode(ModifyTable);
177 * copy node superclass fields
179 CopyPlanFields((const Plan *) from, (Plan *) newnode);
182 * copy remainder of node
184 COPY_SCALAR_FIELD(operation);
185 COPY_SCALAR_FIELD(canSetTag);
186 COPY_SCALAR_FIELD(nominalRelation);
187 COPY_NODE_FIELD(resultRelations);
188 COPY_SCALAR_FIELD(resultRelIndex);
189 COPY_NODE_FIELD(plans);
190 COPY_NODE_FIELD(withCheckOptionLists);
191 COPY_NODE_FIELD(returningLists);
192 COPY_NODE_FIELD(fdwPrivLists);
193 COPY_BITMAPSET_FIELD(fdwDirectModifyPlans);
194 COPY_NODE_FIELD(rowMarks);
195 COPY_SCALAR_FIELD(epqParam);
196 COPY_SCALAR_FIELD(onConflictAction);
197 COPY_NODE_FIELD(arbiterIndexes);
198 COPY_NODE_FIELD(onConflictSet);
199 COPY_NODE_FIELD(onConflictWhere);
200 COPY_SCALAR_FIELD(exclRelRTI);
201 COPY_NODE_FIELD(exclRelTlist);
210 _copyAppend(const Append *from)
212 Append *newnode = makeNode(Append);
215 * copy node superclass fields
217 CopyPlanFields((const Plan *) from, (Plan *) newnode);
220 * copy remainder of node
222 COPY_NODE_FIELD(appendplans);
231 _copyMergeAppend(const MergeAppend *from)
233 MergeAppend *newnode = makeNode(MergeAppend);
236 * copy node superclass fields
238 CopyPlanFields((const Plan *) from, (Plan *) newnode);
241 * copy remainder of node
243 COPY_NODE_FIELD(mergeplans);
244 COPY_SCALAR_FIELD(numCols);
245 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
246 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
247 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
248 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
254 * _copyRecursiveUnion
256 static RecursiveUnion *
257 _copyRecursiveUnion(const RecursiveUnion *from)
259 RecursiveUnion *newnode = makeNode(RecursiveUnion);
262 * copy node superclass fields
264 CopyPlanFields((const Plan *) from, (Plan *) newnode);
267 * copy remainder of node
269 COPY_SCALAR_FIELD(wtParam);
270 COPY_SCALAR_FIELD(numCols);
271 if (from->numCols > 0)
273 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
274 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
276 COPY_SCALAR_FIELD(numGroups);
285 _copyBitmapAnd(const BitmapAnd *from)
287 BitmapAnd *newnode = makeNode(BitmapAnd);
290 * copy node superclass fields
292 CopyPlanFields((const Plan *) from, (Plan *) newnode);
295 * copy remainder of node
297 COPY_NODE_FIELD(bitmapplans);
306 _copyBitmapOr(const BitmapOr *from)
308 BitmapOr *newnode = makeNode(BitmapOr);
311 * copy node superclass fields
313 CopyPlanFields((const Plan *) from, (Plan *) newnode);
316 * copy remainder of node
318 COPY_NODE_FIELD(bitmapplans);
327 _copyGather(const Gather *from)
329 Gather *newnode = makeNode(Gather);
332 * copy node superclass fields
334 CopyPlanFields((const Plan *) from, (Plan *) newnode);
337 * copy remainder of node
339 COPY_SCALAR_FIELD(num_workers);
340 COPY_SCALAR_FIELD(single_copy);
341 COPY_SCALAR_FIELD(invisible);
350 * This function copies the fields of the Scan node. It is used by
351 * all the copy functions for classes which inherit from Scan.
354 CopyScanFields(const Scan *from, Scan *newnode)
356 CopyPlanFields((const Plan *) from, (Plan *) newnode);
358 COPY_SCALAR_FIELD(scanrelid);
365 _copyScan(const Scan *from)
367 Scan *newnode = makeNode(Scan);
370 * copy node superclass fields
372 CopyScanFields((const Scan *) from, (Scan *) newnode);
381 _copySeqScan(const SeqScan *from)
383 SeqScan *newnode = makeNode(SeqScan);
386 * copy node superclass fields
388 CopyScanFields((const Scan *) from, (Scan *) newnode);
397 _copySampleScan(const SampleScan *from)
399 SampleScan *newnode = makeNode(SampleScan);
402 * copy node superclass fields
404 CopyScanFields((const Scan *) from, (Scan *) newnode);
407 * copy remainder of node
409 COPY_NODE_FIELD(tablesample);
418 _copyIndexScan(const IndexScan *from)
420 IndexScan *newnode = makeNode(IndexScan);
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);
433 COPY_NODE_FIELD(indexorderby);
434 COPY_NODE_FIELD(indexorderbyorig);
435 COPY_NODE_FIELD(indexorderbyops);
436 COPY_SCALAR_FIELD(indexorderdir);
444 static IndexOnlyScan *
445 _copyIndexOnlyScan(const IndexOnlyScan *from)
447 IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
450 * copy node superclass fields
452 CopyScanFields((const Scan *) from, (Scan *) newnode);
455 * copy remainder of node
457 COPY_SCALAR_FIELD(indexid);
458 COPY_NODE_FIELD(indexqual);
459 COPY_NODE_FIELD(indexorderby);
460 COPY_NODE_FIELD(indextlist);
461 COPY_SCALAR_FIELD(indexorderdir);
467 * _copyBitmapIndexScan
469 static BitmapIndexScan *
470 _copyBitmapIndexScan(const BitmapIndexScan *from)
472 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
475 * copy node superclass fields
477 CopyScanFields((const Scan *) from, (Scan *) newnode);
480 * copy remainder of node
482 COPY_SCALAR_FIELD(indexid);
483 COPY_NODE_FIELD(indexqual);
484 COPY_NODE_FIELD(indexqualorig);
490 * _copyBitmapHeapScan
492 static BitmapHeapScan *
493 _copyBitmapHeapScan(const BitmapHeapScan *from)
495 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
498 * copy node superclass fields
500 CopyScanFields((const Scan *) from, (Scan *) newnode);
503 * copy remainder of node
505 COPY_NODE_FIELD(bitmapqualorig);
514 _copyTidScan(const TidScan *from)
516 TidScan *newnode = makeNode(TidScan);
519 * copy node superclass fields
521 CopyScanFields((const Scan *) from, (Scan *) newnode);
524 * copy remainder of node
526 COPY_NODE_FIELD(tidquals);
534 static SubqueryScan *
535 _copySubqueryScan(const SubqueryScan *from)
537 SubqueryScan *newnode = makeNode(SubqueryScan);
540 * copy node superclass fields
542 CopyScanFields((const Scan *) from, (Scan *) newnode);
545 * copy remainder of node
547 COPY_NODE_FIELD(subplan);
555 static FunctionScan *
556 _copyFunctionScan(const FunctionScan *from)
558 FunctionScan *newnode = makeNode(FunctionScan);
561 * copy node superclass fields
563 CopyScanFields((const Scan *) from, (Scan *) newnode);
566 * copy remainder of node
568 COPY_NODE_FIELD(functions);
569 COPY_SCALAR_FIELD(funcordinality);
578 _copyValuesScan(const ValuesScan *from)
580 ValuesScan *newnode = makeNode(ValuesScan);
583 * copy node superclass fields
585 CopyScanFields((const Scan *) from, (Scan *) newnode);
588 * copy remainder of node
590 COPY_NODE_FIELD(values_lists);
599 _copyCteScan(const CteScan *from)
601 CteScan *newnode = makeNode(CteScan);
604 * copy node superclass fields
606 CopyScanFields((const Scan *) from, (Scan *) newnode);
609 * copy remainder of node
611 COPY_SCALAR_FIELD(ctePlanId);
612 COPY_SCALAR_FIELD(cteParam);
620 static WorkTableScan *
621 _copyWorkTableScan(const WorkTableScan *from)
623 WorkTableScan *newnode = makeNode(WorkTableScan);
626 * copy node superclass fields
628 CopyScanFields((const Scan *) from, (Scan *) newnode);
631 * copy remainder of node
633 COPY_SCALAR_FIELD(wtParam);
642 _copyForeignScan(const ForeignScan *from)
644 ForeignScan *newnode = makeNode(ForeignScan);
647 * copy node superclass fields
649 CopyScanFields((const Scan *) from, (Scan *) newnode);
652 * copy remainder of node
654 COPY_SCALAR_FIELD(operation);
655 COPY_SCALAR_FIELD(fs_server);
656 COPY_NODE_FIELD(fdw_exprs);
657 COPY_NODE_FIELD(fdw_private);
658 COPY_NODE_FIELD(fdw_scan_tlist);
659 COPY_NODE_FIELD(fdw_recheck_quals);
660 COPY_BITMAPSET_FIELD(fs_relids);
661 COPY_SCALAR_FIELD(fsSystemCol);
670 _copyCustomScan(const CustomScan *from)
672 CustomScan *newnode = makeNode(CustomScan);
675 * copy node superclass fields
677 CopyScanFields((const Scan *) from, (Scan *) newnode);
680 * copy remainder of node
682 COPY_SCALAR_FIELD(flags);
683 COPY_NODE_FIELD(custom_plans);
684 COPY_NODE_FIELD(custom_exprs);
685 COPY_NODE_FIELD(custom_private);
686 COPY_NODE_FIELD(custom_scan_tlist);
687 COPY_BITMAPSET_FIELD(custom_relids);
690 * NOTE: The method field of CustomScan is required to be a pointer to a
691 * static table of callback functions. So we don't copy the table itself,
692 * just reference the original one.
694 COPY_SCALAR_FIELD(methods);
702 * This function copies the fields of the Join node. It is used by
703 * all the copy functions for classes which inherit from Join.
706 CopyJoinFields(const Join *from, Join *newnode)
708 CopyPlanFields((const Plan *) from, (Plan *) newnode);
710 COPY_SCALAR_FIELD(jointype);
711 COPY_NODE_FIELD(joinqual);
719 _copyJoin(const Join *from)
721 Join *newnode = makeNode(Join);
724 * copy node superclass fields
726 CopyJoinFields(from, newnode);
736 _copyNestLoop(const NestLoop *from)
738 NestLoop *newnode = makeNode(NestLoop);
741 * copy node superclass fields
743 CopyJoinFields((const Join *) from, (Join *) newnode);
746 * copy remainder of node
748 COPY_NODE_FIELD(nestParams);
758 _copyMergeJoin(const MergeJoin *from)
760 MergeJoin *newnode = makeNode(MergeJoin);
764 * copy node superclass fields
766 CopyJoinFields((const Join *) from, (Join *) newnode);
769 * copy remainder of node
771 COPY_NODE_FIELD(mergeclauses);
772 numCols = list_length(from->mergeclauses);
775 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
776 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
777 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
778 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
788 _copyHashJoin(const HashJoin *from)
790 HashJoin *newnode = makeNode(HashJoin);
793 * copy node superclass fields
795 CopyJoinFields((const Join *) from, (Join *) newnode);
798 * copy remainder of node
800 COPY_NODE_FIELD(hashclauses);
810 _copyMaterial(const Material *from)
812 Material *newnode = makeNode(Material);
815 * copy node superclass fields
817 CopyPlanFields((const Plan *) from, (Plan *) newnode);
827 _copySort(const Sort *from)
829 Sort *newnode = makeNode(Sort);
832 * copy node superclass fields
834 CopyPlanFields((const Plan *) from, (Plan *) newnode);
836 COPY_SCALAR_FIELD(numCols);
837 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
838 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
839 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
840 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
850 _copyGroup(const Group *from)
852 Group *newnode = makeNode(Group);
854 CopyPlanFields((const Plan *) from, (Plan *) newnode);
856 COPY_SCALAR_FIELD(numCols);
857 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
858 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
867 _copyAgg(const Agg *from)
869 Agg *newnode = makeNode(Agg);
871 CopyPlanFields((const Plan *) from, (Plan *) newnode);
873 COPY_SCALAR_FIELD(aggstrategy);
874 COPY_SCALAR_FIELD(aggsplit);
875 COPY_SCALAR_FIELD(numCols);
876 if (from->numCols > 0)
878 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
879 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
881 COPY_SCALAR_FIELD(numGroups);
882 COPY_BITMAPSET_FIELD(aggParams);
883 COPY_NODE_FIELD(groupingSets);
884 COPY_NODE_FIELD(chain);
893 _copyWindowAgg(const WindowAgg *from)
895 WindowAgg *newnode = makeNode(WindowAgg);
897 CopyPlanFields((const Plan *) from, (Plan *) newnode);
899 COPY_SCALAR_FIELD(winref);
900 COPY_SCALAR_FIELD(partNumCols);
901 if (from->partNumCols > 0)
903 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
904 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
906 COPY_SCALAR_FIELD(ordNumCols);
907 if (from->ordNumCols > 0)
909 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
910 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
912 COPY_SCALAR_FIELD(frameOptions);
913 COPY_NODE_FIELD(startOffset);
914 COPY_NODE_FIELD(endOffset);
923 _copyUnique(const Unique *from)
925 Unique *newnode = makeNode(Unique);
928 * copy node superclass fields
930 CopyPlanFields((const Plan *) from, (Plan *) newnode);
933 * copy remainder of node
935 COPY_SCALAR_FIELD(numCols);
936 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
937 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
946 _copyHash(const Hash *from)
948 Hash *newnode = makeNode(Hash);
951 * copy node superclass fields
953 CopyPlanFields((const Plan *) from, (Plan *) newnode);
956 * copy remainder of node
958 COPY_SCALAR_FIELD(skewTable);
959 COPY_SCALAR_FIELD(skewColumn);
960 COPY_SCALAR_FIELD(skewInherit);
961 COPY_SCALAR_FIELD(skewColType);
962 COPY_SCALAR_FIELD(skewColTypmod);
971 _copySetOp(const SetOp *from)
973 SetOp *newnode = makeNode(SetOp);
976 * copy node superclass fields
978 CopyPlanFields((const Plan *) from, (Plan *) newnode);
981 * copy remainder of node
983 COPY_SCALAR_FIELD(cmd);
984 COPY_SCALAR_FIELD(strategy);
985 COPY_SCALAR_FIELD(numCols);
986 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
987 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
988 COPY_SCALAR_FIELD(flagColIdx);
989 COPY_SCALAR_FIELD(firstFlag);
990 COPY_SCALAR_FIELD(numGroups);
999 _copyLockRows(const LockRows *from)
1001 LockRows *newnode = makeNode(LockRows);
1004 * copy node superclass fields
1006 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1009 * copy remainder of node
1011 COPY_NODE_FIELD(rowMarks);
1012 COPY_SCALAR_FIELD(epqParam);
1021 _copyLimit(const Limit *from)
1023 Limit *newnode = makeNode(Limit);
1026 * copy node superclass fields
1028 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1031 * copy remainder of node
1033 COPY_NODE_FIELD(limitOffset);
1034 COPY_NODE_FIELD(limitCount);
1040 * _copyNestLoopParam
1042 static NestLoopParam *
1043 _copyNestLoopParam(const NestLoopParam *from)
1045 NestLoopParam *newnode = makeNode(NestLoopParam);
1047 COPY_SCALAR_FIELD(paramno);
1048 COPY_NODE_FIELD(paramval);
1056 static PlanRowMark *
1057 _copyPlanRowMark(const PlanRowMark *from)
1059 PlanRowMark *newnode = makeNode(PlanRowMark);
1061 COPY_SCALAR_FIELD(rti);
1062 COPY_SCALAR_FIELD(prti);
1063 COPY_SCALAR_FIELD(rowmarkId);
1064 COPY_SCALAR_FIELD(markType);
1065 COPY_SCALAR_FIELD(allMarkTypes);
1066 COPY_SCALAR_FIELD(strength);
1067 COPY_SCALAR_FIELD(waitPolicy);
1068 COPY_SCALAR_FIELD(isParent);
1074 * _copyPlanInvalItem
1076 static PlanInvalItem *
1077 _copyPlanInvalItem(const PlanInvalItem *from)
1079 PlanInvalItem *newnode = makeNode(PlanInvalItem);
1081 COPY_SCALAR_FIELD(cacheId);
1082 COPY_SCALAR_FIELD(hashValue);
1087 /* ****************************************************************
1088 * primnodes.h copy functions
1089 * ****************************************************************
1096 _copyAlias(const Alias *from)
1098 Alias *newnode = makeNode(Alias);
1100 COPY_STRING_FIELD(aliasname);
1101 COPY_NODE_FIELD(colnames);
1110 _copyRangeVar(const RangeVar *from)
1112 RangeVar *newnode = makeNode(RangeVar);
1114 COPY_STRING_FIELD(catalogname);
1115 COPY_STRING_FIELD(schemaname);
1116 COPY_STRING_FIELD(relname);
1117 COPY_SCALAR_FIELD(inh);
1118 COPY_SCALAR_FIELD(relpersistence);
1119 COPY_NODE_FIELD(alias);
1120 COPY_LOCATION_FIELD(location);
1129 _copyIntoClause(const IntoClause *from)
1131 IntoClause *newnode = makeNode(IntoClause);
1133 COPY_NODE_FIELD(rel);
1134 COPY_NODE_FIELD(colNames);
1135 COPY_NODE_FIELD(options);
1136 COPY_SCALAR_FIELD(onCommit);
1137 COPY_STRING_FIELD(tableSpaceName);
1138 COPY_NODE_FIELD(viewQuery);
1139 COPY_SCALAR_FIELD(skipData);
1145 * We don't need a _copyExpr because Expr is an abstract supertype which
1146 * should never actually get instantiated. Also, since it has no common
1147 * fields except NodeTag, there's no need for a helper routine to factor
1148 * out copying the common fields...
1155 _copyVar(const Var *from)
1157 Var *newnode = makeNode(Var);
1159 COPY_SCALAR_FIELD(varno);
1160 COPY_SCALAR_FIELD(varattno);
1161 COPY_SCALAR_FIELD(vartype);
1162 COPY_SCALAR_FIELD(vartypmod);
1163 COPY_SCALAR_FIELD(varcollid);
1164 COPY_SCALAR_FIELD(varlevelsup);
1165 COPY_SCALAR_FIELD(varnoold);
1166 COPY_SCALAR_FIELD(varoattno);
1167 COPY_LOCATION_FIELD(location);
1176 _copyConst(const Const *from)
1178 Const *newnode = makeNode(Const);
1180 COPY_SCALAR_FIELD(consttype);
1181 COPY_SCALAR_FIELD(consttypmod);
1182 COPY_SCALAR_FIELD(constcollid);
1183 COPY_SCALAR_FIELD(constlen);
1185 if (from->constbyval || from->constisnull)
1188 * passed by value so just copy the datum. Also, don't try to copy
1189 * struct when value is null!
1191 newnode->constvalue = from->constvalue;
1196 * passed by reference. We need a palloc'd copy.
1198 newnode->constvalue = datumCopy(from->constvalue,
1203 COPY_SCALAR_FIELD(constisnull);
1204 COPY_SCALAR_FIELD(constbyval);
1205 COPY_LOCATION_FIELD(location);
1214 _copyParam(const Param *from)
1216 Param *newnode = makeNode(Param);
1218 COPY_SCALAR_FIELD(paramkind);
1219 COPY_SCALAR_FIELD(paramid);
1220 COPY_SCALAR_FIELD(paramtype);
1221 COPY_SCALAR_FIELD(paramtypmod);
1222 COPY_SCALAR_FIELD(paramcollid);
1223 COPY_LOCATION_FIELD(location);
1232 _copyAggref(const Aggref *from)
1234 Aggref *newnode = makeNode(Aggref);
1236 COPY_SCALAR_FIELD(aggfnoid);
1237 COPY_SCALAR_FIELD(aggtype);
1238 COPY_SCALAR_FIELD(aggcollid);
1239 COPY_SCALAR_FIELD(inputcollid);
1240 COPY_SCALAR_FIELD(aggtranstype);
1241 COPY_NODE_FIELD(aggargtypes);
1242 COPY_NODE_FIELD(aggdirectargs);
1243 COPY_NODE_FIELD(args);
1244 COPY_NODE_FIELD(aggorder);
1245 COPY_NODE_FIELD(aggdistinct);
1246 COPY_NODE_FIELD(aggfilter);
1247 COPY_SCALAR_FIELD(aggstar);
1248 COPY_SCALAR_FIELD(aggvariadic);
1249 COPY_SCALAR_FIELD(aggkind);
1250 COPY_SCALAR_FIELD(agglevelsup);
1251 COPY_SCALAR_FIELD(aggsplit);
1252 COPY_LOCATION_FIELD(location);
1260 static GroupingFunc *
1261 _copyGroupingFunc(const GroupingFunc *from)
1263 GroupingFunc *newnode = makeNode(GroupingFunc);
1265 COPY_NODE_FIELD(args);
1266 COPY_NODE_FIELD(refs);
1267 COPY_NODE_FIELD(cols);
1268 COPY_SCALAR_FIELD(agglevelsup);
1269 COPY_LOCATION_FIELD(location);
1278 _copyWindowFunc(const WindowFunc *from)
1280 WindowFunc *newnode = makeNode(WindowFunc);
1282 COPY_SCALAR_FIELD(winfnoid);
1283 COPY_SCALAR_FIELD(wintype);
1284 COPY_SCALAR_FIELD(wincollid);
1285 COPY_SCALAR_FIELD(inputcollid);
1286 COPY_NODE_FIELD(args);
1287 COPY_NODE_FIELD(aggfilter);
1288 COPY_SCALAR_FIELD(winref);
1289 COPY_SCALAR_FIELD(winstar);
1290 COPY_SCALAR_FIELD(winagg);
1291 COPY_LOCATION_FIELD(location);
1300 _copyArrayRef(const ArrayRef *from)
1302 ArrayRef *newnode = makeNode(ArrayRef);
1304 COPY_SCALAR_FIELD(refarraytype);
1305 COPY_SCALAR_FIELD(refelemtype);
1306 COPY_SCALAR_FIELD(reftypmod);
1307 COPY_SCALAR_FIELD(refcollid);
1308 COPY_NODE_FIELD(refupperindexpr);
1309 COPY_NODE_FIELD(reflowerindexpr);
1310 COPY_NODE_FIELD(refexpr);
1311 COPY_NODE_FIELD(refassgnexpr);
1320 _copyFuncExpr(const FuncExpr *from)
1322 FuncExpr *newnode = makeNode(FuncExpr);
1324 COPY_SCALAR_FIELD(funcid);
1325 COPY_SCALAR_FIELD(funcresulttype);
1326 COPY_SCALAR_FIELD(funcretset);
1327 COPY_SCALAR_FIELD(funcvariadic);
1328 COPY_SCALAR_FIELD(funcformat);
1329 COPY_SCALAR_FIELD(funccollid);
1330 COPY_SCALAR_FIELD(inputcollid);
1331 COPY_NODE_FIELD(args);
1332 COPY_LOCATION_FIELD(location);
1338 * _copyNamedArgExpr *
1340 static NamedArgExpr *
1341 _copyNamedArgExpr(const NamedArgExpr *from)
1343 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1345 COPY_NODE_FIELD(arg);
1346 COPY_STRING_FIELD(name);
1347 COPY_SCALAR_FIELD(argnumber);
1348 COPY_LOCATION_FIELD(location);
1357 _copyOpExpr(const OpExpr *from)
1359 OpExpr *newnode = makeNode(OpExpr);
1361 COPY_SCALAR_FIELD(opno);
1362 COPY_SCALAR_FIELD(opfuncid);
1363 COPY_SCALAR_FIELD(opresulttype);
1364 COPY_SCALAR_FIELD(opretset);
1365 COPY_SCALAR_FIELD(opcollid);
1366 COPY_SCALAR_FIELD(inputcollid);
1367 COPY_NODE_FIELD(args);
1368 COPY_LOCATION_FIELD(location);
1374 * _copyDistinctExpr (same as OpExpr)
1376 static DistinctExpr *
1377 _copyDistinctExpr(const DistinctExpr *from)
1379 DistinctExpr *newnode = makeNode(DistinctExpr);
1381 COPY_SCALAR_FIELD(opno);
1382 COPY_SCALAR_FIELD(opfuncid);
1383 COPY_SCALAR_FIELD(opresulttype);
1384 COPY_SCALAR_FIELD(opretset);
1385 COPY_SCALAR_FIELD(opcollid);
1386 COPY_SCALAR_FIELD(inputcollid);
1387 COPY_NODE_FIELD(args);
1388 COPY_LOCATION_FIELD(location);
1394 * _copyNullIfExpr (same as OpExpr)
1397 _copyNullIfExpr(const NullIfExpr *from)
1399 NullIfExpr *newnode = makeNode(NullIfExpr);
1401 COPY_SCALAR_FIELD(opno);
1402 COPY_SCALAR_FIELD(opfuncid);
1403 COPY_SCALAR_FIELD(opresulttype);
1404 COPY_SCALAR_FIELD(opretset);
1405 COPY_SCALAR_FIELD(opcollid);
1406 COPY_SCALAR_FIELD(inputcollid);
1407 COPY_NODE_FIELD(args);
1408 COPY_LOCATION_FIELD(location);
1414 * _copyScalarArrayOpExpr
1416 static ScalarArrayOpExpr *
1417 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
1419 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1421 COPY_SCALAR_FIELD(opno);
1422 COPY_SCALAR_FIELD(opfuncid);
1423 COPY_SCALAR_FIELD(useOr);
1424 COPY_SCALAR_FIELD(inputcollid);
1425 COPY_NODE_FIELD(args);
1426 COPY_LOCATION_FIELD(location);
1435 _copyBoolExpr(const BoolExpr *from)
1437 BoolExpr *newnode = makeNode(BoolExpr);
1439 COPY_SCALAR_FIELD(boolop);
1440 COPY_NODE_FIELD(args);
1441 COPY_LOCATION_FIELD(location);
1450 _copySubLink(const SubLink *from)
1452 SubLink *newnode = makeNode(SubLink);
1454 COPY_SCALAR_FIELD(subLinkType);
1455 COPY_SCALAR_FIELD(subLinkId);
1456 COPY_NODE_FIELD(testexpr);
1457 COPY_NODE_FIELD(operName);
1458 COPY_NODE_FIELD(subselect);
1459 COPY_LOCATION_FIELD(location);
1468 _copySubPlan(const SubPlan *from)
1470 SubPlan *newnode = makeNode(SubPlan);
1472 COPY_SCALAR_FIELD(subLinkType);
1473 COPY_NODE_FIELD(testexpr);
1474 COPY_NODE_FIELD(paramIds);
1475 COPY_SCALAR_FIELD(plan_id);
1476 COPY_STRING_FIELD(plan_name);
1477 COPY_SCALAR_FIELD(firstColType);
1478 COPY_SCALAR_FIELD(firstColTypmod);
1479 COPY_SCALAR_FIELD(firstColCollation);
1480 COPY_SCALAR_FIELD(useHashTable);
1481 COPY_SCALAR_FIELD(unknownEqFalse);
1482 COPY_NODE_FIELD(setParam);
1483 COPY_NODE_FIELD(parParam);
1484 COPY_NODE_FIELD(args);
1485 COPY_SCALAR_FIELD(startup_cost);
1486 COPY_SCALAR_FIELD(per_call_cost);
1492 * _copyAlternativeSubPlan
1494 static AlternativeSubPlan *
1495 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
1497 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1499 COPY_NODE_FIELD(subplans);
1507 static FieldSelect *
1508 _copyFieldSelect(const FieldSelect *from)
1510 FieldSelect *newnode = makeNode(FieldSelect);
1512 COPY_NODE_FIELD(arg);
1513 COPY_SCALAR_FIELD(fieldnum);
1514 COPY_SCALAR_FIELD(resulttype);
1515 COPY_SCALAR_FIELD(resulttypmod);
1516 COPY_SCALAR_FIELD(resultcollid);
1525 _copyFieldStore(const FieldStore *from)
1527 FieldStore *newnode = makeNode(FieldStore);
1529 COPY_NODE_FIELD(arg);
1530 COPY_NODE_FIELD(newvals);
1531 COPY_NODE_FIELD(fieldnums);
1532 COPY_SCALAR_FIELD(resulttype);
1540 static RelabelType *
1541 _copyRelabelType(const RelabelType *from)
1543 RelabelType *newnode = makeNode(RelabelType);
1545 COPY_NODE_FIELD(arg);
1546 COPY_SCALAR_FIELD(resulttype);
1547 COPY_SCALAR_FIELD(resulttypmod);
1548 COPY_SCALAR_FIELD(resultcollid);
1549 COPY_SCALAR_FIELD(relabelformat);
1550 COPY_LOCATION_FIELD(location);
1558 static CoerceViaIO *
1559 _copyCoerceViaIO(const CoerceViaIO *from)
1561 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1563 COPY_NODE_FIELD(arg);
1564 COPY_SCALAR_FIELD(resulttype);
1565 COPY_SCALAR_FIELD(resultcollid);
1566 COPY_SCALAR_FIELD(coerceformat);
1567 COPY_LOCATION_FIELD(location);
1573 * _copyArrayCoerceExpr
1575 static ArrayCoerceExpr *
1576 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
1578 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1580 COPY_NODE_FIELD(arg);
1581 COPY_SCALAR_FIELD(elemfuncid);
1582 COPY_SCALAR_FIELD(resulttype);
1583 COPY_SCALAR_FIELD(resulttypmod);
1584 COPY_SCALAR_FIELD(resultcollid);
1585 COPY_SCALAR_FIELD(isExplicit);
1586 COPY_SCALAR_FIELD(coerceformat);
1587 COPY_LOCATION_FIELD(location);
1593 * _copyConvertRowtypeExpr
1595 static ConvertRowtypeExpr *
1596 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
1598 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1600 COPY_NODE_FIELD(arg);
1601 COPY_SCALAR_FIELD(resulttype);
1602 COPY_SCALAR_FIELD(convertformat);
1603 COPY_LOCATION_FIELD(location);
1611 static CollateExpr *
1612 _copyCollateExpr(const CollateExpr *from)
1614 CollateExpr *newnode = makeNode(CollateExpr);
1616 COPY_NODE_FIELD(arg);
1617 COPY_SCALAR_FIELD(collOid);
1618 COPY_LOCATION_FIELD(location);
1627 _copyCaseExpr(const CaseExpr *from)
1629 CaseExpr *newnode = makeNode(CaseExpr);
1631 COPY_SCALAR_FIELD(casetype);
1632 COPY_SCALAR_FIELD(casecollid);
1633 COPY_NODE_FIELD(arg);
1634 COPY_NODE_FIELD(args);
1635 COPY_NODE_FIELD(defresult);
1636 COPY_LOCATION_FIELD(location);
1645 _copyCaseWhen(const CaseWhen *from)
1647 CaseWhen *newnode = makeNode(CaseWhen);
1649 COPY_NODE_FIELD(expr);
1650 COPY_NODE_FIELD(result);
1651 COPY_LOCATION_FIELD(location);
1659 static CaseTestExpr *
1660 _copyCaseTestExpr(const CaseTestExpr *from)
1662 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1664 COPY_SCALAR_FIELD(typeId);
1665 COPY_SCALAR_FIELD(typeMod);
1666 COPY_SCALAR_FIELD(collation);
1675 _copyArrayExpr(const ArrayExpr *from)
1677 ArrayExpr *newnode = makeNode(ArrayExpr);
1679 COPY_SCALAR_FIELD(array_typeid);
1680 COPY_SCALAR_FIELD(array_collid);
1681 COPY_SCALAR_FIELD(element_typeid);
1682 COPY_NODE_FIELD(elements);
1683 COPY_SCALAR_FIELD(multidims);
1684 COPY_LOCATION_FIELD(location);
1693 _copyRowExpr(const RowExpr *from)
1695 RowExpr *newnode = makeNode(RowExpr);
1697 COPY_NODE_FIELD(args);
1698 COPY_SCALAR_FIELD(row_typeid);
1699 COPY_SCALAR_FIELD(row_format);
1700 COPY_NODE_FIELD(colnames);
1701 COPY_LOCATION_FIELD(location);
1707 * _copyRowCompareExpr
1709 static RowCompareExpr *
1710 _copyRowCompareExpr(const RowCompareExpr *from)
1712 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1714 COPY_SCALAR_FIELD(rctype);
1715 COPY_NODE_FIELD(opnos);
1716 COPY_NODE_FIELD(opfamilies);
1717 COPY_NODE_FIELD(inputcollids);
1718 COPY_NODE_FIELD(largs);
1719 COPY_NODE_FIELD(rargs);
1727 static CoalesceExpr *
1728 _copyCoalesceExpr(const CoalesceExpr *from)
1730 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1732 COPY_SCALAR_FIELD(coalescetype);
1733 COPY_SCALAR_FIELD(coalescecollid);
1734 COPY_NODE_FIELD(args);
1735 COPY_LOCATION_FIELD(location);
1744 _copyMinMaxExpr(const MinMaxExpr *from)
1746 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1748 COPY_SCALAR_FIELD(minmaxtype);
1749 COPY_SCALAR_FIELD(minmaxcollid);
1750 COPY_SCALAR_FIELD(inputcollid);
1751 COPY_SCALAR_FIELD(op);
1752 COPY_NODE_FIELD(args);
1753 COPY_LOCATION_FIELD(location);
1759 * _copySQLValueFunction
1761 static SQLValueFunction *
1762 _copySQLValueFunction(const SQLValueFunction *from)
1764 SQLValueFunction *newnode = makeNode(SQLValueFunction);
1766 COPY_SCALAR_FIELD(op);
1767 COPY_SCALAR_FIELD(type);
1768 COPY_SCALAR_FIELD(typmod);
1769 COPY_LOCATION_FIELD(location);
1778 _copyXmlExpr(const XmlExpr *from)
1780 XmlExpr *newnode = makeNode(XmlExpr);
1782 COPY_SCALAR_FIELD(op);
1783 COPY_STRING_FIELD(name);
1784 COPY_NODE_FIELD(named_args);
1785 COPY_NODE_FIELD(arg_names);
1786 COPY_NODE_FIELD(args);
1787 COPY_SCALAR_FIELD(xmloption);
1788 COPY_SCALAR_FIELD(type);
1789 COPY_SCALAR_FIELD(typmod);
1790 COPY_LOCATION_FIELD(location);
1799 _copyNullTest(const NullTest *from)
1801 NullTest *newnode = makeNode(NullTest);
1803 COPY_NODE_FIELD(arg);
1804 COPY_SCALAR_FIELD(nulltesttype);
1805 COPY_SCALAR_FIELD(argisrow);
1806 COPY_LOCATION_FIELD(location);
1814 static BooleanTest *
1815 _copyBooleanTest(const BooleanTest *from)
1817 BooleanTest *newnode = makeNode(BooleanTest);
1819 COPY_NODE_FIELD(arg);
1820 COPY_SCALAR_FIELD(booltesttype);
1821 COPY_LOCATION_FIELD(location);
1827 * _copyCoerceToDomain
1829 static CoerceToDomain *
1830 _copyCoerceToDomain(const CoerceToDomain *from)
1832 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1834 COPY_NODE_FIELD(arg);
1835 COPY_SCALAR_FIELD(resulttype);
1836 COPY_SCALAR_FIELD(resulttypmod);
1837 COPY_SCALAR_FIELD(resultcollid);
1838 COPY_SCALAR_FIELD(coercionformat);
1839 COPY_LOCATION_FIELD(location);
1845 * _copyCoerceToDomainValue
1847 static CoerceToDomainValue *
1848 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
1850 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1852 COPY_SCALAR_FIELD(typeId);
1853 COPY_SCALAR_FIELD(typeMod);
1854 COPY_SCALAR_FIELD(collation);
1855 COPY_LOCATION_FIELD(location);
1863 static SetToDefault *
1864 _copySetToDefault(const SetToDefault *from)
1866 SetToDefault *newnode = makeNode(SetToDefault);
1868 COPY_SCALAR_FIELD(typeId);
1869 COPY_SCALAR_FIELD(typeMod);
1870 COPY_SCALAR_FIELD(collation);
1871 COPY_LOCATION_FIELD(location);
1877 * _copyCurrentOfExpr
1879 static CurrentOfExpr *
1880 _copyCurrentOfExpr(const CurrentOfExpr *from)
1882 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1884 COPY_SCALAR_FIELD(cvarno);
1885 COPY_STRING_FIELD(cursor_name);
1886 COPY_SCALAR_FIELD(cursor_param);
1892 * _copyInferenceElem
1894 static InferenceElem *
1895 _copyInferenceElem(const InferenceElem *from)
1897 InferenceElem *newnode = makeNode(InferenceElem);
1899 COPY_NODE_FIELD(expr);
1900 COPY_SCALAR_FIELD(infercollid);
1901 COPY_SCALAR_FIELD(inferopclass);
1909 static TargetEntry *
1910 _copyTargetEntry(const TargetEntry *from)
1912 TargetEntry *newnode = makeNode(TargetEntry);
1914 COPY_NODE_FIELD(expr);
1915 COPY_SCALAR_FIELD(resno);
1916 COPY_STRING_FIELD(resname);
1917 COPY_SCALAR_FIELD(ressortgroupref);
1918 COPY_SCALAR_FIELD(resorigtbl);
1919 COPY_SCALAR_FIELD(resorigcol);
1920 COPY_SCALAR_FIELD(resjunk);
1928 static RangeTblRef *
1929 _copyRangeTblRef(const RangeTblRef *from)
1931 RangeTblRef *newnode = makeNode(RangeTblRef);
1933 COPY_SCALAR_FIELD(rtindex);
1942 _copyJoinExpr(const JoinExpr *from)
1944 JoinExpr *newnode = makeNode(JoinExpr);
1946 COPY_SCALAR_FIELD(jointype);
1947 COPY_SCALAR_FIELD(isNatural);
1948 COPY_NODE_FIELD(larg);
1949 COPY_NODE_FIELD(rarg);
1950 COPY_NODE_FIELD(usingClause);
1951 COPY_NODE_FIELD(quals);
1952 COPY_NODE_FIELD(alias);
1953 COPY_SCALAR_FIELD(rtindex);
1962 _copyFromExpr(const FromExpr *from)
1964 FromExpr *newnode = makeNode(FromExpr);
1966 COPY_NODE_FIELD(fromlist);
1967 COPY_NODE_FIELD(quals);
1973 * _copyOnConflictExpr
1975 static OnConflictExpr *
1976 _copyOnConflictExpr(const OnConflictExpr *from)
1978 OnConflictExpr *newnode = makeNode(OnConflictExpr);
1980 COPY_SCALAR_FIELD(action);
1981 COPY_NODE_FIELD(arbiterElems);
1982 COPY_NODE_FIELD(arbiterWhere);
1983 COPY_SCALAR_FIELD(constraint);
1984 COPY_NODE_FIELD(onConflictSet);
1985 COPY_NODE_FIELD(onConflictWhere);
1986 COPY_SCALAR_FIELD(exclRelIndex);
1987 COPY_NODE_FIELD(exclRelTlist);
1992 /* ****************************************************************
1993 * relation.h copy functions
1995 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1996 * There are some subsidiary structs that are useful to copy, though.
1997 * ****************************************************************
2004 _copyPathKey(const PathKey *from)
2006 PathKey *newnode = makeNode(PathKey);
2008 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
2009 COPY_SCALAR_FIELD(pk_eclass);
2010 COPY_SCALAR_FIELD(pk_opfamily);
2011 COPY_SCALAR_FIELD(pk_strategy);
2012 COPY_SCALAR_FIELD(pk_nulls_first);
2020 static RestrictInfo *
2021 _copyRestrictInfo(const RestrictInfo *from)
2023 RestrictInfo *newnode = makeNode(RestrictInfo);
2025 COPY_NODE_FIELD(clause);
2026 COPY_SCALAR_FIELD(is_pushed_down);
2027 COPY_SCALAR_FIELD(outerjoin_delayed);
2028 COPY_SCALAR_FIELD(can_join);
2029 COPY_SCALAR_FIELD(pseudoconstant);
2030 COPY_BITMAPSET_FIELD(clause_relids);
2031 COPY_BITMAPSET_FIELD(required_relids);
2032 COPY_BITMAPSET_FIELD(outer_relids);
2033 COPY_BITMAPSET_FIELD(nullable_relids);
2034 COPY_BITMAPSET_FIELD(left_relids);
2035 COPY_BITMAPSET_FIELD(right_relids);
2036 COPY_NODE_FIELD(orclause);
2037 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2038 COPY_SCALAR_FIELD(parent_ec);
2039 COPY_SCALAR_FIELD(eval_cost);
2040 COPY_SCALAR_FIELD(norm_selec);
2041 COPY_SCALAR_FIELD(outer_selec);
2042 COPY_NODE_FIELD(mergeopfamilies);
2043 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2044 COPY_SCALAR_FIELD(left_ec);
2045 COPY_SCALAR_FIELD(right_ec);
2046 COPY_SCALAR_FIELD(left_em);
2047 COPY_SCALAR_FIELD(right_em);
2048 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
2049 newnode->scansel_cache = NIL;
2050 COPY_SCALAR_FIELD(outer_is_left);
2051 COPY_SCALAR_FIELD(hashjoinoperator);
2052 COPY_SCALAR_FIELD(left_bucketsize);
2053 COPY_SCALAR_FIELD(right_bucketsize);
2059 * _copyPlaceHolderVar
2061 static PlaceHolderVar *
2062 _copyPlaceHolderVar(const PlaceHolderVar *from)
2064 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
2066 COPY_NODE_FIELD(phexpr);
2067 COPY_BITMAPSET_FIELD(phrels);
2068 COPY_SCALAR_FIELD(phid);
2069 COPY_SCALAR_FIELD(phlevelsup);
2075 * _copySpecialJoinInfo
2077 static SpecialJoinInfo *
2078 _copySpecialJoinInfo(const SpecialJoinInfo *from)
2080 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
2082 COPY_BITMAPSET_FIELD(min_lefthand);
2083 COPY_BITMAPSET_FIELD(min_righthand);
2084 COPY_BITMAPSET_FIELD(syn_lefthand);
2085 COPY_BITMAPSET_FIELD(syn_righthand);
2086 COPY_SCALAR_FIELD(jointype);
2087 COPY_SCALAR_FIELD(lhs_strict);
2088 COPY_SCALAR_FIELD(delay_upper_joins);
2089 COPY_SCALAR_FIELD(semi_can_btree);
2090 COPY_SCALAR_FIELD(semi_can_hash);
2091 COPY_NODE_FIELD(semi_operators);
2092 COPY_NODE_FIELD(semi_rhs_exprs);
2098 * _copyAppendRelInfo
2100 static AppendRelInfo *
2101 _copyAppendRelInfo(const AppendRelInfo *from)
2103 AppendRelInfo *newnode = makeNode(AppendRelInfo);
2105 COPY_SCALAR_FIELD(parent_relid);
2106 COPY_SCALAR_FIELD(child_relid);
2107 COPY_SCALAR_FIELD(parent_reltype);
2108 COPY_SCALAR_FIELD(child_reltype);
2109 COPY_NODE_FIELD(translated_vars);
2110 COPY_SCALAR_FIELD(parent_reloid);
2116 * _copyPlaceHolderInfo
2118 static PlaceHolderInfo *
2119 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
2121 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
2123 COPY_SCALAR_FIELD(phid);
2124 COPY_NODE_FIELD(ph_var);
2125 COPY_BITMAPSET_FIELD(ph_eval_at);
2126 COPY_BITMAPSET_FIELD(ph_lateral);
2127 COPY_BITMAPSET_FIELD(ph_needed);
2128 COPY_SCALAR_FIELD(ph_width);
2133 /* ****************************************************************
2134 * parsenodes.h copy functions
2135 * ****************************************************************
2138 static RangeTblEntry *
2139 _copyRangeTblEntry(const RangeTblEntry *from)
2141 RangeTblEntry *newnode = makeNode(RangeTblEntry);
2143 COPY_SCALAR_FIELD(rtekind);
2144 COPY_SCALAR_FIELD(relid);
2145 COPY_SCALAR_FIELD(relkind);
2146 COPY_NODE_FIELD(tablesample);
2147 COPY_NODE_FIELD(subquery);
2148 COPY_SCALAR_FIELD(security_barrier);
2149 COPY_SCALAR_FIELD(jointype);
2150 COPY_NODE_FIELD(joinaliasvars);
2151 COPY_NODE_FIELD(functions);
2152 COPY_SCALAR_FIELD(funcordinality);
2153 COPY_NODE_FIELD(values_lists);
2154 COPY_STRING_FIELD(ctename);
2155 COPY_SCALAR_FIELD(ctelevelsup);
2156 COPY_SCALAR_FIELD(self_reference);
2157 COPY_NODE_FIELD(coltypes);
2158 COPY_NODE_FIELD(coltypmods);
2159 COPY_NODE_FIELD(colcollations);
2160 COPY_NODE_FIELD(alias);
2161 COPY_NODE_FIELD(eref);
2162 COPY_SCALAR_FIELD(lateral);
2163 COPY_SCALAR_FIELD(inh);
2164 COPY_SCALAR_FIELD(inFromCl);
2165 COPY_SCALAR_FIELD(requiredPerms);
2166 COPY_SCALAR_FIELD(checkAsUser);
2167 COPY_BITMAPSET_FIELD(selectedCols);
2168 COPY_BITMAPSET_FIELD(insertedCols);
2169 COPY_BITMAPSET_FIELD(updatedCols);
2170 COPY_NODE_FIELD(securityQuals);
2175 static RangeTblFunction *
2176 _copyRangeTblFunction(const RangeTblFunction *from)
2178 RangeTblFunction *newnode = makeNode(RangeTblFunction);
2180 COPY_NODE_FIELD(funcexpr);
2181 COPY_SCALAR_FIELD(funccolcount);
2182 COPY_NODE_FIELD(funccolnames);
2183 COPY_NODE_FIELD(funccoltypes);
2184 COPY_NODE_FIELD(funccoltypmods);
2185 COPY_NODE_FIELD(funccolcollations);
2186 COPY_BITMAPSET_FIELD(funcparams);
2191 static TableSampleClause *
2192 _copyTableSampleClause(const TableSampleClause *from)
2194 TableSampleClause *newnode = makeNode(TableSampleClause);
2196 COPY_SCALAR_FIELD(tsmhandler);
2197 COPY_NODE_FIELD(args);
2198 COPY_NODE_FIELD(repeatable);
2203 static WithCheckOption *
2204 _copyWithCheckOption(const WithCheckOption *from)
2206 WithCheckOption *newnode = makeNode(WithCheckOption);
2208 COPY_SCALAR_FIELD(kind);
2209 COPY_STRING_FIELD(relname);
2210 COPY_STRING_FIELD(polname);
2211 COPY_NODE_FIELD(qual);
2212 COPY_SCALAR_FIELD(cascaded);
2217 static SortGroupClause *
2218 _copySortGroupClause(const SortGroupClause *from)
2220 SortGroupClause *newnode = makeNode(SortGroupClause);
2222 COPY_SCALAR_FIELD(tleSortGroupRef);
2223 COPY_SCALAR_FIELD(eqop);
2224 COPY_SCALAR_FIELD(sortop);
2225 COPY_SCALAR_FIELD(nulls_first);
2226 COPY_SCALAR_FIELD(hashable);
2231 static GroupingSet *
2232 _copyGroupingSet(const GroupingSet *from)
2234 GroupingSet *newnode = makeNode(GroupingSet);
2236 COPY_SCALAR_FIELD(kind);
2237 COPY_NODE_FIELD(content);
2238 COPY_LOCATION_FIELD(location);
2243 static WindowClause *
2244 _copyWindowClause(const WindowClause *from)
2246 WindowClause *newnode = makeNode(WindowClause);
2248 COPY_STRING_FIELD(name);
2249 COPY_STRING_FIELD(refname);
2250 COPY_NODE_FIELD(partitionClause);
2251 COPY_NODE_FIELD(orderClause);
2252 COPY_SCALAR_FIELD(frameOptions);
2253 COPY_NODE_FIELD(startOffset);
2254 COPY_NODE_FIELD(endOffset);
2255 COPY_SCALAR_FIELD(winref);
2256 COPY_SCALAR_FIELD(copiedOrder);
2261 static RowMarkClause *
2262 _copyRowMarkClause(const RowMarkClause *from)
2264 RowMarkClause *newnode = makeNode(RowMarkClause);
2266 COPY_SCALAR_FIELD(rti);
2267 COPY_SCALAR_FIELD(strength);
2268 COPY_SCALAR_FIELD(waitPolicy);
2269 COPY_SCALAR_FIELD(pushedDown);
2275 _copyWithClause(const WithClause *from)
2277 WithClause *newnode = makeNode(WithClause);
2279 COPY_NODE_FIELD(ctes);
2280 COPY_SCALAR_FIELD(recursive);
2281 COPY_LOCATION_FIELD(location);
2286 static InferClause *
2287 _copyInferClause(const InferClause *from)
2289 InferClause *newnode = makeNode(InferClause);
2291 COPY_NODE_FIELD(indexElems);
2292 COPY_NODE_FIELD(whereClause);
2293 COPY_STRING_FIELD(conname);
2294 COPY_LOCATION_FIELD(location);
2299 static OnConflictClause *
2300 _copyOnConflictClause(const OnConflictClause *from)
2302 OnConflictClause *newnode = makeNode(OnConflictClause);
2304 COPY_SCALAR_FIELD(action);
2305 COPY_NODE_FIELD(infer);
2306 COPY_NODE_FIELD(targetList);
2307 COPY_NODE_FIELD(whereClause);
2308 COPY_LOCATION_FIELD(location);
2313 static CommonTableExpr *
2314 _copyCommonTableExpr(const CommonTableExpr *from)
2316 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2318 COPY_STRING_FIELD(ctename);
2319 COPY_NODE_FIELD(aliascolnames);
2320 COPY_NODE_FIELD(ctequery);
2321 COPY_LOCATION_FIELD(location);
2322 COPY_SCALAR_FIELD(cterecursive);
2323 COPY_SCALAR_FIELD(cterefcount);
2324 COPY_NODE_FIELD(ctecolnames);
2325 COPY_NODE_FIELD(ctecoltypes);
2326 COPY_NODE_FIELD(ctecoltypmods);
2327 COPY_NODE_FIELD(ctecolcollations);
2333 _copyAExpr(const A_Expr *from)
2335 A_Expr *newnode = makeNode(A_Expr);
2337 COPY_SCALAR_FIELD(kind);
2338 COPY_NODE_FIELD(name);
2339 COPY_NODE_FIELD(lexpr);
2340 COPY_NODE_FIELD(rexpr);
2341 COPY_LOCATION_FIELD(location);
2347 _copyColumnRef(const ColumnRef *from)
2349 ColumnRef *newnode = makeNode(ColumnRef);
2351 COPY_NODE_FIELD(fields);
2352 COPY_LOCATION_FIELD(location);
2358 _copyParamRef(const ParamRef *from)
2360 ParamRef *newnode = makeNode(ParamRef);
2362 COPY_SCALAR_FIELD(number);
2363 COPY_LOCATION_FIELD(location);
2369 _copyAConst(const A_Const *from)
2371 A_Const *newnode = makeNode(A_Const);
2373 /* This part must duplicate _copyValue */
2374 COPY_SCALAR_FIELD(val.type);
2375 switch (from->val.type)
2378 COPY_SCALAR_FIELD(val.val.ival);
2383 COPY_STRING_FIELD(val.val.str);
2389 elog(ERROR, "unrecognized node type: %d",
2390 (int) from->val.type);
2394 COPY_LOCATION_FIELD(location);
2400 _copyFuncCall(const FuncCall *from)
2402 FuncCall *newnode = makeNode(FuncCall);
2404 COPY_NODE_FIELD(funcname);
2405 COPY_NODE_FIELD(args);
2406 COPY_NODE_FIELD(agg_order);
2407 COPY_NODE_FIELD(agg_filter);
2408 COPY_SCALAR_FIELD(agg_within_group);
2409 COPY_SCALAR_FIELD(agg_star);
2410 COPY_SCALAR_FIELD(agg_distinct);
2411 COPY_SCALAR_FIELD(func_variadic);
2412 COPY_NODE_FIELD(over);
2413 COPY_LOCATION_FIELD(location);
2419 _copyAStar(const A_Star *from)
2421 A_Star *newnode = makeNode(A_Star);
2427 _copyAIndices(const A_Indices *from)
2429 A_Indices *newnode = makeNode(A_Indices);
2431 COPY_SCALAR_FIELD(is_slice);
2432 COPY_NODE_FIELD(lidx);
2433 COPY_NODE_FIELD(uidx);
2438 static A_Indirection *
2439 _copyA_Indirection(const A_Indirection *from)
2441 A_Indirection *newnode = makeNode(A_Indirection);
2443 COPY_NODE_FIELD(arg);
2444 COPY_NODE_FIELD(indirection);
2449 static A_ArrayExpr *
2450 _copyA_ArrayExpr(const A_ArrayExpr *from)
2452 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2454 COPY_NODE_FIELD(elements);
2455 COPY_LOCATION_FIELD(location);
2461 _copyResTarget(const ResTarget *from)
2463 ResTarget *newnode = makeNode(ResTarget);
2465 COPY_STRING_FIELD(name);
2466 COPY_NODE_FIELD(indirection);
2467 COPY_NODE_FIELD(val);
2468 COPY_LOCATION_FIELD(location);
2473 static MultiAssignRef *
2474 _copyMultiAssignRef(const MultiAssignRef *from)
2476 MultiAssignRef *newnode = makeNode(MultiAssignRef);
2478 COPY_NODE_FIELD(source);
2479 COPY_SCALAR_FIELD(colno);
2480 COPY_SCALAR_FIELD(ncolumns);
2486 _copyTypeName(const TypeName *from)
2488 TypeName *newnode = makeNode(TypeName);
2490 COPY_NODE_FIELD(names);
2491 COPY_SCALAR_FIELD(typeOid);
2492 COPY_SCALAR_FIELD(setof);
2493 COPY_SCALAR_FIELD(pct_type);
2494 COPY_NODE_FIELD(typmods);
2495 COPY_SCALAR_FIELD(typemod);
2496 COPY_NODE_FIELD(arrayBounds);
2497 COPY_LOCATION_FIELD(location);
2503 _copySortBy(const SortBy *from)
2505 SortBy *newnode = makeNode(SortBy);
2507 COPY_NODE_FIELD(node);
2508 COPY_SCALAR_FIELD(sortby_dir);
2509 COPY_SCALAR_FIELD(sortby_nulls);
2510 COPY_NODE_FIELD(useOp);
2511 COPY_LOCATION_FIELD(location);
2517 _copyWindowDef(const WindowDef *from)
2519 WindowDef *newnode = makeNode(WindowDef);
2521 COPY_STRING_FIELD(name);
2522 COPY_STRING_FIELD(refname);
2523 COPY_NODE_FIELD(partitionClause);
2524 COPY_NODE_FIELD(orderClause);
2525 COPY_SCALAR_FIELD(frameOptions);
2526 COPY_NODE_FIELD(startOffset);
2527 COPY_NODE_FIELD(endOffset);
2528 COPY_LOCATION_FIELD(location);
2533 static RangeSubselect *
2534 _copyRangeSubselect(const RangeSubselect *from)
2536 RangeSubselect *newnode = makeNode(RangeSubselect);
2538 COPY_SCALAR_FIELD(lateral);
2539 COPY_NODE_FIELD(subquery);
2540 COPY_NODE_FIELD(alias);
2545 static RangeFunction *
2546 _copyRangeFunction(const RangeFunction *from)
2548 RangeFunction *newnode = makeNode(RangeFunction);
2550 COPY_SCALAR_FIELD(lateral);
2551 COPY_SCALAR_FIELD(ordinality);
2552 COPY_SCALAR_FIELD(is_rowsfrom);
2553 COPY_NODE_FIELD(functions);
2554 COPY_NODE_FIELD(alias);
2555 COPY_NODE_FIELD(coldeflist);
2560 static RangeTableSample *
2561 _copyRangeTableSample(const RangeTableSample *from)
2563 RangeTableSample *newnode = makeNode(RangeTableSample);
2565 COPY_NODE_FIELD(relation);
2566 COPY_NODE_FIELD(method);
2567 COPY_NODE_FIELD(args);
2568 COPY_NODE_FIELD(repeatable);
2569 COPY_LOCATION_FIELD(location);
2575 _copyTypeCast(const TypeCast *from)
2577 TypeCast *newnode = makeNode(TypeCast);
2579 COPY_NODE_FIELD(arg);
2580 COPY_NODE_FIELD(typeName);
2581 COPY_LOCATION_FIELD(location);
2586 static CollateClause *
2587 _copyCollateClause(const CollateClause *from)
2589 CollateClause *newnode = makeNode(CollateClause);
2591 COPY_NODE_FIELD(arg);
2592 COPY_NODE_FIELD(collname);
2593 COPY_LOCATION_FIELD(location);
2599 _copyIndexElem(const IndexElem *from)
2601 IndexElem *newnode = makeNode(IndexElem);
2603 COPY_STRING_FIELD(name);
2604 COPY_NODE_FIELD(expr);
2605 COPY_STRING_FIELD(indexcolname);
2606 COPY_NODE_FIELD(collation);
2607 COPY_NODE_FIELD(opclass);
2608 COPY_SCALAR_FIELD(ordering);
2609 COPY_SCALAR_FIELD(nulls_ordering);
2615 _copyColumnDef(const ColumnDef *from)
2617 ColumnDef *newnode = makeNode(ColumnDef);
2619 COPY_STRING_FIELD(colname);
2620 COPY_NODE_FIELD(typeName);
2621 COPY_SCALAR_FIELD(inhcount);
2622 COPY_SCALAR_FIELD(is_local);
2623 COPY_SCALAR_FIELD(is_not_null);
2624 COPY_SCALAR_FIELD(is_from_type);
2625 COPY_SCALAR_FIELD(storage);
2626 COPY_NODE_FIELD(raw_default);
2627 COPY_NODE_FIELD(cooked_default);
2628 COPY_NODE_FIELD(collClause);
2629 COPY_SCALAR_FIELD(collOid);
2630 COPY_NODE_FIELD(constraints);
2631 COPY_NODE_FIELD(fdwoptions);
2632 COPY_LOCATION_FIELD(location);
2638 _copyConstraint(const Constraint *from)
2640 Constraint *newnode = makeNode(Constraint);
2642 COPY_SCALAR_FIELD(contype);
2643 COPY_STRING_FIELD(conname);
2644 COPY_SCALAR_FIELD(deferrable);
2645 COPY_SCALAR_FIELD(initdeferred);
2646 COPY_LOCATION_FIELD(location);
2647 COPY_SCALAR_FIELD(is_no_inherit);
2648 COPY_NODE_FIELD(raw_expr);
2649 COPY_STRING_FIELD(cooked_expr);
2650 COPY_NODE_FIELD(keys);
2651 COPY_NODE_FIELD(exclusions);
2652 COPY_NODE_FIELD(options);
2653 COPY_STRING_FIELD(indexname);
2654 COPY_STRING_FIELD(indexspace);
2655 COPY_STRING_FIELD(access_method);
2656 COPY_NODE_FIELD(where_clause);
2657 COPY_NODE_FIELD(pktable);
2658 COPY_NODE_FIELD(fk_attrs);
2659 COPY_NODE_FIELD(pk_attrs);
2660 COPY_SCALAR_FIELD(fk_matchtype);
2661 COPY_SCALAR_FIELD(fk_upd_action);
2662 COPY_SCALAR_FIELD(fk_del_action);
2663 COPY_NODE_FIELD(old_conpfeqop);
2664 COPY_SCALAR_FIELD(old_pktable_oid);
2665 COPY_SCALAR_FIELD(skip_validation);
2666 COPY_SCALAR_FIELD(initially_valid);
2672 _copyDefElem(const DefElem *from)
2674 DefElem *newnode = makeNode(DefElem);
2676 COPY_STRING_FIELD(defnamespace);
2677 COPY_STRING_FIELD(defname);
2678 COPY_NODE_FIELD(arg);
2679 COPY_SCALAR_FIELD(defaction);
2680 COPY_LOCATION_FIELD(location);
2685 static LockingClause *
2686 _copyLockingClause(const LockingClause *from)
2688 LockingClause *newnode = makeNode(LockingClause);
2690 COPY_NODE_FIELD(lockedRels);
2691 COPY_SCALAR_FIELD(strength);
2692 COPY_SCALAR_FIELD(waitPolicy);
2697 static XmlSerialize *
2698 _copyXmlSerialize(const XmlSerialize *from)
2700 XmlSerialize *newnode = makeNode(XmlSerialize);
2702 COPY_SCALAR_FIELD(xmloption);
2703 COPY_NODE_FIELD(expr);
2704 COPY_NODE_FIELD(typeName);
2705 COPY_LOCATION_FIELD(location);
2711 _copyRoleSpec(const RoleSpec *from)
2713 RoleSpec *newnode = makeNode(RoleSpec);
2715 COPY_SCALAR_FIELD(roletype);
2716 COPY_STRING_FIELD(rolename);
2717 COPY_LOCATION_FIELD(location);
2722 static TriggerTransition *
2723 _copyTriggerTransition(const TriggerTransition *from)
2725 TriggerTransition *newnode = makeNode(TriggerTransition);
2727 COPY_STRING_FIELD(name);
2728 COPY_SCALAR_FIELD(isNew);
2729 COPY_SCALAR_FIELD(isTable);
2735 _copyQuery(const Query *from)
2737 Query *newnode = makeNode(Query);
2739 COPY_SCALAR_FIELD(commandType);
2740 COPY_SCALAR_FIELD(querySource);
2741 COPY_SCALAR_FIELD(queryId);
2742 COPY_SCALAR_FIELD(canSetTag);
2743 COPY_NODE_FIELD(utilityStmt);
2744 COPY_SCALAR_FIELD(resultRelation);
2745 COPY_SCALAR_FIELD(hasAggs);
2746 COPY_SCALAR_FIELD(hasWindowFuncs);
2747 COPY_SCALAR_FIELD(hasTargetSRFs);
2748 COPY_SCALAR_FIELD(hasSubLinks);
2749 COPY_SCALAR_FIELD(hasDistinctOn);
2750 COPY_SCALAR_FIELD(hasRecursive);
2751 COPY_SCALAR_FIELD(hasModifyingCTE);
2752 COPY_SCALAR_FIELD(hasForUpdate);
2753 COPY_SCALAR_FIELD(hasRowSecurity);
2754 COPY_NODE_FIELD(cteList);
2755 COPY_NODE_FIELD(rtable);
2756 COPY_NODE_FIELD(jointree);
2757 COPY_NODE_FIELD(targetList);
2758 COPY_NODE_FIELD(onConflict);
2759 COPY_NODE_FIELD(returningList);
2760 COPY_NODE_FIELD(groupClause);
2761 COPY_NODE_FIELD(groupingSets);
2762 COPY_NODE_FIELD(havingQual);
2763 COPY_NODE_FIELD(windowClause);
2764 COPY_NODE_FIELD(distinctClause);
2765 COPY_NODE_FIELD(sortClause);
2766 COPY_NODE_FIELD(limitOffset);
2767 COPY_NODE_FIELD(limitCount);
2768 COPY_NODE_FIELD(rowMarks);
2769 COPY_NODE_FIELD(setOperations);
2770 COPY_NODE_FIELD(constraintDeps);
2771 COPY_NODE_FIELD(withCheckOptions);
2772 COPY_LOCATION_FIELD(stmt_location);
2773 COPY_LOCATION_FIELD(stmt_len);
2779 _copyRawStmt(const RawStmt *from)
2781 RawStmt *newnode = makeNode(RawStmt);
2783 COPY_NODE_FIELD(stmt);
2784 COPY_LOCATION_FIELD(stmt_location);
2785 COPY_LOCATION_FIELD(stmt_len);
2791 _copyInsertStmt(const InsertStmt *from)
2793 InsertStmt *newnode = makeNode(InsertStmt);
2795 COPY_NODE_FIELD(relation);
2796 COPY_NODE_FIELD(cols);
2797 COPY_NODE_FIELD(selectStmt);
2798 COPY_NODE_FIELD(onConflictClause);
2799 COPY_NODE_FIELD(returningList);
2800 COPY_NODE_FIELD(withClause);
2806 _copyDeleteStmt(const DeleteStmt *from)
2808 DeleteStmt *newnode = makeNode(DeleteStmt);
2810 COPY_NODE_FIELD(relation);
2811 COPY_NODE_FIELD(usingClause);
2812 COPY_NODE_FIELD(whereClause);
2813 COPY_NODE_FIELD(returningList);
2814 COPY_NODE_FIELD(withClause);
2820 _copyUpdateStmt(const UpdateStmt *from)
2822 UpdateStmt *newnode = makeNode(UpdateStmt);
2824 COPY_NODE_FIELD(relation);
2825 COPY_NODE_FIELD(targetList);
2826 COPY_NODE_FIELD(whereClause);
2827 COPY_NODE_FIELD(fromClause);
2828 COPY_NODE_FIELD(returningList);
2829 COPY_NODE_FIELD(withClause);
2835 _copySelectStmt(const SelectStmt *from)
2837 SelectStmt *newnode = makeNode(SelectStmt);
2839 COPY_NODE_FIELD(distinctClause);
2840 COPY_NODE_FIELD(intoClause);
2841 COPY_NODE_FIELD(targetList);
2842 COPY_NODE_FIELD(fromClause);
2843 COPY_NODE_FIELD(whereClause);
2844 COPY_NODE_FIELD(groupClause);
2845 COPY_NODE_FIELD(havingClause);
2846 COPY_NODE_FIELD(windowClause);
2847 COPY_NODE_FIELD(valuesLists);
2848 COPY_NODE_FIELD(sortClause);
2849 COPY_NODE_FIELD(limitOffset);
2850 COPY_NODE_FIELD(limitCount);
2851 COPY_NODE_FIELD(lockingClause);
2852 COPY_NODE_FIELD(withClause);
2853 COPY_SCALAR_FIELD(op);
2854 COPY_SCALAR_FIELD(all);
2855 COPY_NODE_FIELD(larg);
2856 COPY_NODE_FIELD(rarg);
2861 static SetOperationStmt *
2862 _copySetOperationStmt(const SetOperationStmt *from)
2864 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2866 COPY_SCALAR_FIELD(op);
2867 COPY_SCALAR_FIELD(all);
2868 COPY_NODE_FIELD(larg);
2869 COPY_NODE_FIELD(rarg);
2870 COPY_NODE_FIELD(colTypes);
2871 COPY_NODE_FIELD(colTypmods);
2872 COPY_NODE_FIELD(colCollations);
2873 COPY_NODE_FIELD(groupClauses);
2878 static AlterTableStmt *
2879 _copyAlterTableStmt(const AlterTableStmt *from)
2881 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2883 COPY_NODE_FIELD(relation);
2884 COPY_NODE_FIELD(cmds);
2885 COPY_SCALAR_FIELD(relkind);
2886 COPY_SCALAR_FIELD(missing_ok);
2891 static AlterTableCmd *
2892 _copyAlterTableCmd(const AlterTableCmd *from)
2894 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2896 COPY_SCALAR_FIELD(subtype);
2897 COPY_STRING_FIELD(name);
2898 COPY_NODE_FIELD(newowner);
2899 COPY_NODE_FIELD(def);
2900 COPY_SCALAR_FIELD(behavior);
2901 COPY_SCALAR_FIELD(missing_ok);
2906 static AlterDomainStmt *
2907 _copyAlterDomainStmt(const AlterDomainStmt *from)
2909 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2911 COPY_SCALAR_FIELD(subtype);
2912 COPY_NODE_FIELD(typeName);
2913 COPY_STRING_FIELD(name);
2914 COPY_NODE_FIELD(def);
2915 COPY_SCALAR_FIELD(behavior);
2916 COPY_SCALAR_FIELD(missing_ok);
2922 _copyGrantStmt(const GrantStmt *from)
2924 GrantStmt *newnode = makeNode(GrantStmt);
2926 COPY_SCALAR_FIELD(is_grant);
2927 COPY_SCALAR_FIELD(targtype);
2928 COPY_SCALAR_FIELD(objtype);
2929 COPY_NODE_FIELD(objects);
2930 COPY_NODE_FIELD(privileges);
2931 COPY_NODE_FIELD(grantees);
2932 COPY_SCALAR_FIELD(grant_option);
2933 COPY_SCALAR_FIELD(behavior);
2938 static FuncWithArgs *
2939 _copyFuncWithArgs(const FuncWithArgs *from)
2941 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2943 COPY_NODE_FIELD(funcname);
2944 COPY_NODE_FIELD(funcargs);
2950 _copyAccessPriv(const AccessPriv *from)
2952 AccessPriv *newnode = makeNode(AccessPriv);
2954 COPY_STRING_FIELD(priv_name);
2955 COPY_NODE_FIELD(cols);
2960 static GrantRoleStmt *
2961 _copyGrantRoleStmt(const GrantRoleStmt *from)
2963 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2965 COPY_NODE_FIELD(granted_roles);
2966 COPY_NODE_FIELD(grantee_roles);
2967 COPY_SCALAR_FIELD(is_grant);
2968 COPY_SCALAR_FIELD(admin_opt);
2969 COPY_NODE_FIELD(grantor);
2970 COPY_SCALAR_FIELD(behavior);
2975 static AlterDefaultPrivilegesStmt *
2976 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
2978 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2980 COPY_NODE_FIELD(options);
2981 COPY_NODE_FIELD(action);
2986 static DeclareCursorStmt *
2987 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
2989 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2991 COPY_STRING_FIELD(portalname);
2992 COPY_SCALAR_FIELD(options);
2993 COPY_NODE_FIELD(query);
2998 static ClosePortalStmt *
2999 _copyClosePortalStmt(const ClosePortalStmt *from)
3001 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
3003 COPY_STRING_FIELD(portalname);
3008 static ClusterStmt *
3009 _copyClusterStmt(const ClusterStmt *from)
3011 ClusterStmt *newnode = makeNode(ClusterStmt);
3013 COPY_NODE_FIELD(relation);
3014 COPY_STRING_FIELD(indexname);
3015 COPY_SCALAR_FIELD(verbose);
3021 _copyCopyStmt(const CopyStmt *from)
3023 CopyStmt *newnode = makeNode(CopyStmt);
3025 COPY_NODE_FIELD(relation);
3026 COPY_NODE_FIELD(query);
3027 COPY_NODE_FIELD(attlist);
3028 COPY_SCALAR_FIELD(is_from);
3029 COPY_SCALAR_FIELD(is_program);
3030 COPY_STRING_FIELD(filename);
3031 COPY_NODE_FIELD(options);
3037 * CopyCreateStmtFields
3039 * This function copies the fields of the CreateStmt node. It is used by
3040 * copy functions for classes which inherit from CreateStmt.
3043 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
3045 COPY_NODE_FIELD(relation);
3046 COPY_NODE_FIELD(tableElts);
3047 COPY_NODE_FIELD(inhRelations);
3048 COPY_NODE_FIELD(partspec);
3049 COPY_NODE_FIELD(partbound);
3050 COPY_NODE_FIELD(ofTypename);
3051 COPY_NODE_FIELD(constraints);
3052 COPY_NODE_FIELD(options);
3053 COPY_SCALAR_FIELD(oncommit);
3054 COPY_STRING_FIELD(tablespacename);
3055 COPY_SCALAR_FIELD(if_not_exists);
3059 _copyCreateStmt(const CreateStmt *from)
3061 CreateStmt *newnode = makeNode(CreateStmt);
3063 CopyCreateStmtFields(from, newnode);
3068 static TableLikeClause *
3069 _copyTableLikeClause(const TableLikeClause *from)
3071 TableLikeClause *newnode = makeNode(TableLikeClause);
3073 COPY_NODE_FIELD(relation);
3074 COPY_SCALAR_FIELD(options);
3080 _copyDefineStmt(const DefineStmt *from)
3082 DefineStmt *newnode = makeNode(DefineStmt);
3084 COPY_SCALAR_FIELD(kind);
3085 COPY_SCALAR_FIELD(oldstyle);
3086 COPY_NODE_FIELD(defnames);
3087 COPY_NODE_FIELD(args);
3088 COPY_NODE_FIELD(definition);
3094 _copyDropStmt(const DropStmt *from)
3096 DropStmt *newnode = makeNode(DropStmt);
3098 COPY_NODE_FIELD(objects);
3099 COPY_NODE_FIELD(arguments);
3100 COPY_SCALAR_FIELD(removeType);
3101 COPY_SCALAR_FIELD(behavior);
3102 COPY_SCALAR_FIELD(missing_ok);
3103 COPY_SCALAR_FIELD(concurrent);
3108 static TruncateStmt *
3109 _copyTruncateStmt(const TruncateStmt *from)
3111 TruncateStmt *newnode = makeNode(TruncateStmt);
3113 COPY_NODE_FIELD(relations);
3114 COPY_SCALAR_FIELD(restart_seqs);
3115 COPY_SCALAR_FIELD(behavior);
3120 static CommentStmt *
3121 _copyCommentStmt(const CommentStmt *from)
3123 CommentStmt *newnode = makeNode(CommentStmt);
3125 COPY_SCALAR_FIELD(objtype);
3126 COPY_NODE_FIELD(objname);
3127 COPY_NODE_FIELD(objargs);
3128 COPY_STRING_FIELD(comment);
3133 static SecLabelStmt *
3134 _copySecLabelStmt(const SecLabelStmt *from)
3136 SecLabelStmt *newnode = makeNode(SecLabelStmt);
3138 COPY_SCALAR_FIELD(objtype);
3139 COPY_NODE_FIELD(objname);
3140 COPY_NODE_FIELD(objargs);
3141 COPY_STRING_FIELD(provider);
3142 COPY_STRING_FIELD(label);
3148 _copyFetchStmt(const FetchStmt *from)
3150 FetchStmt *newnode = makeNode(FetchStmt);
3152 COPY_SCALAR_FIELD(direction);
3153 COPY_SCALAR_FIELD(howMany);
3154 COPY_STRING_FIELD(portalname);
3155 COPY_SCALAR_FIELD(ismove);
3161 _copyIndexStmt(const IndexStmt *from)
3163 IndexStmt *newnode = makeNode(IndexStmt);
3165 COPY_STRING_FIELD(idxname);
3166 COPY_NODE_FIELD(relation);
3167 COPY_STRING_FIELD(accessMethod);
3168 COPY_STRING_FIELD(tableSpace);
3169 COPY_NODE_FIELD(indexParams);
3170 COPY_NODE_FIELD(options);
3171 COPY_NODE_FIELD(whereClause);
3172 COPY_NODE_FIELD(excludeOpNames);
3173 COPY_STRING_FIELD(idxcomment);
3174 COPY_SCALAR_FIELD(indexOid);
3175 COPY_SCALAR_FIELD(oldNode);
3176 COPY_SCALAR_FIELD(unique);
3177 COPY_SCALAR_FIELD(primary);
3178 COPY_SCALAR_FIELD(isconstraint);
3179 COPY_SCALAR_FIELD(deferrable);
3180 COPY_SCALAR_FIELD(initdeferred);
3181 COPY_SCALAR_FIELD(transformed);
3182 COPY_SCALAR_FIELD(concurrent);
3183 COPY_SCALAR_FIELD(if_not_exists);
3188 static CreateFunctionStmt *
3189 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
3191 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
3193 COPY_SCALAR_FIELD(replace);
3194 COPY_NODE_FIELD(funcname);
3195 COPY_NODE_FIELD(parameters);
3196 COPY_NODE_FIELD(returnType);
3197 COPY_NODE_FIELD(options);
3198 COPY_NODE_FIELD(withClause);
3203 static FunctionParameter *
3204 _copyFunctionParameter(const FunctionParameter *from)
3206 FunctionParameter *newnode = makeNode(FunctionParameter);
3208 COPY_STRING_FIELD(name);
3209 COPY_NODE_FIELD(argType);
3210 COPY_SCALAR_FIELD(mode);
3211 COPY_NODE_FIELD(defexpr);
3216 static AlterFunctionStmt *
3217 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
3219 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
3221 COPY_NODE_FIELD(func);
3222 COPY_NODE_FIELD(actions);
3228 _copyDoStmt(const DoStmt *from)
3230 DoStmt *newnode = makeNode(DoStmt);
3232 COPY_NODE_FIELD(args);
3238 _copyRenameStmt(const RenameStmt *from)
3240 RenameStmt *newnode = makeNode(RenameStmt);
3242 COPY_SCALAR_FIELD(renameType);
3243 COPY_SCALAR_FIELD(relationType);
3244 COPY_NODE_FIELD(relation);
3245 COPY_NODE_FIELD(object);
3246 COPY_NODE_FIELD(objarg);
3247 COPY_STRING_FIELD(subname);
3248 COPY_STRING_FIELD(newname);
3249 COPY_SCALAR_FIELD(behavior);
3250 COPY_SCALAR_FIELD(missing_ok);
3255 static AlterObjectDependsStmt *
3256 _copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from)
3258 AlterObjectDependsStmt *newnode = makeNode(AlterObjectDependsStmt);
3260 COPY_SCALAR_FIELD(objectType);
3261 COPY_NODE_FIELD(relation);
3262 COPY_NODE_FIELD(objname);
3263 COPY_NODE_FIELD(objargs);
3264 COPY_NODE_FIELD(extname);
3269 static AlterObjectSchemaStmt *
3270 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
3272 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
3274 COPY_SCALAR_FIELD(objectType);
3275 COPY_NODE_FIELD(relation);
3276 COPY_NODE_FIELD(object);
3277 COPY_NODE_FIELD(objarg);
3278 COPY_STRING_FIELD(newschema);
3279 COPY_SCALAR_FIELD(missing_ok);
3284 static AlterOwnerStmt *
3285 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
3287 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
3289 COPY_SCALAR_FIELD(objectType);
3290 COPY_NODE_FIELD(relation);
3291 COPY_NODE_FIELD(object);
3292 COPY_NODE_FIELD(objarg);
3293 COPY_NODE_FIELD(newowner);
3298 static AlterOperatorStmt *
3299 _copyAlterOperatorStmt(const AlterOperatorStmt *from)
3301 AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt);
3303 COPY_NODE_FIELD(opername);
3304 COPY_NODE_FIELD(operargs);
3305 COPY_NODE_FIELD(options);
3311 _copyRuleStmt(const RuleStmt *from)
3313 RuleStmt *newnode = makeNode(RuleStmt);
3315 COPY_NODE_FIELD(relation);
3316 COPY_STRING_FIELD(rulename);
3317 COPY_NODE_FIELD(whereClause);
3318 COPY_SCALAR_FIELD(event);
3319 COPY_SCALAR_FIELD(instead);
3320 COPY_NODE_FIELD(actions);
3321 COPY_SCALAR_FIELD(replace);
3327 _copyNotifyStmt(const NotifyStmt *from)
3329 NotifyStmt *newnode = makeNode(NotifyStmt);
3331 COPY_STRING_FIELD(conditionname);
3332 COPY_STRING_FIELD(payload);
3338 _copyListenStmt(const ListenStmt *from)
3340 ListenStmt *newnode = makeNode(ListenStmt);
3342 COPY_STRING_FIELD(conditionname);
3347 static UnlistenStmt *
3348 _copyUnlistenStmt(const UnlistenStmt *from)
3350 UnlistenStmt *newnode = makeNode(UnlistenStmt);
3352 COPY_STRING_FIELD(conditionname);
3357 static TransactionStmt *
3358 _copyTransactionStmt(const TransactionStmt *from)
3360 TransactionStmt *newnode = makeNode(TransactionStmt);
3362 COPY_SCALAR_FIELD(kind);
3363 COPY_NODE_FIELD(options);
3364 COPY_STRING_FIELD(gid);
3369 static CompositeTypeStmt *
3370 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3372 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3374 COPY_NODE_FIELD(typevar);
3375 COPY_NODE_FIELD(coldeflist);
3380 static CreateEnumStmt *
3381 _copyCreateEnumStmt(const CreateEnumStmt *from)
3383 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3385 COPY_NODE_FIELD(typeName);
3386 COPY_NODE_FIELD(vals);
3391 static CreateRangeStmt *
3392 _copyCreateRangeStmt(const CreateRangeStmt *from)
3394 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3396 COPY_NODE_FIELD(typeName);
3397 COPY_NODE_FIELD(params);
3402 static AlterEnumStmt *
3403 _copyAlterEnumStmt(const AlterEnumStmt *from)
3405 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3407 COPY_NODE_FIELD(typeName);
3408 COPY_STRING_FIELD(oldVal);
3409 COPY_STRING_FIELD(newVal);
3410 COPY_STRING_FIELD(newValNeighbor);
3411 COPY_SCALAR_FIELD(newValIsAfter);
3412 COPY_SCALAR_FIELD(skipIfNewValExists);
3418 _copyViewStmt(const ViewStmt *from)
3420 ViewStmt *newnode = makeNode(ViewStmt);
3422 COPY_NODE_FIELD(view);
3423 COPY_NODE_FIELD(aliases);
3424 COPY_NODE_FIELD(query);
3425 COPY_SCALAR_FIELD(replace);
3426 COPY_NODE_FIELD(options);
3427 COPY_SCALAR_FIELD(withCheckOption);
3433 _copyLoadStmt(const LoadStmt *from)
3435 LoadStmt *newnode = makeNode(LoadStmt);
3437 COPY_STRING_FIELD(filename);
3442 static CreateDomainStmt *
3443 _copyCreateDomainStmt(const CreateDomainStmt *from)
3445 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3447 COPY_NODE_FIELD(domainname);
3448 COPY_NODE_FIELD(typeName);
3449 COPY_NODE_FIELD(collClause);
3450 COPY_NODE_FIELD(constraints);
3455 static CreateOpClassStmt *
3456 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3458 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3460 COPY_NODE_FIELD(opclassname);
3461 COPY_NODE_FIELD(opfamilyname);
3462 COPY_STRING_FIELD(amname);
3463 COPY_NODE_FIELD(datatype);
3464 COPY_NODE_FIELD(items);
3465 COPY_SCALAR_FIELD(isDefault);
3470 static CreateOpClassItem *
3471 _copyCreateOpClassItem(const CreateOpClassItem *from)
3473 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3475 COPY_SCALAR_FIELD(itemtype);
3476 COPY_NODE_FIELD(name);
3477 COPY_NODE_FIELD(args);
3478 COPY_SCALAR_FIELD(number);
3479 COPY_NODE_FIELD(order_family);
3480 COPY_NODE_FIELD(class_args);
3481 COPY_NODE_FIELD(storedtype);
3486 static CreateOpFamilyStmt *
3487 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3489 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3491 COPY_NODE_FIELD(opfamilyname);
3492 COPY_STRING_FIELD(amname);
3497 static AlterOpFamilyStmt *
3498 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3500 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3502 COPY_NODE_FIELD(opfamilyname);
3503 COPY_STRING_FIELD(amname);
3504 COPY_SCALAR_FIELD(isDrop);
3505 COPY_NODE_FIELD(items);
3510 static CreatedbStmt *
3511 _copyCreatedbStmt(const CreatedbStmt *from)
3513 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3515 COPY_STRING_FIELD(dbname);
3516 COPY_NODE_FIELD(options);
3521 static AlterDatabaseStmt *
3522 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3524 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3526 COPY_STRING_FIELD(dbname);
3527 COPY_NODE_FIELD(options);
3532 static AlterDatabaseSetStmt *
3533 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3535 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3537 COPY_STRING_FIELD(dbname);
3538 COPY_NODE_FIELD(setstmt);
3544 _copyDropdbStmt(const DropdbStmt *from)
3546 DropdbStmt *newnode = makeNode(DropdbStmt);
3548 COPY_STRING_FIELD(dbname);
3549 COPY_SCALAR_FIELD(missing_ok);
3555 _copyVacuumStmt(const VacuumStmt *from)
3557 VacuumStmt *newnode = makeNode(VacuumStmt);
3559 COPY_SCALAR_FIELD(options);
3560 COPY_NODE_FIELD(relation);
3561 COPY_NODE_FIELD(va_cols);
3566 static ExplainStmt *
3567 _copyExplainStmt(const ExplainStmt *from)
3569 ExplainStmt *newnode = makeNode(ExplainStmt);
3571 COPY_NODE_FIELD(query);
3572 COPY_NODE_FIELD(options);
3577 static CreateTableAsStmt *
3578 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3580 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3582 COPY_NODE_FIELD(query);
3583 COPY_NODE_FIELD(into);
3584 COPY_SCALAR_FIELD(relkind);
3585 COPY_SCALAR_FIELD(is_select_into);
3586 COPY_SCALAR_FIELD(if_not_exists);
3591 static RefreshMatViewStmt *
3592 _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
3594 RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
3596 COPY_SCALAR_FIELD(concurrent);
3597 COPY_SCALAR_FIELD(skipData);
3598 COPY_NODE_FIELD(relation);
3603 static ReplicaIdentityStmt *
3604 _copyReplicaIdentityStmt(const ReplicaIdentityStmt *from)
3606 ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt);
3608 COPY_SCALAR_FIELD(identity_type);
3609 COPY_STRING_FIELD(name);
3614 static AlterSystemStmt *
3615 _copyAlterSystemStmt(const AlterSystemStmt *from)
3617 AlterSystemStmt *newnode = makeNode(AlterSystemStmt);
3619 COPY_NODE_FIELD(setstmt);
3624 static CreateSeqStmt *
3625 _copyCreateSeqStmt(const CreateSeqStmt *from)
3627 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3629 COPY_NODE_FIELD(sequence);
3630 COPY_NODE_FIELD(options);
3631 COPY_SCALAR_FIELD(ownerId);
3632 COPY_SCALAR_FIELD(if_not_exists);
3637 static AlterSeqStmt *
3638 _copyAlterSeqStmt(const AlterSeqStmt *from)
3640 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3642 COPY_NODE_FIELD(sequence);
3643 COPY_NODE_FIELD(options);
3644 COPY_SCALAR_FIELD(missing_ok);
3649 static VariableSetStmt *
3650 _copyVariableSetStmt(const VariableSetStmt *from)
3652 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3654 COPY_SCALAR_FIELD(kind);
3655 COPY_STRING_FIELD(name);
3656 COPY_NODE_FIELD(args);
3657 COPY_SCALAR_FIELD(is_local);
3662 static VariableShowStmt *
3663 _copyVariableShowStmt(const VariableShowStmt *from)
3665 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3667 COPY_STRING_FIELD(name);
3672 static DiscardStmt *
3673 _copyDiscardStmt(const DiscardStmt *from)
3675 DiscardStmt *newnode = makeNode(DiscardStmt);
3677 COPY_SCALAR_FIELD(target);
3682 static CreateTableSpaceStmt *
3683 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3685 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3687 COPY_STRING_FIELD(tablespacename);
3688 COPY_NODE_FIELD(owner);
3689 COPY_STRING_FIELD(location);
3690 COPY_NODE_FIELD(options);
3695 static DropTableSpaceStmt *
3696 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
3698 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3700 COPY_STRING_FIELD(tablespacename);
3701 COPY_SCALAR_FIELD(missing_ok);
3706 static AlterTableSpaceOptionsStmt *
3707 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
3709 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3711 COPY_STRING_FIELD(tablespacename);
3712 COPY_NODE_FIELD(options);
3713 COPY_SCALAR_FIELD(isReset);
3718 static AlterTableMoveAllStmt *
3719 _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
3721 AlterTableMoveAllStmt *newnode = makeNode(AlterTableMoveAllStmt);
3723 COPY_STRING_FIELD(orig_tablespacename);
3724 COPY_SCALAR_FIELD(objtype);
3725 COPY_NODE_FIELD(roles);
3726 COPY_STRING_FIELD(new_tablespacename);
3727 COPY_SCALAR_FIELD(nowait);
3732 static CreateExtensionStmt *
3733 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
3735 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3737 COPY_STRING_FIELD(extname);
3738 COPY_SCALAR_FIELD(if_not_exists);
3739 COPY_NODE_FIELD(options);
3744 static AlterExtensionStmt *
3745 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
3747 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3749 COPY_STRING_FIELD(extname);
3750 COPY_NODE_FIELD(options);
3755 static AlterExtensionContentsStmt *
3756 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
3758 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3760 COPY_STRING_FIELD(extname);
3761 COPY_SCALAR_FIELD(action);
3762 COPY_SCALAR_FIELD(objtype);
3763 COPY_NODE_FIELD(objname);
3764 COPY_NODE_FIELD(objargs);
3769 static CreateFdwStmt *
3770 _copyCreateFdwStmt(const CreateFdwStmt *from)
3772 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3774 COPY_STRING_FIELD(fdwname);
3775 COPY_NODE_FIELD(func_options);
3776 COPY_NODE_FIELD(options);
3781 static AlterFdwStmt *
3782 _copyAlterFdwStmt(const AlterFdwStmt *from)
3784 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3786 COPY_STRING_FIELD(fdwname);
3787 COPY_NODE_FIELD(func_options);
3788 COPY_NODE_FIELD(options);
3793 static CreateForeignServerStmt *
3794 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
3796 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3798 COPY_STRING_FIELD(servername);
3799 COPY_STRING_FIELD(servertype);
3800 COPY_STRING_FIELD(version);
3801 COPY_STRING_FIELD(fdwname);
3802 COPY_NODE_FIELD(options);
3807 static AlterForeignServerStmt *
3808 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
3810 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3812 COPY_STRING_FIELD(servername);
3813 COPY_STRING_FIELD(version);
3814 COPY_NODE_FIELD(options);
3815 COPY_SCALAR_FIELD(has_version);
3820 static CreateUserMappingStmt *
3821 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
3823 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3825 COPY_NODE_FIELD(user);
3826 COPY_STRING_FIELD(servername);
3827 COPY_NODE_FIELD(options);
3832 static AlterUserMappingStmt *
3833 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
3835 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3837 COPY_NODE_FIELD(user);
3838 COPY_STRING_FIELD(servername);
3839 COPY_NODE_FIELD(options);
3844 static DropUserMappingStmt *
3845 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
3847 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3849 COPY_NODE_FIELD(user);
3850 COPY_STRING_FIELD(servername);
3851 COPY_SCALAR_FIELD(missing_ok);
3856 static CreateForeignTableStmt *
3857 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
3859 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3861 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
3863 COPY_STRING_FIELD(servername);
3864 COPY_NODE_FIELD(options);
3869 static ImportForeignSchemaStmt *
3870 _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
3872 ImportForeignSchemaStmt *newnode = makeNode(ImportForeignSchemaStmt);
3874 COPY_STRING_FIELD(server_name);
3875 COPY_STRING_FIELD(remote_schema);
3876 COPY_STRING_FIELD(local_schema);
3877 COPY_SCALAR_FIELD(list_type);
3878 COPY_NODE_FIELD(table_list);
3879 COPY_NODE_FIELD(options);
3884 static CreateTransformStmt *
3885 _copyCreateTransformStmt(const CreateTransformStmt *from)
3887 CreateTransformStmt *newnode = makeNode(CreateTransformStmt);
3889 COPY_SCALAR_FIELD(replace);
3890 COPY_NODE_FIELD(type_name);
3891 COPY_STRING_FIELD(lang);
3892 COPY_NODE_FIELD(fromsql);
3893 COPY_NODE_FIELD(tosql);
3898 static CreateAmStmt *
3899 _copyCreateAmStmt(const CreateAmStmt *from)
3901 CreateAmStmt *newnode = makeNode(CreateAmStmt);
3903 COPY_STRING_FIELD(amname);
3904 COPY_NODE_FIELD(handler_name);
3905 COPY_SCALAR_FIELD(amtype);
3910 static CreateTrigStmt *
3911 _copyCreateTrigStmt(const CreateTrigStmt *from)
3913 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3915 COPY_STRING_FIELD(trigname);
3916 COPY_NODE_FIELD(relation);
3917 COPY_NODE_FIELD(funcname);
3918 COPY_NODE_FIELD(args);
3919 COPY_SCALAR_FIELD(row);
3920 COPY_SCALAR_FIELD(timing);
3921 COPY_SCALAR_FIELD(events);
3922 COPY_NODE_FIELD(columns);
3923 COPY_NODE_FIELD(whenClause);
3924 COPY_SCALAR_FIELD(isconstraint);
3925 COPY_NODE_FIELD(transitionRels);
3926 COPY_SCALAR_FIELD(deferrable);
3927 COPY_SCALAR_FIELD(initdeferred);
3928 COPY_NODE_FIELD(constrrel);
3933 static CreateEventTrigStmt *
3934 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
3936 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
3938 COPY_STRING_FIELD(trigname);
3939 COPY_STRING_FIELD(eventname);
3940 COPY_NODE_FIELD(whenclause);
3941 COPY_NODE_FIELD(funcname);
3946 static AlterEventTrigStmt *
3947 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
3949 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
3951 COPY_STRING_FIELD(trigname);
3952 COPY_SCALAR_FIELD(tgenabled);
3957 static CreatePLangStmt *
3958 _copyCreatePLangStmt(const CreatePLangStmt *from)
3960 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3962 COPY_SCALAR_FIELD(replace);
3963 COPY_STRING_FIELD(plname);
3964 COPY_NODE_FIELD(plhandler);
3965 COPY_NODE_FIELD(plinline);
3966 COPY_NODE_FIELD(plvalidator);
3967 COPY_SCALAR_FIELD(pltrusted);
3972 static CreateRoleStmt *
3973 _copyCreateRoleStmt(const CreateRoleStmt *from)
3975 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3977 COPY_SCALAR_FIELD(stmt_type);
3978 COPY_STRING_FIELD(role);
3979 COPY_NODE_FIELD(options);
3984 static AlterRoleStmt *
3985 _copyAlterRoleStmt(const AlterRoleStmt *from)
3987 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3989 COPY_NODE_FIELD(role);
3990 COPY_NODE_FIELD(options);
3991 COPY_SCALAR_FIELD(action);
3996 static AlterRoleSetStmt *
3997 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
3999 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
4001 COPY_NODE_FIELD(role);
4002 COPY_STRING_FIELD(database);
4003 COPY_NODE_FIELD(setstmt);
4008 static DropRoleStmt *
4009 _copyDropRoleStmt(const DropRoleStmt *from)
4011 DropRoleStmt *newnode = makeNode(DropRoleStmt);
4013 COPY_NODE_FIELD(roles);
4014 COPY_SCALAR_FIELD(missing_ok);
4020 _copyLockStmt(const LockStmt *from)
4022 LockStmt *newnode = makeNode(LockStmt);
4024 COPY_NODE_FIELD(relations);
4025 COPY_SCALAR_FIELD(mode);
4026 COPY_SCALAR_FIELD(nowait);
4031 static ConstraintsSetStmt *
4032 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
4034 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
4036 COPY_NODE_FIELD(constraints);
4037 COPY_SCALAR_FIELD(deferred);
4042 static ReindexStmt *
4043 _copyReindexStmt(const ReindexStmt *from)
4045 ReindexStmt *newnode = makeNode(ReindexStmt);
4047 COPY_SCALAR_FIELD(kind);
4048 COPY_NODE_FIELD(relation);
4049 COPY_STRING_FIELD(name);
4050 COPY_SCALAR_FIELD(options);
4055 static CreateSchemaStmt *
4056 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
4058 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
4060 COPY_STRING_FIELD(schemaname);
4061 COPY_NODE_FIELD(authrole);
4062 COPY_NODE_FIELD(schemaElts);
4063 COPY_SCALAR_FIELD(if_not_exists);
4068 static CreateConversionStmt *
4069 _copyCreateConversionStmt(const CreateConversionStmt *from)
4071 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
4073 COPY_NODE_FIELD(conversion_name);
4074 COPY_STRING_FIELD(for_encoding_name);
4075 COPY_STRING_FIELD(to_encoding_name);
4076 COPY_NODE_FIELD(func_name);
4077 COPY_SCALAR_FIELD(def);
4082 static CreateCastStmt *
4083 _copyCreateCastStmt(const CreateCastStmt *from)
4085 CreateCastStmt *newnode = makeNode(CreateCastStmt);
4087 COPY_NODE_FIELD(sourcetype);
4088 COPY_NODE_FIELD(targettype);
4089 COPY_NODE_FIELD(func);
4090 COPY_SCALAR_FIELD(context);
4091 COPY_SCALAR_FIELD(inout);
4096 static PrepareStmt *
4097 _copyPrepareStmt(const PrepareStmt *from)
4099 PrepareStmt *newnode = makeNode(PrepareStmt);
4101 COPY_STRING_FIELD(name);
4102 COPY_NODE_FIELD(argtypes);
4103 COPY_NODE_FIELD(query);
4108 static ExecuteStmt *
4109 _copyExecuteStmt(const ExecuteStmt *from)
4111 ExecuteStmt *newnode = makeNode(ExecuteStmt);
4113 COPY_STRING_FIELD(name);
4114 COPY_NODE_FIELD(params);
4119 static DeallocateStmt *
4120 _copyDeallocateStmt(const DeallocateStmt *from)
4122 DeallocateStmt *newnode = makeNode(DeallocateStmt);
4124 COPY_STRING_FIELD(name);
4129 static DropOwnedStmt *
4130 _copyDropOwnedStmt(const DropOwnedStmt *from)
4132 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
4134 COPY_NODE_FIELD(roles);
4135 COPY_SCALAR_FIELD(behavior);
4140 static ReassignOwnedStmt *
4141 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
4143 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
4145 COPY_NODE_FIELD(roles);
4146 COPY_NODE_FIELD(newrole);
4151 static AlterTSDictionaryStmt *
4152 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
4154 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
4156 COPY_NODE_FIELD(dictname);
4157 COPY_NODE_FIELD(options);
4162 static AlterTSConfigurationStmt *
4163 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
4165 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
4167 COPY_SCALAR_FIELD(kind);
4168 COPY_NODE_FIELD(cfgname);
4169 COPY_NODE_FIELD(tokentype);
4170 COPY_NODE_FIELD(dicts);
4171 COPY_SCALAR_FIELD(override);
4172 COPY_SCALAR_FIELD(replace);
4173 COPY_SCALAR_FIELD(missing_ok);
4178 static CreatePolicyStmt *
4179 _copyCreatePolicyStmt(const CreatePolicyStmt *from)
4181 CreatePolicyStmt *newnode = makeNode(CreatePolicyStmt);
4183 COPY_STRING_FIELD(policy_name);
4184 COPY_NODE_FIELD(table);
4185 COPY_STRING_FIELD(cmd_name);
4186 COPY_SCALAR_FIELD(permissive);
4187 COPY_NODE_FIELD(roles);
4188 COPY_NODE_FIELD(qual);
4189 COPY_NODE_FIELD(with_check);
4194 static AlterPolicyStmt *
4195 _copyAlterPolicyStmt(const AlterPolicyStmt *from)
4197 AlterPolicyStmt *newnode = makeNode(AlterPolicyStmt);
4199 COPY_STRING_FIELD(policy_name);
4200 COPY_NODE_FIELD(table);
4201 COPY_NODE_FIELD(roles);
4202 COPY_NODE_FIELD(qual);
4203 COPY_NODE_FIELD(with_check);
4208 static PartitionSpec *
4209 _copyPartitionSpec(const PartitionSpec *from)
4211 PartitionSpec *newnode = makeNode(PartitionSpec);
4213 COPY_STRING_FIELD(strategy);
4214 COPY_NODE_FIELD(partParams);
4215 COPY_LOCATION_FIELD(location);
4220 static PartitionElem *
4221 _copyPartitionElem(const PartitionElem *from)
4223 PartitionElem *newnode = makeNode(PartitionElem);
4225 COPY_STRING_FIELD(name);
4226 COPY_NODE_FIELD(expr);
4227 COPY_NODE_FIELD(collation);
4228 COPY_NODE_FIELD(opclass);
4229 COPY_LOCATION_FIELD(location);
4234 static PartitionBoundSpec *
4235 _copyPartitionBoundSpec(const PartitionBoundSpec *from)
4237 PartitionBoundSpec *newnode = makeNode(PartitionBoundSpec);
4239 COPY_SCALAR_FIELD(strategy);
4240 COPY_NODE_FIELD(listdatums);
4241 COPY_NODE_FIELD(lowerdatums);
4242 COPY_NODE_FIELD(upperdatums);
4243 COPY_LOCATION_FIELD(location);
4248 static PartitionRangeDatum *
4249 _copyPartitionRangeDatum(const PartitionRangeDatum *from)
4251 PartitionRangeDatum *newnode = makeNode(PartitionRangeDatum);
4253 COPY_SCALAR_FIELD(infinite);
4254 COPY_NODE_FIELD(value);
4255 COPY_LOCATION_FIELD(location);
4260 static PartitionCmd *
4261 _copyPartitionCmd(const PartitionCmd *from)
4263 PartitionCmd *newnode = makeNode(PartitionCmd);
4265 COPY_NODE_FIELD(name);
4266 COPY_NODE_FIELD(bound);
4271 /* ****************************************************************
4272 * pg_list.h copy functions
4273 * ****************************************************************
4277 * Perform a deep copy of the specified list, using copyObject(). The
4278 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
4279 * need deep copies, so they should be copied via list_copy()
4281 #define COPY_NODE_CELL(new, old) \
4282 (new) = (ListCell *) palloc(sizeof(ListCell)); \
4283 lfirst(new) = copyObject(lfirst(old));
4286 _copyList(const List *from)
4292 Assert(list_length(from) >= 1);
4294 new = makeNode(List);
4295 new->length = from->length;
4297 COPY_NODE_CELL(new->head, from->head);
4298 prev_new = new->head;
4299 curr_old = lnext(from->head);
4303 COPY_NODE_CELL(prev_new->next, curr_old);
4304 prev_new = prev_new->next;
4305 curr_old = curr_old->next;
4307 prev_new->next = NULL;
4308 new->tail = prev_new;
4313 /* ****************************************************************
4314 * extensible.h copy functions
4315 * ****************************************************************
4317 static ExtensibleNode *
4318 _copyExtensibleNode(const ExtensibleNode *from)
4320 ExtensibleNode *newnode;
4321 const ExtensibleNodeMethods *methods;
4323 methods = GetExtensibleNodeMethods(from->extnodename, false);
4324 newnode = (ExtensibleNode *) newNode(methods->node_size,
4326 COPY_STRING_FIELD(extnodename);
4328 /* copy the private fields */
4329 methods->nodeCopy(newnode, from);
4334 /* ****************************************************************
4335 * value.h copy functions
4336 * ****************************************************************
4339 _copyValue(const Value *from)
4341 Value *newnode = makeNode(Value);
4343 /* See also _copyAConst when changing this code! */
4345 COPY_SCALAR_FIELD(type);
4349 COPY_SCALAR_FIELD(val.ival);
4354 COPY_STRING_FIELD(val.str);
4360 elog(ERROR, "unrecognized node type: %d",
4368 static ForeignKeyCacheInfo *
4369 _copyForeignKeyCacheInfo(const ForeignKeyCacheInfo *from)
4371 ForeignKeyCacheInfo *newnode = makeNode(ForeignKeyCacheInfo);
4373 COPY_SCALAR_FIELD(conrelid);
4374 COPY_SCALAR_FIELD(confrelid);
4375 COPY_SCALAR_FIELD(nkeys);
4376 /* COPY_SCALAR_FIELD might work for these, but let's not assume that */
4377 memcpy(newnode->conkey, from->conkey, sizeof(newnode->conkey));
4378 memcpy(newnode->confkey, from->confkey, sizeof(newnode->confkey));
4379 memcpy(newnode->conpfeqop, from->conpfeqop, sizeof(newnode->conpfeqop));
4388 * Create a copy of a Node tree or list. This is a "deep" copy: all
4389 * substructure is copied too, recursively.
4392 copyObject(const void *from)
4399 /* Guard against stack overflow due to overly complex expressions */
4400 check_stack_depth();
4402 switch (nodeTag(from))
4408 retval = _copyPlannedStmt(from);
4411 retval = _copyPlan(from);
4414 retval = _copyResult(from);
4417 retval = _copyModifyTable(from);
4420 retval = _copyAppend(from);
4423 retval = _copyMergeAppend(from);
4425 case T_RecursiveUnion:
4426 retval = _copyRecursiveUnion(from);
4429 retval = _copyBitmapAnd(from);
4432 retval = _copyBitmapOr(from);
4435 retval = _copyScan(from);
4438 retval = _copyGather(from);
4441 retval = _copySeqScan(from);
4444 retval = _copySampleScan(from);
4447 retval = _copyIndexScan(from);
4449 case T_IndexOnlyScan:
4450 retval = _copyIndexOnlyScan(from);
4452 case T_BitmapIndexScan:
4453 retval = _copyBitmapIndexScan(from);
4455 case T_BitmapHeapScan:
4456 retval = _copyBitmapHeapScan(from);
4459 retval = _copyTidScan(from);
4461 case T_SubqueryScan:
4462 retval = _copySubqueryScan(from);
4464 case T_FunctionScan:
4465 retval = _copyFunctionScan(from);
4468 retval = _copyValuesScan(from);
4471 retval = _copyCteScan(from);
4473 case T_WorkTableScan:
4474 retval = _copyWorkTableScan(from);
4477 retval = _copyForeignScan(from);
4480 retval = _copyCustomScan(from);
4483 retval = _copyJoin(from);
4486 retval = _copyNestLoop(from);
4489 retval = _copyMergeJoin(from);
4492 retval = _copyHashJoin(from);
4495 retval = _copyMaterial(from);
4498 retval = _copySort(from);
4501 retval = _copyGroup(from);
4504 retval = _copyAgg(from);
4507 retval = _copyWindowAgg(from);
4510 retval = _copyUnique(from);
4513 retval = _copyHash(from);
4516 retval = _copySetOp(from);
4519 retval = _copyLockRows(from);
4522 retval = _copyLimit(from);
4524 case T_NestLoopParam:
4525 retval = _copyNestLoopParam(from);
4528 retval = _copyPlanRowMark(from);
4530 case T_PlanInvalItem:
4531 retval = _copyPlanInvalItem(from);
4538 retval = _copyAlias(from);
4541 retval = _copyRangeVar(from);
4544 retval = _copyIntoClause(from);
4547 retval = _copyVar(from);
4550 retval = _copyConst(from);
4553 retval = _copyParam(from);
4556 retval = _copyAggref(from);
4558 case T_GroupingFunc:
4559 retval = _copyGroupingFunc(from);
4562 retval = _copyWindowFunc(from);
4565 retval = _copyArrayRef(from);
4568 retval = _copyFuncExpr(from);
4570 case T_NamedArgExpr:
4571 retval = _copyNamedArgExpr(from);
4574 retval = _copyOpExpr(from);
4576 case T_DistinctExpr:
4577 retval = _copyDistinctExpr(from);
4580 retval = _copyNullIfExpr(from);
4582 case T_ScalarArrayOpExpr:
4583 retval = _copyScalarArrayOpExpr(from);
4586 retval = _copyBoolExpr(from);
4589 retval = _copySubLink(from);
4592 retval = _copySubPlan(from);
4594 case T_AlternativeSubPlan:
4595 retval = _copyAlternativeSubPlan(from);
4598 retval = _copyFieldSelect(from);
4601 retval = _copyFieldStore(from);
4604 retval = _copyRelabelType(from);
4607 retval = _copyCoerceViaIO(from);
4609 case T_ArrayCoerceExpr:
4610 retval = _copyArrayCoerceExpr(from);
4612 case T_ConvertRowtypeExpr:
4613 retval = _copyConvertRowtypeExpr(from);
4616 retval = _copyCollateExpr(from);
4619 retval = _copyCaseExpr(from);
4622 retval = _copyCaseWhen(from);
4624 case T_CaseTestExpr:
4625 retval = _copyCaseTestExpr(from);
4628 retval = _copyArrayExpr(from);
4631 retval = _copyRowExpr(from);
4633 case T_RowCompareExpr:
4634 retval = _copyRowCompareExpr(from);
4636 case T_CoalesceExpr:
4637 retval = _copyCoalesceExpr(from);
4640 retval = _copyMinMaxExpr(from);
4642 case T_SQLValueFunction:
4643 retval = _copySQLValueFunction(from);
4646 retval = _copyXmlExpr(from);
4649 retval = _copyNullTest(from);
4652 retval = _copyBooleanTest(from);
4654 case T_CoerceToDomain:
4655 retval = _copyCoerceToDomain(from);
4657 case T_CoerceToDomainValue:
4658 retval = _copyCoerceToDomainValue(from);
4660 case T_SetToDefault:
4661 retval = _copySetToDefault(from);
4663 case T_CurrentOfExpr:
4664 retval = _copyCurrentOfExpr(from);
4666 case T_InferenceElem:
4667 retval = _copyInferenceElem(from);
4670 retval = _copyTargetEntry(from);
4673 retval = _copyRangeTblRef(from);
4676 retval = _copyJoinExpr(from);
4679 retval = _copyFromExpr(from);
4681 case T_OnConflictExpr:
4682 retval = _copyOnConflictExpr(from);
4689 retval = _copyPathKey(from);
4691 case T_RestrictInfo:
4692 retval = _copyRestrictInfo(from);
4694 case T_PlaceHolderVar:
4695 retval = _copyPlaceHolderVar(from);
4697 case T_SpecialJoinInfo:
4698 retval = _copySpecialJoinInfo(from);
4700 case T_AppendRelInfo:
4701 retval = _copyAppendRelInfo(from);
4703 case T_PlaceHolderInfo:
4704 retval = _copyPlaceHolderInfo(from);
4715 retval = _copyValue(from);
4722 retval = _copyList(from);
4726 * Lists of integers and OIDs don't need to be deep-copied, so we
4727 * perform a shallow copy via list_copy()
4731 retval = list_copy(from);
4737 case T_ExtensibleNode:
4738 retval = _copyExtensibleNode(from);
4745 retval = _copyQuery(from);
4748 retval = _copyRawStmt(from);
4751 retval = _copyInsertStmt(from);
4754 retval = _copyDeleteStmt(from);
4757 retval = _copyUpdateStmt(from);
4760 retval = _copySelectStmt(from);
4762 case T_SetOperationStmt:
4763 retval = _copySetOperationStmt(from);
4765 case T_AlterTableStmt:
4766 retval = _copyAlterTableStmt(from);
4768 case T_AlterTableCmd:
4769 retval = _copyAlterTableCmd(from);
4771 case T_AlterDomainStmt:
4772 retval = _copyAlterDomainStmt(from);
4775 retval = _copyGrantStmt(from);
4777 case T_GrantRoleStmt:
4778 retval = _copyGrantRoleStmt(from);
4780 case T_AlterDefaultPrivilegesStmt:
4781 retval = _copyAlterDefaultPrivilegesStmt(from);
4783 case T_DeclareCursorStmt:
4784 retval = _copyDeclareCursorStmt(from);
4786 case T_ClosePortalStmt:
4787 retval = _copyClosePortalStmt(from);
4790 retval = _copyClusterStmt(from);
4793 retval = _copyCopyStmt(from);
4796 retval = _copyCreateStmt(from);
4798 case T_TableLikeClause:
4799 retval = _copyTableLikeClause(from);
4802 retval = _copyDefineStmt(from);
4805 retval = _copyDropStmt(from);
4807 case T_TruncateStmt:
4808 retval = _copyTruncateStmt(from);
4811 retval = _copyCommentStmt(from);
4813 case T_SecLabelStmt:
4814 retval = _copySecLabelStmt(from);
4817 retval = _copyFetchStmt(from);
4820 retval = _copyIndexStmt(from);
4822 case T_CreateFunctionStmt:
4823 retval = _copyCreateFunctionStmt(from);
4825 case T_FunctionParameter:
4826 retval = _copyFunctionParameter(from);
4828 case T_AlterFunctionStmt:
4829 retval = _copyAlterFunctionStmt(from);
4832 retval = _copyDoStmt(from);
4835 retval = _copyRenameStmt(from);
4837 case T_AlterObjectDependsStmt:
4838 retval = _copyAlterObjectDependsStmt(from);
4840 case T_AlterObjectSchemaStmt:
4841 retval = _copyAlterObjectSchemaStmt(from);
4843 case T_AlterOwnerStmt:
4844 retval = _copyAlterOwnerStmt(from);
4846 case T_AlterOperatorStmt:
4847 retval = _copyAlterOperatorStmt(from);
4850 retval = _copyRuleStmt(from);
4853 retval = _copyNotifyStmt(from);
4856 retval = _copyListenStmt(from);
4858 case T_UnlistenStmt:
4859 retval = _copyUnlistenStmt(from);
4861 case T_TransactionStmt:
4862 retval = _copyTransactionStmt(from);
4864 case T_CompositeTypeStmt:
4865 retval = _copyCompositeTypeStmt(from);
4867 case T_CreateEnumStmt:
4868 retval = _copyCreateEnumStmt(from);
4870 case T_CreateRangeStmt:
4871 retval = _copyCreateRangeStmt(from);
4873 case T_AlterEnumStmt:
4874 retval = _copyAlterEnumStmt(from);
4877 retval = _copyViewStmt(from);
4880 retval = _copyLoadStmt(from);
4882 case T_CreateDomainStmt:
4883 retval = _copyCreateDomainStmt(from);
4885 case T_CreateOpClassStmt:
4886 retval = _copyCreateOpClassStmt(from);
4888 case T_CreateOpClassItem:
4889 retval = _copyCreateOpClassItem(from);
4891 case T_CreateOpFamilyStmt:
4892 retval = _copyCreateOpFamilyStmt(from);
4894 case T_AlterOpFamilyStmt:
4895 retval = _copyAlterOpFamilyStmt(from);
4897 case T_CreatedbStmt:
4898 retval = _copyCreatedbStmt(from);
4900 case T_AlterDatabaseStmt:
4901 retval = _copyAlterDatabaseStmt(from);
4903 case T_AlterDatabaseSetStmt:
4904 retval = _copyAlterDatabaseSetStmt(from);
4907 retval = _copyDropdbStmt(from);
4910 retval = _copyVacuumStmt(from);
4913 retval = _copyExplainStmt(from);
4915 case T_CreateTableAsStmt:
4916 retval = _copyCreateTableAsStmt(from);
4918 case T_RefreshMatViewStmt:
4919 retval = _copyRefreshMatViewStmt(from);
4921 case T_ReplicaIdentityStmt:
4922 retval = _copyReplicaIdentityStmt(from);
4924 case T_AlterSystemStmt:
4925 retval = _copyAlterSystemStmt(from);
4927 case T_CreateSeqStmt:
4928 retval = _copyCreateSeqStmt(from);
4930 case T_AlterSeqStmt:
4931 retval = _copyAlterSeqStmt(from);
4933 case T_VariableSetStmt:
4934 retval = _copyVariableSetStmt(from);
4936 case T_VariableShowStmt:
4937 retval = _copyVariableShowStmt(from);
4940 retval = _copyDiscardStmt(from);
4942 case T_CreateTableSpaceStmt:
4943 retval = _copyCreateTableSpaceStmt(from);
4945 case T_DropTableSpaceStmt:
4946 retval = _copyDropTableSpaceStmt(from);
4948 case T_AlterTableSpaceOptionsStmt:
4949 retval = _copyAlterTableSpaceOptionsStmt(from);
4951 case T_AlterTableMoveAllStmt:
4952 retval = _copyAlterTableMoveAllStmt(from);
4954 case T_CreateExtensionStmt:
4955 retval = _copyCreateExtensionStmt(from);
4957 case T_AlterExtensionStmt:
4958 retval = _copyAlterExtensionStmt(from);
4960 case T_AlterExtensionContentsStmt:
4961 retval = _copyAlterExtensionContentsStmt(from);
4963 case T_CreateFdwStmt:
4964 retval = _copyCreateFdwStmt(from);
4966 case T_AlterFdwStmt:
4967 retval = _copyAlterFdwStmt(from);
4969 case T_CreateForeignServerStmt:
4970 retval = _copyCreateForeignServerStmt(from);
4972 case T_AlterForeignServerStmt:
4973 retval = _copyAlterForeignServerStmt(from);
4975 case T_CreateUserMappingStmt:
4976 retval = _copyCreateUserMappingStmt(from);
4978 case T_AlterUserMappingStmt:
4979 retval = _copyAlterUserMappingStmt(from);
4981 case T_DropUserMappingStmt:
4982 retval = _copyDropUserMappingStmt(from);
4984 case T_CreateForeignTableStmt:
4985 retval = _copyCreateForeignTableStmt(from);
4987 case T_ImportForeignSchemaStmt:
4988 retval = _copyImportForeignSchemaStmt(from);
4990 case T_CreateTransformStmt:
4991 retval = _copyCreateTransformStmt(from);
4993 case T_CreateAmStmt:
4994 retval = _copyCreateAmStmt(from);
4996 case T_CreateTrigStmt:
4997 retval = _copyCreateTrigStmt(from);
4999 case T_CreateEventTrigStmt:
5000 retval = _copyCreateEventTrigStmt(from);
5002 case T_AlterEventTrigStmt:
5003 retval = _copyAlterEventTrigStmt(from);
5005 case T_CreatePLangStmt:
5006 retval = _copyCreatePLangStmt(from);
5008 case T_CreateRoleStmt:
5009 retval = _copyCreateRoleStmt(from);
5011 case T_AlterRoleStmt:
5012 retval = _copyAlterRoleStmt(from);
5014 case T_AlterRoleSetStmt:
5015 retval = _copyAlterRoleSetStmt(from);
5017 case T_DropRoleStmt:
5018 retval = _copyDropRoleStmt(from);
5021 retval = _copyLockStmt(from);
5023 case T_ConstraintsSetStmt:
5024 retval = _copyConstraintsSetStmt(from);
5027 retval = _copyReindexStmt(from);
5029 case T_CheckPointStmt:
5030 retval = (void *) makeNode(CheckPointStmt);
5032 case T_CreateSchemaStmt:
5033 retval = _copyCreateSchemaStmt(from);
5035 case T_CreateConversionStmt:
5036 retval = _copyCreateConversionStmt(from);
5038 case T_CreateCastStmt:
5039 retval = _copyCreateCastStmt(from);
5042 retval = _copyPrepareStmt(from);
5045 retval = _copyExecuteStmt(from);
5047 case T_DeallocateStmt:
5048 retval = _copyDeallocateStmt(from);
5050 case T_DropOwnedStmt:
5051 retval = _copyDropOwnedStmt(from);
5053 case T_ReassignOwnedStmt:
5054 retval = _copyReassignOwnedStmt(from);
5056 case T_AlterTSDictionaryStmt:
5057 retval = _copyAlterTSDictionaryStmt(from);
5059 case T_AlterTSConfigurationStmt:
5060 retval = _copyAlterTSConfigurationStmt(from);
5062 case T_CreatePolicyStmt:
5063 retval = _copyCreatePolicyStmt(from);
5065 case T_AlterPolicyStmt:
5066 retval = _copyAlterPolicyStmt(from);
5069 retval = _copyAExpr(from);
5072 retval = _copyColumnRef(from);
5075 retval = _copyParamRef(from);
5078 retval = _copyAConst(from);
5081 retval = _copyFuncCall(from);
5084 retval = _copyAStar(from);
5087 retval = _copyAIndices(from);
5089 case T_A_Indirection:
5090 retval = _copyA_Indirection(from);
5093 retval = _copyA_ArrayExpr(from);
5096 retval = _copyResTarget(from);
5098 case T_MultiAssignRef:
5099 retval = _copyMultiAssignRef(from);
5102 retval = _copyTypeCast(from);
5104 case T_CollateClause:
5105 retval = _copyCollateClause(from);
5108 retval = _copySortBy(from);
5111 retval = _copyWindowDef(from);
5113 case T_RangeSubselect:
5114 retval = _copyRangeSubselect(from);
5116 case T_RangeFunction:
5117 retval = _copyRangeFunction(from);
5119 case T_RangeTableSample:
5120 retval = _copyRangeTableSample(from);
5123 retval = _copyTypeName(from);
5126 retval = _copyIndexElem(from);
5129 retval = _copyColumnDef(from);
5132 retval = _copyConstraint(from);
5135 retval = _copyDefElem(from);
5137 case T_LockingClause:
5138 retval = _copyLockingClause(from);
5140 case T_RangeTblEntry:
5141 retval = _copyRangeTblEntry(from);
5143 case T_RangeTblFunction:
5144 retval = _copyRangeTblFunction(from);
5146 case T_TableSampleClause:
5147 retval = _copyTableSampleClause(from);
5149 case T_WithCheckOption:
5150 retval = _copyWithCheckOption(from);
5152 case T_SortGroupClause:
5153 retval = _copySortGroupClause(from);
5156 retval = _copyGroupingSet(from);
5158 case T_WindowClause:
5159 retval = _copyWindowClause(from);
5161 case T_RowMarkClause:
5162 retval = _copyRowMarkClause(from);
5165 retval = _copyWithClause(from);
5168 retval = _copyInferClause(from);
5170 case T_OnConflictClause:
5171 retval = _copyOnConflictClause(from);
5173 case T_CommonTableExpr:
5174 retval = _copyCommonTableExpr(from);
5176 case T_FuncWithArgs:
5177 retval = _copyFuncWithArgs(from);
5180 retval = _copyAccessPriv(from);
5182 case T_XmlSerialize:
5183 retval = _copyXmlSerialize(from);
5186 retval = _copyRoleSpec(from);
5188 case T_TriggerTransition:
5189 retval = _copyTriggerTransition(from);
5191 case T_PartitionSpec:
5192 retval = _copyPartitionSpec(from);
5194 case T_PartitionElem:
5195 retval = _copyPartitionElem(from);
5197 case T_PartitionBoundSpec:
5198 retval = _copyPartitionBoundSpec(from);
5200 case T_PartitionRangeDatum:
5201 retval = _copyPartitionRangeDatum(from);
5203 case T_PartitionCmd:
5204 retval = _copyPartitionCmd(from);
5208 * MISCELLANEOUS NODES
5210 case T_ForeignKeyCacheInfo:
5211 retval = _copyForeignKeyCacheInfo(from);
5215 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
5216 retval = 0; /* keep compiler quiet */