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 * _copyAppendRelInfo
1912 static AppendRelInfo *
1913 _copyAppendRelInfo(const AppendRelInfo *from)
1915 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1917 COPY_SCALAR_FIELD(parent_relid);
1918 COPY_SCALAR_FIELD(child_relid);
1919 COPY_SCALAR_FIELD(parent_reltype);
1920 COPY_SCALAR_FIELD(child_reltype);
1921 COPY_NODE_FIELD(translated_vars);
1922 COPY_SCALAR_FIELD(parent_reloid);
1928 * _copyPlaceHolderInfo
1930 static PlaceHolderInfo *
1931 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
1933 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
1935 COPY_SCALAR_FIELD(phid);
1936 COPY_NODE_FIELD(ph_var);
1937 COPY_BITMAPSET_FIELD(ph_eval_at);
1938 COPY_BITMAPSET_FIELD(ph_needed);
1939 COPY_BITMAPSET_FIELD(ph_may_need);
1940 COPY_SCALAR_FIELD(ph_width);
1945 /* ****************************************************************
1946 * parsenodes.h copy functions
1947 * ****************************************************************
1950 static RangeTblEntry *
1951 _copyRangeTblEntry(const RangeTblEntry *from)
1953 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1955 COPY_SCALAR_FIELD(rtekind);
1956 COPY_SCALAR_FIELD(relid);
1957 COPY_SCALAR_FIELD(relkind);
1958 COPY_NODE_FIELD(subquery);
1959 COPY_SCALAR_FIELD(security_barrier);
1960 COPY_SCALAR_FIELD(jointype);
1961 COPY_NODE_FIELD(joinaliasvars);
1962 COPY_NODE_FIELD(funcexpr);
1963 COPY_NODE_FIELD(funccoltypes);
1964 COPY_NODE_FIELD(funccoltypmods);
1965 COPY_NODE_FIELD(funccolcollations);
1966 COPY_NODE_FIELD(values_lists);
1967 COPY_NODE_FIELD(values_collations);
1968 COPY_STRING_FIELD(ctename);
1969 COPY_SCALAR_FIELD(ctelevelsup);
1970 COPY_SCALAR_FIELD(self_reference);
1971 COPY_NODE_FIELD(ctecoltypes);
1972 COPY_NODE_FIELD(ctecoltypmods);
1973 COPY_NODE_FIELD(ctecolcollations);
1974 COPY_NODE_FIELD(alias);
1975 COPY_NODE_FIELD(eref);
1976 COPY_SCALAR_FIELD(inh);
1977 COPY_SCALAR_FIELD(inFromCl);
1978 COPY_SCALAR_FIELD(requiredPerms);
1979 COPY_SCALAR_FIELD(checkAsUser);
1980 COPY_BITMAPSET_FIELD(selectedCols);
1981 COPY_BITMAPSET_FIELD(modifiedCols);
1986 static SortGroupClause *
1987 _copySortGroupClause(const SortGroupClause *from)
1989 SortGroupClause *newnode = makeNode(SortGroupClause);
1991 COPY_SCALAR_FIELD(tleSortGroupRef);
1992 COPY_SCALAR_FIELD(eqop);
1993 COPY_SCALAR_FIELD(sortop);
1994 COPY_SCALAR_FIELD(nulls_first);
1995 COPY_SCALAR_FIELD(hashable);
2000 static WindowClause *
2001 _copyWindowClause(const WindowClause *from)
2003 WindowClause *newnode = makeNode(WindowClause);
2005 COPY_STRING_FIELD(name);
2006 COPY_STRING_FIELD(refname);
2007 COPY_NODE_FIELD(partitionClause);
2008 COPY_NODE_FIELD(orderClause);
2009 COPY_SCALAR_FIELD(frameOptions);
2010 COPY_NODE_FIELD(startOffset);
2011 COPY_NODE_FIELD(endOffset);
2012 COPY_SCALAR_FIELD(winref);
2013 COPY_SCALAR_FIELD(copiedOrder);
2018 static RowMarkClause *
2019 _copyRowMarkClause(const RowMarkClause *from)
2021 RowMarkClause *newnode = makeNode(RowMarkClause);
2023 COPY_SCALAR_FIELD(rti);
2024 COPY_SCALAR_FIELD(forUpdate);
2025 COPY_SCALAR_FIELD(noWait);
2026 COPY_SCALAR_FIELD(pushedDown);
2032 _copyWithClause(const WithClause *from)
2034 WithClause *newnode = makeNode(WithClause);
2036 COPY_NODE_FIELD(ctes);
2037 COPY_SCALAR_FIELD(recursive);
2038 COPY_LOCATION_FIELD(location);
2043 static CommonTableExpr *
2044 _copyCommonTableExpr(const CommonTableExpr *from)
2046 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2048 COPY_STRING_FIELD(ctename);
2049 COPY_NODE_FIELD(aliascolnames);
2050 COPY_NODE_FIELD(ctequery);
2051 COPY_LOCATION_FIELD(location);
2052 COPY_SCALAR_FIELD(cterecursive);
2053 COPY_SCALAR_FIELD(cterefcount);
2054 COPY_NODE_FIELD(ctecolnames);
2055 COPY_NODE_FIELD(ctecoltypes);
2056 COPY_NODE_FIELD(ctecoltypmods);
2057 COPY_NODE_FIELD(ctecolcollations);
2063 _copyAExpr(const A_Expr *from)
2065 A_Expr *newnode = makeNode(A_Expr);
2067 COPY_SCALAR_FIELD(kind);
2068 COPY_NODE_FIELD(name);
2069 COPY_NODE_FIELD(lexpr);
2070 COPY_NODE_FIELD(rexpr);
2071 COPY_LOCATION_FIELD(location);
2077 _copyColumnRef(const ColumnRef *from)
2079 ColumnRef *newnode = makeNode(ColumnRef);
2081 COPY_NODE_FIELD(fields);
2082 COPY_LOCATION_FIELD(location);
2088 _copyParamRef(const ParamRef *from)
2090 ParamRef *newnode = makeNode(ParamRef);
2092 COPY_SCALAR_FIELD(number);
2093 COPY_LOCATION_FIELD(location);
2099 _copyAConst(const A_Const *from)
2101 A_Const *newnode = makeNode(A_Const);
2103 /* This part must duplicate _copyValue */
2104 COPY_SCALAR_FIELD(val.type);
2105 switch (from->val.type)
2108 COPY_SCALAR_FIELD(val.val.ival);
2113 COPY_STRING_FIELD(val.val.str);
2119 elog(ERROR, "unrecognized node type: %d",
2120 (int) from->val.type);
2124 COPY_LOCATION_FIELD(location);
2130 _copyFuncCall(const FuncCall *from)
2132 FuncCall *newnode = makeNode(FuncCall);
2134 COPY_NODE_FIELD(funcname);
2135 COPY_NODE_FIELD(args);
2136 COPY_NODE_FIELD(agg_order);
2137 COPY_SCALAR_FIELD(agg_star);
2138 COPY_SCALAR_FIELD(agg_distinct);
2139 COPY_SCALAR_FIELD(func_variadic);
2140 COPY_NODE_FIELD(over);
2141 COPY_LOCATION_FIELD(location);
2147 _copyAStar(const A_Star *from)
2149 A_Star *newnode = makeNode(A_Star);
2155 _copyAIndices(const A_Indices *from)
2157 A_Indices *newnode = makeNode(A_Indices);
2159 COPY_NODE_FIELD(lidx);
2160 COPY_NODE_FIELD(uidx);
2165 static A_Indirection *
2166 _copyA_Indirection(const A_Indirection *from)
2168 A_Indirection *newnode = makeNode(A_Indirection);
2170 COPY_NODE_FIELD(arg);
2171 COPY_NODE_FIELD(indirection);
2176 static A_ArrayExpr *
2177 _copyA_ArrayExpr(const A_ArrayExpr *from)
2179 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2181 COPY_NODE_FIELD(elements);
2182 COPY_LOCATION_FIELD(location);
2188 _copyResTarget(const ResTarget *from)
2190 ResTarget *newnode = makeNode(ResTarget);
2192 COPY_STRING_FIELD(name);
2193 COPY_NODE_FIELD(indirection);
2194 COPY_NODE_FIELD(val);
2195 COPY_LOCATION_FIELD(location);
2201 _copyTypeName(const TypeName *from)
2203 TypeName *newnode = makeNode(TypeName);
2205 COPY_NODE_FIELD(names);
2206 COPY_SCALAR_FIELD(typeOid);
2207 COPY_SCALAR_FIELD(setof);
2208 COPY_SCALAR_FIELD(pct_type);
2209 COPY_NODE_FIELD(typmods);
2210 COPY_SCALAR_FIELD(typemod);
2211 COPY_NODE_FIELD(arrayBounds);
2212 COPY_LOCATION_FIELD(location);
2218 _copySortBy(const SortBy *from)
2220 SortBy *newnode = makeNode(SortBy);
2222 COPY_NODE_FIELD(node);
2223 COPY_SCALAR_FIELD(sortby_dir);
2224 COPY_SCALAR_FIELD(sortby_nulls);
2225 COPY_NODE_FIELD(useOp);
2226 COPY_LOCATION_FIELD(location);
2232 _copyWindowDef(const WindowDef *from)
2234 WindowDef *newnode = makeNode(WindowDef);
2236 COPY_STRING_FIELD(name);
2237 COPY_STRING_FIELD(refname);
2238 COPY_NODE_FIELD(partitionClause);
2239 COPY_NODE_FIELD(orderClause);
2240 COPY_SCALAR_FIELD(frameOptions);
2241 COPY_NODE_FIELD(startOffset);
2242 COPY_NODE_FIELD(endOffset);
2243 COPY_LOCATION_FIELD(location);
2248 static RangeSubselect *
2249 _copyRangeSubselect(const RangeSubselect *from)
2251 RangeSubselect *newnode = makeNode(RangeSubselect);
2253 COPY_NODE_FIELD(subquery);
2254 COPY_NODE_FIELD(alias);
2259 static RangeFunction *
2260 _copyRangeFunction(const RangeFunction *from)
2262 RangeFunction *newnode = makeNode(RangeFunction);
2264 COPY_NODE_FIELD(funccallnode);
2265 COPY_NODE_FIELD(alias);
2266 COPY_NODE_FIELD(coldeflist);
2272 _copyTypeCast(const TypeCast *from)
2274 TypeCast *newnode = makeNode(TypeCast);
2276 COPY_NODE_FIELD(arg);
2277 COPY_NODE_FIELD(typeName);
2278 COPY_LOCATION_FIELD(location);
2283 static CollateClause *
2284 _copyCollateClause(const CollateClause *from)
2286 CollateClause *newnode = makeNode(CollateClause);
2288 COPY_NODE_FIELD(arg);
2289 COPY_NODE_FIELD(collname);
2290 COPY_LOCATION_FIELD(location);
2296 _copyIndexElem(const IndexElem *from)
2298 IndexElem *newnode = makeNode(IndexElem);
2300 COPY_STRING_FIELD(name);
2301 COPY_NODE_FIELD(expr);
2302 COPY_STRING_FIELD(indexcolname);
2303 COPY_NODE_FIELD(collation);
2304 COPY_NODE_FIELD(opclass);
2305 COPY_SCALAR_FIELD(ordering);
2306 COPY_SCALAR_FIELD(nulls_ordering);
2312 _copyColumnDef(const ColumnDef *from)
2314 ColumnDef *newnode = makeNode(ColumnDef);
2316 COPY_STRING_FIELD(colname);
2317 COPY_NODE_FIELD(typeName);
2318 COPY_SCALAR_FIELD(inhcount);
2319 COPY_SCALAR_FIELD(is_local);
2320 COPY_SCALAR_FIELD(is_not_null);
2321 COPY_SCALAR_FIELD(is_from_type);
2322 COPY_SCALAR_FIELD(storage);
2323 COPY_NODE_FIELD(raw_default);
2324 COPY_NODE_FIELD(cooked_default);
2325 COPY_NODE_FIELD(collClause);
2326 COPY_SCALAR_FIELD(collOid);
2327 COPY_NODE_FIELD(constraints);
2328 COPY_NODE_FIELD(fdwoptions);
2334 _copyConstraint(const Constraint *from)
2336 Constraint *newnode = makeNode(Constraint);
2338 COPY_SCALAR_FIELD(contype);
2339 COPY_STRING_FIELD(conname);
2340 COPY_SCALAR_FIELD(deferrable);
2341 COPY_SCALAR_FIELD(initdeferred);
2342 COPY_LOCATION_FIELD(location);
2343 COPY_SCALAR_FIELD(is_no_inherit);
2344 COPY_NODE_FIELD(raw_expr);
2345 COPY_STRING_FIELD(cooked_expr);
2346 COPY_NODE_FIELD(keys);
2347 COPY_NODE_FIELD(exclusions);
2348 COPY_NODE_FIELD(options);
2349 COPY_STRING_FIELD(indexname);
2350 COPY_STRING_FIELD(indexspace);
2351 COPY_STRING_FIELD(access_method);
2352 COPY_NODE_FIELD(where_clause);
2353 COPY_NODE_FIELD(pktable);
2354 COPY_NODE_FIELD(fk_attrs);
2355 COPY_NODE_FIELD(pk_attrs);
2356 COPY_SCALAR_FIELD(fk_matchtype);
2357 COPY_SCALAR_FIELD(fk_upd_action);
2358 COPY_SCALAR_FIELD(fk_del_action);
2359 COPY_NODE_FIELD(old_conpfeqop);
2360 COPY_SCALAR_FIELD(skip_validation);
2361 COPY_SCALAR_FIELD(initially_valid);
2367 _copyDefElem(const DefElem *from)
2369 DefElem *newnode = makeNode(DefElem);
2371 COPY_STRING_FIELD(defnamespace);
2372 COPY_STRING_FIELD(defname);
2373 COPY_NODE_FIELD(arg);
2374 COPY_SCALAR_FIELD(defaction);
2379 static LockingClause *
2380 _copyLockingClause(const LockingClause *from)
2382 LockingClause *newnode = makeNode(LockingClause);
2384 COPY_NODE_FIELD(lockedRels);
2385 COPY_SCALAR_FIELD(forUpdate);
2386 COPY_SCALAR_FIELD(noWait);
2391 static XmlSerialize *
2392 _copyXmlSerialize(const XmlSerialize *from)
2394 XmlSerialize *newnode = makeNode(XmlSerialize);
2396 COPY_SCALAR_FIELD(xmloption);
2397 COPY_NODE_FIELD(expr);
2398 COPY_NODE_FIELD(typeName);
2399 COPY_LOCATION_FIELD(location);
2405 _copyQuery(const Query *from)
2407 Query *newnode = makeNode(Query);
2409 COPY_SCALAR_FIELD(commandType);
2410 COPY_SCALAR_FIELD(querySource);
2411 COPY_SCALAR_FIELD(queryId);
2412 COPY_SCALAR_FIELD(canSetTag);
2413 COPY_NODE_FIELD(utilityStmt);
2414 COPY_SCALAR_FIELD(resultRelation);
2415 COPY_SCALAR_FIELD(hasAggs);
2416 COPY_SCALAR_FIELD(hasWindowFuncs);
2417 COPY_SCALAR_FIELD(hasSubLinks);
2418 COPY_SCALAR_FIELD(hasDistinctOn);
2419 COPY_SCALAR_FIELD(hasRecursive);
2420 COPY_SCALAR_FIELD(hasModifyingCTE);
2421 COPY_SCALAR_FIELD(hasForUpdate);
2422 COPY_NODE_FIELD(cteList);
2423 COPY_NODE_FIELD(rtable);
2424 COPY_NODE_FIELD(jointree);
2425 COPY_NODE_FIELD(targetList);
2426 COPY_NODE_FIELD(returningList);
2427 COPY_NODE_FIELD(groupClause);
2428 COPY_NODE_FIELD(havingQual);
2429 COPY_NODE_FIELD(windowClause);
2430 COPY_NODE_FIELD(distinctClause);
2431 COPY_NODE_FIELD(sortClause);
2432 COPY_NODE_FIELD(limitOffset);
2433 COPY_NODE_FIELD(limitCount);
2434 COPY_NODE_FIELD(rowMarks);
2435 COPY_NODE_FIELD(setOperations);
2436 COPY_NODE_FIELD(constraintDeps);
2442 _copyInsertStmt(const InsertStmt *from)
2444 InsertStmt *newnode = makeNode(InsertStmt);
2446 COPY_NODE_FIELD(relation);
2447 COPY_NODE_FIELD(cols);
2448 COPY_NODE_FIELD(selectStmt);
2449 COPY_NODE_FIELD(returningList);
2450 COPY_NODE_FIELD(withClause);
2456 _copyDeleteStmt(const DeleteStmt *from)
2458 DeleteStmt *newnode = makeNode(DeleteStmt);
2460 COPY_NODE_FIELD(relation);
2461 COPY_NODE_FIELD(usingClause);
2462 COPY_NODE_FIELD(whereClause);
2463 COPY_NODE_FIELD(returningList);
2464 COPY_NODE_FIELD(withClause);
2470 _copyUpdateStmt(const UpdateStmt *from)
2472 UpdateStmt *newnode = makeNode(UpdateStmt);
2474 COPY_NODE_FIELD(relation);
2475 COPY_NODE_FIELD(targetList);
2476 COPY_NODE_FIELD(whereClause);
2477 COPY_NODE_FIELD(fromClause);
2478 COPY_NODE_FIELD(returningList);
2479 COPY_NODE_FIELD(withClause);
2485 _copySelectStmt(const SelectStmt *from)
2487 SelectStmt *newnode = makeNode(SelectStmt);
2489 COPY_NODE_FIELD(distinctClause);
2490 COPY_NODE_FIELD(intoClause);
2491 COPY_NODE_FIELD(targetList);
2492 COPY_NODE_FIELD(fromClause);
2493 COPY_NODE_FIELD(whereClause);
2494 COPY_NODE_FIELD(groupClause);
2495 COPY_NODE_FIELD(havingClause);
2496 COPY_NODE_FIELD(windowClause);
2497 COPY_NODE_FIELD(valuesLists);
2498 COPY_NODE_FIELD(sortClause);
2499 COPY_NODE_FIELD(limitOffset);
2500 COPY_NODE_FIELD(limitCount);
2501 COPY_NODE_FIELD(lockingClause);
2502 COPY_NODE_FIELD(withClause);
2503 COPY_SCALAR_FIELD(op);
2504 COPY_SCALAR_FIELD(all);
2505 COPY_NODE_FIELD(larg);
2506 COPY_NODE_FIELD(rarg);
2511 static SetOperationStmt *
2512 _copySetOperationStmt(const SetOperationStmt *from)
2514 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2516 COPY_SCALAR_FIELD(op);
2517 COPY_SCALAR_FIELD(all);
2518 COPY_NODE_FIELD(larg);
2519 COPY_NODE_FIELD(rarg);
2520 COPY_NODE_FIELD(colTypes);
2521 COPY_NODE_FIELD(colTypmods);
2522 COPY_NODE_FIELD(colCollations);
2523 COPY_NODE_FIELD(groupClauses);
2528 static AlterTableStmt *
2529 _copyAlterTableStmt(const AlterTableStmt *from)
2531 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2533 COPY_NODE_FIELD(relation);
2534 COPY_NODE_FIELD(cmds);
2535 COPY_SCALAR_FIELD(relkind);
2536 COPY_SCALAR_FIELD(missing_ok);
2541 static AlterTableCmd *
2542 _copyAlterTableCmd(const AlterTableCmd *from)
2544 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2546 COPY_SCALAR_FIELD(subtype);
2547 COPY_STRING_FIELD(name);
2548 COPY_NODE_FIELD(def);
2549 COPY_SCALAR_FIELD(behavior);
2550 COPY_SCALAR_FIELD(missing_ok);
2555 static AlterDomainStmt *
2556 _copyAlterDomainStmt(const AlterDomainStmt *from)
2558 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2560 COPY_SCALAR_FIELD(subtype);
2561 COPY_NODE_FIELD(typeName);
2562 COPY_STRING_FIELD(name);
2563 COPY_NODE_FIELD(def);
2564 COPY_SCALAR_FIELD(behavior);
2565 COPY_SCALAR_FIELD(missing_ok);
2571 _copyGrantStmt(const GrantStmt *from)
2573 GrantStmt *newnode = makeNode(GrantStmt);
2575 COPY_SCALAR_FIELD(is_grant);
2576 COPY_SCALAR_FIELD(targtype);
2577 COPY_SCALAR_FIELD(objtype);
2578 COPY_NODE_FIELD(objects);
2579 COPY_NODE_FIELD(privileges);
2580 COPY_NODE_FIELD(grantees);
2581 COPY_SCALAR_FIELD(grant_option);
2582 COPY_SCALAR_FIELD(behavior);
2587 static PrivGrantee *
2588 _copyPrivGrantee(const PrivGrantee *from)
2590 PrivGrantee *newnode = makeNode(PrivGrantee);
2592 COPY_STRING_FIELD(rolname);
2597 static FuncWithArgs *
2598 _copyFuncWithArgs(const FuncWithArgs *from)
2600 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2602 COPY_NODE_FIELD(funcname);
2603 COPY_NODE_FIELD(funcargs);
2609 _copyAccessPriv(const AccessPriv *from)
2611 AccessPriv *newnode = makeNode(AccessPriv);
2613 COPY_STRING_FIELD(priv_name);
2614 COPY_NODE_FIELD(cols);
2619 static GrantRoleStmt *
2620 _copyGrantRoleStmt(const GrantRoleStmt *from)
2622 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2624 COPY_NODE_FIELD(granted_roles);
2625 COPY_NODE_FIELD(grantee_roles);
2626 COPY_SCALAR_FIELD(is_grant);
2627 COPY_SCALAR_FIELD(admin_opt);
2628 COPY_STRING_FIELD(grantor);
2629 COPY_SCALAR_FIELD(behavior);
2634 static AlterDefaultPrivilegesStmt *
2635 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
2637 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2639 COPY_NODE_FIELD(options);
2640 COPY_NODE_FIELD(action);
2645 static DeclareCursorStmt *
2646 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
2648 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2650 COPY_STRING_FIELD(portalname);
2651 COPY_SCALAR_FIELD(options);
2652 COPY_NODE_FIELD(query);
2657 static ClosePortalStmt *
2658 _copyClosePortalStmt(const ClosePortalStmt *from)
2660 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2662 COPY_STRING_FIELD(portalname);
2667 static ClusterStmt *
2668 _copyClusterStmt(const ClusterStmt *from)
2670 ClusterStmt *newnode = makeNode(ClusterStmt);
2672 COPY_NODE_FIELD(relation);
2673 COPY_STRING_FIELD(indexname);
2674 COPY_SCALAR_FIELD(verbose);
2680 _copyCopyStmt(const CopyStmt *from)
2682 CopyStmt *newnode = makeNode(CopyStmt);
2684 COPY_NODE_FIELD(relation);
2685 COPY_NODE_FIELD(query);
2686 COPY_NODE_FIELD(attlist);
2687 COPY_SCALAR_FIELD(is_from);
2688 COPY_STRING_FIELD(filename);
2689 COPY_NODE_FIELD(options);
2695 * CopyCreateStmtFields
2697 * This function copies the fields of the CreateStmt node. It is used by
2698 * copy functions for classes which inherit from CreateStmt.
2701 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
2703 COPY_NODE_FIELD(relation);
2704 COPY_NODE_FIELD(tableElts);
2705 COPY_NODE_FIELD(inhRelations);
2706 COPY_NODE_FIELD(ofTypename);
2707 COPY_NODE_FIELD(constraints);
2708 COPY_NODE_FIELD(options);
2709 COPY_SCALAR_FIELD(oncommit);
2710 COPY_STRING_FIELD(tablespacename);
2711 COPY_SCALAR_FIELD(if_not_exists);
2715 _copyCreateStmt(const CreateStmt *from)
2717 CreateStmt *newnode = makeNode(CreateStmt);
2719 CopyCreateStmtFields(from, newnode);
2724 static TableLikeClause *
2725 _copyTableLikeClause(const TableLikeClause *from)
2727 TableLikeClause *newnode = makeNode(TableLikeClause);
2729 COPY_NODE_FIELD(relation);
2730 COPY_SCALAR_FIELD(options);
2736 _copyDefineStmt(const DefineStmt *from)
2738 DefineStmt *newnode = makeNode(DefineStmt);
2740 COPY_SCALAR_FIELD(kind);
2741 COPY_SCALAR_FIELD(oldstyle);
2742 COPY_NODE_FIELD(defnames);
2743 COPY_NODE_FIELD(args);
2744 COPY_NODE_FIELD(definition);
2750 _copyDropStmt(const DropStmt *from)
2752 DropStmt *newnode = makeNode(DropStmt);
2754 COPY_NODE_FIELD(objects);
2755 COPY_NODE_FIELD(arguments);
2756 COPY_SCALAR_FIELD(removeType);
2757 COPY_SCALAR_FIELD(behavior);
2758 COPY_SCALAR_FIELD(missing_ok);
2759 COPY_SCALAR_FIELD(concurrent);
2764 static TruncateStmt *
2765 _copyTruncateStmt(const TruncateStmt *from)
2767 TruncateStmt *newnode = makeNode(TruncateStmt);
2769 COPY_NODE_FIELD(relations);
2770 COPY_SCALAR_FIELD(restart_seqs);
2771 COPY_SCALAR_FIELD(behavior);
2776 static CommentStmt *
2777 _copyCommentStmt(const CommentStmt *from)
2779 CommentStmt *newnode = makeNode(CommentStmt);
2781 COPY_SCALAR_FIELD(objtype);
2782 COPY_NODE_FIELD(objname);
2783 COPY_NODE_FIELD(objargs);
2784 COPY_STRING_FIELD(comment);
2789 static SecLabelStmt *
2790 _copySecLabelStmt(const SecLabelStmt *from)
2792 SecLabelStmt *newnode = makeNode(SecLabelStmt);
2794 COPY_SCALAR_FIELD(objtype);
2795 COPY_NODE_FIELD(objname);
2796 COPY_NODE_FIELD(objargs);
2797 COPY_STRING_FIELD(provider);
2798 COPY_STRING_FIELD(label);
2804 _copyFetchStmt(const FetchStmt *from)
2806 FetchStmt *newnode = makeNode(FetchStmt);
2808 COPY_SCALAR_FIELD(direction);
2809 COPY_SCALAR_FIELD(howMany);
2810 COPY_STRING_FIELD(portalname);
2811 COPY_SCALAR_FIELD(ismove);
2817 _copyIndexStmt(const IndexStmt *from)
2819 IndexStmt *newnode = makeNode(IndexStmt);
2821 COPY_STRING_FIELD(idxname);
2822 COPY_NODE_FIELD(relation);
2823 COPY_STRING_FIELD(accessMethod);
2824 COPY_STRING_FIELD(tableSpace);
2825 COPY_NODE_FIELD(indexParams);
2826 COPY_NODE_FIELD(options);
2827 COPY_NODE_FIELD(whereClause);
2828 COPY_NODE_FIELD(excludeOpNames);
2829 COPY_STRING_FIELD(idxcomment);
2830 COPY_SCALAR_FIELD(indexOid);
2831 COPY_SCALAR_FIELD(oldNode);
2832 COPY_SCALAR_FIELD(unique);
2833 COPY_SCALAR_FIELD(primary);
2834 COPY_SCALAR_FIELD(isconstraint);
2835 COPY_SCALAR_FIELD(deferrable);
2836 COPY_SCALAR_FIELD(initdeferred);
2837 COPY_SCALAR_FIELD(concurrent);
2842 static CreateFunctionStmt *
2843 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
2845 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2847 COPY_SCALAR_FIELD(replace);
2848 COPY_NODE_FIELD(funcname);
2849 COPY_NODE_FIELD(parameters);
2850 COPY_NODE_FIELD(returnType);
2851 COPY_NODE_FIELD(options);
2852 COPY_NODE_FIELD(withClause);
2857 static FunctionParameter *
2858 _copyFunctionParameter(const FunctionParameter *from)
2860 FunctionParameter *newnode = makeNode(FunctionParameter);
2862 COPY_STRING_FIELD(name);
2863 COPY_NODE_FIELD(argType);
2864 COPY_SCALAR_FIELD(mode);
2865 COPY_NODE_FIELD(defexpr);
2870 static AlterFunctionStmt *
2871 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
2873 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2875 COPY_NODE_FIELD(func);
2876 COPY_NODE_FIELD(actions);
2882 _copyDoStmt(const DoStmt *from)
2884 DoStmt *newnode = makeNode(DoStmt);
2886 COPY_NODE_FIELD(args);
2892 _copyRenameStmt(const RenameStmt *from)
2894 RenameStmt *newnode = makeNode(RenameStmt);
2896 COPY_SCALAR_FIELD(renameType);
2897 COPY_SCALAR_FIELD(relationType);
2898 COPY_NODE_FIELD(relation);
2899 COPY_NODE_FIELD(object);
2900 COPY_NODE_FIELD(objarg);
2901 COPY_STRING_FIELD(subname);
2902 COPY_STRING_FIELD(newname);
2903 COPY_SCALAR_FIELD(behavior);
2904 COPY_SCALAR_FIELD(missing_ok);
2909 static AlterObjectSchemaStmt *
2910 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
2912 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2914 COPY_SCALAR_FIELD(objectType);
2915 COPY_NODE_FIELD(relation);
2916 COPY_NODE_FIELD(object);
2917 COPY_NODE_FIELD(objarg);
2918 COPY_STRING_FIELD(addname);
2919 COPY_STRING_FIELD(newschema);
2920 COPY_SCALAR_FIELD(missing_ok);
2925 static AlterOwnerStmt *
2926 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
2928 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2930 COPY_SCALAR_FIELD(objectType);
2931 COPY_NODE_FIELD(relation);
2932 COPY_NODE_FIELD(object);
2933 COPY_NODE_FIELD(objarg);
2934 COPY_STRING_FIELD(addname);
2935 COPY_STRING_FIELD(newowner);
2941 _copyRuleStmt(const RuleStmt *from)
2943 RuleStmt *newnode = makeNode(RuleStmt);
2945 COPY_NODE_FIELD(relation);
2946 COPY_STRING_FIELD(rulename);
2947 COPY_NODE_FIELD(whereClause);
2948 COPY_SCALAR_FIELD(event);
2949 COPY_SCALAR_FIELD(instead);
2950 COPY_NODE_FIELD(actions);
2951 COPY_SCALAR_FIELD(replace);
2957 _copyNotifyStmt(const NotifyStmt *from)
2959 NotifyStmt *newnode = makeNode(NotifyStmt);
2961 COPY_STRING_FIELD(conditionname);
2962 COPY_STRING_FIELD(payload);
2968 _copyListenStmt(const ListenStmt *from)
2970 ListenStmt *newnode = makeNode(ListenStmt);
2972 COPY_STRING_FIELD(conditionname);
2977 static UnlistenStmt *
2978 _copyUnlistenStmt(const UnlistenStmt *from)
2980 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2982 COPY_STRING_FIELD(conditionname);
2987 static TransactionStmt *
2988 _copyTransactionStmt(const TransactionStmt *from)
2990 TransactionStmt *newnode = makeNode(TransactionStmt);
2992 COPY_SCALAR_FIELD(kind);
2993 COPY_NODE_FIELD(options);
2994 COPY_STRING_FIELD(gid);
2999 static CompositeTypeStmt *
3000 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3002 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3004 COPY_NODE_FIELD(typevar);
3005 COPY_NODE_FIELD(coldeflist);
3010 static CreateEnumStmt *
3011 _copyCreateEnumStmt(const CreateEnumStmt *from)
3013 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3015 COPY_NODE_FIELD(typeName);
3016 COPY_NODE_FIELD(vals);
3021 static CreateRangeStmt *
3022 _copyCreateRangeStmt(const CreateRangeStmt *from)
3024 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3026 COPY_NODE_FIELD(typeName);
3027 COPY_NODE_FIELD(params);
3032 static AlterEnumStmt *
3033 _copyAlterEnumStmt(const AlterEnumStmt *from)
3035 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3037 COPY_NODE_FIELD(typeName);
3038 COPY_STRING_FIELD(newVal);
3039 COPY_STRING_FIELD(newValNeighbor);
3040 COPY_SCALAR_FIELD(newValIsAfter);
3046 _copyViewStmt(const ViewStmt *from)
3048 ViewStmt *newnode = makeNode(ViewStmt);
3050 COPY_NODE_FIELD(view);
3051 COPY_NODE_FIELD(aliases);
3052 COPY_NODE_FIELD(query);
3053 COPY_SCALAR_FIELD(replace);
3054 COPY_NODE_FIELD(options);
3060 _copyLoadStmt(const LoadStmt *from)
3062 LoadStmt *newnode = makeNode(LoadStmt);
3064 COPY_STRING_FIELD(filename);
3069 static CreateDomainStmt *
3070 _copyCreateDomainStmt(const CreateDomainStmt *from)
3072 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3074 COPY_NODE_FIELD(domainname);
3075 COPY_NODE_FIELD(typeName);
3076 COPY_NODE_FIELD(collClause);
3077 COPY_NODE_FIELD(constraints);
3082 static CreateOpClassStmt *
3083 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3085 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3087 COPY_NODE_FIELD(opclassname);
3088 COPY_NODE_FIELD(opfamilyname);
3089 COPY_STRING_FIELD(amname);
3090 COPY_NODE_FIELD(datatype);
3091 COPY_NODE_FIELD(items);
3092 COPY_SCALAR_FIELD(isDefault);
3097 static CreateOpClassItem *
3098 _copyCreateOpClassItem(const CreateOpClassItem *from)
3100 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3102 COPY_SCALAR_FIELD(itemtype);
3103 COPY_NODE_FIELD(name);
3104 COPY_NODE_FIELD(args);
3105 COPY_SCALAR_FIELD(number);
3106 COPY_NODE_FIELD(order_family);
3107 COPY_NODE_FIELD(class_args);
3108 COPY_NODE_FIELD(storedtype);
3113 static CreateOpFamilyStmt *
3114 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3116 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3118 COPY_NODE_FIELD(opfamilyname);
3119 COPY_STRING_FIELD(amname);
3124 static AlterOpFamilyStmt *
3125 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3127 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3129 COPY_NODE_FIELD(opfamilyname);
3130 COPY_STRING_FIELD(amname);
3131 COPY_SCALAR_FIELD(isDrop);
3132 COPY_NODE_FIELD(items);
3137 static CreatedbStmt *
3138 _copyCreatedbStmt(const CreatedbStmt *from)
3140 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3142 COPY_STRING_FIELD(dbname);
3143 COPY_NODE_FIELD(options);
3148 static AlterDatabaseStmt *
3149 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3151 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3153 COPY_STRING_FIELD(dbname);
3154 COPY_NODE_FIELD(options);
3159 static AlterDatabaseSetStmt *
3160 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3162 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3164 COPY_STRING_FIELD(dbname);
3165 COPY_NODE_FIELD(setstmt);
3171 _copyDropdbStmt(const DropdbStmt *from)
3173 DropdbStmt *newnode = makeNode(DropdbStmt);
3175 COPY_STRING_FIELD(dbname);
3176 COPY_SCALAR_FIELD(missing_ok);
3182 _copyVacuumStmt(const VacuumStmt *from)
3184 VacuumStmt *newnode = makeNode(VacuumStmt);
3186 COPY_SCALAR_FIELD(options);
3187 COPY_SCALAR_FIELD(freeze_min_age);
3188 COPY_SCALAR_FIELD(freeze_table_age);
3189 COPY_NODE_FIELD(relation);
3190 COPY_NODE_FIELD(va_cols);
3195 static ExplainStmt *
3196 _copyExplainStmt(const ExplainStmt *from)
3198 ExplainStmt *newnode = makeNode(ExplainStmt);
3200 COPY_NODE_FIELD(query);
3201 COPY_NODE_FIELD(options);
3206 static CreateTableAsStmt *
3207 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3209 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3211 COPY_NODE_FIELD(query);
3212 COPY_NODE_FIELD(into);
3213 COPY_SCALAR_FIELD(is_select_into);
3218 static CreateSeqStmt *
3219 _copyCreateSeqStmt(const CreateSeqStmt *from)
3221 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3223 COPY_NODE_FIELD(sequence);
3224 COPY_NODE_FIELD(options);
3225 COPY_SCALAR_FIELD(ownerId);
3230 static AlterSeqStmt *
3231 _copyAlterSeqStmt(const AlterSeqStmt *from)
3233 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3235 COPY_NODE_FIELD(sequence);
3236 COPY_NODE_FIELD(options);
3237 COPY_SCALAR_FIELD(missing_ok);
3242 static VariableSetStmt *
3243 _copyVariableSetStmt(const VariableSetStmt *from)
3245 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3247 COPY_SCALAR_FIELD(kind);
3248 COPY_STRING_FIELD(name);
3249 COPY_NODE_FIELD(args);
3250 COPY_SCALAR_FIELD(is_local);
3255 static VariableShowStmt *
3256 _copyVariableShowStmt(const VariableShowStmt *from)
3258 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3260 COPY_STRING_FIELD(name);
3265 static DiscardStmt *
3266 _copyDiscardStmt(const DiscardStmt *from)
3268 DiscardStmt *newnode = makeNode(DiscardStmt);
3270 COPY_SCALAR_FIELD(target);
3275 static CreateTableSpaceStmt *
3276 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3278 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3280 COPY_STRING_FIELD(tablespacename);
3281 COPY_STRING_FIELD(owner);
3282 COPY_STRING_FIELD(location);
3287 static DropTableSpaceStmt *
3288 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
3290 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3292 COPY_STRING_FIELD(tablespacename);
3293 COPY_SCALAR_FIELD(missing_ok);
3298 static AlterTableSpaceOptionsStmt *
3299 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
3301 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3303 COPY_STRING_FIELD(tablespacename);
3304 COPY_NODE_FIELD(options);
3305 COPY_SCALAR_FIELD(isReset);
3310 static CreateExtensionStmt *
3311 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
3313 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3315 COPY_STRING_FIELD(extname);
3316 COPY_SCALAR_FIELD(if_not_exists);
3317 COPY_NODE_FIELD(options);
3322 static AlterExtensionStmt *
3323 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
3325 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3327 COPY_STRING_FIELD(extname);
3328 COPY_NODE_FIELD(options);
3333 static AlterExtensionContentsStmt *
3334 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
3336 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3338 COPY_STRING_FIELD(extname);
3339 COPY_SCALAR_FIELD(action);
3340 COPY_SCALAR_FIELD(objtype);
3341 COPY_NODE_FIELD(objname);
3342 COPY_NODE_FIELD(objargs);
3347 static CreateFdwStmt *
3348 _copyCreateFdwStmt(const CreateFdwStmt *from)
3350 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3352 COPY_STRING_FIELD(fdwname);
3353 COPY_NODE_FIELD(func_options);
3354 COPY_NODE_FIELD(options);
3359 static AlterFdwStmt *
3360 _copyAlterFdwStmt(const AlterFdwStmt *from)
3362 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3364 COPY_STRING_FIELD(fdwname);
3365 COPY_NODE_FIELD(func_options);
3366 COPY_NODE_FIELD(options);
3371 static CreateForeignServerStmt *
3372 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
3374 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3376 COPY_STRING_FIELD(servername);
3377 COPY_STRING_FIELD(servertype);
3378 COPY_STRING_FIELD(version);
3379 COPY_STRING_FIELD(fdwname);
3380 COPY_NODE_FIELD(options);
3385 static AlterForeignServerStmt *
3386 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
3388 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3390 COPY_STRING_FIELD(servername);
3391 COPY_STRING_FIELD(version);
3392 COPY_NODE_FIELD(options);
3393 COPY_SCALAR_FIELD(has_version);
3398 static CreateUserMappingStmt *
3399 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
3401 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3403 COPY_STRING_FIELD(username);
3404 COPY_STRING_FIELD(servername);
3405 COPY_NODE_FIELD(options);
3410 static AlterUserMappingStmt *
3411 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
3413 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3415 COPY_STRING_FIELD(username);
3416 COPY_STRING_FIELD(servername);
3417 COPY_NODE_FIELD(options);
3422 static DropUserMappingStmt *
3423 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
3425 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3427 COPY_STRING_FIELD(username);
3428 COPY_STRING_FIELD(servername);
3429 COPY_SCALAR_FIELD(missing_ok);
3434 static CreateForeignTableStmt *
3435 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
3437 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3439 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
3441 COPY_STRING_FIELD(servername);
3442 COPY_NODE_FIELD(options);
3447 static CreateTrigStmt *
3448 _copyCreateTrigStmt(const CreateTrigStmt *from)
3450 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3452 COPY_STRING_FIELD(trigname);
3453 COPY_NODE_FIELD(relation);
3454 COPY_NODE_FIELD(funcname);
3455 COPY_NODE_FIELD(args);
3456 COPY_SCALAR_FIELD(row);
3457 COPY_SCALAR_FIELD(timing);
3458 COPY_SCALAR_FIELD(events);
3459 COPY_NODE_FIELD(columns);
3460 COPY_NODE_FIELD(whenClause);
3461 COPY_SCALAR_FIELD(isconstraint);
3462 COPY_SCALAR_FIELD(deferrable);
3463 COPY_SCALAR_FIELD(initdeferred);
3464 COPY_NODE_FIELD(constrrel);
3469 static CreateEventTrigStmt *
3470 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
3472 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
3474 COPY_STRING_FIELD(trigname);
3475 COPY_SCALAR_FIELD(eventname);
3476 COPY_NODE_FIELD(whenclause);
3477 COPY_NODE_FIELD(funcname);
3482 static AlterEventTrigStmt *
3483 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
3485 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
3487 COPY_STRING_FIELD(trigname);
3488 COPY_SCALAR_FIELD(tgenabled);
3493 static CreatePLangStmt *
3494 _copyCreatePLangStmt(const CreatePLangStmt *from)
3496 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3498 COPY_SCALAR_FIELD(replace);
3499 COPY_STRING_FIELD(plname);
3500 COPY_NODE_FIELD(plhandler);
3501 COPY_NODE_FIELD(plinline);
3502 COPY_NODE_FIELD(plvalidator);
3503 COPY_SCALAR_FIELD(pltrusted);
3508 static CreateRoleStmt *
3509 _copyCreateRoleStmt(const CreateRoleStmt *from)
3511 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3513 COPY_SCALAR_FIELD(stmt_type);
3514 COPY_STRING_FIELD(role);
3515 COPY_NODE_FIELD(options);
3520 static AlterRoleStmt *
3521 _copyAlterRoleStmt(const AlterRoleStmt *from)
3523 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3525 COPY_STRING_FIELD(role);
3526 COPY_NODE_FIELD(options);
3527 COPY_SCALAR_FIELD(action);
3532 static AlterRoleSetStmt *
3533 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
3535 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3537 COPY_STRING_FIELD(role);
3538 COPY_STRING_FIELD(database);
3539 COPY_NODE_FIELD(setstmt);
3544 static DropRoleStmt *
3545 _copyDropRoleStmt(const DropRoleStmt *from)
3547 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3549 COPY_NODE_FIELD(roles);
3550 COPY_SCALAR_FIELD(missing_ok);
3556 _copyLockStmt(const LockStmt *from)
3558 LockStmt *newnode = makeNode(LockStmt);
3560 COPY_NODE_FIELD(relations);
3561 COPY_SCALAR_FIELD(mode);
3562 COPY_SCALAR_FIELD(nowait);
3567 static ConstraintsSetStmt *
3568 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
3570 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3572 COPY_NODE_FIELD(constraints);
3573 COPY_SCALAR_FIELD(deferred);
3578 static ReindexStmt *
3579 _copyReindexStmt(const ReindexStmt *from)
3581 ReindexStmt *newnode = makeNode(ReindexStmt);
3583 COPY_SCALAR_FIELD(kind);
3584 COPY_NODE_FIELD(relation);
3585 COPY_STRING_FIELD(name);
3586 COPY_SCALAR_FIELD(do_system);
3587 COPY_SCALAR_FIELD(do_user);
3592 static CreateSchemaStmt *
3593 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
3595 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3597 COPY_STRING_FIELD(schemaname);
3598 COPY_STRING_FIELD(authid);
3599 COPY_NODE_FIELD(schemaElts);
3604 static CreateConversionStmt *
3605 _copyCreateConversionStmt(const CreateConversionStmt *from)
3607 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3609 COPY_NODE_FIELD(conversion_name);
3610 COPY_STRING_FIELD(for_encoding_name);
3611 COPY_STRING_FIELD(to_encoding_name);
3612 COPY_NODE_FIELD(func_name);
3613 COPY_SCALAR_FIELD(def);
3618 static CreateCastStmt *
3619 _copyCreateCastStmt(const CreateCastStmt *from)
3621 CreateCastStmt *newnode = makeNode(CreateCastStmt);
3623 COPY_NODE_FIELD(sourcetype);
3624 COPY_NODE_FIELD(targettype);
3625 COPY_NODE_FIELD(func);
3626 COPY_SCALAR_FIELD(context);
3627 COPY_SCALAR_FIELD(inout);
3632 static PrepareStmt *
3633 _copyPrepareStmt(const PrepareStmt *from)
3635 PrepareStmt *newnode = makeNode(PrepareStmt);
3637 COPY_STRING_FIELD(name);
3638 COPY_NODE_FIELD(argtypes);
3639 COPY_NODE_FIELD(query);
3644 static ExecuteStmt *
3645 _copyExecuteStmt(const ExecuteStmt *from)
3647 ExecuteStmt *newnode = makeNode(ExecuteStmt);
3649 COPY_STRING_FIELD(name);
3650 COPY_NODE_FIELD(params);
3655 static DeallocateStmt *
3656 _copyDeallocateStmt(const DeallocateStmt *from)
3658 DeallocateStmt *newnode = makeNode(DeallocateStmt);
3660 COPY_STRING_FIELD(name);
3665 static DropOwnedStmt *
3666 _copyDropOwnedStmt(const DropOwnedStmt *from)
3668 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3670 COPY_NODE_FIELD(roles);
3671 COPY_SCALAR_FIELD(behavior);
3676 static ReassignOwnedStmt *
3677 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
3679 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3681 COPY_NODE_FIELD(roles);
3682 COPY_STRING_FIELD(newrole);
3687 static AlterTSDictionaryStmt *
3688 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
3690 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3692 COPY_NODE_FIELD(dictname);
3693 COPY_NODE_FIELD(options);
3698 static AlterTSConfigurationStmt *
3699 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
3701 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3703 COPY_NODE_FIELD(cfgname);
3704 COPY_NODE_FIELD(tokentype);
3705 COPY_NODE_FIELD(dicts);
3706 COPY_SCALAR_FIELD(override);
3707 COPY_SCALAR_FIELD(replace);
3708 COPY_SCALAR_FIELD(missing_ok);
3713 /* ****************************************************************
3714 * pg_list.h copy functions
3715 * ****************************************************************
3719 * Perform a deep copy of the specified list, using copyObject(). The
3720 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
3721 * need deep copies, so they should be copied via list_copy()
3723 #define COPY_NODE_CELL(new, old) \
3724 (new) = (ListCell *) palloc(sizeof(ListCell)); \
3725 lfirst(new) = copyObject(lfirst(old));
3728 _copyList(const List *from)
3734 Assert(list_length(from) >= 1);
3736 new = makeNode(List);
3737 new->length = from->length;
3739 COPY_NODE_CELL(new->head, from->head);
3740 prev_new = new->head;
3741 curr_old = lnext(from->head);
3745 COPY_NODE_CELL(prev_new->next, curr_old);
3746 prev_new = prev_new->next;
3747 curr_old = curr_old->next;
3749 prev_new->next = NULL;
3750 new->tail = prev_new;
3755 /* ****************************************************************
3756 * value.h copy functions
3757 * ****************************************************************
3760 _copyValue(const Value *from)
3762 Value *newnode = makeNode(Value);
3764 /* See also _copyAConst when changing this code! */
3766 COPY_SCALAR_FIELD(type);
3770 COPY_SCALAR_FIELD(val.ival);
3775 COPY_STRING_FIELD(val.str);
3781 elog(ERROR, "unrecognized node type: %d",
3791 * Create a copy of a Node tree or list. This is a "deep" copy: all
3792 * substructure is copied too, recursively.
3795 copyObject(const void *from)
3802 /* Guard against stack overflow due to overly complex expressions */
3803 check_stack_depth();
3805 switch (nodeTag(from))
3811 retval = _copyPlannedStmt(from);
3814 retval = _copyPlan(from);
3817 retval = _copyResult(from);
3820 retval = _copyModifyTable(from);
3823 retval = _copyAppend(from);
3826 retval = _copyMergeAppend(from);
3828 case T_RecursiveUnion:
3829 retval = _copyRecursiveUnion(from);
3832 retval = _copyBitmapAnd(from);
3835 retval = _copyBitmapOr(from);
3838 retval = _copyScan(from);
3841 retval = _copySeqScan(from);
3844 retval = _copyIndexScan(from);
3846 case T_IndexOnlyScan:
3847 retval = _copyIndexOnlyScan(from);
3849 case T_BitmapIndexScan:
3850 retval = _copyBitmapIndexScan(from);
3852 case T_BitmapHeapScan:
3853 retval = _copyBitmapHeapScan(from);
3856 retval = _copyTidScan(from);
3858 case T_SubqueryScan:
3859 retval = _copySubqueryScan(from);
3861 case T_FunctionScan:
3862 retval = _copyFunctionScan(from);
3865 retval = _copyValuesScan(from);
3868 retval = _copyCteScan(from);
3870 case T_WorkTableScan:
3871 retval = _copyWorkTableScan(from);
3874 retval = _copyForeignScan(from);
3877 retval = _copyJoin(from);
3880 retval = _copyNestLoop(from);
3883 retval = _copyMergeJoin(from);
3886 retval = _copyHashJoin(from);
3889 retval = _copyMaterial(from);
3892 retval = _copySort(from);
3895 retval = _copyGroup(from);
3898 retval = _copyAgg(from);
3901 retval = _copyWindowAgg(from);
3904 retval = _copyUnique(from);
3907 retval = _copyHash(from);
3910 retval = _copySetOp(from);
3913 retval = _copyLockRows(from);
3916 retval = _copyLimit(from);
3918 case T_NestLoopParam:
3919 retval = _copyNestLoopParam(from);
3922 retval = _copyPlanRowMark(from);
3924 case T_PlanInvalItem:
3925 retval = _copyPlanInvalItem(from);
3932 retval = _copyAlias(from);
3935 retval = _copyRangeVar(from);
3938 retval = _copyIntoClause(from);
3941 retval = _copyVar(from);
3944 retval = _copyConst(from);
3947 retval = _copyParam(from);
3950 retval = _copyAggref(from);
3953 retval = _copyWindowFunc(from);
3956 retval = _copyArrayRef(from);
3959 retval = _copyFuncExpr(from);
3961 case T_NamedArgExpr:
3962 retval = _copyNamedArgExpr(from);
3965 retval = _copyOpExpr(from);
3967 case T_DistinctExpr:
3968 retval = _copyDistinctExpr(from);
3971 retval = _copyNullIfExpr(from);
3973 case T_ScalarArrayOpExpr:
3974 retval = _copyScalarArrayOpExpr(from);
3977 retval = _copyBoolExpr(from);
3980 retval = _copySubLink(from);
3983 retval = _copySubPlan(from);
3985 case T_AlternativeSubPlan:
3986 retval = _copyAlternativeSubPlan(from);
3989 retval = _copyFieldSelect(from);
3992 retval = _copyFieldStore(from);
3995 retval = _copyRelabelType(from);
3998 retval = _copyCoerceViaIO(from);
4000 case T_ArrayCoerceExpr:
4001 retval = _copyArrayCoerceExpr(from);
4003 case T_ConvertRowtypeExpr:
4004 retval = _copyConvertRowtypeExpr(from);
4007 retval = _copyCollateExpr(from);
4010 retval = _copyCaseExpr(from);
4013 retval = _copyCaseWhen(from);
4015 case T_CaseTestExpr:
4016 retval = _copyCaseTestExpr(from);
4019 retval = _copyArrayExpr(from);
4022 retval = _copyRowExpr(from);
4024 case T_RowCompareExpr:
4025 retval = _copyRowCompareExpr(from);
4027 case T_CoalesceExpr:
4028 retval = _copyCoalesceExpr(from);
4031 retval = _copyMinMaxExpr(from);
4034 retval = _copyXmlExpr(from);
4037 retval = _copyNullTest(from);
4040 retval = _copyBooleanTest(from);
4042 case T_CoerceToDomain:
4043 retval = _copyCoerceToDomain(from);
4045 case T_CoerceToDomainValue:
4046 retval = _copyCoerceToDomainValue(from);
4048 case T_SetToDefault:
4049 retval = _copySetToDefault(from);
4051 case T_CurrentOfExpr:
4052 retval = _copyCurrentOfExpr(from);
4055 retval = _copyTargetEntry(from);
4058 retval = _copyRangeTblRef(from);
4061 retval = _copyJoinExpr(from);
4064 retval = _copyFromExpr(from);
4071 retval = _copyPathKey(from);
4073 case T_RestrictInfo:
4074 retval = _copyRestrictInfo(from);
4076 case T_PlaceHolderVar:
4077 retval = _copyPlaceHolderVar(from);
4079 case T_SpecialJoinInfo:
4080 retval = _copySpecialJoinInfo(from);
4082 case T_AppendRelInfo:
4083 retval = _copyAppendRelInfo(from);
4085 case T_PlaceHolderInfo:
4086 retval = _copyPlaceHolderInfo(from);
4097 retval = _copyValue(from);
4104 retval = _copyList(from);
4108 * Lists of integers and OIDs don't need to be deep-copied, so we
4109 * perform a shallow copy via list_copy()
4113 retval = list_copy(from);
4120 retval = _copyQuery(from);
4123 retval = _copyInsertStmt(from);
4126 retval = _copyDeleteStmt(from);
4129 retval = _copyUpdateStmt(from);
4132 retval = _copySelectStmt(from);
4134 case T_SetOperationStmt:
4135 retval = _copySetOperationStmt(from);
4137 case T_AlterTableStmt:
4138 retval = _copyAlterTableStmt(from);
4140 case T_AlterTableCmd:
4141 retval = _copyAlterTableCmd(from);
4143 case T_AlterDomainStmt:
4144 retval = _copyAlterDomainStmt(from);
4147 retval = _copyGrantStmt(from);
4149 case T_GrantRoleStmt:
4150 retval = _copyGrantRoleStmt(from);
4152 case T_AlterDefaultPrivilegesStmt:
4153 retval = _copyAlterDefaultPrivilegesStmt(from);
4155 case T_DeclareCursorStmt:
4156 retval = _copyDeclareCursorStmt(from);
4158 case T_ClosePortalStmt:
4159 retval = _copyClosePortalStmt(from);
4162 retval = _copyClusterStmt(from);
4165 retval = _copyCopyStmt(from);
4168 retval = _copyCreateStmt(from);
4170 case T_TableLikeClause:
4171 retval = _copyTableLikeClause(from);
4174 retval = _copyDefineStmt(from);
4177 retval = _copyDropStmt(from);
4179 case T_TruncateStmt:
4180 retval = _copyTruncateStmt(from);
4183 retval = _copyCommentStmt(from);
4185 case T_SecLabelStmt:
4186 retval = _copySecLabelStmt(from);
4189 retval = _copyFetchStmt(from);
4192 retval = _copyIndexStmt(from);
4194 case T_CreateFunctionStmt:
4195 retval = _copyCreateFunctionStmt(from);
4197 case T_FunctionParameter:
4198 retval = _copyFunctionParameter(from);
4200 case T_AlterFunctionStmt:
4201 retval = _copyAlterFunctionStmt(from);
4204 retval = _copyDoStmt(from);
4207 retval = _copyRenameStmt(from);
4209 case T_AlterObjectSchemaStmt:
4210 retval = _copyAlterObjectSchemaStmt(from);
4212 case T_AlterOwnerStmt:
4213 retval = _copyAlterOwnerStmt(from);
4216 retval = _copyRuleStmt(from);
4219 retval = _copyNotifyStmt(from);
4222 retval = _copyListenStmt(from);
4224 case T_UnlistenStmt:
4225 retval = _copyUnlistenStmt(from);
4227 case T_TransactionStmt:
4228 retval = _copyTransactionStmt(from);
4230 case T_CompositeTypeStmt:
4231 retval = _copyCompositeTypeStmt(from);
4233 case T_CreateEnumStmt:
4234 retval = _copyCreateEnumStmt(from);
4236 case T_CreateRangeStmt:
4237 retval = _copyCreateRangeStmt(from);
4239 case T_AlterEnumStmt:
4240 retval = _copyAlterEnumStmt(from);
4243 retval = _copyViewStmt(from);
4246 retval = _copyLoadStmt(from);
4248 case T_CreateDomainStmt:
4249 retval = _copyCreateDomainStmt(from);
4251 case T_CreateOpClassStmt:
4252 retval = _copyCreateOpClassStmt(from);
4254 case T_CreateOpClassItem:
4255 retval = _copyCreateOpClassItem(from);
4257 case T_CreateOpFamilyStmt:
4258 retval = _copyCreateOpFamilyStmt(from);
4260 case T_AlterOpFamilyStmt:
4261 retval = _copyAlterOpFamilyStmt(from);
4263 case T_CreatedbStmt:
4264 retval = _copyCreatedbStmt(from);
4266 case T_AlterDatabaseStmt:
4267 retval = _copyAlterDatabaseStmt(from);
4269 case T_AlterDatabaseSetStmt:
4270 retval = _copyAlterDatabaseSetStmt(from);
4273 retval = _copyDropdbStmt(from);
4276 retval = _copyVacuumStmt(from);
4279 retval = _copyExplainStmt(from);
4281 case T_CreateTableAsStmt:
4282 retval = _copyCreateTableAsStmt(from);
4284 case T_CreateSeqStmt:
4285 retval = _copyCreateSeqStmt(from);
4287 case T_AlterSeqStmt:
4288 retval = _copyAlterSeqStmt(from);
4290 case T_VariableSetStmt:
4291 retval = _copyVariableSetStmt(from);
4293 case T_VariableShowStmt:
4294 retval = _copyVariableShowStmt(from);
4297 retval = _copyDiscardStmt(from);
4299 case T_CreateTableSpaceStmt:
4300 retval = _copyCreateTableSpaceStmt(from);
4302 case T_DropTableSpaceStmt:
4303 retval = _copyDropTableSpaceStmt(from);
4305 case T_AlterTableSpaceOptionsStmt:
4306 retval = _copyAlterTableSpaceOptionsStmt(from);
4308 case T_CreateExtensionStmt:
4309 retval = _copyCreateExtensionStmt(from);
4311 case T_AlterExtensionStmt:
4312 retval = _copyAlterExtensionStmt(from);
4314 case T_AlterExtensionContentsStmt:
4315 retval = _copyAlterExtensionContentsStmt(from);
4317 case T_CreateFdwStmt:
4318 retval = _copyCreateFdwStmt(from);
4320 case T_AlterFdwStmt:
4321 retval = _copyAlterFdwStmt(from);
4323 case T_CreateForeignServerStmt:
4324 retval = _copyCreateForeignServerStmt(from);
4326 case T_AlterForeignServerStmt:
4327 retval = _copyAlterForeignServerStmt(from);
4329 case T_CreateUserMappingStmt:
4330 retval = _copyCreateUserMappingStmt(from);
4332 case T_AlterUserMappingStmt:
4333 retval = _copyAlterUserMappingStmt(from);
4335 case T_DropUserMappingStmt:
4336 retval = _copyDropUserMappingStmt(from);
4338 case T_CreateForeignTableStmt:
4339 retval = _copyCreateForeignTableStmt(from);
4341 case T_CreateTrigStmt:
4342 retval = _copyCreateTrigStmt(from);
4344 case T_CreateEventTrigStmt:
4345 retval = _copyCreateEventTrigStmt(from);
4347 case T_AlterEventTrigStmt:
4348 retval = _copyAlterEventTrigStmt(from);
4350 case T_CreatePLangStmt:
4351 retval = _copyCreatePLangStmt(from);
4353 case T_CreateRoleStmt:
4354 retval = _copyCreateRoleStmt(from);
4356 case T_AlterRoleStmt:
4357 retval = _copyAlterRoleStmt(from);
4359 case T_AlterRoleSetStmt:
4360 retval = _copyAlterRoleSetStmt(from);
4362 case T_DropRoleStmt:
4363 retval = _copyDropRoleStmt(from);
4366 retval = _copyLockStmt(from);
4368 case T_ConstraintsSetStmt:
4369 retval = _copyConstraintsSetStmt(from);
4372 retval = _copyReindexStmt(from);
4374 case T_CheckPointStmt:
4375 retval = (void *) makeNode(CheckPointStmt);
4377 case T_CreateSchemaStmt:
4378 retval = _copyCreateSchemaStmt(from);
4380 case T_CreateConversionStmt:
4381 retval = _copyCreateConversionStmt(from);
4383 case T_CreateCastStmt:
4384 retval = _copyCreateCastStmt(from);
4387 retval = _copyPrepareStmt(from);
4390 retval = _copyExecuteStmt(from);
4392 case T_DeallocateStmt:
4393 retval = _copyDeallocateStmt(from);
4395 case T_DropOwnedStmt:
4396 retval = _copyDropOwnedStmt(from);
4398 case T_ReassignOwnedStmt:
4399 retval = _copyReassignOwnedStmt(from);
4401 case T_AlterTSDictionaryStmt:
4402 retval = _copyAlterTSDictionaryStmt(from);
4404 case T_AlterTSConfigurationStmt:
4405 retval = _copyAlterTSConfigurationStmt(from);
4409 retval = _copyAExpr(from);
4412 retval = _copyColumnRef(from);
4415 retval = _copyParamRef(from);
4418 retval = _copyAConst(from);
4421 retval = _copyFuncCall(from);
4424 retval = _copyAStar(from);
4427 retval = _copyAIndices(from);
4429 case T_A_Indirection:
4430 retval = _copyA_Indirection(from);
4433 retval = _copyA_ArrayExpr(from);
4436 retval = _copyResTarget(from);
4439 retval = _copyTypeCast(from);
4441 case T_CollateClause:
4442 retval = _copyCollateClause(from);
4445 retval = _copySortBy(from);
4448 retval = _copyWindowDef(from);
4450 case T_RangeSubselect:
4451 retval = _copyRangeSubselect(from);
4453 case T_RangeFunction:
4454 retval = _copyRangeFunction(from);
4457 retval = _copyTypeName(from);
4460 retval = _copyIndexElem(from);
4463 retval = _copyColumnDef(from);
4466 retval = _copyConstraint(from);
4469 retval = _copyDefElem(from);
4471 case T_LockingClause:
4472 retval = _copyLockingClause(from);
4474 case T_RangeTblEntry:
4475 retval = _copyRangeTblEntry(from);
4477 case T_SortGroupClause:
4478 retval = _copySortGroupClause(from);
4480 case T_WindowClause:
4481 retval = _copyWindowClause(from);
4483 case T_RowMarkClause:
4484 retval = _copyRowMarkClause(from);
4487 retval = _copyWithClause(from);
4489 case T_CommonTableExpr:
4490 retval = _copyCommonTableExpr(from);
4493 retval = _copyPrivGrantee(from);
4495 case T_FuncWithArgs:
4496 retval = _copyFuncWithArgs(from);
4499 retval = _copyAccessPriv(from);
4501 case T_XmlSerialize:
4502 retval = _copyXmlSerialize(from);
4506 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4507 retval = 0; /* keep compiler quiet */