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-2012, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
18 * src/backend/nodes/copyfuncs.c
20 *-------------------------------------------------------------------------
25 #include "miscadmin.h"
26 #include "nodes/plannodes.h"
27 #include "nodes/relation.h"
28 #include "utils/datum.h"
32 * Macros to simplify copying of different kinds of fields. Use these
33 * wherever possible to reduce the chance for silly typos. Note that these
34 * hard-wire the convention that the local variables in a Copy routine are
35 * named 'newnode' and 'from'.
38 /* Copy a simple scalar field (int, float, bool, enum, etc) */
39 #define COPY_SCALAR_FIELD(fldname) \
40 (newnode->fldname = from->fldname)
42 /* Copy a field that is a pointer to some kind of Node or Node tree */
43 #define COPY_NODE_FIELD(fldname) \
44 (newnode->fldname = copyObject(from->fldname))
46 /* Copy a field that is a pointer to a Bitmapset */
47 #define COPY_BITMAPSET_FIELD(fldname) \
48 (newnode->fldname = bms_copy(from->fldname))
50 /* Copy a field that is a pointer to a C string, or perhaps NULL */
51 #define COPY_STRING_FIELD(fldname) \
52 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
54 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
55 #define COPY_POINTER_FIELD(fldname, sz) \
58 newnode->fldname = palloc(_size); \
59 memcpy(newnode->fldname, from->fldname, _size); \
62 /* Copy a parse location field (for Copy, this is same as scalar case) */
63 #define COPY_LOCATION_FIELD(fldname) \
64 (newnode->fldname = from->fldname)
67 /* ****************************************************************
68 * plannodes.h copy functions
69 * ****************************************************************
76 _copyPlannedStmt(const PlannedStmt *from)
78 PlannedStmt *newnode = makeNode(PlannedStmt);
80 COPY_SCALAR_FIELD(commandType);
81 COPY_SCALAR_FIELD(queryId);
82 COPY_SCALAR_FIELD(hasReturning);
83 COPY_SCALAR_FIELD(hasModifyingCTE);
84 COPY_SCALAR_FIELD(canSetTag);
85 COPY_SCALAR_FIELD(transientPlan);
86 COPY_NODE_FIELD(planTree);
87 COPY_NODE_FIELD(rtable);
88 COPY_NODE_FIELD(resultRelations);
89 COPY_NODE_FIELD(utilityStmt);
90 COPY_NODE_FIELD(subplans);
91 COPY_BITMAPSET_FIELD(rewindPlanIDs);
92 COPY_NODE_FIELD(rowMarks);
93 COPY_NODE_FIELD(relationOids);
94 COPY_NODE_FIELD(invalItems);
95 COPY_SCALAR_FIELD(nParamExec);
103 * This function copies the fields of the Plan node. It is used by
104 * all the copy functions for classes which inherit from Plan.
107 CopyPlanFields(const Plan *from, Plan *newnode)
109 COPY_SCALAR_FIELD(startup_cost);
110 COPY_SCALAR_FIELD(total_cost);
111 COPY_SCALAR_FIELD(plan_rows);
112 COPY_SCALAR_FIELD(plan_width);
113 COPY_NODE_FIELD(targetlist);
114 COPY_NODE_FIELD(qual);
115 COPY_NODE_FIELD(lefttree);
116 COPY_NODE_FIELD(righttree);
117 COPY_NODE_FIELD(initPlan);
118 COPY_BITMAPSET_FIELD(extParam);
119 COPY_BITMAPSET_FIELD(allParam);
126 _copyPlan(const Plan *from)
128 Plan *newnode = makeNode(Plan);
131 * copy node superclass fields
133 CopyPlanFields(from, newnode);
143 _copyResult(const Result *from)
145 Result *newnode = makeNode(Result);
148 * copy node superclass fields
150 CopyPlanFields((const Plan *) from, (Plan *) newnode);
153 * copy remainder of node
155 COPY_NODE_FIELD(resconstantqual);
164 _copyModifyTable(const ModifyTable *from)
166 ModifyTable *newnode = makeNode(ModifyTable);
169 * copy node superclass fields
171 CopyPlanFields((const Plan *) from, (Plan *) newnode);
174 * copy remainder of node
176 COPY_SCALAR_FIELD(operation);
177 COPY_SCALAR_FIELD(canSetTag);
178 COPY_NODE_FIELD(resultRelations);
179 COPY_SCALAR_FIELD(resultRelIndex);
180 COPY_NODE_FIELD(plans);
181 COPY_NODE_FIELD(returningLists);
182 COPY_NODE_FIELD(rowMarks);
183 COPY_SCALAR_FIELD(epqParam);
192 _copyAppend(const Append *from)
194 Append *newnode = makeNode(Append);
197 * copy node superclass fields
199 CopyPlanFields((const Plan *) from, (Plan *) newnode);
202 * copy remainder of node
204 COPY_NODE_FIELD(appendplans);
213 _copyMergeAppend(const MergeAppend *from)
215 MergeAppend *newnode = makeNode(MergeAppend);
218 * copy node superclass fields
220 CopyPlanFields((const Plan *) from, (Plan *) newnode);
223 * copy remainder of node
225 COPY_NODE_FIELD(mergeplans);
226 COPY_SCALAR_FIELD(numCols);
227 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
228 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
229 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
230 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
236 * _copyRecursiveUnion
238 static RecursiveUnion *
239 _copyRecursiveUnion(const RecursiveUnion *from)
241 RecursiveUnion *newnode = makeNode(RecursiveUnion);
244 * copy node superclass fields
246 CopyPlanFields((const Plan *) from, (Plan *) newnode);
249 * copy remainder of node
251 COPY_SCALAR_FIELD(wtParam);
252 COPY_SCALAR_FIELD(numCols);
253 if (from->numCols > 0)
255 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
256 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
258 COPY_SCALAR_FIELD(numGroups);
267 _copyBitmapAnd(const BitmapAnd *from)
269 BitmapAnd *newnode = makeNode(BitmapAnd);
272 * copy node superclass fields
274 CopyPlanFields((const Plan *) from, (Plan *) newnode);
277 * copy remainder of node
279 COPY_NODE_FIELD(bitmapplans);
288 _copyBitmapOr(const BitmapOr *from)
290 BitmapOr *newnode = makeNode(BitmapOr);
293 * copy node superclass fields
295 CopyPlanFields((const Plan *) from, (Plan *) newnode);
298 * copy remainder of node
300 COPY_NODE_FIELD(bitmapplans);
309 * This function copies the fields of the Scan node. It is used by
310 * all the copy functions for classes which inherit from Scan.
313 CopyScanFields(const Scan *from, Scan *newnode)
315 CopyPlanFields((const Plan *) from, (Plan *) newnode);
317 COPY_SCALAR_FIELD(scanrelid);
324 _copyScan(const Scan *from)
326 Scan *newnode = makeNode(Scan);
329 * copy node superclass fields
331 CopyScanFields((const Scan *) from, (Scan *) newnode);
340 _copySeqScan(const SeqScan *from)
342 SeqScan *newnode = makeNode(SeqScan);
345 * copy node superclass fields
347 CopyScanFields((const Scan *) from, (Scan *) newnode);
356 _copyIndexScan(const IndexScan *from)
358 IndexScan *newnode = makeNode(IndexScan);
361 * copy node superclass fields
363 CopyScanFields((const Scan *) from, (Scan *) newnode);
366 * copy remainder of node
368 COPY_SCALAR_FIELD(indexid);
369 COPY_NODE_FIELD(indexqual);
370 COPY_NODE_FIELD(indexqualorig);
371 COPY_NODE_FIELD(indexorderby);
372 COPY_NODE_FIELD(indexorderbyorig);
373 COPY_SCALAR_FIELD(indexorderdir);
381 static IndexOnlyScan *
382 _copyIndexOnlyScan(const IndexOnlyScan *from)
384 IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
387 * copy node superclass fields
389 CopyScanFields((const Scan *) from, (Scan *) newnode);
392 * copy remainder of node
394 COPY_SCALAR_FIELD(indexid);
395 COPY_NODE_FIELD(indexqual);
396 COPY_NODE_FIELD(indexorderby);
397 COPY_NODE_FIELD(indextlist);
398 COPY_SCALAR_FIELD(indexorderdir);
404 * _copyBitmapIndexScan
406 static BitmapIndexScan *
407 _copyBitmapIndexScan(const BitmapIndexScan *from)
409 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
412 * copy node superclass fields
414 CopyScanFields((const Scan *) from, (Scan *) newnode);
417 * copy remainder of node
419 COPY_SCALAR_FIELD(indexid);
420 COPY_NODE_FIELD(indexqual);
421 COPY_NODE_FIELD(indexqualorig);
427 * _copyBitmapHeapScan
429 static BitmapHeapScan *
430 _copyBitmapHeapScan(const BitmapHeapScan *from)
432 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
435 * copy node superclass fields
437 CopyScanFields((const Scan *) from, (Scan *) newnode);
440 * copy remainder of node
442 COPY_NODE_FIELD(bitmapqualorig);
451 _copyTidScan(const TidScan *from)
453 TidScan *newnode = makeNode(TidScan);
456 * copy node superclass fields
458 CopyScanFields((const Scan *) from, (Scan *) newnode);
461 * copy remainder of node
463 COPY_NODE_FIELD(tidquals);
471 static SubqueryScan *
472 _copySubqueryScan(const SubqueryScan *from)
474 SubqueryScan *newnode = makeNode(SubqueryScan);
477 * copy node superclass fields
479 CopyScanFields((const Scan *) from, (Scan *) newnode);
482 * copy remainder of node
484 COPY_NODE_FIELD(subplan);
492 static FunctionScan *
493 _copyFunctionScan(const FunctionScan *from)
495 FunctionScan *newnode = makeNode(FunctionScan);
498 * copy node superclass fields
500 CopyScanFields((const Scan *) from, (Scan *) newnode);
503 * copy remainder of node
505 COPY_NODE_FIELD(funcexpr);
506 COPY_NODE_FIELD(funccolnames);
507 COPY_NODE_FIELD(funccoltypes);
508 COPY_NODE_FIELD(funccoltypmods);
509 COPY_NODE_FIELD(funccolcollations);
518 _copyValuesScan(const ValuesScan *from)
520 ValuesScan *newnode = makeNode(ValuesScan);
523 * copy node superclass fields
525 CopyScanFields((const Scan *) from, (Scan *) newnode);
528 * copy remainder of node
530 COPY_NODE_FIELD(values_lists);
539 _copyCteScan(const CteScan *from)
541 CteScan *newnode = makeNode(CteScan);
544 * copy node superclass fields
546 CopyScanFields((const Scan *) from, (Scan *) newnode);
549 * copy remainder of node
551 COPY_SCALAR_FIELD(ctePlanId);
552 COPY_SCALAR_FIELD(cteParam);
560 static WorkTableScan *
561 _copyWorkTableScan(const WorkTableScan *from)
563 WorkTableScan *newnode = makeNode(WorkTableScan);
566 * copy node superclass fields
568 CopyScanFields((const Scan *) from, (Scan *) newnode);
571 * copy remainder of node
573 COPY_SCALAR_FIELD(wtParam);
582 _copyForeignScan(const ForeignScan *from)
584 ForeignScan *newnode = makeNode(ForeignScan);
587 * copy node superclass fields
589 CopyScanFields((const Scan *) from, (Scan *) newnode);
592 * copy remainder of node
594 COPY_NODE_FIELD(fdw_exprs);
595 COPY_NODE_FIELD(fdw_private);
596 COPY_SCALAR_FIELD(fsSystemCol);
604 * This function copies the fields of the Join node. It is used by
605 * all the copy functions for classes which inherit from Join.
608 CopyJoinFields(const Join *from, Join *newnode)
610 CopyPlanFields((const Plan *) from, (Plan *) newnode);
612 COPY_SCALAR_FIELD(jointype);
613 COPY_NODE_FIELD(joinqual);
621 _copyJoin(const Join *from)
623 Join *newnode = makeNode(Join);
626 * copy node superclass fields
628 CopyJoinFields(from, newnode);
638 _copyNestLoop(const NestLoop *from)
640 NestLoop *newnode = makeNode(NestLoop);
643 * copy node superclass fields
645 CopyJoinFields((const Join *) from, (Join *) newnode);
648 * copy remainder of node
650 COPY_NODE_FIELD(nestParams);
660 _copyMergeJoin(const MergeJoin *from)
662 MergeJoin *newnode = makeNode(MergeJoin);
666 * copy node superclass fields
668 CopyJoinFields((const Join *) from, (Join *) newnode);
671 * copy remainder of node
673 COPY_NODE_FIELD(mergeclauses);
674 numCols = list_length(from->mergeclauses);
677 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
678 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
679 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
680 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
690 _copyHashJoin(const HashJoin *from)
692 HashJoin *newnode = makeNode(HashJoin);
695 * copy node superclass fields
697 CopyJoinFields((const Join *) from, (Join *) newnode);
700 * copy remainder of node
702 COPY_NODE_FIELD(hashclauses);
712 _copyMaterial(const Material *from)
714 Material *newnode = makeNode(Material);
717 * copy node superclass fields
719 CopyPlanFields((const Plan *) from, (Plan *) newnode);
729 _copySort(const Sort *from)
731 Sort *newnode = makeNode(Sort);
734 * copy node superclass fields
736 CopyPlanFields((const Plan *) from, (Plan *) newnode);
738 COPY_SCALAR_FIELD(numCols);
739 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
740 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
741 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
742 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
752 _copyGroup(const Group *from)
754 Group *newnode = makeNode(Group);
756 CopyPlanFields((const Plan *) from, (Plan *) newnode);
758 COPY_SCALAR_FIELD(numCols);
759 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
760 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
769 _copyAgg(const Agg *from)
771 Agg *newnode = makeNode(Agg);
773 CopyPlanFields((const Plan *) from, (Plan *) newnode);
775 COPY_SCALAR_FIELD(aggstrategy);
776 COPY_SCALAR_FIELD(numCols);
777 if (from->numCols > 0)
779 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
780 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
782 COPY_SCALAR_FIELD(numGroups);
791 _copyWindowAgg(const WindowAgg *from)
793 WindowAgg *newnode = makeNode(WindowAgg);
795 CopyPlanFields((const Plan *) from, (Plan *) newnode);
797 COPY_SCALAR_FIELD(winref);
798 COPY_SCALAR_FIELD(partNumCols);
799 if (from->partNumCols > 0)
801 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
802 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
804 COPY_SCALAR_FIELD(ordNumCols);
805 if (from->ordNumCols > 0)
807 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
808 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
810 COPY_SCALAR_FIELD(frameOptions);
811 COPY_NODE_FIELD(startOffset);
812 COPY_NODE_FIELD(endOffset);
821 _copyUnique(const Unique *from)
823 Unique *newnode = makeNode(Unique);
826 * copy node superclass fields
828 CopyPlanFields((const Plan *) from, (Plan *) newnode);
831 * copy remainder of node
833 COPY_SCALAR_FIELD(numCols);
834 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
835 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
844 _copyHash(const Hash *from)
846 Hash *newnode = makeNode(Hash);
849 * copy node superclass fields
851 CopyPlanFields((const Plan *) from, (Plan *) newnode);
854 * copy remainder of node
856 COPY_SCALAR_FIELD(skewTable);
857 COPY_SCALAR_FIELD(skewColumn);
858 COPY_SCALAR_FIELD(skewInherit);
859 COPY_SCALAR_FIELD(skewColType);
860 COPY_SCALAR_FIELD(skewColTypmod);
869 _copySetOp(const SetOp *from)
871 SetOp *newnode = makeNode(SetOp);
874 * copy node superclass fields
876 CopyPlanFields((const Plan *) from, (Plan *) newnode);
879 * copy remainder of node
881 COPY_SCALAR_FIELD(cmd);
882 COPY_SCALAR_FIELD(strategy);
883 COPY_SCALAR_FIELD(numCols);
884 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
885 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
886 COPY_SCALAR_FIELD(flagColIdx);
887 COPY_SCALAR_FIELD(firstFlag);
888 COPY_SCALAR_FIELD(numGroups);
897 _copyLockRows(const LockRows *from)
899 LockRows *newnode = makeNode(LockRows);
902 * copy node superclass fields
904 CopyPlanFields((const Plan *) from, (Plan *) newnode);
907 * copy remainder of node
909 COPY_NODE_FIELD(rowMarks);
910 COPY_SCALAR_FIELD(epqParam);
919 _copyLimit(const Limit *from)
921 Limit *newnode = makeNode(Limit);
924 * copy node superclass fields
926 CopyPlanFields((const Plan *) from, (Plan *) newnode);
929 * copy remainder of node
931 COPY_NODE_FIELD(limitOffset);
932 COPY_NODE_FIELD(limitCount);
940 static NestLoopParam *
941 _copyNestLoopParam(const NestLoopParam *from)
943 NestLoopParam *newnode = makeNode(NestLoopParam);
945 COPY_SCALAR_FIELD(paramno);
946 COPY_NODE_FIELD(paramval);
955 _copyPlanRowMark(const PlanRowMark *from)
957 PlanRowMark *newnode = makeNode(PlanRowMark);
959 COPY_SCALAR_FIELD(rti);
960 COPY_SCALAR_FIELD(prti);
961 COPY_SCALAR_FIELD(rowmarkId);
962 COPY_SCALAR_FIELD(markType);
963 COPY_SCALAR_FIELD(noWait);
964 COPY_SCALAR_FIELD(isParent);
972 static PlanInvalItem *
973 _copyPlanInvalItem(const PlanInvalItem *from)
975 PlanInvalItem *newnode = makeNode(PlanInvalItem);
977 COPY_SCALAR_FIELD(cacheId);
978 COPY_SCALAR_FIELD(hashValue);
983 /* ****************************************************************
984 * primnodes.h copy functions
985 * ****************************************************************
992 _copyAlias(const Alias *from)
994 Alias *newnode = makeNode(Alias);
996 COPY_STRING_FIELD(aliasname);
997 COPY_NODE_FIELD(colnames);
1006 _copyRangeVar(const RangeVar *from)
1008 RangeVar *newnode = makeNode(RangeVar);
1010 COPY_STRING_FIELD(catalogname);
1011 COPY_STRING_FIELD(schemaname);
1012 COPY_STRING_FIELD(relname);
1013 COPY_SCALAR_FIELD(inhOpt);
1014 COPY_SCALAR_FIELD(relpersistence);
1015 COPY_NODE_FIELD(alias);
1016 COPY_LOCATION_FIELD(location);
1025 _copyIntoClause(const IntoClause *from)
1027 IntoClause *newnode = makeNode(IntoClause);
1029 COPY_NODE_FIELD(rel);
1030 COPY_NODE_FIELD(colNames);
1031 COPY_NODE_FIELD(options);
1032 COPY_SCALAR_FIELD(onCommit);
1033 COPY_STRING_FIELD(tableSpaceName);
1034 COPY_SCALAR_FIELD(skipData);
1040 * We don't need a _copyExpr because Expr is an abstract supertype which
1041 * should never actually get instantiated. Also, since it has no common
1042 * fields except NodeTag, there's no need for a helper routine to factor
1043 * out copying the common fields...
1050 _copyVar(const Var *from)
1052 Var *newnode = makeNode(Var);
1054 COPY_SCALAR_FIELD(varno);
1055 COPY_SCALAR_FIELD(varattno);
1056 COPY_SCALAR_FIELD(vartype);
1057 COPY_SCALAR_FIELD(vartypmod);
1058 COPY_SCALAR_FIELD(varcollid);
1059 COPY_SCALAR_FIELD(varlevelsup);
1060 COPY_SCALAR_FIELD(varnoold);
1061 COPY_SCALAR_FIELD(varoattno);
1062 COPY_LOCATION_FIELD(location);
1071 _copyConst(const Const *from)
1073 Const *newnode = makeNode(Const);
1075 COPY_SCALAR_FIELD(consttype);
1076 COPY_SCALAR_FIELD(consttypmod);
1077 COPY_SCALAR_FIELD(constcollid);
1078 COPY_SCALAR_FIELD(constlen);
1080 if (from->constbyval || from->constisnull)
1083 * passed by value so just copy the datum. Also, don't try to copy
1084 * struct when value is null!
1086 newnode->constvalue = from->constvalue;
1091 * passed by reference. We need a palloc'd copy.
1093 newnode->constvalue = datumCopy(from->constvalue,
1098 COPY_SCALAR_FIELD(constisnull);
1099 COPY_SCALAR_FIELD(constbyval);
1100 COPY_LOCATION_FIELD(location);
1109 _copyParam(const Param *from)
1111 Param *newnode = makeNode(Param);
1113 COPY_SCALAR_FIELD(paramkind);
1114 COPY_SCALAR_FIELD(paramid);
1115 COPY_SCALAR_FIELD(paramtype);
1116 COPY_SCALAR_FIELD(paramtypmod);
1117 COPY_SCALAR_FIELD(paramcollid);
1118 COPY_LOCATION_FIELD(location);
1127 _copyAggref(const Aggref *from)
1129 Aggref *newnode = makeNode(Aggref);
1131 COPY_SCALAR_FIELD(aggfnoid);
1132 COPY_SCALAR_FIELD(aggtype);
1133 COPY_SCALAR_FIELD(aggcollid);
1134 COPY_SCALAR_FIELD(inputcollid);
1135 COPY_NODE_FIELD(args);
1136 COPY_NODE_FIELD(aggorder);
1137 COPY_NODE_FIELD(aggdistinct);
1138 COPY_SCALAR_FIELD(aggstar);
1139 COPY_SCALAR_FIELD(agglevelsup);
1140 COPY_LOCATION_FIELD(location);
1149 _copyWindowFunc(const WindowFunc *from)
1151 WindowFunc *newnode = makeNode(WindowFunc);
1153 COPY_SCALAR_FIELD(winfnoid);
1154 COPY_SCALAR_FIELD(wintype);
1155 COPY_SCALAR_FIELD(wincollid);
1156 COPY_SCALAR_FIELD(inputcollid);
1157 COPY_NODE_FIELD(args);
1158 COPY_SCALAR_FIELD(winref);
1159 COPY_SCALAR_FIELD(winstar);
1160 COPY_SCALAR_FIELD(winagg);
1161 COPY_LOCATION_FIELD(location);
1170 _copyArrayRef(const ArrayRef *from)
1172 ArrayRef *newnode = makeNode(ArrayRef);
1174 COPY_SCALAR_FIELD(refarraytype);
1175 COPY_SCALAR_FIELD(refelemtype);
1176 COPY_SCALAR_FIELD(reftypmod);
1177 COPY_SCALAR_FIELD(refcollid);
1178 COPY_NODE_FIELD(refupperindexpr);
1179 COPY_NODE_FIELD(reflowerindexpr);
1180 COPY_NODE_FIELD(refexpr);
1181 COPY_NODE_FIELD(refassgnexpr);
1190 _copyFuncExpr(const FuncExpr *from)
1192 FuncExpr *newnode = makeNode(FuncExpr);
1194 COPY_SCALAR_FIELD(funcid);
1195 COPY_SCALAR_FIELD(funcresulttype);
1196 COPY_SCALAR_FIELD(funcretset);
1197 COPY_SCALAR_FIELD(funcformat);
1198 COPY_SCALAR_FIELD(funccollid);
1199 COPY_SCALAR_FIELD(inputcollid);
1200 COPY_NODE_FIELD(args);
1201 COPY_LOCATION_FIELD(location);
1207 * _copyNamedArgExpr *
1209 static NamedArgExpr *
1210 _copyNamedArgExpr(const NamedArgExpr *from)
1212 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1214 COPY_NODE_FIELD(arg);
1215 COPY_STRING_FIELD(name);
1216 COPY_SCALAR_FIELD(argnumber);
1217 COPY_LOCATION_FIELD(location);
1226 _copyOpExpr(const OpExpr *from)
1228 OpExpr *newnode = makeNode(OpExpr);
1230 COPY_SCALAR_FIELD(opno);
1231 COPY_SCALAR_FIELD(opfuncid);
1232 COPY_SCALAR_FIELD(opresulttype);
1233 COPY_SCALAR_FIELD(opretset);
1234 COPY_SCALAR_FIELD(opcollid);
1235 COPY_SCALAR_FIELD(inputcollid);
1236 COPY_NODE_FIELD(args);
1237 COPY_LOCATION_FIELD(location);
1243 * _copyDistinctExpr (same as OpExpr)
1245 static DistinctExpr *
1246 _copyDistinctExpr(const DistinctExpr *from)
1248 DistinctExpr *newnode = makeNode(DistinctExpr);
1250 COPY_SCALAR_FIELD(opno);
1251 COPY_SCALAR_FIELD(opfuncid);
1252 COPY_SCALAR_FIELD(opresulttype);
1253 COPY_SCALAR_FIELD(opretset);
1254 COPY_SCALAR_FIELD(opcollid);
1255 COPY_SCALAR_FIELD(inputcollid);
1256 COPY_NODE_FIELD(args);
1257 COPY_LOCATION_FIELD(location);
1263 * _copyNullIfExpr (same as OpExpr)
1266 _copyNullIfExpr(const NullIfExpr *from)
1268 NullIfExpr *newnode = makeNode(NullIfExpr);
1270 COPY_SCALAR_FIELD(opno);
1271 COPY_SCALAR_FIELD(opfuncid);
1272 COPY_SCALAR_FIELD(opresulttype);
1273 COPY_SCALAR_FIELD(opretset);
1274 COPY_SCALAR_FIELD(opcollid);
1275 COPY_SCALAR_FIELD(inputcollid);
1276 COPY_NODE_FIELD(args);
1277 COPY_LOCATION_FIELD(location);
1283 * _copyScalarArrayOpExpr
1285 static ScalarArrayOpExpr *
1286 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
1288 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1290 COPY_SCALAR_FIELD(opno);
1291 COPY_SCALAR_FIELD(opfuncid);
1292 COPY_SCALAR_FIELD(useOr);
1293 COPY_SCALAR_FIELD(inputcollid);
1294 COPY_NODE_FIELD(args);
1295 COPY_LOCATION_FIELD(location);
1304 _copyBoolExpr(const BoolExpr *from)
1306 BoolExpr *newnode = makeNode(BoolExpr);
1308 COPY_SCALAR_FIELD(boolop);
1309 COPY_NODE_FIELD(args);
1310 COPY_LOCATION_FIELD(location);
1319 _copySubLink(const SubLink *from)
1321 SubLink *newnode = makeNode(SubLink);
1323 COPY_SCALAR_FIELD(subLinkType);
1324 COPY_NODE_FIELD(testexpr);
1325 COPY_NODE_FIELD(operName);
1326 COPY_NODE_FIELD(subselect);
1327 COPY_LOCATION_FIELD(location);
1336 _copySubPlan(const SubPlan *from)
1338 SubPlan *newnode = makeNode(SubPlan);
1340 COPY_SCALAR_FIELD(subLinkType);
1341 COPY_NODE_FIELD(testexpr);
1342 COPY_NODE_FIELD(paramIds);
1343 COPY_SCALAR_FIELD(plan_id);
1344 COPY_STRING_FIELD(plan_name);
1345 COPY_SCALAR_FIELD(firstColType);
1346 COPY_SCALAR_FIELD(firstColTypmod);
1347 COPY_SCALAR_FIELD(firstColCollation);
1348 COPY_SCALAR_FIELD(useHashTable);
1349 COPY_SCALAR_FIELD(unknownEqFalse);
1350 COPY_NODE_FIELD(setParam);
1351 COPY_NODE_FIELD(parParam);
1352 COPY_NODE_FIELD(args);
1353 COPY_SCALAR_FIELD(startup_cost);
1354 COPY_SCALAR_FIELD(per_call_cost);
1360 * _copyAlternativeSubPlan
1362 static AlternativeSubPlan *
1363 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
1365 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1367 COPY_NODE_FIELD(subplans);
1375 static FieldSelect *
1376 _copyFieldSelect(const FieldSelect *from)
1378 FieldSelect *newnode = makeNode(FieldSelect);
1380 COPY_NODE_FIELD(arg);
1381 COPY_SCALAR_FIELD(fieldnum);
1382 COPY_SCALAR_FIELD(resulttype);
1383 COPY_SCALAR_FIELD(resulttypmod);
1384 COPY_SCALAR_FIELD(resultcollid);
1393 _copyFieldStore(const FieldStore *from)
1395 FieldStore *newnode = makeNode(FieldStore);
1397 COPY_NODE_FIELD(arg);
1398 COPY_NODE_FIELD(newvals);
1399 COPY_NODE_FIELD(fieldnums);
1400 COPY_SCALAR_FIELD(resulttype);
1408 static RelabelType *
1409 _copyRelabelType(const RelabelType *from)
1411 RelabelType *newnode = makeNode(RelabelType);
1413 COPY_NODE_FIELD(arg);
1414 COPY_SCALAR_FIELD(resulttype);
1415 COPY_SCALAR_FIELD(resulttypmod);
1416 COPY_SCALAR_FIELD(resultcollid);
1417 COPY_SCALAR_FIELD(relabelformat);
1418 COPY_LOCATION_FIELD(location);
1426 static CoerceViaIO *
1427 _copyCoerceViaIO(const CoerceViaIO *from)
1429 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1431 COPY_NODE_FIELD(arg);
1432 COPY_SCALAR_FIELD(resulttype);
1433 COPY_SCALAR_FIELD(resultcollid);
1434 COPY_SCALAR_FIELD(coerceformat);
1435 COPY_LOCATION_FIELD(location);
1441 * _copyArrayCoerceExpr
1443 static ArrayCoerceExpr *
1444 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
1446 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1448 COPY_NODE_FIELD(arg);
1449 COPY_SCALAR_FIELD(elemfuncid);
1450 COPY_SCALAR_FIELD(resulttype);
1451 COPY_SCALAR_FIELD(resulttypmod);
1452 COPY_SCALAR_FIELD(resultcollid);
1453 COPY_SCALAR_FIELD(isExplicit);
1454 COPY_SCALAR_FIELD(coerceformat);
1455 COPY_LOCATION_FIELD(location);
1461 * _copyConvertRowtypeExpr
1463 static ConvertRowtypeExpr *
1464 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
1466 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1468 COPY_NODE_FIELD(arg);
1469 COPY_SCALAR_FIELD(resulttype);
1470 COPY_SCALAR_FIELD(convertformat);
1471 COPY_LOCATION_FIELD(location);
1479 static CollateExpr *
1480 _copyCollateExpr(const CollateExpr *from)
1482 CollateExpr *newnode = makeNode(CollateExpr);
1484 COPY_NODE_FIELD(arg);
1485 COPY_SCALAR_FIELD(collOid);
1486 COPY_LOCATION_FIELD(location);
1495 _copyCaseExpr(const CaseExpr *from)
1497 CaseExpr *newnode = makeNode(CaseExpr);
1499 COPY_SCALAR_FIELD(casetype);
1500 COPY_SCALAR_FIELD(casecollid);
1501 COPY_NODE_FIELD(arg);
1502 COPY_NODE_FIELD(args);
1503 COPY_NODE_FIELD(defresult);
1504 COPY_LOCATION_FIELD(location);
1513 _copyCaseWhen(const CaseWhen *from)
1515 CaseWhen *newnode = makeNode(CaseWhen);
1517 COPY_NODE_FIELD(expr);
1518 COPY_NODE_FIELD(result);
1519 COPY_LOCATION_FIELD(location);
1527 static CaseTestExpr *
1528 _copyCaseTestExpr(const CaseTestExpr *from)
1530 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1532 COPY_SCALAR_FIELD(typeId);
1533 COPY_SCALAR_FIELD(typeMod);
1534 COPY_SCALAR_FIELD(collation);
1543 _copyArrayExpr(const ArrayExpr *from)
1545 ArrayExpr *newnode = makeNode(ArrayExpr);
1547 COPY_SCALAR_FIELD(array_typeid);
1548 COPY_SCALAR_FIELD(array_collid);
1549 COPY_SCALAR_FIELD(element_typeid);
1550 COPY_NODE_FIELD(elements);
1551 COPY_SCALAR_FIELD(multidims);
1552 COPY_LOCATION_FIELD(location);
1561 _copyRowExpr(const RowExpr *from)
1563 RowExpr *newnode = makeNode(RowExpr);
1565 COPY_NODE_FIELD(args);
1566 COPY_SCALAR_FIELD(row_typeid);
1567 COPY_SCALAR_FIELD(row_format);
1568 COPY_NODE_FIELD(colnames);
1569 COPY_LOCATION_FIELD(location);
1575 * _copyRowCompareExpr
1577 static RowCompareExpr *
1578 _copyRowCompareExpr(const RowCompareExpr *from)
1580 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1582 COPY_SCALAR_FIELD(rctype);
1583 COPY_NODE_FIELD(opnos);
1584 COPY_NODE_FIELD(opfamilies);
1585 COPY_NODE_FIELD(inputcollids);
1586 COPY_NODE_FIELD(largs);
1587 COPY_NODE_FIELD(rargs);
1595 static CoalesceExpr *
1596 _copyCoalesceExpr(const CoalesceExpr *from)
1598 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1600 COPY_SCALAR_FIELD(coalescetype);
1601 COPY_SCALAR_FIELD(coalescecollid);
1602 COPY_NODE_FIELD(args);
1603 COPY_LOCATION_FIELD(location);
1612 _copyMinMaxExpr(const MinMaxExpr *from)
1614 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1616 COPY_SCALAR_FIELD(minmaxtype);
1617 COPY_SCALAR_FIELD(minmaxcollid);
1618 COPY_SCALAR_FIELD(inputcollid);
1619 COPY_SCALAR_FIELD(op);
1620 COPY_NODE_FIELD(args);
1621 COPY_LOCATION_FIELD(location);
1630 _copyXmlExpr(const XmlExpr *from)
1632 XmlExpr *newnode = makeNode(XmlExpr);
1634 COPY_SCALAR_FIELD(op);
1635 COPY_STRING_FIELD(name);
1636 COPY_NODE_FIELD(named_args);
1637 COPY_NODE_FIELD(arg_names);
1638 COPY_NODE_FIELD(args);
1639 COPY_SCALAR_FIELD(xmloption);
1640 COPY_SCALAR_FIELD(type);
1641 COPY_SCALAR_FIELD(typmod);
1642 COPY_LOCATION_FIELD(location);
1651 _copyNullTest(const NullTest *from)
1653 NullTest *newnode = makeNode(NullTest);
1655 COPY_NODE_FIELD(arg);
1656 COPY_SCALAR_FIELD(nulltesttype);
1657 COPY_SCALAR_FIELD(argisrow);
1665 static BooleanTest *
1666 _copyBooleanTest(const BooleanTest *from)
1668 BooleanTest *newnode = makeNode(BooleanTest);
1670 COPY_NODE_FIELD(arg);
1671 COPY_SCALAR_FIELD(booltesttype);
1677 * _copyCoerceToDomain
1679 static CoerceToDomain *
1680 _copyCoerceToDomain(const CoerceToDomain *from)
1682 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1684 COPY_NODE_FIELD(arg);
1685 COPY_SCALAR_FIELD(resulttype);
1686 COPY_SCALAR_FIELD(resulttypmod);
1687 COPY_SCALAR_FIELD(resultcollid);
1688 COPY_SCALAR_FIELD(coercionformat);
1689 COPY_LOCATION_FIELD(location);
1695 * _copyCoerceToDomainValue
1697 static CoerceToDomainValue *
1698 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
1700 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1702 COPY_SCALAR_FIELD(typeId);
1703 COPY_SCALAR_FIELD(typeMod);
1704 COPY_SCALAR_FIELD(collation);
1705 COPY_LOCATION_FIELD(location);
1713 static SetToDefault *
1714 _copySetToDefault(const SetToDefault *from)
1716 SetToDefault *newnode = makeNode(SetToDefault);
1718 COPY_SCALAR_FIELD(typeId);
1719 COPY_SCALAR_FIELD(typeMod);
1720 COPY_SCALAR_FIELD(collation);
1721 COPY_LOCATION_FIELD(location);
1727 * _copyCurrentOfExpr
1729 static CurrentOfExpr *
1730 _copyCurrentOfExpr(const CurrentOfExpr *from)
1732 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1734 COPY_SCALAR_FIELD(cvarno);
1735 COPY_STRING_FIELD(cursor_name);
1736 COPY_SCALAR_FIELD(cursor_param);
1744 static TargetEntry *
1745 _copyTargetEntry(const TargetEntry *from)
1747 TargetEntry *newnode = makeNode(TargetEntry);
1749 COPY_NODE_FIELD(expr);
1750 COPY_SCALAR_FIELD(resno);
1751 COPY_STRING_FIELD(resname);
1752 COPY_SCALAR_FIELD(ressortgroupref);
1753 COPY_SCALAR_FIELD(resorigtbl);
1754 COPY_SCALAR_FIELD(resorigcol);
1755 COPY_SCALAR_FIELD(resjunk);
1763 static RangeTblRef *
1764 _copyRangeTblRef(const RangeTblRef *from)
1766 RangeTblRef *newnode = makeNode(RangeTblRef);
1768 COPY_SCALAR_FIELD(rtindex);
1777 _copyJoinExpr(const JoinExpr *from)
1779 JoinExpr *newnode = makeNode(JoinExpr);
1781 COPY_SCALAR_FIELD(jointype);
1782 COPY_SCALAR_FIELD(isNatural);
1783 COPY_NODE_FIELD(larg);
1784 COPY_NODE_FIELD(rarg);
1785 COPY_NODE_FIELD(usingClause);
1786 COPY_NODE_FIELD(quals);
1787 COPY_NODE_FIELD(alias);
1788 COPY_SCALAR_FIELD(rtindex);
1797 _copyFromExpr(const FromExpr *from)
1799 FromExpr *newnode = makeNode(FromExpr);
1801 COPY_NODE_FIELD(fromlist);
1802 COPY_NODE_FIELD(quals);
1807 /* ****************************************************************
1808 * relation.h copy functions
1810 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1811 * There are some subsidiary structs that are useful to copy, though.
1812 * ****************************************************************
1819 _copyPathKey(const PathKey *from)
1821 PathKey *newnode = makeNode(PathKey);
1823 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1824 COPY_SCALAR_FIELD(pk_eclass);
1825 COPY_SCALAR_FIELD(pk_opfamily);
1826 COPY_SCALAR_FIELD(pk_strategy);
1827 COPY_SCALAR_FIELD(pk_nulls_first);
1835 static RestrictInfo *
1836 _copyRestrictInfo(const RestrictInfo *from)
1838 RestrictInfo *newnode = makeNode(RestrictInfo);
1840 COPY_NODE_FIELD(clause);
1841 COPY_SCALAR_FIELD(is_pushed_down);
1842 COPY_SCALAR_FIELD(outerjoin_delayed);
1843 COPY_SCALAR_FIELD(can_join);
1844 COPY_SCALAR_FIELD(pseudoconstant);
1845 COPY_BITMAPSET_FIELD(clause_relids);
1846 COPY_BITMAPSET_FIELD(required_relids);
1847 COPY_BITMAPSET_FIELD(outer_relids);
1848 COPY_BITMAPSET_FIELD(nullable_relids);
1849 COPY_BITMAPSET_FIELD(left_relids);
1850 COPY_BITMAPSET_FIELD(right_relids);
1851 COPY_NODE_FIELD(orclause);
1852 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1853 COPY_SCALAR_FIELD(parent_ec);
1854 COPY_SCALAR_FIELD(eval_cost);
1855 COPY_SCALAR_FIELD(norm_selec);
1856 COPY_SCALAR_FIELD(outer_selec);
1857 COPY_NODE_FIELD(mergeopfamilies);
1858 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1859 COPY_SCALAR_FIELD(left_ec);
1860 COPY_SCALAR_FIELD(right_ec);
1861 COPY_SCALAR_FIELD(left_em);
1862 COPY_SCALAR_FIELD(right_em);
1863 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1864 newnode->scansel_cache = NIL;
1865 COPY_SCALAR_FIELD(outer_is_left);
1866 COPY_SCALAR_FIELD(hashjoinoperator);
1867 COPY_SCALAR_FIELD(left_bucketsize);
1868 COPY_SCALAR_FIELD(right_bucketsize);
1874 * _copyPlaceHolderVar
1876 static PlaceHolderVar *
1877 _copyPlaceHolderVar(const PlaceHolderVar *from)
1879 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
1881 COPY_NODE_FIELD(phexpr);
1882 COPY_BITMAPSET_FIELD(phrels);
1883 COPY_SCALAR_FIELD(phid);
1884 COPY_SCALAR_FIELD(phlevelsup);
1890 * _copySpecialJoinInfo
1892 static SpecialJoinInfo *
1893 _copySpecialJoinInfo(const SpecialJoinInfo *from)
1895 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
1897 COPY_BITMAPSET_FIELD(min_lefthand);
1898 COPY_BITMAPSET_FIELD(min_righthand);
1899 COPY_BITMAPSET_FIELD(syn_lefthand);
1900 COPY_BITMAPSET_FIELD(syn_righthand);
1901 COPY_SCALAR_FIELD(jointype);
1902 COPY_SCALAR_FIELD(lhs_strict);
1903 COPY_SCALAR_FIELD(delay_upper_joins);
1904 COPY_NODE_FIELD(join_quals);
1910 * _copyLateralJoinInfo
1912 static LateralJoinInfo *
1913 _copyLateralJoinInfo(const LateralJoinInfo *from)
1915 LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
1917 COPY_SCALAR_FIELD(lateral_rhs);
1918 COPY_BITMAPSET_FIELD(lateral_lhs);
1924 * _copyAppendRelInfo
1926 static AppendRelInfo *
1927 _copyAppendRelInfo(const AppendRelInfo *from)
1929 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1931 COPY_SCALAR_FIELD(parent_relid);
1932 COPY_SCALAR_FIELD(child_relid);
1933 COPY_SCALAR_FIELD(parent_reltype);
1934 COPY_SCALAR_FIELD(child_reltype);
1935 COPY_NODE_FIELD(translated_vars);
1936 COPY_SCALAR_FIELD(parent_reloid);
1942 * _copyPlaceHolderInfo
1944 static PlaceHolderInfo *
1945 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
1947 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
1949 COPY_SCALAR_FIELD(phid);
1950 COPY_NODE_FIELD(ph_var);
1951 COPY_BITMAPSET_FIELD(ph_eval_at);
1952 COPY_BITMAPSET_FIELD(ph_needed);
1953 COPY_BITMAPSET_FIELD(ph_may_need);
1954 COPY_SCALAR_FIELD(ph_width);
1959 /* ****************************************************************
1960 * parsenodes.h copy functions
1961 * ****************************************************************
1964 static RangeTblEntry *
1965 _copyRangeTblEntry(const RangeTblEntry *from)
1967 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1969 COPY_SCALAR_FIELD(rtekind);
1970 COPY_SCALAR_FIELD(relid);
1971 COPY_SCALAR_FIELD(relkind);
1972 COPY_NODE_FIELD(subquery);
1973 COPY_SCALAR_FIELD(security_barrier);
1974 COPY_SCALAR_FIELD(jointype);
1975 COPY_NODE_FIELD(joinaliasvars);
1976 COPY_NODE_FIELD(funcexpr);
1977 COPY_NODE_FIELD(funccoltypes);
1978 COPY_NODE_FIELD(funccoltypmods);
1979 COPY_NODE_FIELD(funccolcollations);
1980 COPY_NODE_FIELD(values_lists);
1981 COPY_NODE_FIELD(values_collations);
1982 COPY_STRING_FIELD(ctename);
1983 COPY_SCALAR_FIELD(ctelevelsup);
1984 COPY_SCALAR_FIELD(self_reference);
1985 COPY_NODE_FIELD(ctecoltypes);
1986 COPY_NODE_FIELD(ctecoltypmods);
1987 COPY_NODE_FIELD(ctecolcollations);
1988 COPY_NODE_FIELD(alias);
1989 COPY_NODE_FIELD(eref);
1990 COPY_SCALAR_FIELD(lateral);
1991 COPY_SCALAR_FIELD(inh);
1992 COPY_SCALAR_FIELD(inFromCl);
1993 COPY_SCALAR_FIELD(requiredPerms);
1994 COPY_SCALAR_FIELD(checkAsUser);
1995 COPY_BITMAPSET_FIELD(selectedCols);
1996 COPY_BITMAPSET_FIELD(modifiedCols);
2001 static SortGroupClause *
2002 _copySortGroupClause(const SortGroupClause *from)
2004 SortGroupClause *newnode = makeNode(SortGroupClause);
2006 COPY_SCALAR_FIELD(tleSortGroupRef);
2007 COPY_SCALAR_FIELD(eqop);
2008 COPY_SCALAR_FIELD(sortop);
2009 COPY_SCALAR_FIELD(nulls_first);
2010 COPY_SCALAR_FIELD(hashable);
2015 static WindowClause *
2016 _copyWindowClause(const WindowClause *from)
2018 WindowClause *newnode = makeNode(WindowClause);
2020 COPY_STRING_FIELD(name);
2021 COPY_STRING_FIELD(refname);
2022 COPY_NODE_FIELD(partitionClause);
2023 COPY_NODE_FIELD(orderClause);
2024 COPY_SCALAR_FIELD(frameOptions);
2025 COPY_NODE_FIELD(startOffset);
2026 COPY_NODE_FIELD(endOffset);
2027 COPY_SCALAR_FIELD(winref);
2028 COPY_SCALAR_FIELD(copiedOrder);
2033 static RowMarkClause *
2034 _copyRowMarkClause(const RowMarkClause *from)
2036 RowMarkClause *newnode = makeNode(RowMarkClause);
2038 COPY_SCALAR_FIELD(rti);
2039 COPY_SCALAR_FIELD(forUpdate);
2040 COPY_SCALAR_FIELD(noWait);
2041 COPY_SCALAR_FIELD(pushedDown);
2047 _copyWithClause(const WithClause *from)
2049 WithClause *newnode = makeNode(WithClause);
2051 COPY_NODE_FIELD(ctes);
2052 COPY_SCALAR_FIELD(recursive);
2053 COPY_LOCATION_FIELD(location);
2058 static CommonTableExpr *
2059 _copyCommonTableExpr(const CommonTableExpr *from)
2061 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2063 COPY_STRING_FIELD(ctename);
2064 COPY_NODE_FIELD(aliascolnames);
2065 COPY_NODE_FIELD(ctequery);
2066 COPY_LOCATION_FIELD(location);
2067 COPY_SCALAR_FIELD(cterecursive);
2068 COPY_SCALAR_FIELD(cterefcount);
2069 COPY_NODE_FIELD(ctecolnames);
2070 COPY_NODE_FIELD(ctecoltypes);
2071 COPY_NODE_FIELD(ctecoltypmods);
2072 COPY_NODE_FIELD(ctecolcollations);
2078 _copyAExpr(const A_Expr *from)
2080 A_Expr *newnode = makeNode(A_Expr);
2082 COPY_SCALAR_FIELD(kind);
2083 COPY_NODE_FIELD(name);
2084 COPY_NODE_FIELD(lexpr);
2085 COPY_NODE_FIELD(rexpr);
2086 COPY_LOCATION_FIELD(location);
2092 _copyColumnRef(const ColumnRef *from)
2094 ColumnRef *newnode = makeNode(ColumnRef);
2096 COPY_NODE_FIELD(fields);
2097 COPY_LOCATION_FIELD(location);
2103 _copyParamRef(const ParamRef *from)
2105 ParamRef *newnode = makeNode(ParamRef);
2107 COPY_SCALAR_FIELD(number);
2108 COPY_LOCATION_FIELD(location);
2114 _copyAConst(const A_Const *from)
2116 A_Const *newnode = makeNode(A_Const);
2118 /* This part must duplicate _copyValue */
2119 COPY_SCALAR_FIELD(val.type);
2120 switch (from->val.type)
2123 COPY_SCALAR_FIELD(val.val.ival);
2128 COPY_STRING_FIELD(val.val.str);
2134 elog(ERROR, "unrecognized node type: %d",
2135 (int) from->val.type);
2139 COPY_LOCATION_FIELD(location);
2145 _copyFuncCall(const FuncCall *from)
2147 FuncCall *newnode = makeNode(FuncCall);
2149 COPY_NODE_FIELD(funcname);
2150 COPY_NODE_FIELD(args);
2151 COPY_NODE_FIELD(agg_order);
2152 COPY_SCALAR_FIELD(agg_star);
2153 COPY_SCALAR_FIELD(agg_distinct);
2154 COPY_SCALAR_FIELD(func_variadic);
2155 COPY_NODE_FIELD(over);
2156 COPY_LOCATION_FIELD(location);
2162 _copyAStar(const A_Star *from)
2164 A_Star *newnode = makeNode(A_Star);
2170 _copyAIndices(const A_Indices *from)
2172 A_Indices *newnode = makeNode(A_Indices);
2174 COPY_NODE_FIELD(lidx);
2175 COPY_NODE_FIELD(uidx);
2180 static A_Indirection *
2181 _copyA_Indirection(const A_Indirection *from)
2183 A_Indirection *newnode = makeNode(A_Indirection);
2185 COPY_NODE_FIELD(arg);
2186 COPY_NODE_FIELD(indirection);
2191 static A_ArrayExpr *
2192 _copyA_ArrayExpr(const A_ArrayExpr *from)
2194 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2196 COPY_NODE_FIELD(elements);
2197 COPY_LOCATION_FIELD(location);
2203 _copyResTarget(const ResTarget *from)
2205 ResTarget *newnode = makeNode(ResTarget);
2207 COPY_STRING_FIELD(name);
2208 COPY_NODE_FIELD(indirection);
2209 COPY_NODE_FIELD(val);
2210 COPY_LOCATION_FIELD(location);
2216 _copyTypeName(const TypeName *from)
2218 TypeName *newnode = makeNode(TypeName);
2220 COPY_NODE_FIELD(names);
2221 COPY_SCALAR_FIELD(typeOid);
2222 COPY_SCALAR_FIELD(setof);
2223 COPY_SCALAR_FIELD(pct_type);
2224 COPY_NODE_FIELD(typmods);
2225 COPY_SCALAR_FIELD(typemod);
2226 COPY_NODE_FIELD(arrayBounds);
2227 COPY_LOCATION_FIELD(location);
2233 _copySortBy(const SortBy *from)
2235 SortBy *newnode = makeNode(SortBy);
2237 COPY_NODE_FIELD(node);
2238 COPY_SCALAR_FIELD(sortby_dir);
2239 COPY_SCALAR_FIELD(sortby_nulls);
2240 COPY_NODE_FIELD(useOp);
2241 COPY_LOCATION_FIELD(location);
2247 _copyWindowDef(const WindowDef *from)
2249 WindowDef *newnode = makeNode(WindowDef);
2251 COPY_STRING_FIELD(name);
2252 COPY_STRING_FIELD(refname);
2253 COPY_NODE_FIELD(partitionClause);
2254 COPY_NODE_FIELD(orderClause);
2255 COPY_SCALAR_FIELD(frameOptions);
2256 COPY_NODE_FIELD(startOffset);
2257 COPY_NODE_FIELD(endOffset);
2258 COPY_LOCATION_FIELD(location);
2263 static RangeSubselect *
2264 _copyRangeSubselect(const RangeSubselect *from)
2266 RangeSubselect *newnode = makeNode(RangeSubselect);
2268 COPY_SCALAR_FIELD(lateral);
2269 COPY_NODE_FIELD(subquery);
2270 COPY_NODE_FIELD(alias);
2275 static RangeFunction *
2276 _copyRangeFunction(const RangeFunction *from)
2278 RangeFunction *newnode = makeNode(RangeFunction);
2280 COPY_SCALAR_FIELD(lateral);
2281 COPY_NODE_FIELD(funccallnode);
2282 COPY_NODE_FIELD(alias);
2283 COPY_NODE_FIELD(coldeflist);
2289 _copyTypeCast(const TypeCast *from)
2291 TypeCast *newnode = makeNode(TypeCast);
2293 COPY_NODE_FIELD(arg);
2294 COPY_NODE_FIELD(typeName);
2295 COPY_LOCATION_FIELD(location);
2300 static CollateClause *
2301 _copyCollateClause(const CollateClause *from)
2303 CollateClause *newnode = makeNode(CollateClause);
2305 COPY_NODE_FIELD(arg);
2306 COPY_NODE_FIELD(collname);
2307 COPY_LOCATION_FIELD(location);
2313 _copyIndexElem(const IndexElem *from)
2315 IndexElem *newnode = makeNode(IndexElem);
2317 COPY_STRING_FIELD(name);
2318 COPY_NODE_FIELD(expr);
2319 COPY_STRING_FIELD(indexcolname);
2320 COPY_NODE_FIELD(collation);
2321 COPY_NODE_FIELD(opclass);
2322 COPY_SCALAR_FIELD(ordering);
2323 COPY_SCALAR_FIELD(nulls_ordering);
2329 _copyColumnDef(const ColumnDef *from)
2331 ColumnDef *newnode = makeNode(ColumnDef);
2333 COPY_STRING_FIELD(colname);
2334 COPY_NODE_FIELD(typeName);
2335 COPY_SCALAR_FIELD(inhcount);
2336 COPY_SCALAR_FIELD(is_local);
2337 COPY_SCALAR_FIELD(is_not_null);
2338 COPY_SCALAR_FIELD(is_from_type);
2339 COPY_SCALAR_FIELD(storage);
2340 COPY_NODE_FIELD(raw_default);
2341 COPY_NODE_FIELD(cooked_default);
2342 COPY_NODE_FIELD(collClause);
2343 COPY_SCALAR_FIELD(collOid);
2344 COPY_NODE_FIELD(constraints);
2345 COPY_NODE_FIELD(fdwoptions);
2351 _copyConstraint(const Constraint *from)
2353 Constraint *newnode = makeNode(Constraint);
2355 COPY_SCALAR_FIELD(contype);
2356 COPY_STRING_FIELD(conname);
2357 COPY_SCALAR_FIELD(deferrable);
2358 COPY_SCALAR_FIELD(initdeferred);
2359 COPY_LOCATION_FIELD(location);
2360 COPY_SCALAR_FIELD(is_no_inherit);
2361 COPY_NODE_FIELD(raw_expr);
2362 COPY_STRING_FIELD(cooked_expr);
2363 COPY_NODE_FIELD(keys);
2364 COPY_NODE_FIELD(exclusions);
2365 COPY_NODE_FIELD(options);
2366 COPY_STRING_FIELD(indexname);
2367 COPY_STRING_FIELD(indexspace);
2368 COPY_STRING_FIELD(access_method);
2369 COPY_NODE_FIELD(where_clause);
2370 COPY_NODE_FIELD(pktable);
2371 COPY_NODE_FIELD(fk_attrs);
2372 COPY_NODE_FIELD(pk_attrs);
2373 COPY_SCALAR_FIELD(fk_matchtype);
2374 COPY_SCALAR_FIELD(fk_upd_action);
2375 COPY_SCALAR_FIELD(fk_del_action);
2376 COPY_NODE_FIELD(old_conpfeqop);
2377 COPY_SCALAR_FIELD(skip_validation);
2378 COPY_SCALAR_FIELD(initially_valid);
2384 _copyDefElem(const DefElem *from)
2386 DefElem *newnode = makeNode(DefElem);
2388 COPY_STRING_FIELD(defnamespace);
2389 COPY_STRING_FIELD(defname);
2390 COPY_NODE_FIELD(arg);
2391 COPY_SCALAR_FIELD(defaction);
2396 static LockingClause *
2397 _copyLockingClause(const LockingClause *from)
2399 LockingClause *newnode = makeNode(LockingClause);
2401 COPY_NODE_FIELD(lockedRels);
2402 COPY_SCALAR_FIELD(forUpdate);
2403 COPY_SCALAR_FIELD(noWait);
2408 static XmlSerialize *
2409 _copyXmlSerialize(const XmlSerialize *from)
2411 XmlSerialize *newnode = makeNode(XmlSerialize);
2413 COPY_SCALAR_FIELD(xmloption);
2414 COPY_NODE_FIELD(expr);
2415 COPY_NODE_FIELD(typeName);
2416 COPY_LOCATION_FIELD(location);
2422 _copyQuery(const Query *from)
2424 Query *newnode = makeNode(Query);
2426 COPY_SCALAR_FIELD(commandType);
2427 COPY_SCALAR_FIELD(querySource);
2428 COPY_SCALAR_FIELD(queryId);
2429 COPY_SCALAR_FIELD(canSetTag);
2430 COPY_NODE_FIELD(utilityStmt);
2431 COPY_SCALAR_FIELD(resultRelation);
2432 COPY_SCALAR_FIELD(hasAggs);
2433 COPY_SCALAR_FIELD(hasWindowFuncs);
2434 COPY_SCALAR_FIELD(hasSubLinks);
2435 COPY_SCALAR_FIELD(hasDistinctOn);
2436 COPY_SCALAR_FIELD(hasRecursive);
2437 COPY_SCALAR_FIELD(hasModifyingCTE);
2438 COPY_SCALAR_FIELD(hasForUpdate);
2439 COPY_NODE_FIELD(cteList);
2440 COPY_NODE_FIELD(rtable);
2441 COPY_NODE_FIELD(jointree);
2442 COPY_NODE_FIELD(targetList);
2443 COPY_NODE_FIELD(returningList);
2444 COPY_NODE_FIELD(groupClause);
2445 COPY_NODE_FIELD(havingQual);
2446 COPY_NODE_FIELD(windowClause);
2447 COPY_NODE_FIELD(distinctClause);
2448 COPY_NODE_FIELD(sortClause);
2449 COPY_NODE_FIELD(limitOffset);
2450 COPY_NODE_FIELD(limitCount);
2451 COPY_NODE_FIELD(rowMarks);
2452 COPY_NODE_FIELD(setOperations);
2453 COPY_NODE_FIELD(constraintDeps);
2459 _copyInsertStmt(const InsertStmt *from)
2461 InsertStmt *newnode = makeNode(InsertStmt);
2463 COPY_NODE_FIELD(relation);
2464 COPY_NODE_FIELD(cols);
2465 COPY_NODE_FIELD(selectStmt);
2466 COPY_NODE_FIELD(returningList);
2467 COPY_NODE_FIELD(withClause);
2473 _copyDeleteStmt(const DeleteStmt *from)
2475 DeleteStmt *newnode = makeNode(DeleteStmt);
2477 COPY_NODE_FIELD(relation);
2478 COPY_NODE_FIELD(usingClause);
2479 COPY_NODE_FIELD(whereClause);
2480 COPY_NODE_FIELD(returningList);
2481 COPY_NODE_FIELD(withClause);
2487 _copyUpdateStmt(const UpdateStmt *from)
2489 UpdateStmt *newnode = makeNode(UpdateStmt);
2491 COPY_NODE_FIELD(relation);
2492 COPY_NODE_FIELD(targetList);
2493 COPY_NODE_FIELD(whereClause);
2494 COPY_NODE_FIELD(fromClause);
2495 COPY_NODE_FIELD(returningList);
2496 COPY_NODE_FIELD(withClause);
2502 _copySelectStmt(const SelectStmt *from)
2504 SelectStmt *newnode = makeNode(SelectStmt);
2506 COPY_NODE_FIELD(distinctClause);
2507 COPY_NODE_FIELD(intoClause);
2508 COPY_NODE_FIELD(targetList);
2509 COPY_NODE_FIELD(fromClause);
2510 COPY_NODE_FIELD(whereClause);
2511 COPY_NODE_FIELD(groupClause);
2512 COPY_NODE_FIELD(havingClause);
2513 COPY_NODE_FIELD(windowClause);
2514 COPY_NODE_FIELD(valuesLists);
2515 COPY_NODE_FIELD(sortClause);
2516 COPY_NODE_FIELD(limitOffset);
2517 COPY_NODE_FIELD(limitCount);
2518 COPY_NODE_FIELD(lockingClause);
2519 COPY_NODE_FIELD(withClause);
2520 COPY_SCALAR_FIELD(op);
2521 COPY_SCALAR_FIELD(all);
2522 COPY_NODE_FIELD(larg);
2523 COPY_NODE_FIELD(rarg);
2528 static SetOperationStmt *
2529 _copySetOperationStmt(const SetOperationStmt *from)
2531 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2533 COPY_SCALAR_FIELD(op);
2534 COPY_SCALAR_FIELD(all);
2535 COPY_NODE_FIELD(larg);
2536 COPY_NODE_FIELD(rarg);
2537 COPY_NODE_FIELD(colTypes);
2538 COPY_NODE_FIELD(colTypmods);
2539 COPY_NODE_FIELD(colCollations);
2540 COPY_NODE_FIELD(groupClauses);
2545 static AlterTableStmt *
2546 _copyAlterTableStmt(const AlterTableStmt *from)
2548 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2550 COPY_NODE_FIELD(relation);
2551 COPY_NODE_FIELD(cmds);
2552 COPY_SCALAR_FIELD(relkind);
2553 COPY_SCALAR_FIELD(missing_ok);
2558 static AlterTableCmd *
2559 _copyAlterTableCmd(const AlterTableCmd *from)
2561 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2563 COPY_SCALAR_FIELD(subtype);
2564 COPY_STRING_FIELD(name);
2565 COPY_NODE_FIELD(def);
2566 COPY_SCALAR_FIELD(behavior);
2567 COPY_SCALAR_FIELD(missing_ok);
2572 static AlterDomainStmt *
2573 _copyAlterDomainStmt(const AlterDomainStmt *from)
2575 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2577 COPY_SCALAR_FIELD(subtype);
2578 COPY_NODE_FIELD(typeName);
2579 COPY_STRING_FIELD(name);
2580 COPY_NODE_FIELD(def);
2581 COPY_SCALAR_FIELD(behavior);
2582 COPY_SCALAR_FIELD(missing_ok);
2588 _copyGrantStmt(const GrantStmt *from)
2590 GrantStmt *newnode = makeNode(GrantStmt);
2592 COPY_SCALAR_FIELD(is_grant);
2593 COPY_SCALAR_FIELD(targtype);
2594 COPY_SCALAR_FIELD(objtype);
2595 COPY_NODE_FIELD(objects);
2596 COPY_NODE_FIELD(privileges);
2597 COPY_NODE_FIELD(grantees);
2598 COPY_SCALAR_FIELD(grant_option);
2599 COPY_SCALAR_FIELD(behavior);
2604 static PrivGrantee *
2605 _copyPrivGrantee(const PrivGrantee *from)
2607 PrivGrantee *newnode = makeNode(PrivGrantee);
2609 COPY_STRING_FIELD(rolname);
2614 static FuncWithArgs *
2615 _copyFuncWithArgs(const FuncWithArgs *from)
2617 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2619 COPY_NODE_FIELD(funcname);
2620 COPY_NODE_FIELD(funcargs);
2626 _copyAccessPriv(const AccessPriv *from)
2628 AccessPriv *newnode = makeNode(AccessPriv);
2630 COPY_STRING_FIELD(priv_name);
2631 COPY_NODE_FIELD(cols);
2636 static GrantRoleStmt *
2637 _copyGrantRoleStmt(const GrantRoleStmt *from)
2639 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2641 COPY_NODE_FIELD(granted_roles);
2642 COPY_NODE_FIELD(grantee_roles);
2643 COPY_SCALAR_FIELD(is_grant);
2644 COPY_SCALAR_FIELD(admin_opt);
2645 COPY_STRING_FIELD(grantor);
2646 COPY_SCALAR_FIELD(behavior);
2651 static AlterDefaultPrivilegesStmt *
2652 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
2654 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2656 COPY_NODE_FIELD(options);
2657 COPY_NODE_FIELD(action);
2662 static DeclareCursorStmt *
2663 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
2665 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2667 COPY_STRING_FIELD(portalname);
2668 COPY_SCALAR_FIELD(options);
2669 COPY_NODE_FIELD(query);
2674 static ClosePortalStmt *
2675 _copyClosePortalStmt(const ClosePortalStmt *from)
2677 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2679 COPY_STRING_FIELD(portalname);
2684 static ClusterStmt *
2685 _copyClusterStmt(const ClusterStmt *from)
2687 ClusterStmt *newnode = makeNode(ClusterStmt);
2689 COPY_NODE_FIELD(relation);
2690 COPY_STRING_FIELD(indexname);
2691 COPY_SCALAR_FIELD(verbose);
2697 _copyCopyStmt(const CopyStmt *from)
2699 CopyStmt *newnode = makeNode(CopyStmt);
2701 COPY_NODE_FIELD(relation);
2702 COPY_NODE_FIELD(query);
2703 COPY_NODE_FIELD(attlist);
2704 COPY_SCALAR_FIELD(is_from);
2705 COPY_STRING_FIELD(filename);
2706 COPY_NODE_FIELD(options);
2712 * CopyCreateStmtFields
2714 * This function copies the fields of the CreateStmt node. It is used by
2715 * copy functions for classes which inherit from CreateStmt.
2718 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
2720 COPY_NODE_FIELD(relation);
2721 COPY_NODE_FIELD(tableElts);
2722 COPY_NODE_FIELD(inhRelations);
2723 COPY_NODE_FIELD(ofTypename);
2724 COPY_NODE_FIELD(constraints);
2725 COPY_NODE_FIELD(options);
2726 COPY_SCALAR_FIELD(oncommit);
2727 COPY_STRING_FIELD(tablespacename);
2728 COPY_SCALAR_FIELD(if_not_exists);
2732 _copyCreateStmt(const CreateStmt *from)
2734 CreateStmt *newnode = makeNode(CreateStmt);
2736 CopyCreateStmtFields(from, newnode);
2741 static TableLikeClause *
2742 _copyTableLikeClause(const TableLikeClause *from)
2744 TableLikeClause *newnode = makeNode(TableLikeClause);
2746 COPY_NODE_FIELD(relation);
2747 COPY_SCALAR_FIELD(options);
2753 _copyDefineStmt(const DefineStmt *from)
2755 DefineStmt *newnode = makeNode(DefineStmt);
2757 COPY_SCALAR_FIELD(kind);
2758 COPY_SCALAR_FIELD(oldstyle);
2759 COPY_NODE_FIELD(defnames);
2760 COPY_NODE_FIELD(args);
2761 COPY_NODE_FIELD(definition);
2767 _copyDropStmt(const DropStmt *from)
2769 DropStmt *newnode = makeNode(DropStmt);
2771 COPY_NODE_FIELD(objects);
2772 COPY_NODE_FIELD(arguments);
2773 COPY_SCALAR_FIELD(removeType);
2774 COPY_SCALAR_FIELD(behavior);
2775 COPY_SCALAR_FIELD(missing_ok);
2776 COPY_SCALAR_FIELD(concurrent);
2781 static TruncateStmt *
2782 _copyTruncateStmt(const TruncateStmt *from)
2784 TruncateStmt *newnode = makeNode(TruncateStmt);
2786 COPY_NODE_FIELD(relations);
2787 COPY_SCALAR_FIELD(restart_seqs);
2788 COPY_SCALAR_FIELD(behavior);
2793 static CommentStmt *
2794 _copyCommentStmt(const CommentStmt *from)
2796 CommentStmt *newnode = makeNode(CommentStmt);
2798 COPY_SCALAR_FIELD(objtype);
2799 COPY_NODE_FIELD(objname);
2800 COPY_NODE_FIELD(objargs);
2801 COPY_STRING_FIELD(comment);
2806 static SecLabelStmt *
2807 _copySecLabelStmt(const SecLabelStmt *from)
2809 SecLabelStmt *newnode = makeNode(SecLabelStmt);
2811 COPY_SCALAR_FIELD(objtype);
2812 COPY_NODE_FIELD(objname);
2813 COPY_NODE_FIELD(objargs);
2814 COPY_STRING_FIELD(provider);
2815 COPY_STRING_FIELD(label);
2821 _copyFetchStmt(const FetchStmt *from)
2823 FetchStmt *newnode = makeNode(FetchStmt);
2825 COPY_SCALAR_FIELD(direction);
2826 COPY_SCALAR_FIELD(howMany);
2827 COPY_STRING_FIELD(portalname);
2828 COPY_SCALAR_FIELD(ismove);
2834 _copyIndexStmt(const IndexStmt *from)
2836 IndexStmt *newnode = makeNode(IndexStmt);
2838 COPY_STRING_FIELD(idxname);
2839 COPY_NODE_FIELD(relation);
2840 COPY_STRING_FIELD(accessMethod);
2841 COPY_STRING_FIELD(tableSpace);
2842 COPY_NODE_FIELD(indexParams);
2843 COPY_NODE_FIELD(options);
2844 COPY_NODE_FIELD(whereClause);
2845 COPY_NODE_FIELD(excludeOpNames);
2846 COPY_STRING_FIELD(idxcomment);
2847 COPY_SCALAR_FIELD(indexOid);
2848 COPY_SCALAR_FIELD(oldNode);
2849 COPY_SCALAR_FIELD(unique);
2850 COPY_SCALAR_FIELD(primary);
2851 COPY_SCALAR_FIELD(isconstraint);
2852 COPY_SCALAR_FIELD(deferrable);
2853 COPY_SCALAR_FIELD(initdeferred);
2854 COPY_SCALAR_FIELD(concurrent);
2859 static CreateFunctionStmt *
2860 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
2862 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2864 COPY_SCALAR_FIELD(replace);
2865 COPY_NODE_FIELD(funcname);
2866 COPY_NODE_FIELD(parameters);
2867 COPY_NODE_FIELD(returnType);
2868 COPY_NODE_FIELD(options);
2869 COPY_NODE_FIELD(withClause);
2874 static FunctionParameter *
2875 _copyFunctionParameter(const FunctionParameter *from)
2877 FunctionParameter *newnode = makeNode(FunctionParameter);
2879 COPY_STRING_FIELD(name);
2880 COPY_NODE_FIELD(argType);
2881 COPY_SCALAR_FIELD(mode);
2882 COPY_NODE_FIELD(defexpr);
2887 static AlterFunctionStmt *
2888 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
2890 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2892 COPY_NODE_FIELD(func);
2893 COPY_NODE_FIELD(actions);
2899 _copyDoStmt(const DoStmt *from)
2901 DoStmt *newnode = makeNode(DoStmt);
2903 COPY_NODE_FIELD(args);
2909 _copyRenameStmt(const RenameStmt *from)
2911 RenameStmt *newnode = makeNode(RenameStmt);
2913 COPY_SCALAR_FIELD(renameType);
2914 COPY_SCALAR_FIELD(relationType);
2915 COPY_NODE_FIELD(relation);
2916 COPY_NODE_FIELD(object);
2917 COPY_NODE_FIELD(objarg);
2918 COPY_STRING_FIELD(subname);
2919 COPY_STRING_FIELD(newname);
2920 COPY_SCALAR_FIELD(behavior);
2921 COPY_SCALAR_FIELD(missing_ok);
2926 static AlterObjectSchemaStmt *
2927 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
2929 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2931 COPY_SCALAR_FIELD(objectType);
2932 COPY_NODE_FIELD(relation);
2933 COPY_NODE_FIELD(object);
2934 COPY_NODE_FIELD(objarg);
2935 COPY_STRING_FIELD(newschema);
2936 COPY_SCALAR_FIELD(missing_ok);
2941 static AlterOwnerStmt *
2942 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
2944 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2946 COPY_SCALAR_FIELD(objectType);
2947 COPY_NODE_FIELD(relation);
2948 COPY_NODE_FIELD(object);
2949 COPY_NODE_FIELD(objarg);
2950 COPY_STRING_FIELD(newowner);
2956 _copyRuleStmt(const RuleStmt *from)
2958 RuleStmt *newnode = makeNode(RuleStmt);
2960 COPY_NODE_FIELD(relation);
2961 COPY_STRING_FIELD(rulename);
2962 COPY_NODE_FIELD(whereClause);
2963 COPY_SCALAR_FIELD(event);
2964 COPY_SCALAR_FIELD(instead);
2965 COPY_NODE_FIELD(actions);
2966 COPY_SCALAR_FIELD(replace);
2972 _copyNotifyStmt(const NotifyStmt *from)
2974 NotifyStmt *newnode = makeNode(NotifyStmt);
2976 COPY_STRING_FIELD(conditionname);
2977 COPY_STRING_FIELD(payload);
2983 _copyListenStmt(const ListenStmt *from)
2985 ListenStmt *newnode = makeNode(ListenStmt);
2987 COPY_STRING_FIELD(conditionname);
2992 static UnlistenStmt *
2993 _copyUnlistenStmt(const UnlistenStmt *from)
2995 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2997 COPY_STRING_FIELD(conditionname);
3002 static TransactionStmt *
3003 _copyTransactionStmt(const TransactionStmt *from)
3005 TransactionStmt *newnode = makeNode(TransactionStmt);
3007 COPY_SCALAR_FIELD(kind);
3008 COPY_NODE_FIELD(options);
3009 COPY_STRING_FIELD(gid);
3014 static CompositeTypeStmt *
3015 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3017 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3019 COPY_NODE_FIELD(typevar);
3020 COPY_NODE_FIELD(coldeflist);
3025 static CreateEnumStmt *
3026 _copyCreateEnumStmt(const CreateEnumStmt *from)
3028 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3030 COPY_NODE_FIELD(typeName);
3031 COPY_NODE_FIELD(vals);
3036 static CreateRangeStmt *
3037 _copyCreateRangeStmt(const CreateRangeStmt *from)
3039 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3041 COPY_NODE_FIELD(typeName);
3042 COPY_NODE_FIELD(params);
3047 static AlterEnumStmt *
3048 _copyAlterEnumStmt(const AlterEnumStmt *from)
3050 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3052 COPY_NODE_FIELD(typeName);
3053 COPY_STRING_FIELD(newVal);
3054 COPY_STRING_FIELD(newValNeighbor);
3055 COPY_SCALAR_FIELD(newValIsAfter);
3056 COPY_SCALAR_FIELD(skipIfExists);
3062 _copyViewStmt(const ViewStmt *from)
3064 ViewStmt *newnode = makeNode(ViewStmt);
3066 COPY_NODE_FIELD(view);
3067 COPY_NODE_FIELD(aliases);
3068 COPY_NODE_FIELD(query);
3069 COPY_SCALAR_FIELD(replace);
3070 COPY_NODE_FIELD(options);
3076 _copyLoadStmt(const LoadStmt *from)
3078 LoadStmt *newnode = makeNode(LoadStmt);
3080 COPY_STRING_FIELD(filename);
3085 static CreateDomainStmt *
3086 _copyCreateDomainStmt(const CreateDomainStmt *from)
3088 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3090 COPY_NODE_FIELD(domainname);
3091 COPY_NODE_FIELD(typeName);
3092 COPY_NODE_FIELD(collClause);
3093 COPY_NODE_FIELD(constraints);
3098 static CreateOpClassStmt *
3099 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3101 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3103 COPY_NODE_FIELD(opclassname);
3104 COPY_NODE_FIELD(opfamilyname);
3105 COPY_STRING_FIELD(amname);
3106 COPY_NODE_FIELD(datatype);
3107 COPY_NODE_FIELD(items);
3108 COPY_SCALAR_FIELD(isDefault);
3113 static CreateOpClassItem *
3114 _copyCreateOpClassItem(const CreateOpClassItem *from)
3116 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3118 COPY_SCALAR_FIELD(itemtype);
3119 COPY_NODE_FIELD(name);
3120 COPY_NODE_FIELD(args);
3121 COPY_SCALAR_FIELD(number);
3122 COPY_NODE_FIELD(order_family);
3123 COPY_NODE_FIELD(class_args);
3124 COPY_NODE_FIELD(storedtype);
3129 static CreateOpFamilyStmt *
3130 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3132 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3134 COPY_NODE_FIELD(opfamilyname);
3135 COPY_STRING_FIELD(amname);
3140 static AlterOpFamilyStmt *
3141 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3143 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3145 COPY_NODE_FIELD(opfamilyname);
3146 COPY_STRING_FIELD(amname);
3147 COPY_SCALAR_FIELD(isDrop);
3148 COPY_NODE_FIELD(items);
3153 static CreatedbStmt *
3154 _copyCreatedbStmt(const CreatedbStmt *from)
3156 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3158 COPY_STRING_FIELD(dbname);
3159 COPY_NODE_FIELD(options);
3164 static AlterDatabaseStmt *
3165 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3167 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3169 COPY_STRING_FIELD(dbname);
3170 COPY_NODE_FIELD(options);
3175 static AlterDatabaseSetStmt *
3176 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3178 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3180 COPY_STRING_FIELD(dbname);
3181 COPY_NODE_FIELD(setstmt);
3187 _copyDropdbStmt(const DropdbStmt *from)
3189 DropdbStmt *newnode = makeNode(DropdbStmt);
3191 COPY_STRING_FIELD(dbname);
3192 COPY_SCALAR_FIELD(missing_ok);
3198 _copyVacuumStmt(const VacuumStmt *from)
3200 VacuumStmt *newnode = makeNode(VacuumStmt);
3202 COPY_SCALAR_FIELD(options);
3203 COPY_SCALAR_FIELD(freeze_min_age);
3204 COPY_SCALAR_FIELD(freeze_table_age);
3205 COPY_NODE_FIELD(relation);
3206 COPY_NODE_FIELD(va_cols);
3211 static ExplainStmt *
3212 _copyExplainStmt(const ExplainStmt *from)
3214 ExplainStmt *newnode = makeNode(ExplainStmt);
3216 COPY_NODE_FIELD(query);
3217 COPY_NODE_FIELD(options);
3222 static CreateTableAsStmt *
3223 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3225 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3227 COPY_NODE_FIELD(query);
3228 COPY_NODE_FIELD(into);
3229 COPY_SCALAR_FIELD(is_select_into);
3234 static CreateSeqStmt *
3235 _copyCreateSeqStmt(const CreateSeqStmt *from)
3237 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3239 COPY_NODE_FIELD(sequence);
3240 COPY_NODE_FIELD(options);
3241 COPY_SCALAR_FIELD(ownerId);
3246 static AlterSeqStmt *
3247 _copyAlterSeqStmt(const AlterSeqStmt *from)
3249 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3251 COPY_NODE_FIELD(sequence);
3252 COPY_NODE_FIELD(options);
3253 COPY_SCALAR_FIELD(missing_ok);
3258 static VariableSetStmt *
3259 _copyVariableSetStmt(const VariableSetStmt *from)
3261 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3263 COPY_SCALAR_FIELD(kind);
3264 COPY_STRING_FIELD(name);
3265 COPY_NODE_FIELD(args);
3266 COPY_SCALAR_FIELD(is_local);
3271 static VariableShowStmt *
3272 _copyVariableShowStmt(const VariableShowStmt *from)
3274 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3276 COPY_STRING_FIELD(name);
3281 static DiscardStmt *
3282 _copyDiscardStmt(const DiscardStmt *from)
3284 DiscardStmt *newnode = makeNode(DiscardStmt);
3286 COPY_SCALAR_FIELD(target);
3291 static CreateTableSpaceStmt *
3292 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3294 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3296 COPY_STRING_FIELD(tablespacename);
3297 COPY_STRING_FIELD(owner);
3298 COPY_STRING_FIELD(location);
3303 static DropTableSpaceStmt *
3304 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
3306 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3308 COPY_STRING_FIELD(tablespacename);
3309 COPY_SCALAR_FIELD(missing_ok);
3314 static AlterTableSpaceOptionsStmt *
3315 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
3317 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3319 COPY_STRING_FIELD(tablespacename);
3320 COPY_NODE_FIELD(options);
3321 COPY_SCALAR_FIELD(isReset);
3326 static CreateExtensionStmt *
3327 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
3329 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3331 COPY_STRING_FIELD(extname);
3332 COPY_SCALAR_FIELD(if_not_exists);
3333 COPY_NODE_FIELD(options);
3338 static AlterExtensionStmt *
3339 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
3341 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3343 COPY_STRING_FIELD(extname);
3344 COPY_NODE_FIELD(options);
3349 static AlterExtensionContentsStmt *
3350 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
3352 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3354 COPY_STRING_FIELD(extname);
3355 COPY_SCALAR_FIELD(action);
3356 COPY_SCALAR_FIELD(objtype);
3357 COPY_NODE_FIELD(objname);
3358 COPY_NODE_FIELD(objargs);
3363 static CreateFdwStmt *
3364 _copyCreateFdwStmt(const CreateFdwStmt *from)
3366 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3368 COPY_STRING_FIELD(fdwname);
3369 COPY_NODE_FIELD(func_options);
3370 COPY_NODE_FIELD(options);
3375 static AlterFdwStmt *
3376 _copyAlterFdwStmt(const AlterFdwStmt *from)
3378 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3380 COPY_STRING_FIELD(fdwname);
3381 COPY_NODE_FIELD(func_options);
3382 COPY_NODE_FIELD(options);
3387 static CreateForeignServerStmt *
3388 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
3390 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3392 COPY_STRING_FIELD(servername);
3393 COPY_STRING_FIELD(servertype);
3394 COPY_STRING_FIELD(version);
3395 COPY_STRING_FIELD(fdwname);
3396 COPY_NODE_FIELD(options);
3401 static AlterForeignServerStmt *
3402 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
3404 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3406 COPY_STRING_FIELD(servername);
3407 COPY_STRING_FIELD(version);
3408 COPY_NODE_FIELD(options);
3409 COPY_SCALAR_FIELD(has_version);
3414 static CreateUserMappingStmt *
3415 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
3417 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3419 COPY_STRING_FIELD(username);
3420 COPY_STRING_FIELD(servername);
3421 COPY_NODE_FIELD(options);
3426 static AlterUserMappingStmt *
3427 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
3429 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3431 COPY_STRING_FIELD(username);
3432 COPY_STRING_FIELD(servername);
3433 COPY_NODE_FIELD(options);
3438 static DropUserMappingStmt *
3439 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
3441 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3443 COPY_STRING_FIELD(username);
3444 COPY_STRING_FIELD(servername);
3445 COPY_SCALAR_FIELD(missing_ok);
3450 static CreateForeignTableStmt *
3451 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
3453 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3455 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
3457 COPY_STRING_FIELD(servername);
3458 COPY_NODE_FIELD(options);
3463 static CreateTrigStmt *
3464 _copyCreateTrigStmt(const CreateTrigStmt *from)
3466 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3468 COPY_STRING_FIELD(trigname);
3469 COPY_NODE_FIELD(relation);
3470 COPY_NODE_FIELD(funcname);
3471 COPY_NODE_FIELD(args);
3472 COPY_SCALAR_FIELD(row);
3473 COPY_SCALAR_FIELD(timing);
3474 COPY_SCALAR_FIELD(events);
3475 COPY_NODE_FIELD(columns);
3476 COPY_NODE_FIELD(whenClause);
3477 COPY_SCALAR_FIELD(isconstraint);
3478 COPY_SCALAR_FIELD(deferrable);
3479 COPY_SCALAR_FIELD(initdeferred);
3480 COPY_NODE_FIELD(constrrel);
3485 static CreateEventTrigStmt *
3486 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
3488 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
3490 COPY_STRING_FIELD(trigname);
3491 COPY_SCALAR_FIELD(eventname);
3492 COPY_NODE_FIELD(whenclause);
3493 COPY_NODE_FIELD(funcname);
3498 static AlterEventTrigStmt *
3499 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
3501 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
3503 COPY_STRING_FIELD(trigname);
3504 COPY_SCALAR_FIELD(tgenabled);
3509 static CreatePLangStmt *
3510 _copyCreatePLangStmt(const CreatePLangStmt *from)
3512 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3514 COPY_SCALAR_FIELD(replace);
3515 COPY_STRING_FIELD(plname);
3516 COPY_NODE_FIELD(plhandler);
3517 COPY_NODE_FIELD(plinline);
3518 COPY_NODE_FIELD(plvalidator);
3519 COPY_SCALAR_FIELD(pltrusted);
3524 static CreateRoleStmt *
3525 _copyCreateRoleStmt(const CreateRoleStmt *from)
3527 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3529 COPY_SCALAR_FIELD(stmt_type);
3530 COPY_STRING_FIELD(role);
3531 COPY_NODE_FIELD(options);
3536 static AlterRoleStmt *
3537 _copyAlterRoleStmt(const AlterRoleStmt *from)
3539 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3541 COPY_STRING_FIELD(role);
3542 COPY_NODE_FIELD(options);
3543 COPY_SCALAR_FIELD(action);
3548 static AlterRoleSetStmt *
3549 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
3551 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3553 COPY_STRING_FIELD(role);
3554 COPY_STRING_FIELD(database);
3555 COPY_NODE_FIELD(setstmt);
3560 static DropRoleStmt *
3561 _copyDropRoleStmt(const DropRoleStmt *from)
3563 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3565 COPY_NODE_FIELD(roles);
3566 COPY_SCALAR_FIELD(missing_ok);
3572 _copyLockStmt(const LockStmt *from)
3574 LockStmt *newnode = makeNode(LockStmt);
3576 COPY_NODE_FIELD(relations);
3577 COPY_SCALAR_FIELD(mode);
3578 COPY_SCALAR_FIELD(nowait);
3583 static ConstraintsSetStmt *
3584 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
3586 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3588 COPY_NODE_FIELD(constraints);
3589 COPY_SCALAR_FIELD(deferred);
3594 static ReindexStmt *
3595 _copyReindexStmt(const ReindexStmt *from)
3597 ReindexStmt *newnode = makeNode(ReindexStmt);
3599 COPY_SCALAR_FIELD(kind);
3600 COPY_NODE_FIELD(relation);
3601 COPY_STRING_FIELD(name);
3602 COPY_SCALAR_FIELD(do_system);
3603 COPY_SCALAR_FIELD(do_user);
3608 static CreateSchemaStmt *
3609 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
3611 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3613 COPY_STRING_FIELD(schemaname);
3614 COPY_STRING_FIELD(authid);
3615 COPY_NODE_FIELD(schemaElts);
3620 static CreateConversionStmt *
3621 _copyCreateConversionStmt(const CreateConversionStmt *from)
3623 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3625 COPY_NODE_FIELD(conversion_name);
3626 COPY_STRING_FIELD(for_encoding_name);
3627 COPY_STRING_FIELD(to_encoding_name);
3628 COPY_NODE_FIELD(func_name);
3629 COPY_SCALAR_FIELD(def);
3634 static CreateCastStmt *
3635 _copyCreateCastStmt(const CreateCastStmt *from)
3637 CreateCastStmt *newnode = makeNode(CreateCastStmt);
3639 COPY_NODE_FIELD(sourcetype);
3640 COPY_NODE_FIELD(targettype);
3641 COPY_NODE_FIELD(func);
3642 COPY_SCALAR_FIELD(context);
3643 COPY_SCALAR_FIELD(inout);
3648 static PrepareStmt *
3649 _copyPrepareStmt(const PrepareStmt *from)
3651 PrepareStmt *newnode = makeNode(PrepareStmt);
3653 COPY_STRING_FIELD(name);
3654 COPY_NODE_FIELD(argtypes);
3655 COPY_NODE_FIELD(query);
3660 static ExecuteStmt *
3661 _copyExecuteStmt(const ExecuteStmt *from)
3663 ExecuteStmt *newnode = makeNode(ExecuteStmt);
3665 COPY_STRING_FIELD(name);
3666 COPY_NODE_FIELD(params);
3671 static DeallocateStmt *
3672 _copyDeallocateStmt(const DeallocateStmt *from)
3674 DeallocateStmt *newnode = makeNode(DeallocateStmt);
3676 COPY_STRING_FIELD(name);
3681 static DropOwnedStmt *
3682 _copyDropOwnedStmt(const DropOwnedStmt *from)
3684 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3686 COPY_NODE_FIELD(roles);
3687 COPY_SCALAR_FIELD(behavior);
3692 static ReassignOwnedStmt *
3693 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
3695 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3697 COPY_NODE_FIELD(roles);
3698 COPY_STRING_FIELD(newrole);
3703 static AlterTSDictionaryStmt *
3704 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
3706 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3708 COPY_NODE_FIELD(dictname);
3709 COPY_NODE_FIELD(options);
3714 static AlterTSConfigurationStmt *
3715 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
3717 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3719 COPY_NODE_FIELD(cfgname);
3720 COPY_NODE_FIELD(tokentype);
3721 COPY_NODE_FIELD(dicts);
3722 COPY_SCALAR_FIELD(override);
3723 COPY_SCALAR_FIELD(replace);
3724 COPY_SCALAR_FIELD(missing_ok);
3729 /* ****************************************************************
3730 * pg_list.h copy functions
3731 * ****************************************************************
3735 * Perform a deep copy of the specified list, using copyObject(). The
3736 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
3737 * need deep copies, so they should be copied via list_copy()
3739 #define COPY_NODE_CELL(new, old) \
3740 (new) = (ListCell *) palloc(sizeof(ListCell)); \
3741 lfirst(new) = copyObject(lfirst(old));
3744 _copyList(const List *from)
3750 Assert(list_length(from) >= 1);
3752 new = makeNode(List);
3753 new->length = from->length;
3755 COPY_NODE_CELL(new->head, from->head);
3756 prev_new = new->head;
3757 curr_old = lnext(from->head);
3761 COPY_NODE_CELL(prev_new->next, curr_old);
3762 prev_new = prev_new->next;
3763 curr_old = curr_old->next;
3765 prev_new->next = NULL;
3766 new->tail = prev_new;
3771 /* ****************************************************************
3772 * value.h copy functions
3773 * ****************************************************************
3776 _copyValue(const Value *from)
3778 Value *newnode = makeNode(Value);
3780 /* See also _copyAConst when changing this code! */
3782 COPY_SCALAR_FIELD(type);
3786 COPY_SCALAR_FIELD(val.ival);
3791 COPY_STRING_FIELD(val.str);
3797 elog(ERROR, "unrecognized node type: %d",
3807 * Create a copy of a Node tree or list. This is a "deep" copy: all
3808 * substructure is copied too, recursively.
3811 copyObject(const void *from)
3818 /* Guard against stack overflow due to overly complex expressions */
3819 check_stack_depth();
3821 switch (nodeTag(from))
3827 retval = _copyPlannedStmt(from);
3830 retval = _copyPlan(from);
3833 retval = _copyResult(from);
3836 retval = _copyModifyTable(from);
3839 retval = _copyAppend(from);
3842 retval = _copyMergeAppend(from);
3844 case T_RecursiveUnion:
3845 retval = _copyRecursiveUnion(from);
3848 retval = _copyBitmapAnd(from);
3851 retval = _copyBitmapOr(from);
3854 retval = _copyScan(from);
3857 retval = _copySeqScan(from);
3860 retval = _copyIndexScan(from);
3862 case T_IndexOnlyScan:
3863 retval = _copyIndexOnlyScan(from);
3865 case T_BitmapIndexScan:
3866 retval = _copyBitmapIndexScan(from);
3868 case T_BitmapHeapScan:
3869 retval = _copyBitmapHeapScan(from);
3872 retval = _copyTidScan(from);
3874 case T_SubqueryScan:
3875 retval = _copySubqueryScan(from);
3877 case T_FunctionScan:
3878 retval = _copyFunctionScan(from);
3881 retval = _copyValuesScan(from);
3884 retval = _copyCteScan(from);
3886 case T_WorkTableScan:
3887 retval = _copyWorkTableScan(from);
3890 retval = _copyForeignScan(from);
3893 retval = _copyJoin(from);
3896 retval = _copyNestLoop(from);
3899 retval = _copyMergeJoin(from);
3902 retval = _copyHashJoin(from);
3905 retval = _copyMaterial(from);
3908 retval = _copySort(from);
3911 retval = _copyGroup(from);
3914 retval = _copyAgg(from);
3917 retval = _copyWindowAgg(from);
3920 retval = _copyUnique(from);
3923 retval = _copyHash(from);
3926 retval = _copySetOp(from);
3929 retval = _copyLockRows(from);
3932 retval = _copyLimit(from);
3934 case T_NestLoopParam:
3935 retval = _copyNestLoopParam(from);
3938 retval = _copyPlanRowMark(from);
3940 case T_PlanInvalItem:
3941 retval = _copyPlanInvalItem(from);
3948 retval = _copyAlias(from);
3951 retval = _copyRangeVar(from);
3954 retval = _copyIntoClause(from);
3957 retval = _copyVar(from);
3960 retval = _copyConst(from);
3963 retval = _copyParam(from);
3966 retval = _copyAggref(from);
3969 retval = _copyWindowFunc(from);
3972 retval = _copyArrayRef(from);
3975 retval = _copyFuncExpr(from);
3977 case T_NamedArgExpr:
3978 retval = _copyNamedArgExpr(from);
3981 retval = _copyOpExpr(from);
3983 case T_DistinctExpr:
3984 retval = _copyDistinctExpr(from);
3987 retval = _copyNullIfExpr(from);
3989 case T_ScalarArrayOpExpr:
3990 retval = _copyScalarArrayOpExpr(from);
3993 retval = _copyBoolExpr(from);
3996 retval = _copySubLink(from);
3999 retval = _copySubPlan(from);
4001 case T_AlternativeSubPlan:
4002 retval = _copyAlternativeSubPlan(from);
4005 retval = _copyFieldSelect(from);
4008 retval = _copyFieldStore(from);
4011 retval = _copyRelabelType(from);
4014 retval = _copyCoerceViaIO(from);
4016 case T_ArrayCoerceExpr:
4017 retval = _copyArrayCoerceExpr(from);
4019 case T_ConvertRowtypeExpr:
4020 retval = _copyConvertRowtypeExpr(from);
4023 retval = _copyCollateExpr(from);
4026 retval = _copyCaseExpr(from);
4029 retval = _copyCaseWhen(from);
4031 case T_CaseTestExpr:
4032 retval = _copyCaseTestExpr(from);
4035 retval = _copyArrayExpr(from);
4038 retval = _copyRowExpr(from);
4040 case T_RowCompareExpr:
4041 retval = _copyRowCompareExpr(from);
4043 case T_CoalesceExpr:
4044 retval = _copyCoalesceExpr(from);
4047 retval = _copyMinMaxExpr(from);
4050 retval = _copyXmlExpr(from);
4053 retval = _copyNullTest(from);
4056 retval = _copyBooleanTest(from);
4058 case T_CoerceToDomain:
4059 retval = _copyCoerceToDomain(from);
4061 case T_CoerceToDomainValue:
4062 retval = _copyCoerceToDomainValue(from);
4064 case T_SetToDefault:
4065 retval = _copySetToDefault(from);
4067 case T_CurrentOfExpr:
4068 retval = _copyCurrentOfExpr(from);
4071 retval = _copyTargetEntry(from);
4074 retval = _copyRangeTblRef(from);
4077 retval = _copyJoinExpr(from);
4080 retval = _copyFromExpr(from);
4087 retval = _copyPathKey(from);
4089 case T_RestrictInfo:
4090 retval = _copyRestrictInfo(from);
4092 case T_PlaceHolderVar:
4093 retval = _copyPlaceHolderVar(from);
4095 case T_SpecialJoinInfo:
4096 retval = _copySpecialJoinInfo(from);
4098 case T_LateralJoinInfo:
4099 retval = _copyLateralJoinInfo(from);
4101 case T_AppendRelInfo:
4102 retval = _copyAppendRelInfo(from);
4104 case T_PlaceHolderInfo:
4105 retval = _copyPlaceHolderInfo(from);
4116 retval = _copyValue(from);
4123 retval = _copyList(from);
4127 * Lists of integers and OIDs don't need to be deep-copied, so we
4128 * perform a shallow copy via list_copy()
4132 retval = list_copy(from);
4139 retval = _copyQuery(from);
4142 retval = _copyInsertStmt(from);
4145 retval = _copyDeleteStmt(from);
4148 retval = _copyUpdateStmt(from);
4151 retval = _copySelectStmt(from);
4153 case T_SetOperationStmt:
4154 retval = _copySetOperationStmt(from);
4156 case T_AlterTableStmt:
4157 retval = _copyAlterTableStmt(from);
4159 case T_AlterTableCmd:
4160 retval = _copyAlterTableCmd(from);
4162 case T_AlterDomainStmt:
4163 retval = _copyAlterDomainStmt(from);
4166 retval = _copyGrantStmt(from);
4168 case T_GrantRoleStmt:
4169 retval = _copyGrantRoleStmt(from);
4171 case T_AlterDefaultPrivilegesStmt:
4172 retval = _copyAlterDefaultPrivilegesStmt(from);
4174 case T_DeclareCursorStmt:
4175 retval = _copyDeclareCursorStmt(from);
4177 case T_ClosePortalStmt:
4178 retval = _copyClosePortalStmt(from);
4181 retval = _copyClusterStmt(from);
4184 retval = _copyCopyStmt(from);
4187 retval = _copyCreateStmt(from);
4189 case T_TableLikeClause:
4190 retval = _copyTableLikeClause(from);
4193 retval = _copyDefineStmt(from);
4196 retval = _copyDropStmt(from);
4198 case T_TruncateStmt:
4199 retval = _copyTruncateStmt(from);
4202 retval = _copyCommentStmt(from);
4204 case T_SecLabelStmt:
4205 retval = _copySecLabelStmt(from);
4208 retval = _copyFetchStmt(from);
4211 retval = _copyIndexStmt(from);
4213 case T_CreateFunctionStmt:
4214 retval = _copyCreateFunctionStmt(from);
4216 case T_FunctionParameter:
4217 retval = _copyFunctionParameter(from);
4219 case T_AlterFunctionStmt:
4220 retval = _copyAlterFunctionStmt(from);
4223 retval = _copyDoStmt(from);
4226 retval = _copyRenameStmt(from);
4228 case T_AlterObjectSchemaStmt:
4229 retval = _copyAlterObjectSchemaStmt(from);
4231 case T_AlterOwnerStmt:
4232 retval = _copyAlterOwnerStmt(from);
4235 retval = _copyRuleStmt(from);
4238 retval = _copyNotifyStmt(from);
4241 retval = _copyListenStmt(from);
4243 case T_UnlistenStmt:
4244 retval = _copyUnlistenStmt(from);
4246 case T_TransactionStmt:
4247 retval = _copyTransactionStmt(from);
4249 case T_CompositeTypeStmt:
4250 retval = _copyCompositeTypeStmt(from);
4252 case T_CreateEnumStmt:
4253 retval = _copyCreateEnumStmt(from);
4255 case T_CreateRangeStmt:
4256 retval = _copyCreateRangeStmt(from);
4258 case T_AlterEnumStmt:
4259 retval = _copyAlterEnumStmt(from);
4262 retval = _copyViewStmt(from);
4265 retval = _copyLoadStmt(from);
4267 case T_CreateDomainStmt:
4268 retval = _copyCreateDomainStmt(from);
4270 case T_CreateOpClassStmt:
4271 retval = _copyCreateOpClassStmt(from);
4273 case T_CreateOpClassItem:
4274 retval = _copyCreateOpClassItem(from);
4276 case T_CreateOpFamilyStmt:
4277 retval = _copyCreateOpFamilyStmt(from);
4279 case T_AlterOpFamilyStmt:
4280 retval = _copyAlterOpFamilyStmt(from);
4282 case T_CreatedbStmt:
4283 retval = _copyCreatedbStmt(from);
4285 case T_AlterDatabaseStmt:
4286 retval = _copyAlterDatabaseStmt(from);
4288 case T_AlterDatabaseSetStmt:
4289 retval = _copyAlterDatabaseSetStmt(from);
4292 retval = _copyDropdbStmt(from);
4295 retval = _copyVacuumStmt(from);
4298 retval = _copyExplainStmt(from);
4300 case T_CreateTableAsStmt:
4301 retval = _copyCreateTableAsStmt(from);
4303 case T_CreateSeqStmt:
4304 retval = _copyCreateSeqStmt(from);
4306 case T_AlterSeqStmt:
4307 retval = _copyAlterSeqStmt(from);
4309 case T_VariableSetStmt:
4310 retval = _copyVariableSetStmt(from);
4312 case T_VariableShowStmt:
4313 retval = _copyVariableShowStmt(from);
4316 retval = _copyDiscardStmt(from);
4318 case T_CreateTableSpaceStmt:
4319 retval = _copyCreateTableSpaceStmt(from);
4321 case T_DropTableSpaceStmt:
4322 retval = _copyDropTableSpaceStmt(from);
4324 case T_AlterTableSpaceOptionsStmt:
4325 retval = _copyAlterTableSpaceOptionsStmt(from);
4327 case T_CreateExtensionStmt:
4328 retval = _copyCreateExtensionStmt(from);
4330 case T_AlterExtensionStmt:
4331 retval = _copyAlterExtensionStmt(from);
4333 case T_AlterExtensionContentsStmt:
4334 retval = _copyAlterExtensionContentsStmt(from);
4336 case T_CreateFdwStmt:
4337 retval = _copyCreateFdwStmt(from);
4339 case T_AlterFdwStmt:
4340 retval = _copyAlterFdwStmt(from);
4342 case T_CreateForeignServerStmt:
4343 retval = _copyCreateForeignServerStmt(from);
4345 case T_AlterForeignServerStmt:
4346 retval = _copyAlterForeignServerStmt(from);
4348 case T_CreateUserMappingStmt:
4349 retval = _copyCreateUserMappingStmt(from);
4351 case T_AlterUserMappingStmt:
4352 retval = _copyAlterUserMappingStmt(from);
4354 case T_DropUserMappingStmt:
4355 retval = _copyDropUserMappingStmt(from);
4357 case T_CreateForeignTableStmt:
4358 retval = _copyCreateForeignTableStmt(from);
4360 case T_CreateTrigStmt:
4361 retval = _copyCreateTrigStmt(from);
4363 case T_CreateEventTrigStmt:
4364 retval = _copyCreateEventTrigStmt(from);
4366 case T_AlterEventTrigStmt:
4367 retval = _copyAlterEventTrigStmt(from);
4369 case T_CreatePLangStmt:
4370 retval = _copyCreatePLangStmt(from);
4372 case T_CreateRoleStmt:
4373 retval = _copyCreateRoleStmt(from);
4375 case T_AlterRoleStmt:
4376 retval = _copyAlterRoleStmt(from);
4378 case T_AlterRoleSetStmt:
4379 retval = _copyAlterRoleSetStmt(from);
4381 case T_DropRoleStmt:
4382 retval = _copyDropRoleStmt(from);
4385 retval = _copyLockStmt(from);
4387 case T_ConstraintsSetStmt:
4388 retval = _copyConstraintsSetStmt(from);
4391 retval = _copyReindexStmt(from);
4393 case T_CheckPointStmt:
4394 retval = (void *) makeNode(CheckPointStmt);
4396 case T_CreateSchemaStmt:
4397 retval = _copyCreateSchemaStmt(from);
4399 case T_CreateConversionStmt:
4400 retval = _copyCreateConversionStmt(from);
4402 case T_CreateCastStmt:
4403 retval = _copyCreateCastStmt(from);
4406 retval = _copyPrepareStmt(from);
4409 retval = _copyExecuteStmt(from);
4411 case T_DeallocateStmt:
4412 retval = _copyDeallocateStmt(from);
4414 case T_DropOwnedStmt:
4415 retval = _copyDropOwnedStmt(from);
4417 case T_ReassignOwnedStmt:
4418 retval = _copyReassignOwnedStmt(from);
4420 case T_AlterTSDictionaryStmt:
4421 retval = _copyAlterTSDictionaryStmt(from);
4423 case T_AlterTSConfigurationStmt:
4424 retval = _copyAlterTSConfigurationStmt(from);
4428 retval = _copyAExpr(from);
4431 retval = _copyColumnRef(from);
4434 retval = _copyParamRef(from);
4437 retval = _copyAConst(from);
4440 retval = _copyFuncCall(from);
4443 retval = _copyAStar(from);
4446 retval = _copyAIndices(from);
4448 case T_A_Indirection:
4449 retval = _copyA_Indirection(from);
4452 retval = _copyA_ArrayExpr(from);
4455 retval = _copyResTarget(from);
4458 retval = _copyTypeCast(from);
4460 case T_CollateClause:
4461 retval = _copyCollateClause(from);
4464 retval = _copySortBy(from);
4467 retval = _copyWindowDef(from);
4469 case T_RangeSubselect:
4470 retval = _copyRangeSubselect(from);
4472 case T_RangeFunction:
4473 retval = _copyRangeFunction(from);
4476 retval = _copyTypeName(from);
4479 retval = _copyIndexElem(from);
4482 retval = _copyColumnDef(from);
4485 retval = _copyConstraint(from);
4488 retval = _copyDefElem(from);
4490 case T_LockingClause:
4491 retval = _copyLockingClause(from);
4493 case T_RangeTblEntry:
4494 retval = _copyRangeTblEntry(from);
4496 case T_SortGroupClause:
4497 retval = _copySortGroupClause(from);
4499 case T_WindowClause:
4500 retval = _copyWindowClause(from);
4502 case T_RowMarkClause:
4503 retval = _copyRowMarkClause(from);
4506 retval = _copyWithClause(from);
4508 case T_CommonTableExpr:
4509 retval = _copyCommonTableExpr(from);
4512 retval = _copyPrivGrantee(from);
4514 case T_FuncWithArgs:
4515 retval = _copyFuncWithArgs(from);
4518 retval = _copyAccessPriv(from);
4520 case T_XmlSerialize:
4521 retval = _copyXmlSerialize(from);
4525 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4526 retval = 0; /* keep compiler quiet */