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-2011, 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 "foreign/fdwapi.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify copying of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire the convention that the local variables in a Copy routine are
36 * named 'newnode' and 'from'.
39 /* Copy a simple scalar field (int, float, bool, enum, etc) */
40 #define COPY_SCALAR_FIELD(fldname) \
41 (newnode->fldname = from->fldname)
43 /* Copy a field that is a pointer to some kind of Node or Node tree */
44 #define COPY_NODE_FIELD(fldname) \
45 (newnode->fldname = copyObject(from->fldname))
47 /* Copy a field that is a pointer to a Bitmapset */
48 #define COPY_BITMAPSET_FIELD(fldname) \
49 (newnode->fldname = bms_copy(from->fldname))
51 /* Copy a field that is a pointer to a C string, or perhaps NULL */
52 #define COPY_STRING_FIELD(fldname) \
53 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
55 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
56 #define COPY_POINTER_FIELD(fldname, sz) \
59 newnode->fldname = palloc(_size); \
60 memcpy(newnode->fldname, from->fldname, _size); \
63 /* Copy a parse location field (for Copy, this is same as scalar case) */
64 #define COPY_LOCATION_FIELD(fldname) \
65 (newnode->fldname = from->fldname)
68 /* ****************************************************************
69 * plannodes.h copy functions
70 * ****************************************************************
77 _copyPlannedStmt(PlannedStmt *from)
79 PlannedStmt *newnode = makeNode(PlannedStmt);
81 COPY_SCALAR_FIELD(commandType);
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(intoClause);
91 COPY_NODE_FIELD(subplans);
92 COPY_BITMAPSET_FIELD(rewindPlanIDs);
93 COPY_NODE_FIELD(rowMarks);
94 COPY_NODE_FIELD(relationOids);
95 COPY_NODE_FIELD(invalItems);
96 COPY_SCALAR_FIELD(nParamExec);
104 * This function copies the fields of the Plan node. It is used by
105 * all the copy functions for classes which inherit from Plan.
108 CopyPlanFields(Plan *from, Plan *newnode)
110 COPY_SCALAR_FIELD(startup_cost);
111 COPY_SCALAR_FIELD(total_cost);
112 COPY_SCALAR_FIELD(plan_rows);
113 COPY_SCALAR_FIELD(plan_width);
114 COPY_NODE_FIELD(targetlist);
115 COPY_NODE_FIELD(qual);
116 COPY_NODE_FIELD(lefttree);
117 COPY_NODE_FIELD(righttree);
118 COPY_NODE_FIELD(initPlan);
119 COPY_BITMAPSET_FIELD(extParam);
120 COPY_BITMAPSET_FIELD(allParam);
127 _copyPlan(Plan *from)
129 Plan *newnode = makeNode(Plan);
132 * copy node superclass fields
134 CopyPlanFields(from, newnode);
144 _copyResult(Result *from)
146 Result *newnode = makeNode(Result);
149 * copy node superclass fields
151 CopyPlanFields((Plan *) from, (Plan *) newnode);
154 * copy remainder of node
156 COPY_NODE_FIELD(resconstantqual);
165 _copyModifyTable(ModifyTable *from)
167 ModifyTable *newnode = makeNode(ModifyTable);
170 * copy node superclass fields
172 CopyPlanFields((Plan *) from, (Plan *) newnode);
175 * copy remainder of node
177 COPY_SCALAR_FIELD(operation);
178 COPY_SCALAR_FIELD(canSetTag);
179 COPY_NODE_FIELD(resultRelations);
180 COPY_SCALAR_FIELD(resultRelIndex);
181 COPY_NODE_FIELD(plans);
182 COPY_NODE_FIELD(returningLists);
183 COPY_NODE_FIELD(rowMarks);
184 COPY_SCALAR_FIELD(epqParam);
193 _copyAppend(Append *from)
195 Append *newnode = makeNode(Append);
198 * copy node superclass fields
200 CopyPlanFields((Plan *) from, (Plan *) newnode);
203 * copy remainder of node
205 COPY_NODE_FIELD(appendplans);
214 _copyMergeAppend(MergeAppend *from)
216 MergeAppend *newnode = makeNode(MergeAppend);
219 * copy node superclass fields
221 CopyPlanFields((Plan *) from, (Plan *) newnode);
224 * copy remainder of node
226 COPY_NODE_FIELD(mergeplans);
227 COPY_SCALAR_FIELD(numCols);
228 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
229 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
230 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
231 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
237 * _copyRecursiveUnion
239 static RecursiveUnion *
240 _copyRecursiveUnion(RecursiveUnion *from)
242 RecursiveUnion *newnode = makeNode(RecursiveUnion);
245 * copy node superclass fields
247 CopyPlanFields((Plan *) from, (Plan *) newnode);
250 * copy remainder of node
252 COPY_SCALAR_FIELD(wtParam);
253 COPY_SCALAR_FIELD(numCols);
254 if (from->numCols > 0)
256 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
257 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
259 COPY_SCALAR_FIELD(numGroups);
268 _copyBitmapAnd(BitmapAnd *from)
270 BitmapAnd *newnode = makeNode(BitmapAnd);
273 * copy node superclass fields
275 CopyPlanFields((Plan *) from, (Plan *) newnode);
278 * copy remainder of node
280 COPY_NODE_FIELD(bitmapplans);
289 _copyBitmapOr(BitmapOr *from)
291 BitmapOr *newnode = makeNode(BitmapOr);
294 * copy node superclass fields
296 CopyPlanFields((Plan *) from, (Plan *) newnode);
299 * copy remainder of node
301 COPY_NODE_FIELD(bitmapplans);
310 * This function copies the fields of the Scan node. It is used by
311 * all the copy functions for classes which inherit from Scan.
314 CopyScanFields(Scan *from, Scan *newnode)
316 CopyPlanFields((Plan *) from, (Plan *) newnode);
318 COPY_SCALAR_FIELD(scanrelid);
325 _copyScan(Scan *from)
327 Scan *newnode = makeNode(Scan);
330 * copy node superclass fields
332 CopyScanFields((Scan *) from, (Scan *) newnode);
341 _copySeqScan(SeqScan *from)
343 SeqScan *newnode = makeNode(SeqScan);
346 * copy node superclass fields
348 CopyScanFields((Scan *) from, (Scan *) newnode);
357 _copyIndexScan(IndexScan *from)
359 IndexScan *newnode = makeNode(IndexScan);
362 * copy node superclass fields
364 CopyScanFields((Scan *) from, (Scan *) newnode);
367 * copy remainder of node
369 COPY_SCALAR_FIELD(indexid);
370 COPY_NODE_FIELD(indexqual);
371 COPY_NODE_FIELD(indexqualorig);
372 COPY_NODE_FIELD(indexorderby);
373 COPY_NODE_FIELD(indexorderbyorig);
374 COPY_SCALAR_FIELD(indexorderdir);
380 * _copyBitmapIndexScan
382 static BitmapIndexScan *
383 _copyBitmapIndexScan(BitmapIndexScan *from)
385 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
388 * copy node superclass fields
390 CopyScanFields((Scan *) from, (Scan *) newnode);
393 * copy remainder of node
395 COPY_SCALAR_FIELD(indexid);
396 COPY_NODE_FIELD(indexqual);
397 COPY_NODE_FIELD(indexqualorig);
403 * _copyBitmapHeapScan
405 static BitmapHeapScan *
406 _copyBitmapHeapScan(BitmapHeapScan *from)
408 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
411 * copy node superclass fields
413 CopyScanFields((Scan *) from, (Scan *) newnode);
416 * copy remainder of node
418 COPY_NODE_FIELD(bitmapqualorig);
427 _copyTidScan(TidScan *from)
429 TidScan *newnode = makeNode(TidScan);
432 * copy node superclass fields
434 CopyScanFields((Scan *) from, (Scan *) newnode);
437 * copy remainder of node
439 COPY_NODE_FIELD(tidquals);
447 static SubqueryScan *
448 _copySubqueryScan(SubqueryScan *from)
450 SubqueryScan *newnode = makeNode(SubqueryScan);
453 * copy node superclass fields
455 CopyScanFields((Scan *) from, (Scan *) newnode);
458 * copy remainder of node
460 COPY_NODE_FIELD(subplan);
461 COPY_NODE_FIELD(subrtable);
462 COPY_NODE_FIELD(subrowmark);
470 static FunctionScan *
471 _copyFunctionScan(FunctionScan *from)
473 FunctionScan *newnode = makeNode(FunctionScan);
476 * copy node superclass fields
478 CopyScanFields((Scan *) from, (Scan *) newnode);
481 * copy remainder of node
483 COPY_NODE_FIELD(funcexpr);
484 COPY_NODE_FIELD(funccolnames);
485 COPY_NODE_FIELD(funccoltypes);
486 COPY_NODE_FIELD(funccoltypmods);
487 COPY_NODE_FIELD(funccolcollations);
496 _copyValuesScan(ValuesScan *from)
498 ValuesScan *newnode = makeNode(ValuesScan);
501 * copy node superclass fields
503 CopyScanFields((Scan *) from, (Scan *) newnode);
506 * copy remainder of node
508 COPY_NODE_FIELD(values_lists);
517 _copyCteScan(CteScan *from)
519 CteScan *newnode = makeNode(CteScan);
522 * copy node superclass fields
524 CopyScanFields((Scan *) from, (Scan *) newnode);
527 * copy remainder of node
529 COPY_SCALAR_FIELD(ctePlanId);
530 COPY_SCALAR_FIELD(cteParam);
538 static WorkTableScan *
539 _copyWorkTableScan(WorkTableScan *from)
541 WorkTableScan *newnode = makeNode(WorkTableScan);
544 * copy node superclass fields
546 CopyScanFields((Scan *) from, (Scan *) newnode);
549 * copy remainder of node
551 COPY_SCALAR_FIELD(wtParam);
560 _copyForeignScan(ForeignScan *from)
562 ForeignScan *newnode = makeNode(ForeignScan);
565 * copy node superclass fields
567 CopyScanFields((Scan *) from, (Scan *) newnode);
570 * copy remainder of node
572 COPY_SCALAR_FIELD(fsSystemCol);
573 COPY_NODE_FIELD(fdwplan);
582 _copyFdwPlan(FdwPlan *from)
584 FdwPlan *newnode = makeNode(FdwPlan);
586 COPY_SCALAR_FIELD(startup_cost);
587 COPY_SCALAR_FIELD(total_cost);
588 COPY_NODE_FIELD(fdw_private);
596 * This function copies the fields of the Join node. It is used by
597 * all the copy functions for classes which inherit from Join.
600 CopyJoinFields(Join *from, Join *newnode)
602 CopyPlanFields((Plan *) from, (Plan *) newnode);
604 COPY_SCALAR_FIELD(jointype);
605 COPY_NODE_FIELD(joinqual);
613 _copyJoin(Join *from)
615 Join *newnode = makeNode(Join);
618 * copy node superclass fields
620 CopyJoinFields(from, newnode);
630 _copyNestLoop(NestLoop *from)
632 NestLoop *newnode = makeNode(NestLoop);
635 * copy node superclass fields
637 CopyJoinFields((Join *) from, (Join *) newnode);
640 * copy remainder of node
642 COPY_NODE_FIELD(nestParams);
652 _copyMergeJoin(MergeJoin *from)
654 MergeJoin *newnode = makeNode(MergeJoin);
658 * copy node superclass fields
660 CopyJoinFields((Join *) from, (Join *) newnode);
663 * copy remainder of node
665 COPY_NODE_FIELD(mergeclauses);
666 numCols = list_length(from->mergeclauses);
667 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
668 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
669 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
670 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
679 _copyHashJoin(HashJoin *from)
681 HashJoin *newnode = makeNode(HashJoin);
684 * copy node superclass fields
686 CopyJoinFields((Join *) from, (Join *) newnode);
689 * copy remainder of node
691 COPY_NODE_FIELD(hashclauses);
701 _copyMaterial(Material *from)
703 Material *newnode = makeNode(Material);
706 * copy node superclass fields
708 CopyPlanFields((Plan *) from, (Plan *) newnode);
718 _copySort(Sort *from)
720 Sort *newnode = makeNode(Sort);
723 * copy node superclass fields
725 CopyPlanFields((Plan *) from, (Plan *) newnode);
727 COPY_SCALAR_FIELD(numCols);
728 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
729 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
730 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
731 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
741 _copyGroup(Group *from)
743 Group *newnode = makeNode(Group);
745 CopyPlanFields((Plan *) from, (Plan *) newnode);
747 COPY_SCALAR_FIELD(numCols);
748 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
749 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
760 Agg *newnode = makeNode(Agg);
762 CopyPlanFields((Plan *) from, (Plan *) newnode);
764 COPY_SCALAR_FIELD(aggstrategy);
765 COPY_SCALAR_FIELD(numCols);
766 if (from->numCols > 0)
768 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
769 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
771 COPY_SCALAR_FIELD(numGroups);
780 _copyWindowAgg(WindowAgg *from)
782 WindowAgg *newnode = makeNode(WindowAgg);
784 CopyPlanFields((Plan *) from, (Plan *) newnode);
786 COPY_SCALAR_FIELD(winref);
787 COPY_SCALAR_FIELD(partNumCols);
788 if (from->partNumCols > 0)
790 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
791 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
793 COPY_SCALAR_FIELD(ordNumCols);
794 if (from->ordNumCols > 0)
796 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
797 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
799 COPY_SCALAR_FIELD(frameOptions);
800 COPY_NODE_FIELD(startOffset);
801 COPY_NODE_FIELD(endOffset);
810 _copyUnique(Unique *from)
812 Unique *newnode = makeNode(Unique);
815 * copy node superclass fields
817 CopyPlanFields((Plan *) from, (Plan *) newnode);
820 * copy remainder of node
822 COPY_SCALAR_FIELD(numCols);
823 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
824 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
833 _copyHash(Hash *from)
835 Hash *newnode = makeNode(Hash);
838 * copy node superclass fields
840 CopyPlanFields((Plan *) from, (Plan *) newnode);
843 * copy remainder of node
845 COPY_SCALAR_FIELD(skewTable);
846 COPY_SCALAR_FIELD(skewColumn);
847 COPY_SCALAR_FIELD(skewInherit);
848 COPY_SCALAR_FIELD(skewColType);
849 COPY_SCALAR_FIELD(skewColTypmod);
858 _copySetOp(SetOp *from)
860 SetOp *newnode = makeNode(SetOp);
863 * copy node superclass fields
865 CopyPlanFields((Plan *) from, (Plan *) newnode);
868 * copy remainder of node
870 COPY_SCALAR_FIELD(cmd);
871 COPY_SCALAR_FIELD(strategy);
872 COPY_SCALAR_FIELD(numCols);
873 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
874 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
875 COPY_SCALAR_FIELD(flagColIdx);
876 COPY_SCALAR_FIELD(firstFlag);
877 COPY_SCALAR_FIELD(numGroups);
886 _copyLockRows(LockRows *from)
888 LockRows *newnode = makeNode(LockRows);
891 * copy node superclass fields
893 CopyPlanFields((Plan *) from, (Plan *) newnode);
896 * copy remainder of node
898 COPY_NODE_FIELD(rowMarks);
899 COPY_SCALAR_FIELD(epqParam);
908 _copyLimit(Limit *from)
910 Limit *newnode = makeNode(Limit);
913 * copy node superclass fields
915 CopyPlanFields((Plan *) from, (Plan *) newnode);
918 * copy remainder of node
920 COPY_NODE_FIELD(limitOffset);
921 COPY_NODE_FIELD(limitCount);
929 static NestLoopParam *
930 _copyNestLoopParam(NestLoopParam *from)
932 NestLoopParam *newnode = makeNode(NestLoopParam);
934 COPY_SCALAR_FIELD(paramno);
935 COPY_NODE_FIELD(paramval);
944 _copyPlanRowMark(PlanRowMark *from)
946 PlanRowMark *newnode = makeNode(PlanRowMark);
948 COPY_SCALAR_FIELD(rti);
949 COPY_SCALAR_FIELD(prti);
950 COPY_SCALAR_FIELD(rowmarkId);
951 COPY_SCALAR_FIELD(markType);
952 COPY_SCALAR_FIELD(noWait);
953 COPY_SCALAR_FIELD(isParent);
961 static PlanInvalItem *
962 _copyPlanInvalItem(PlanInvalItem *from)
964 PlanInvalItem *newnode = makeNode(PlanInvalItem);
966 COPY_SCALAR_FIELD(cacheId);
967 /* tupleId isn't really a "scalar", but this works anyway */
968 COPY_SCALAR_FIELD(tupleId);
973 /* ****************************************************************
974 * primnodes.h copy functions
975 * ****************************************************************
982 _copyAlias(Alias *from)
984 Alias *newnode = makeNode(Alias);
986 COPY_STRING_FIELD(aliasname);
987 COPY_NODE_FIELD(colnames);
996 _copyRangeVar(RangeVar *from)
998 RangeVar *newnode = makeNode(RangeVar);
1000 COPY_STRING_FIELD(catalogname);
1001 COPY_STRING_FIELD(schemaname);
1002 COPY_STRING_FIELD(relname);
1003 COPY_SCALAR_FIELD(inhOpt);
1004 COPY_SCALAR_FIELD(relpersistence);
1005 COPY_NODE_FIELD(alias);
1006 COPY_LOCATION_FIELD(location);
1015 _copyIntoClause(IntoClause *from)
1017 IntoClause *newnode = makeNode(IntoClause);
1019 COPY_NODE_FIELD(rel);
1020 COPY_NODE_FIELD(colNames);
1021 COPY_NODE_FIELD(options);
1022 COPY_SCALAR_FIELD(onCommit);
1023 COPY_STRING_FIELD(tableSpaceName);
1029 * We don't need a _copyExpr because Expr is an abstract supertype which
1030 * should never actually get instantiated. Also, since it has no common
1031 * fields except NodeTag, there's no need for a helper routine to factor
1032 * out copying the common fields...
1041 Var *newnode = makeNode(Var);
1043 COPY_SCALAR_FIELD(varno);
1044 COPY_SCALAR_FIELD(varattno);
1045 COPY_SCALAR_FIELD(vartype);
1046 COPY_SCALAR_FIELD(vartypmod);
1047 COPY_SCALAR_FIELD(varcollid);
1048 COPY_SCALAR_FIELD(varlevelsup);
1049 COPY_SCALAR_FIELD(varnoold);
1050 COPY_SCALAR_FIELD(varoattno);
1051 COPY_LOCATION_FIELD(location);
1060 _copyConst(Const *from)
1062 Const *newnode = makeNode(Const);
1064 COPY_SCALAR_FIELD(consttype);
1065 COPY_SCALAR_FIELD(consttypmod);
1066 COPY_SCALAR_FIELD(constcollid);
1067 COPY_SCALAR_FIELD(constlen);
1069 if (from->constbyval || from->constisnull)
1072 * passed by value so just copy the datum. Also, don't try to copy
1073 * struct when value is null!
1075 newnode->constvalue = from->constvalue;
1080 * passed by reference. We need a palloc'd copy.
1082 newnode->constvalue = datumCopy(from->constvalue,
1087 COPY_SCALAR_FIELD(constisnull);
1088 COPY_SCALAR_FIELD(constbyval);
1089 COPY_LOCATION_FIELD(location);
1098 _copyParam(Param *from)
1100 Param *newnode = makeNode(Param);
1102 COPY_SCALAR_FIELD(paramkind);
1103 COPY_SCALAR_FIELD(paramid);
1104 COPY_SCALAR_FIELD(paramtype);
1105 COPY_SCALAR_FIELD(paramtypmod);
1106 COPY_SCALAR_FIELD(paramcollid);
1107 COPY_LOCATION_FIELD(location);
1116 _copyAggref(Aggref *from)
1118 Aggref *newnode = makeNode(Aggref);
1120 COPY_SCALAR_FIELD(aggfnoid);
1121 COPY_SCALAR_FIELD(aggtype);
1122 COPY_SCALAR_FIELD(aggcollid);
1123 COPY_SCALAR_FIELD(inputcollid);
1124 COPY_NODE_FIELD(args);
1125 COPY_NODE_FIELD(aggorder);
1126 COPY_NODE_FIELD(aggdistinct);
1127 COPY_SCALAR_FIELD(aggstar);
1128 COPY_SCALAR_FIELD(agglevelsup);
1129 COPY_LOCATION_FIELD(location);
1138 _copyWindowFunc(WindowFunc *from)
1140 WindowFunc *newnode = makeNode(WindowFunc);
1142 COPY_SCALAR_FIELD(winfnoid);
1143 COPY_SCALAR_FIELD(wintype);
1144 COPY_SCALAR_FIELD(wincollid);
1145 COPY_SCALAR_FIELD(inputcollid);
1146 COPY_NODE_FIELD(args);
1147 COPY_SCALAR_FIELD(winref);
1148 COPY_SCALAR_FIELD(winstar);
1149 COPY_SCALAR_FIELD(winagg);
1150 COPY_LOCATION_FIELD(location);
1159 _copyArrayRef(ArrayRef *from)
1161 ArrayRef *newnode = makeNode(ArrayRef);
1163 COPY_SCALAR_FIELD(refarraytype);
1164 COPY_SCALAR_FIELD(refelemtype);
1165 COPY_SCALAR_FIELD(reftypmod);
1166 COPY_SCALAR_FIELD(refcollid);
1167 COPY_NODE_FIELD(refupperindexpr);
1168 COPY_NODE_FIELD(reflowerindexpr);
1169 COPY_NODE_FIELD(refexpr);
1170 COPY_NODE_FIELD(refassgnexpr);
1179 _copyFuncExpr(FuncExpr *from)
1181 FuncExpr *newnode = makeNode(FuncExpr);
1183 COPY_SCALAR_FIELD(funcid);
1184 COPY_SCALAR_FIELD(funcresulttype);
1185 COPY_SCALAR_FIELD(funcretset);
1186 COPY_SCALAR_FIELD(funcformat);
1187 COPY_SCALAR_FIELD(funccollid);
1188 COPY_SCALAR_FIELD(inputcollid);
1189 COPY_NODE_FIELD(args);
1190 COPY_LOCATION_FIELD(location);
1196 * _copyNamedArgExpr *
1198 static NamedArgExpr *
1199 _copyNamedArgExpr(NamedArgExpr *from)
1201 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1203 COPY_NODE_FIELD(arg);
1204 COPY_STRING_FIELD(name);
1205 COPY_SCALAR_FIELD(argnumber);
1206 COPY_LOCATION_FIELD(location);
1215 _copyOpExpr(OpExpr *from)
1217 OpExpr *newnode = makeNode(OpExpr);
1219 COPY_SCALAR_FIELD(opno);
1220 COPY_SCALAR_FIELD(opfuncid);
1221 COPY_SCALAR_FIELD(opresulttype);
1222 COPY_SCALAR_FIELD(opretset);
1223 COPY_SCALAR_FIELD(opcollid);
1224 COPY_SCALAR_FIELD(inputcollid);
1225 COPY_NODE_FIELD(args);
1226 COPY_LOCATION_FIELD(location);
1232 * _copyDistinctExpr (same as OpExpr)
1234 static DistinctExpr *
1235 _copyDistinctExpr(DistinctExpr *from)
1237 DistinctExpr *newnode = makeNode(DistinctExpr);
1239 COPY_SCALAR_FIELD(opno);
1240 COPY_SCALAR_FIELD(opfuncid);
1241 COPY_SCALAR_FIELD(opresulttype);
1242 COPY_SCALAR_FIELD(opretset);
1243 COPY_SCALAR_FIELD(opcollid);
1244 COPY_SCALAR_FIELD(inputcollid);
1245 COPY_NODE_FIELD(args);
1246 COPY_LOCATION_FIELD(location);
1252 * _copyNullIfExpr (same as OpExpr)
1255 _copyNullIfExpr(NullIfExpr *from)
1257 NullIfExpr *newnode = makeNode(NullIfExpr);
1259 COPY_SCALAR_FIELD(opno);
1260 COPY_SCALAR_FIELD(opfuncid);
1261 COPY_SCALAR_FIELD(opresulttype);
1262 COPY_SCALAR_FIELD(opretset);
1263 COPY_SCALAR_FIELD(opcollid);
1264 COPY_SCALAR_FIELD(inputcollid);
1265 COPY_NODE_FIELD(args);
1266 COPY_LOCATION_FIELD(location);
1272 * _copyScalarArrayOpExpr
1274 static ScalarArrayOpExpr *
1275 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
1277 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1279 COPY_SCALAR_FIELD(opno);
1280 COPY_SCALAR_FIELD(opfuncid);
1281 COPY_SCALAR_FIELD(useOr);
1282 COPY_SCALAR_FIELD(inputcollid);
1283 COPY_NODE_FIELD(args);
1284 COPY_LOCATION_FIELD(location);
1293 _copyBoolExpr(BoolExpr *from)
1295 BoolExpr *newnode = makeNode(BoolExpr);
1297 COPY_SCALAR_FIELD(boolop);
1298 COPY_NODE_FIELD(args);
1299 COPY_LOCATION_FIELD(location);
1308 _copySubLink(SubLink *from)
1310 SubLink *newnode = makeNode(SubLink);
1312 COPY_SCALAR_FIELD(subLinkType);
1313 COPY_NODE_FIELD(testexpr);
1314 COPY_NODE_FIELD(operName);
1315 COPY_NODE_FIELD(subselect);
1316 COPY_LOCATION_FIELD(location);
1325 _copySubPlan(SubPlan *from)
1327 SubPlan *newnode = makeNode(SubPlan);
1329 COPY_SCALAR_FIELD(subLinkType);
1330 COPY_NODE_FIELD(testexpr);
1331 COPY_NODE_FIELD(paramIds);
1332 COPY_SCALAR_FIELD(plan_id);
1333 COPY_STRING_FIELD(plan_name);
1334 COPY_SCALAR_FIELD(firstColType);
1335 COPY_SCALAR_FIELD(firstColTypmod);
1336 COPY_SCALAR_FIELD(firstColCollation);
1337 COPY_SCALAR_FIELD(useHashTable);
1338 COPY_SCALAR_FIELD(unknownEqFalse);
1339 COPY_NODE_FIELD(setParam);
1340 COPY_NODE_FIELD(parParam);
1341 COPY_NODE_FIELD(args);
1342 COPY_SCALAR_FIELD(startup_cost);
1343 COPY_SCALAR_FIELD(per_call_cost);
1349 * _copyAlternativeSubPlan
1351 static AlternativeSubPlan *
1352 _copyAlternativeSubPlan(AlternativeSubPlan *from)
1354 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1356 COPY_NODE_FIELD(subplans);
1364 static FieldSelect *
1365 _copyFieldSelect(FieldSelect *from)
1367 FieldSelect *newnode = makeNode(FieldSelect);
1369 COPY_NODE_FIELD(arg);
1370 COPY_SCALAR_FIELD(fieldnum);
1371 COPY_SCALAR_FIELD(resulttype);
1372 COPY_SCALAR_FIELD(resulttypmod);
1373 COPY_SCALAR_FIELD(resultcollid);
1382 _copyFieldStore(FieldStore *from)
1384 FieldStore *newnode = makeNode(FieldStore);
1386 COPY_NODE_FIELD(arg);
1387 COPY_NODE_FIELD(newvals);
1388 COPY_NODE_FIELD(fieldnums);
1389 COPY_SCALAR_FIELD(resulttype);
1397 static RelabelType *
1398 _copyRelabelType(RelabelType *from)
1400 RelabelType *newnode = makeNode(RelabelType);
1402 COPY_NODE_FIELD(arg);
1403 COPY_SCALAR_FIELD(resulttype);
1404 COPY_SCALAR_FIELD(resulttypmod);
1405 COPY_SCALAR_FIELD(resultcollid);
1406 COPY_SCALAR_FIELD(relabelformat);
1407 COPY_LOCATION_FIELD(location);
1415 static CoerceViaIO *
1416 _copyCoerceViaIO(CoerceViaIO *from)
1418 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1420 COPY_NODE_FIELD(arg);
1421 COPY_SCALAR_FIELD(resulttype);
1422 COPY_SCALAR_FIELD(resultcollid);
1423 COPY_SCALAR_FIELD(coerceformat);
1424 COPY_LOCATION_FIELD(location);
1430 * _copyArrayCoerceExpr
1432 static ArrayCoerceExpr *
1433 _copyArrayCoerceExpr(ArrayCoerceExpr *from)
1435 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1437 COPY_NODE_FIELD(arg);
1438 COPY_SCALAR_FIELD(elemfuncid);
1439 COPY_SCALAR_FIELD(resulttype);
1440 COPY_SCALAR_FIELD(resulttypmod);
1441 COPY_SCALAR_FIELD(resultcollid);
1442 COPY_SCALAR_FIELD(isExplicit);
1443 COPY_SCALAR_FIELD(coerceformat);
1444 COPY_LOCATION_FIELD(location);
1450 * _copyConvertRowtypeExpr
1452 static ConvertRowtypeExpr *
1453 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
1455 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1457 COPY_NODE_FIELD(arg);
1458 COPY_SCALAR_FIELD(resulttype);
1459 COPY_SCALAR_FIELD(convertformat);
1460 COPY_LOCATION_FIELD(location);
1468 static CollateExpr *
1469 _copyCollateExpr(CollateExpr *from)
1471 CollateExpr *newnode = makeNode(CollateExpr);
1473 COPY_NODE_FIELD(arg);
1474 COPY_SCALAR_FIELD(collOid);
1475 COPY_LOCATION_FIELD(location);
1484 _copyCaseExpr(CaseExpr *from)
1486 CaseExpr *newnode = makeNode(CaseExpr);
1488 COPY_SCALAR_FIELD(casetype);
1489 COPY_SCALAR_FIELD(casecollid);
1490 COPY_NODE_FIELD(arg);
1491 COPY_NODE_FIELD(args);
1492 COPY_NODE_FIELD(defresult);
1493 COPY_LOCATION_FIELD(location);
1502 _copyCaseWhen(CaseWhen *from)
1504 CaseWhen *newnode = makeNode(CaseWhen);
1506 COPY_NODE_FIELD(expr);
1507 COPY_NODE_FIELD(result);
1508 COPY_LOCATION_FIELD(location);
1516 static CaseTestExpr *
1517 _copyCaseTestExpr(CaseTestExpr *from)
1519 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1521 COPY_SCALAR_FIELD(typeId);
1522 COPY_SCALAR_FIELD(typeMod);
1523 COPY_SCALAR_FIELD(collation);
1532 _copyArrayExpr(ArrayExpr *from)
1534 ArrayExpr *newnode = makeNode(ArrayExpr);
1536 COPY_SCALAR_FIELD(array_typeid);
1537 COPY_SCALAR_FIELD(array_collid);
1538 COPY_SCALAR_FIELD(element_typeid);
1539 COPY_NODE_FIELD(elements);
1540 COPY_SCALAR_FIELD(multidims);
1541 COPY_LOCATION_FIELD(location);
1550 _copyRowExpr(RowExpr *from)
1552 RowExpr *newnode = makeNode(RowExpr);
1554 COPY_NODE_FIELD(args);
1555 COPY_SCALAR_FIELD(row_typeid);
1556 COPY_SCALAR_FIELD(row_format);
1557 COPY_NODE_FIELD(colnames);
1558 COPY_LOCATION_FIELD(location);
1564 * _copyRowCompareExpr
1566 static RowCompareExpr *
1567 _copyRowCompareExpr(RowCompareExpr *from)
1569 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1571 COPY_SCALAR_FIELD(rctype);
1572 COPY_NODE_FIELD(opnos);
1573 COPY_NODE_FIELD(opfamilies);
1574 COPY_NODE_FIELD(inputcollids);
1575 COPY_NODE_FIELD(largs);
1576 COPY_NODE_FIELD(rargs);
1584 static CoalesceExpr *
1585 _copyCoalesceExpr(CoalesceExpr *from)
1587 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1589 COPY_SCALAR_FIELD(coalescetype);
1590 COPY_SCALAR_FIELD(coalescecollid);
1591 COPY_NODE_FIELD(args);
1592 COPY_LOCATION_FIELD(location);
1601 _copyMinMaxExpr(MinMaxExpr *from)
1603 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1605 COPY_SCALAR_FIELD(minmaxtype);
1606 COPY_SCALAR_FIELD(minmaxcollid);
1607 COPY_SCALAR_FIELD(inputcollid);
1608 COPY_SCALAR_FIELD(op);
1609 COPY_NODE_FIELD(args);
1610 COPY_LOCATION_FIELD(location);
1619 _copyXmlExpr(XmlExpr *from)
1621 XmlExpr *newnode = makeNode(XmlExpr);
1623 COPY_SCALAR_FIELD(op);
1624 COPY_STRING_FIELD(name);
1625 COPY_NODE_FIELD(named_args);
1626 COPY_NODE_FIELD(arg_names);
1627 COPY_NODE_FIELD(args);
1628 COPY_SCALAR_FIELD(xmloption);
1629 COPY_SCALAR_FIELD(type);
1630 COPY_SCALAR_FIELD(typmod);
1631 COPY_LOCATION_FIELD(location);
1640 _copyNullTest(NullTest *from)
1642 NullTest *newnode = makeNode(NullTest);
1644 COPY_NODE_FIELD(arg);
1645 COPY_SCALAR_FIELD(nulltesttype);
1646 COPY_SCALAR_FIELD(argisrow);
1654 static BooleanTest *
1655 _copyBooleanTest(BooleanTest *from)
1657 BooleanTest *newnode = makeNode(BooleanTest);
1659 COPY_NODE_FIELD(arg);
1660 COPY_SCALAR_FIELD(booltesttype);
1666 * _copyCoerceToDomain
1668 static CoerceToDomain *
1669 _copyCoerceToDomain(CoerceToDomain *from)
1671 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1673 COPY_NODE_FIELD(arg);
1674 COPY_SCALAR_FIELD(resulttype);
1675 COPY_SCALAR_FIELD(resulttypmod);
1676 COPY_SCALAR_FIELD(resultcollid);
1677 COPY_SCALAR_FIELD(coercionformat);
1678 COPY_LOCATION_FIELD(location);
1684 * _copyCoerceToDomainValue
1686 static CoerceToDomainValue *
1687 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1689 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1691 COPY_SCALAR_FIELD(typeId);
1692 COPY_SCALAR_FIELD(typeMod);
1693 COPY_SCALAR_FIELD(collation);
1694 COPY_LOCATION_FIELD(location);
1702 static SetToDefault *
1703 _copySetToDefault(SetToDefault *from)
1705 SetToDefault *newnode = makeNode(SetToDefault);
1707 COPY_SCALAR_FIELD(typeId);
1708 COPY_SCALAR_FIELD(typeMod);
1709 COPY_SCALAR_FIELD(collation);
1710 COPY_LOCATION_FIELD(location);
1716 * _copyCurrentOfExpr
1718 static CurrentOfExpr *
1719 _copyCurrentOfExpr(CurrentOfExpr *from)
1721 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1723 COPY_SCALAR_FIELD(cvarno);
1724 COPY_STRING_FIELD(cursor_name);
1725 COPY_SCALAR_FIELD(cursor_param);
1733 static TargetEntry *
1734 _copyTargetEntry(TargetEntry *from)
1736 TargetEntry *newnode = makeNode(TargetEntry);
1738 COPY_NODE_FIELD(expr);
1739 COPY_SCALAR_FIELD(resno);
1740 COPY_STRING_FIELD(resname);
1741 COPY_SCALAR_FIELD(ressortgroupref);
1742 COPY_SCALAR_FIELD(resorigtbl);
1743 COPY_SCALAR_FIELD(resorigcol);
1744 COPY_SCALAR_FIELD(resjunk);
1752 static RangeTblRef *
1753 _copyRangeTblRef(RangeTblRef *from)
1755 RangeTblRef *newnode = makeNode(RangeTblRef);
1757 COPY_SCALAR_FIELD(rtindex);
1766 _copyJoinExpr(JoinExpr *from)
1768 JoinExpr *newnode = makeNode(JoinExpr);
1770 COPY_SCALAR_FIELD(jointype);
1771 COPY_SCALAR_FIELD(isNatural);
1772 COPY_NODE_FIELD(larg);
1773 COPY_NODE_FIELD(rarg);
1774 COPY_NODE_FIELD(usingClause);
1775 COPY_NODE_FIELD(quals);
1776 COPY_NODE_FIELD(alias);
1777 COPY_SCALAR_FIELD(rtindex);
1786 _copyFromExpr(FromExpr *from)
1788 FromExpr *newnode = makeNode(FromExpr);
1790 COPY_NODE_FIELD(fromlist);
1791 COPY_NODE_FIELD(quals);
1796 /* ****************************************************************
1797 * relation.h copy functions
1799 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1800 * There are some subsidiary structs that are useful to copy, though.
1801 * ****************************************************************
1808 _copyPathKey(PathKey *from)
1810 PathKey *newnode = makeNode(PathKey);
1812 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1813 COPY_SCALAR_FIELD(pk_eclass);
1814 COPY_SCALAR_FIELD(pk_opfamily);
1815 COPY_SCALAR_FIELD(pk_strategy);
1816 COPY_SCALAR_FIELD(pk_nulls_first);
1824 static RestrictInfo *
1825 _copyRestrictInfo(RestrictInfo *from)
1827 RestrictInfo *newnode = makeNode(RestrictInfo);
1829 COPY_NODE_FIELD(clause);
1830 COPY_SCALAR_FIELD(is_pushed_down);
1831 COPY_SCALAR_FIELD(outerjoin_delayed);
1832 COPY_SCALAR_FIELD(can_join);
1833 COPY_SCALAR_FIELD(pseudoconstant);
1834 COPY_BITMAPSET_FIELD(clause_relids);
1835 COPY_BITMAPSET_FIELD(required_relids);
1836 COPY_BITMAPSET_FIELD(nullable_relids);
1837 COPY_BITMAPSET_FIELD(left_relids);
1838 COPY_BITMAPSET_FIELD(right_relids);
1839 COPY_NODE_FIELD(orclause);
1840 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1841 COPY_SCALAR_FIELD(parent_ec);
1842 COPY_SCALAR_FIELD(eval_cost);
1843 COPY_SCALAR_FIELD(norm_selec);
1844 COPY_SCALAR_FIELD(outer_selec);
1845 COPY_NODE_FIELD(mergeopfamilies);
1846 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1847 COPY_SCALAR_FIELD(left_ec);
1848 COPY_SCALAR_FIELD(right_ec);
1849 COPY_SCALAR_FIELD(left_em);
1850 COPY_SCALAR_FIELD(right_em);
1851 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1852 newnode->scansel_cache = NIL;
1853 COPY_SCALAR_FIELD(outer_is_left);
1854 COPY_SCALAR_FIELD(hashjoinoperator);
1855 COPY_SCALAR_FIELD(left_bucketsize);
1856 COPY_SCALAR_FIELD(right_bucketsize);
1862 * _copyPlaceHolderVar
1864 static PlaceHolderVar *
1865 _copyPlaceHolderVar(PlaceHolderVar *from)
1867 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
1869 COPY_NODE_FIELD(phexpr);
1870 COPY_BITMAPSET_FIELD(phrels);
1871 COPY_SCALAR_FIELD(phid);
1872 COPY_SCALAR_FIELD(phlevelsup);
1878 * _copySpecialJoinInfo
1880 static SpecialJoinInfo *
1881 _copySpecialJoinInfo(SpecialJoinInfo *from)
1883 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
1885 COPY_BITMAPSET_FIELD(min_lefthand);
1886 COPY_BITMAPSET_FIELD(min_righthand);
1887 COPY_BITMAPSET_FIELD(syn_lefthand);
1888 COPY_BITMAPSET_FIELD(syn_righthand);
1889 COPY_SCALAR_FIELD(jointype);
1890 COPY_SCALAR_FIELD(lhs_strict);
1891 COPY_SCALAR_FIELD(delay_upper_joins);
1892 COPY_NODE_FIELD(join_quals);
1898 * _copyAppendRelInfo
1900 static AppendRelInfo *
1901 _copyAppendRelInfo(AppendRelInfo *from)
1903 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1905 COPY_SCALAR_FIELD(parent_relid);
1906 COPY_SCALAR_FIELD(child_relid);
1907 COPY_SCALAR_FIELD(parent_reltype);
1908 COPY_SCALAR_FIELD(child_reltype);
1909 COPY_NODE_FIELD(translated_vars);
1910 COPY_SCALAR_FIELD(parent_reloid);
1916 * _copyPlaceHolderInfo
1918 static PlaceHolderInfo *
1919 _copyPlaceHolderInfo(PlaceHolderInfo *from)
1921 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
1923 COPY_SCALAR_FIELD(phid);
1924 COPY_NODE_FIELD(ph_var);
1925 COPY_BITMAPSET_FIELD(ph_eval_at);
1926 COPY_BITMAPSET_FIELD(ph_needed);
1927 COPY_BITMAPSET_FIELD(ph_may_need);
1928 COPY_SCALAR_FIELD(ph_width);
1933 /* ****************************************************************
1934 * parsenodes.h copy functions
1935 * ****************************************************************
1938 static RangeTblEntry *
1939 _copyRangeTblEntry(RangeTblEntry *from)
1941 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1943 COPY_SCALAR_FIELD(rtekind);
1944 COPY_SCALAR_FIELD(relid);
1945 COPY_SCALAR_FIELD(relkind);
1946 COPY_NODE_FIELD(subquery);
1947 COPY_SCALAR_FIELD(jointype);
1948 COPY_NODE_FIELD(joinaliasvars);
1949 COPY_NODE_FIELD(funcexpr);
1950 COPY_NODE_FIELD(funccoltypes);
1951 COPY_NODE_FIELD(funccoltypmods);
1952 COPY_NODE_FIELD(funccolcollations);
1953 COPY_NODE_FIELD(values_lists);
1954 COPY_NODE_FIELD(values_collations);
1955 COPY_STRING_FIELD(ctename);
1956 COPY_SCALAR_FIELD(ctelevelsup);
1957 COPY_SCALAR_FIELD(self_reference);
1958 COPY_NODE_FIELD(ctecoltypes);
1959 COPY_NODE_FIELD(ctecoltypmods);
1960 COPY_NODE_FIELD(ctecolcollations);
1961 COPY_NODE_FIELD(alias);
1962 COPY_NODE_FIELD(eref);
1963 COPY_SCALAR_FIELD(inh);
1964 COPY_SCALAR_FIELD(inFromCl);
1965 COPY_SCALAR_FIELD(requiredPerms);
1966 COPY_SCALAR_FIELD(checkAsUser);
1967 COPY_BITMAPSET_FIELD(selectedCols);
1968 COPY_BITMAPSET_FIELD(modifiedCols);
1973 static SortGroupClause *
1974 _copySortGroupClause(SortGroupClause *from)
1976 SortGroupClause *newnode = makeNode(SortGroupClause);
1978 COPY_SCALAR_FIELD(tleSortGroupRef);
1979 COPY_SCALAR_FIELD(eqop);
1980 COPY_SCALAR_FIELD(sortop);
1981 COPY_SCALAR_FIELD(nulls_first);
1982 COPY_SCALAR_FIELD(hashable);
1987 static WindowClause *
1988 _copyWindowClause(WindowClause *from)
1990 WindowClause *newnode = makeNode(WindowClause);
1992 COPY_STRING_FIELD(name);
1993 COPY_STRING_FIELD(refname);
1994 COPY_NODE_FIELD(partitionClause);
1995 COPY_NODE_FIELD(orderClause);
1996 COPY_SCALAR_FIELD(frameOptions);
1997 COPY_NODE_FIELD(startOffset);
1998 COPY_NODE_FIELD(endOffset);
1999 COPY_SCALAR_FIELD(winref);
2000 COPY_SCALAR_FIELD(copiedOrder);
2005 static RowMarkClause *
2006 _copyRowMarkClause(RowMarkClause *from)
2008 RowMarkClause *newnode = makeNode(RowMarkClause);
2010 COPY_SCALAR_FIELD(rti);
2011 COPY_SCALAR_FIELD(forUpdate);
2012 COPY_SCALAR_FIELD(noWait);
2013 COPY_SCALAR_FIELD(pushedDown);
2019 _copyWithClause(WithClause *from)
2021 WithClause *newnode = makeNode(WithClause);
2023 COPY_NODE_FIELD(ctes);
2024 COPY_SCALAR_FIELD(recursive);
2025 COPY_LOCATION_FIELD(location);
2030 static CommonTableExpr *
2031 _copyCommonTableExpr(CommonTableExpr *from)
2033 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2035 COPY_STRING_FIELD(ctename);
2036 COPY_NODE_FIELD(aliascolnames);
2037 COPY_NODE_FIELD(ctequery);
2038 COPY_LOCATION_FIELD(location);
2039 COPY_SCALAR_FIELD(cterecursive);
2040 COPY_SCALAR_FIELD(cterefcount);
2041 COPY_NODE_FIELD(ctecolnames);
2042 COPY_NODE_FIELD(ctecoltypes);
2043 COPY_NODE_FIELD(ctecoltypmods);
2044 COPY_NODE_FIELD(ctecolcollations);
2050 _copyAExpr(A_Expr *from)
2052 A_Expr *newnode = makeNode(A_Expr);
2054 COPY_SCALAR_FIELD(kind);
2055 COPY_NODE_FIELD(name);
2056 COPY_NODE_FIELD(lexpr);
2057 COPY_NODE_FIELD(rexpr);
2058 COPY_LOCATION_FIELD(location);
2064 _copyColumnRef(ColumnRef *from)
2066 ColumnRef *newnode = makeNode(ColumnRef);
2068 COPY_NODE_FIELD(fields);
2069 COPY_LOCATION_FIELD(location);
2075 _copyParamRef(ParamRef *from)
2077 ParamRef *newnode = makeNode(ParamRef);
2079 COPY_SCALAR_FIELD(number);
2080 COPY_LOCATION_FIELD(location);
2086 _copyAConst(A_Const *from)
2088 A_Const *newnode = makeNode(A_Const);
2090 /* This part must duplicate _copyValue */
2091 COPY_SCALAR_FIELD(val.type);
2092 switch (from->val.type)
2095 COPY_SCALAR_FIELD(val.val.ival);
2100 COPY_STRING_FIELD(val.val.str);
2106 elog(ERROR, "unrecognized node type: %d",
2107 (int) from->val.type);
2111 COPY_LOCATION_FIELD(location);
2117 _copyFuncCall(FuncCall *from)
2119 FuncCall *newnode = makeNode(FuncCall);
2121 COPY_NODE_FIELD(funcname);
2122 COPY_NODE_FIELD(args);
2123 COPY_NODE_FIELD(agg_order);
2124 COPY_SCALAR_FIELD(agg_star);
2125 COPY_SCALAR_FIELD(agg_distinct);
2126 COPY_SCALAR_FIELD(func_variadic);
2127 COPY_NODE_FIELD(over);
2128 COPY_LOCATION_FIELD(location);
2134 _copyAStar(A_Star *from)
2136 A_Star *newnode = makeNode(A_Star);
2142 _copyAIndices(A_Indices *from)
2144 A_Indices *newnode = makeNode(A_Indices);
2146 COPY_NODE_FIELD(lidx);
2147 COPY_NODE_FIELD(uidx);
2152 static A_Indirection *
2153 _copyA_Indirection(A_Indirection *from)
2155 A_Indirection *newnode = makeNode(A_Indirection);
2157 COPY_NODE_FIELD(arg);
2158 COPY_NODE_FIELD(indirection);
2163 static A_ArrayExpr *
2164 _copyA_ArrayExpr(A_ArrayExpr *from)
2166 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2168 COPY_NODE_FIELD(elements);
2169 COPY_LOCATION_FIELD(location);
2175 _copyResTarget(ResTarget *from)
2177 ResTarget *newnode = makeNode(ResTarget);
2179 COPY_STRING_FIELD(name);
2180 COPY_NODE_FIELD(indirection);
2181 COPY_NODE_FIELD(val);
2182 COPY_LOCATION_FIELD(location);
2188 _copyTypeName(TypeName *from)
2190 TypeName *newnode = makeNode(TypeName);
2192 COPY_NODE_FIELD(names);
2193 COPY_SCALAR_FIELD(typeOid);
2194 COPY_SCALAR_FIELD(setof);
2195 COPY_SCALAR_FIELD(pct_type);
2196 COPY_NODE_FIELD(typmods);
2197 COPY_SCALAR_FIELD(typemod);
2198 COPY_NODE_FIELD(arrayBounds);
2199 COPY_LOCATION_FIELD(location);
2205 _copySortBy(SortBy *from)
2207 SortBy *newnode = makeNode(SortBy);
2209 COPY_NODE_FIELD(node);
2210 COPY_SCALAR_FIELD(sortby_dir);
2211 COPY_SCALAR_FIELD(sortby_nulls);
2212 COPY_NODE_FIELD(useOp);
2213 COPY_LOCATION_FIELD(location);
2219 _copyWindowDef(WindowDef *from)
2221 WindowDef *newnode = makeNode(WindowDef);
2223 COPY_STRING_FIELD(name);
2224 COPY_STRING_FIELD(refname);
2225 COPY_NODE_FIELD(partitionClause);
2226 COPY_NODE_FIELD(orderClause);
2227 COPY_SCALAR_FIELD(frameOptions);
2228 COPY_NODE_FIELD(startOffset);
2229 COPY_NODE_FIELD(endOffset);
2230 COPY_LOCATION_FIELD(location);
2235 static RangeSubselect *
2236 _copyRangeSubselect(RangeSubselect *from)
2238 RangeSubselect *newnode = makeNode(RangeSubselect);
2240 COPY_NODE_FIELD(subquery);
2241 COPY_NODE_FIELD(alias);
2246 static RangeFunction *
2247 _copyRangeFunction(RangeFunction *from)
2249 RangeFunction *newnode = makeNode(RangeFunction);
2251 COPY_NODE_FIELD(funccallnode);
2252 COPY_NODE_FIELD(alias);
2253 COPY_NODE_FIELD(coldeflist);
2259 _copyTypeCast(TypeCast *from)
2261 TypeCast *newnode = makeNode(TypeCast);
2263 COPY_NODE_FIELD(arg);
2264 COPY_NODE_FIELD(typeName);
2265 COPY_LOCATION_FIELD(location);
2270 static CollateClause *
2271 _copyCollateClause(CollateClause *from)
2273 CollateClause *newnode = makeNode(CollateClause);
2275 COPY_NODE_FIELD(arg);
2276 COPY_NODE_FIELD(collname);
2277 COPY_LOCATION_FIELD(location);
2283 _copyIndexElem(IndexElem *from)
2285 IndexElem *newnode = makeNode(IndexElem);
2287 COPY_STRING_FIELD(name);
2288 COPY_NODE_FIELD(expr);
2289 COPY_STRING_FIELD(indexcolname);
2290 COPY_NODE_FIELD(collation);
2291 COPY_NODE_FIELD(opclass);
2292 COPY_SCALAR_FIELD(ordering);
2293 COPY_SCALAR_FIELD(nulls_ordering);
2299 _copyColumnDef(ColumnDef *from)
2301 ColumnDef *newnode = makeNode(ColumnDef);
2303 COPY_STRING_FIELD(colname);
2304 COPY_NODE_FIELD(typeName);
2305 COPY_SCALAR_FIELD(inhcount);
2306 COPY_SCALAR_FIELD(is_local);
2307 COPY_SCALAR_FIELD(is_not_null);
2308 COPY_SCALAR_FIELD(is_from_type);
2309 COPY_SCALAR_FIELD(storage);
2310 COPY_NODE_FIELD(raw_default);
2311 COPY_NODE_FIELD(cooked_default);
2312 COPY_NODE_FIELD(collClause);
2313 COPY_SCALAR_FIELD(collOid);
2314 COPY_NODE_FIELD(constraints);
2320 _copyConstraint(Constraint *from)
2322 Constraint *newnode = makeNode(Constraint);
2324 COPY_SCALAR_FIELD(contype);
2325 COPY_STRING_FIELD(conname);
2326 COPY_SCALAR_FIELD(deferrable);
2327 COPY_SCALAR_FIELD(initdeferred);
2328 COPY_LOCATION_FIELD(location);
2329 COPY_NODE_FIELD(raw_expr);
2330 COPY_STRING_FIELD(cooked_expr);
2331 COPY_NODE_FIELD(keys);
2332 COPY_NODE_FIELD(exclusions);
2333 COPY_NODE_FIELD(options);
2334 COPY_STRING_FIELD(indexname);
2335 COPY_STRING_FIELD(indexspace);
2336 COPY_STRING_FIELD(access_method);
2337 COPY_NODE_FIELD(where_clause);
2338 COPY_NODE_FIELD(pktable);
2339 COPY_NODE_FIELD(fk_attrs);
2340 COPY_NODE_FIELD(pk_attrs);
2341 COPY_SCALAR_FIELD(fk_matchtype);
2342 COPY_SCALAR_FIELD(fk_upd_action);
2343 COPY_SCALAR_FIELD(fk_del_action);
2344 COPY_SCALAR_FIELD(skip_validation);
2345 COPY_SCALAR_FIELD(initially_valid);
2351 _copyDefElem(DefElem *from)
2353 DefElem *newnode = makeNode(DefElem);
2355 COPY_STRING_FIELD(defnamespace);
2356 COPY_STRING_FIELD(defname);
2357 COPY_NODE_FIELD(arg);
2358 COPY_SCALAR_FIELD(defaction);
2363 static LockingClause *
2364 _copyLockingClause(LockingClause *from)
2366 LockingClause *newnode = makeNode(LockingClause);
2368 COPY_NODE_FIELD(lockedRels);
2369 COPY_SCALAR_FIELD(forUpdate);
2370 COPY_SCALAR_FIELD(noWait);
2375 static XmlSerialize *
2376 _copyXmlSerialize(XmlSerialize *from)
2378 XmlSerialize *newnode = makeNode(XmlSerialize);
2380 COPY_SCALAR_FIELD(xmloption);
2381 COPY_NODE_FIELD(expr);
2382 COPY_NODE_FIELD(typeName);
2383 COPY_LOCATION_FIELD(location);
2389 _copyQuery(Query *from)
2391 Query *newnode = makeNode(Query);
2393 COPY_SCALAR_FIELD(commandType);
2394 COPY_SCALAR_FIELD(querySource);
2395 COPY_SCALAR_FIELD(canSetTag);
2396 COPY_NODE_FIELD(utilityStmt);
2397 COPY_SCALAR_FIELD(resultRelation);
2398 COPY_NODE_FIELD(intoClause);
2399 COPY_SCALAR_FIELD(hasAggs);
2400 COPY_SCALAR_FIELD(hasWindowFuncs);
2401 COPY_SCALAR_FIELD(hasSubLinks);
2402 COPY_SCALAR_FIELD(hasDistinctOn);
2403 COPY_SCALAR_FIELD(hasRecursive);
2404 COPY_SCALAR_FIELD(hasModifyingCTE);
2405 COPY_SCALAR_FIELD(hasForUpdate);
2406 COPY_NODE_FIELD(cteList);
2407 COPY_NODE_FIELD(rtable);
2408 COPY_NODE_FIELD(jointree);
2409 COPY_NODE_FIELD(targetList);
2410 COPY_NODE_FIELD(returningList);
2411 COPY_NODE_FIELD(groupClause);
2412 COPY_NODE_FIELD(havingQual);
2413 COPY_NODE_FIELD(windowClause);
2414 COPY_NODE_FIELD(distinctClause);
2415 COPY_NODE_FIELD(sortClause);
2416 COPY_NODE_FIELD(limitOffset);
2417 COPY_NODE_FIELD(limitCount);
2418 COPY_NODE_FIELD(rowMarks);
2419 COPY_NODE_FIELD(setOperations);
2420 COPY_NODE_FIELD(constraintDeps);
2426 _copyInsertStmt(InsertStmt *from)
2428 InsertStmt *newnode = makeNode(InsertStmt);
2430 COPY_NODE_FIELD(relation);
2431 COPY_NODE_FIELD(cols);
2432 COPY_NODE_FIELD(selectStmt);
2433 COPY_NODE_FIELD(returningList);
2434 COPY_NODE_FIELD(withClause);
2440 _copyDeleteStmt(DeleteStmt *from)
2442 DeleteStmt *newnode = makeNode(DeleteStmt);
2444 COPY_NODE_FIELD(relation);
2445 COPY_NODE_FIELD(usingClause);
2446 COPY_NODE_FIELD(whereClause);
2447 COPY_NODE_FIELD(returningList);
2448 COPY_NODE_FIELD(withClause);
2454 _copyUpdateStmt(UpdateStmt *from)
2456 UpdateStmt *newnode = makeNode(UpdateStmt);
2458 COPY_NODE_FIELD(relation);
2459 COPY_NODE_FIELD(targetList);
2460 COPY_NODE_FIELD(whereClause);
2461 COPY_NODE_FIELD(fromClause);
2462 COPY_NODE_FIELD(returningList);
2463 COPY_NODE_FIELD(withClause);
2469 _copySelectStmt(SelectStmt *from)
2471 SelectStmt *newnode = makeNode(SelectStmt);
2473 COPY_NODE_FIELD(distinctClause);
2474 COPY_NODE_FIELD(intoClause);
2475 COPY_NODE_FIELD(targetList);
2476 COPY_NODE_FIELD(fromClause);
2477 COPY_NODE_FIELD(whereClause);
2478 COPY_NODE_FIELD(groupClause);
2479 COPY_NODE_FIELD(havingClause);
2480 COPY_NODE_FIELD(windowClause);
2481 COPY_NODE_FIELD(withClause);
2482 COPY_NODE_FIELD(valuesLists);
2483 COPY_NODE_FIELD(sortClause);
2484 COPY_NODE_FIELD(limitOffset);
2485 COPY_NODE_FIELD(limitCount);
2486 COPY_NODE_FIELD(lockingClause);
2487 COPY_SCALAR_FIELD(op);
2488 COPY_SCALAR_FIELD(all);
2489 COPY_NODE_FIELD(larg);
2490 COPY_NODE_FIELD(rarg);
2495 static SetOperationStmt *
2496 _copySetOperationStmt(SetOperationStmt *from)
2498 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2500 COPY_SCALAR_FIELD(op);
2501 COPY_SCALAR_FIELD(all);
2502 COPY_NODE_FIELD(larg);
2503 COPY_NODE_FIELD(rarg);
2504 COPY_NODE_FIELD(colTypes);
2505 COPY_NODE_FIELD(colTypmods);
2506 COPY_NODE_FIELD(colCollations);
2507 COPY_NODE_FIELD(groupClauses);
2512 static AlterTableStmt *
2513 _copyAlterTableStmt(AlterTableStmt *from)
2515 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2517 COPY_NODE_FIELD(relation);
2518 COPY_NODE_FIELD(cmds);
2519 COPY_SCALAR_FIELD(relkind);
2524 static AlterTableCmd *
2525 _copyAlterTableCmd(AlterTableCmd *from)
2527 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2529 COPY_SCALAR_FIELD(subtype);
2530 COPY_STRING_FIELD(name);
2531 COPY_NODE_FIELD(def);
2532 COPY_SCALAR_FIELD(behavior);
2533 COPY_SCALAR_FIELD(missing_ok);
2538 static AlterDomainStmt *
2539 _copyAlterDomainStmt(AlterDomainStmt *from)
2541 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2543 COPY_SCALAR_FIELD(subtype);
2544 COPY_NODE_FIELD(typeName);
2545 COPY_STRING_FIELD(name);
2546 COPY_NODE_FIELD(def);
2547 COPY_SCALAR_FIELD(behavior);
2553 _copyGrantStmt(GrantStmt *from)
2555 GrantStmt *newnode = makeNode(GrantStmt);
2557 COPY_SCALAR_FIELD(is_grant);
2558 COPY_SCALAR_FIELD(targtype);
2559 COPY_SCALAR_FIELD(objtype);
2560 COPY_NODE_FIELD(objects);
2561 COPY_NODE_FIELD(privileges);
2562 COPY_NODE_FIELD(grantees);
2563 COPY_SCALAR_FIELD(grant_option);
2564 COPY_SCALAR_FIELD(behavior);
2569 static PrivGrantee *
2570 _copyPrivGrantee(PrivGrantee *from)
2572 PrivGrantee *newnode = makeNode(PrivGrantee);
2574 COPY_STRING_FIELD(rolname);
2579 static FuncWithArgs *
2580 _copyFuncWithArgs(FuncWithArgs *from)
2582 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2584 COPY_NODE_FIELD(funcname);
2585 COPY_NODE_FIELD(funcargs);
2591 _copyAccessPriv(AccessPriv *from)
2593 AccessPriv *newnode = makeNode(AccessPriv);
2595 COPY_STRING_FIELD(priv_name);
2596 COPY_NODE_FIELD(cols);
2601 static GrantRoleStmt *
2602 _copyGrantRoleStmt(GrantRoleStmt *from)
2604 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2606 COPY_NODE_FIELD(granted_roles);
2607 COPY_NODE_FIELD(grantee_roles);
2608 COPY_SCALAR_FIELD(is_grant);
2609 COPY_SCALAR_FIELD(admin_opt);
2610 COPY_STRING_FIELD(grantor);
2611 COPY_SCALAR_FIELD(behavior);
2616 static AlterDefaultPrivilegesStmt *
2617 _copyAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *from)
2619 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2621 COPY_NODE_FIELD(options);
2622 COPY_NODE_FIELD(action);
2627 static DeclareCursorStmt *
2628 _copyDeclareCursorStmt(DeclareCursorStmt *from)
2630 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2632 COPY_STRING_FIELD(portalname);
2633 COPY_SCALAR_FIELD(options);
2634 COPY_NODE_FIELD(query);
2639 static ClosePortalStmt *
2640 _copyClosePortalStmt(ClosePortalStmt *from)
2642 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2644 COPY_STRING_FIELD(portalname);
2649 static ClusterStmt *
2650 _copyClusterStmt(ClusterStmt *from)
2652 ClusterStmt *newnode = makeNode(ClusterStmt);
2654 COPY_NODE_FIELD(relation);
2655 COPY_STRING_FIELD(indexname);
2656 COPY_SCALAR_FIELD(verbose);
2662 _copyCopyStmt(CopyStmt *from)
2664 CopyStmt *newnode = makeNode(CopyStmt);
2666 COPY_NODE_FIELD(relation);
2667 COPY_NODE_FIELD(query);
2668 COPY_NODE_FIELD(attlist);
2669 COPY_SCALAR_FIELD(is_from);
2670 COPY_STRING_FIELD(filename);
2671 COPY_NODE_FIELD(options);
2677 * CopyCreateStmtFields
2679 * This function copies the fields of the CreateStmt node. It is used by
2680 * copy functions for classes which inherit from CreateStmt.
2683 CopyCreateStmtFields(CreateStmt *from, CreateStmt *newnode)
2685 COPY_NODE_FIELD(relation);
2686 COPY_NODE_FIELD(tableElts);
2687 COPY_NODE_FIELD(inhRelations);
2688 COPY_NODE_FIELD(ofTypename);
2689 COPY_NODE_FIELD(constraints);
2690 COPY_NODE_FIELD(options);
2691 COPY_SCALAR_FIELD(oncommit);
2692 COPY_STRING_FIELD(tablespacename);
2693 COPY_SCALAR_FIELD(if_not_exists);
2697 _copyCreateStmt(CreateStmt *from)
2699 CreateStmt *newnode = makeNode(CreateStmt);
2701 CopyCreateStmtFields(from, newnode);
2706 static InhRelation *
2707 _copyInhRelation(InhRelation *from)
2709 InhRelation *newnode = makeNode(InhRelation);
2711 COPY_NODE_FIELD(relation);
2712 COPY_SCALAR_FIELD(options);
2718 _copyDefineStmt(DefineStmt *from)
2720 DefineStmt *newnode = makeNode(DefineStmt);
2722 COPY_SCALAR_FIELD(kind);
2723 COPY_SCALAR_FIELD(oldstyle);
2724 COPY_NODE_FIELD(defnames);
2725 COPY_NODE_FIELD(args);
2726 COPY_NODE_FIELD(definition);
2732 _copyDropStmt(DropStmt *from)
2734 DropStmt *newnode = makeNode(DropStmt);
2736 COPY_NODE_FIELD(objects);
2737 COPY_SCALAR_FIELD(removeType);
2738 COPY_SCALAR_FIELD(behavior);
2739 COPY_SCALAR_FIELD(missing_ok);
2744 static TruncateStmt *
2745 _copyTruncateStmt(TruncateStmt *from)
2747 TruncateStmt *newnode = makeNode(TruncateStmt);
2749 COPY_NODE_FIELD(relations);
2750 COPY_SCALAR_FIELD(restart_seqs);
2751 COPY_SCALAR_FIELD(behavior);
2756 static CommentStmt *
2757 _copyCommentStmt(CommentStmt *from)
2759 CommentStmt *newnode = makeNode(CommentStmt);
2761 COPY_SCALAR_FIELD(objtype);
2762 COPY_NODE_FIELD(objname);
2763 COPY_NODE_FIELD(objargs);
2764 COPY_STRING_FIELD(comment);
2769 static SecLabelStmt *
2770 _copySecLabelStmt(SecLabelStmt *from)
2772 SecLabelStmt *newnode = makeNode(SecLabelStmt);
2774 COPY_SCALAR_FIELD(objtype);
2775 COPY_NODE_FIELD(objname);
2776 COPY_NODE_FIELD(objargs);
2777 COPY_STRING_FIELD(provider);
2778 COPY_STRING_FIELD(label);
2784 _copyFetchStmt(FetchStmt *from)
2786 FetchStmt *newnode = makeNode(FetchStmt);
2788 COPY_SCALAR_FIELD(direction);
2789 COPY_SCALAR_FIELD(howMany);
2790 COPY_STRING_FIELD(portalname);
2791 COPY_SCALAR_FIELD(ismove);
2797 _copyIndexStmt(IndexStmt *from)
2799 IndexStmt *newnode = makeNode(IndexStmt);
2801 COPY_STRING_FIELD(idxname);
2802 COPY_NODE_FIELD(relation);
2803 COPY_STRING_FIELD(accessMethod);
2804 COPY_STRING_FIELD(tableSpace);
2805 COPY_NODE_FIELD(indexParams);
2806 COPY_NODE_FIELD(options);
2807 COPY_NODE_FIELD(whereClause);
2808 COPY_NODE_FIELD(excludeOpNames);
2809 COPY_SCALAR_FIELD(indexOid);
2810 COPY_SCALAR_FIELD(unique);
2811 COPY_SCALAR_FIELD(primary);
2812 COPY_SCALAR_FIELD(isconstraint);
2813 COPY_SCALAR_FIELD(deferrable);
2814 COPY_SCALAR_FIELD(initdeferred);
2815 COPY_SCALAR_FIELD(concurrent);
2820 static CreateFunctionStmt *
2821 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2823 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2825 COPY_SCALAR_FIELD(replace);
2826 COPY_NODE_FIELD(funcname);
2827 COPY_NODE_FIELD(parameters);
2828 COPY_NODE_FIELD(returnType);
2829 COPY_NODE_FIELD(options);
2830 COPY_NODE_FIELD(withClause);
2835 static FunctionParameter *
2836 _copyFunctionParameter(FunctionParameter *from)
2838 FunctionParameter *newnode = makeNode(FunctionParameter);
2840 COPY_STRING_FIELD(name);
2841 COPY_NODE_FIELD(argType);
2842 COPY_SCALAR_FIELD(mode);
2843 COPY_NODE_FIELD(defexpr);
2848 static AlterFunctionStmt *
2849 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2851 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2853 COPY_NODE_FIELD(func);
2854 COPY_NODE_FIELD(actions);
2859 static RemoveFuncStmt *
2860 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2862 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2864 COPY_SCALAR_FIELD(kind);
2865 COPY_NODE_FIELD(name);
2866 COPY_NODE_FIELD(args);
2867 COPY_SCALAR_FIELD(behavior);
2868 COPY_SCALAR_FIELD(missing_ok);
2874 _copyDoStmt(DoStmt *from)
2876 DoStmt *newnode = makeNode(DoStmt);
2878 COPY_NODE_FIELD(args);
2883 static RemoveOpClassStmt *
2884 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2886 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2888 COPY_NODE_FIELD(opclassname);
2889 COPY_STRING_FIELD(amname);
2890 COPY_SCALAR_FIELD(behavior);
2891 COPY_SCALAR_FIELD(missing_ok);
2896 static RemoveOpFamilyStmt *
2897 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2899 RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2901 COPY_NODE_FIELD(opfamilyname);
2902 COPY_STRING_FIELD(amname);
2903 COPY_SCALAR_FIELD(behavior);
2904 COPY_SCALAR_FIELD(missing_ok);
2910 _copyRenameStmt(RenameStmt *from)
2912 RenameStmt *newnode = makeNode(RenameStmt);
2914 COPY_SCALAR_FIELD(renameType);
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);
2925 static AlterObjectSchemaStmt *
2926 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2928 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
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(newschema);
2940 static AlterOwnerStmt *
2941 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2943 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2945 COPY_SCALAR_FIELD(objectType);
2946 COPY_NODE_FIELD(relation);
2947 COPY_NODE_FIELD(object);
2948 COPY_NODE_FIELD(objarg);
2949 COPY_STRING_FIELD(addname);
2950 COPY_STRING_FIELD(newowner);
2956 _copyRuleStmt(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(NotifyStmt *from)
2974 NotifyStmt *newnode = makeNode(NotifyStmt);
2976 COPY_STRING_FIELD(conditionname);
2977 COPY_STRING_FIELD(payload);
2983 _copyListenStmt(ListenStmt *from)
2985 ListenStmt *newnode = makeNode(ListenStmt);
2987 COPY_STRING_FIELD(conditionname);
2992 static UnlistenStmt *
2993 _copyUnlistenStmt(UnlistenStmt *from)
2995 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2997 COPY_STRING_FIELD(conditionname);
3002 static TransactionStmt *
3003 _copyTransactionStmt(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(CompositeTypeStmt *from)
3017 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3019 COPY_NODE_FIELD(typevar);
3020 COPY_NODE_FIELD(coldeflist);
3025 static CreateEnumStmt *
3026 _copyCreateEnumStmt(CreateEnumStmt *from)
3028 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3030 COPY_NODE_FIELD(typeName);
3031 COPY_NODE_FIELD(vals);
3036 static AlterEnumStmt *
3037 _copyAlterEnumStmt(AlterEnumStmt *from)
3039 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3041 COPY_NODE_FIELD(typeName);
3042 COPY_STRING_FIELD(newVal);
3043 COPY_STRING_FIELD(newValNeighbor);
3044 COPY_SCALAR_FIELD(newValIsAfter);
3050 _copyViewStmt(ViewStmt *from)
3052 ViewStmt *newnode = makeNode(ViewStmt);
3054 COPY_NODE_FIELD(view);
3055 COPY_NODE_FIELD(aliases);
3056 COPY_NODE_FIELD(query);
3057 COPY_SCALAR_FIELD(replace);
3063 _copyLoadStmt(LoadStmt *from)
3065 LoadStmt *newnode = makeNode(LoadStmt);
3067 COPY_STRING_FIELD(filename);
3072 static CreateDomainStmt *
3073 _copyCreateDomainStmt(CreateDomainStmt *from)
3075 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3077 COPY_NODE_FIELD(domainname);
3078 COPY_NODE_FIELD(typeName);
3079 COPY_NODE_FIELD(collClause);
3080 COPY_NODE_FIELD(constraints);
3085 static CreateOpClassStmt *
3086 _copyCreateOpClassStmt(CreateOpClassStmt *from)
3088 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3090 COPY_NODE_FIELD(opclassname);
3091 COPY_NODE_FIELD(opfamilyname);
3092 COPY_STRING_FIELD(amname);
3093 COPY_NODE_FIELD(datatype);
3094 COPY_NODE_FIELD(items);
3095 COPY_SCALAR_FIELD(isDefault);
3100 static CreateOpClassItem *
3101 _copyCreateOpClassItem(CreateOpClassItem *from)
3103 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3105 COPY_SCALAR_FIELD(itemtype);
3106 COPY_NODE_FIELD(name);
3107 COPY_NODE_FIELD(args);
3108 COPY_SCALAR_FIELD(number);
3109 COPY_NODE_FIELD(order_family);
3110 COPY_NODE_FIELD(class_args);
3111 COPY_NODE_FIELD(storedtype);
3116 static CreateOpFamilyStmt *
3117 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
3119 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3121 COPY_NODE_FIELD(opfamilyname);
3122 COPY_STRING_FIELD(amname);
3127 static AlterOpFamilyStmt *
3128 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
3130 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3132 COPY_NODE_FIELD(opfamilyname);
3133 COPY_STRING_FIELD(amname);
3134 COPY_SCALAR_FIELD(isDrop);
3135 COPY_NODE_FIELD(items);
3140 static CreatedbStmt *
3141 _copyCreatedbStmt(CreatedbStmt *from)
3143 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3145 COPY_STRING_FIELD(dbname);
3146 COPY_NODE_FIELD(options);
3151 static AlterDatabaseStmt *
3152 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
3154 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3156 COPY_STRING_FIELD(dbname);
3157 COPY_NODE_FIELD(options);
3162 static AlterDatabaseSetStmt *
3163 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
3165 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3167 COPY_STRING_FIELD(dbname);
3168 COPY_NODE_FIELD(setstmt);
3174 _copyDropdbStmt(DropdbStmt *from)
3176 DropdbStmt *newnode = makeNode(DropdbStmt);
3178 COPY_STRING_FIELD(dbname);
3179 COPY_SCALAR_FIELD(missing_ok);
3185 _copyVacuumStmt(VacuumStmt *from)
3187 VacuumStmt *newnode = makeNode(VacuumStmt);
3189 COPY_SCALAR_FIELD(options);
3190 COPY_SCALAR_FIELD(freeze_min_age);
3191 COPY_SCALAR_FIELD(freeze_table_age);
3192 COPY_NODE_FIELD(relation);
3193 COPY_NODE_FIELD(va_cols);
3198 static ExplainStmt *
3199 _copyExplainStmt(ExplainStmt *from)
3201 ExplainStmt *newnode = makeNode(ExplainStmt);
3203 COPY_NODE_FIELD(query);
3204 COPY_NODE_FIELD(options);
3209 static CreateSeqStmt *
3210 _copyCreateSeqStmt(CreateSeqStmt *from)
3212 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3214 COPY_NODE_FIELD(sequence);
3215 COPY_NODE_FIELD(options);
3216 COPY_SCALAR_FIELD(ownerId);
3221 static AlterSeqStmt *
3222 _copyAlterSeqStmt(AlterSeqStmt *from)
3224 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3226 COPY_NODE_FIELD(sequence);
3227 COPY_NODE_FIELD(options);
3232 static VariableSetStmt *
3233 _copyVariableSetStmt(VariableSetStmt *from)
3235 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3237 COPY_SCALAR_FIELD(kind);
3238 COPY_STRING_FIELD(name);
3239 COPY_NODE_FIELD(args);
3240 COPY_SCALAR_FIELD(is_local);
3245 static VariableShowStmt *
3246 _copyVariableShowStmt(VariableShowStmt *from)
3248 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3250 COPY_STRING_FIELD(name);
3255 static DiscardStmt *
3256 _copyDiscardStmt(DiscardStmt *from)
3258 DiscardStmt *newnode = makeNode(DiscardStmt);
3260 COPY_SCALAR_FIELD(target);
3265 static CreateTableSpaceStmt *
3266 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
3268 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3270 COPY_STRING_FIELD(tablespacename);
3271 COPY_STRING_FIELD(owner);
3272 COPY_STRING_FIELD(location);
3277 static DropTableSpaceStmt *
3278 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
3280 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3282 COPY_STRING_FIELD(tablespacename);
3283 COPY_SCALAR_FIELD(missing_ok);
3288 static AlterTableSpaceOptionsStmt *
3289 _copyAlterTableSpaceOptionsStmt(AlterTableSpaceOptionsStmt *from)
3291 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3293 COPY_STRING_FIELD(tablespacename);
3294 COPY_NODE_FIELD(options);
3295 COPY_SCALAR_FIELD(isReset);
3300 static CreateExtensionStmt *
3301 _copyCreateExtensionStmt(CreateExtensionStmt *from)
3303 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3305 COPY_STRING_FIELD(extname);
3306 COPY_SCALAR_FIELD(if_not_exists);
3307 COPY_NODE_FIELD(options);
3312 static AlterExtensionStmt *
3313 _copyAlterExtensionStmt(AlterExtensionStmt *from)
3315 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3317 COPY_STRING_FIELD(extname);
3318 COPY_NODE_FIELD(options);
3323 static AlterExtensionContentsStmt *
3324 _copyAlterExtensionContentsStmt(AlterExtensionContentsStmt *from)
3326 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3328 COPY_STRING_FIELD(extname);
3329 COPY_SCALAR_FIELD(action);
3330 COPY_SCALAR_FIELD(objtype);
3331 COPY_NODE_FIELD(objname);
3332 COPY_NODE_FIELD(objargs);
3337 static CreateFdwStmt *
3338 _copyCreateFdwStmt(CreateFdwStmt *from)
3340 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3342 COPY_STRING_FIELD(fdwname);
3343 COPY_NODE_FIELD(func_options);
3344 COPY_NODE_FIELD(options);
3349 static AlterFdwStmt *
3350 _copyAlterFdwStmt(AlterFdwStmt *from)
3352 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3354 COPY_STRING_FIELD(fdwname);
3355 COPY_NODE_FIELD(func_options);
3356 COPY_NODE_FIELD(options);
3361 static DropFdwStmt *
3362 _copyDropFdwStmt(DropFdwStmt *from)
3364 DropFdwStmt *newnode = makeNode(DropFdwStmt);
3366 COPY_STRING_FIELD(fdwname);
3367 COPY_SCALAR_FIELD(missing_ok);
3368 COPY_SCALAR_FIELD(behavior);
3373 static CreateForeignServerStmt *
3374 _copyCreateForeignServerStmt(CreateForeignServerStmt *from)
3376 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3378 COPY_STRING_FIELD(servername);
3379 COPY_STRING_FIELD(servertype);
3380 COPY_STRING_FIELD(version);
3381 COPY_STRING_FIELD(fdwname);
3382 COPY_NODE_FIELD(options);
3387 static AlterForeignServerStmt *
3388 _copyAlterForeignServerStmt(AlterForeignServerStmt *from)
3390 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3392 COPY_STRING_FIELD(servername);
3393 COPY_STRING_FIELD(version);
3394 COPY_NODE_FIELD(options);
3395 COPY_SCALAR_FIELD(has_version);
3400 static DropForeignServerStmt *
3401 _copyDropForeignServerStmt(DropForeignServerStmt *from)
3403 DropForeignServerStmt *newnode = makeNode(DropForeignServerStmt);
3405 COPY_STRING_FIELD(servername);
3406 COPY_SCALAR_FIELD(missing_ok);
3407 COPY_SCALAR_FIELD(behavior);
3412 static CreateUserMappingStmt *
3413 _copyCreateUserMappingStmt(CreateUserMappingStmt *from)
3415 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3417 COPY_STRING_FIELD(username);
3418 COPY_STRING_FIELD(servername);
3419 COPY_NODE_FIELD(options);
3424 static AlterUserMappingStmt *
3425 _copyAlterUserMappingStmt(AlterUserMappingStmt *from)
3427 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3429 COPY_STRING_FIELD(username);
3430 COPY_STRING_FIELD(servername);
3431 COPY_NODE_FIELD(options);
3436 static DropUserMappingStmt *
3437 _copyDropUserMappingStmt(DropUserMappingStmt *from)
3439 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3441 COPY_STRING_FIELD(username);
3442 COPY_STRING_FIELD(servername);
3443 COPY_SCALAR_FIELD(missing_ok);
3448 static CreateForeignTableStmt *
3449 _copyCreateForeignTableStmt(CreateForeignTableStmt *from)
3451 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3453 CopyCreateStmtFields((CreateStmt *) from, (CreateStmt *) newnode);
3455 COPY_STRING_FIELD(servername);
3456 COPY_NODE_FIELD(options);
3461 static CreateTrigStmt *
3462 _copyCreateTrigStmt(CreateTrigStmt *from)
3464 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3466 COPY_STRING_FIELD(trigname);
3467 COPY_NODE_FIELD(relation);
3468 COPY_NODE_FIELD(funcname);
3469 COPY_NODE_FIELD(args);
3470 COPY_SCALAR_FIELD(row);
3471 COPY_SCALAR_FIELD(timing);
3472 COPY_SCALAR_FIELD(events);
3473 COPY_NODE_FIELD(columns);
3474 COPY_NODE_FIELD(whenClause);
3475 COPY_SCALAR_FIELD(isconstraint);
3476 COPY_SCALAR_FIELD(deferrable);
3477 COPY_SCALAR_FIELD(initdeferred);
3478 COPY_NODE_FIELD(constrrel);
3483 static DropPropertyStmt *
3484 _copyDropPropertyStmt(DropPropertyStmt *from)
3486 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
3488 COPY_NODE_FIELD(relation);
3489 COPY_STRING_FIELD(property);
3490 COPY_SCALAR_FIELD(removeType);
3491 COPY_SCALAR_FIELD(behavior);
3492 COPY_SCALAR_FIELD(missing_ok);
3497 static CreatePLangStmt *
3498 _copyCreatePLangStmt(CreatePLangStmt *from)
3500 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3502 COPY_SCALAR_FIELD(replace);
3503 COPY_STRING_FIELD(plname);
3504 COPY_NODE_FIELD(plhandler);
3505 COPY_NODE_FIELD(plinline);
3506 COPY_NODE_FIELD(plvalidator);
3507 COPY_SCALAR_FIELD(pltrusted);
3512 static DropPLangStmt *
3513 _copyDropPLangStmt(DropPLangStmt *from)
3515 DropPLangStmt *newnode = makeNode(DropPLangStmt);
3517 COPY_STRING_FIELD(plname);
3518 COPY_SCALAR_FIELD(behavior);
3519 COPY_SCALAR_FIELD(missing_ok);
3524 static CreateRoleStmt *
3525 _copyCreateRoleStmt(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(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(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(DropRoleStmt *from)
3563 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3565 COPY_NODE_FIELD(roles);
3566 COPY_SCALAR_FIELD(missing_ok);
3572 _copyLockStmt(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(ConstraintsSetStmt *from)
3586 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3588 COPY_NODE_FIELD(constraints);
3589 COPY_SCALAR_FIELD(deferred);
3594 static ReindexStmt *
3595 _copyReindexStmt(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(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(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(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 DropCastStmt *
3649 _copyDropCastStmt(DropCastStmt *from)
3651 DropCastStmt *newnode = makeNode(DropCastStmt);
3653 COPY_NODE_FIELD(sourcetype);
3654 COPY_NODE_FIELD(targettype);
3655 COPY_SCALAR_FIELD(behavior);
3656 COPY_SCALAR_FIELD(missing_ok);
3661 static PrepareStmt *
3662 _copyPrepareStmt(PrepareStmt *from)
3664 PrepareStmt *newnode = makeNode(PrepareStmt);
3666 COPY_STRING_FIELD(name);
3667 COPY_NODE_FIELD(argtypes);
3668 COPY_NODE_FIELD(query);
3673 static ExecuteStmt *
3674 _copyExecuteStmt(ExecuteStmt *from)
3676 ExecuteStmt *newnode = makeNode(ExecuteStmt);
3678 COPY_STRING_FIELD(name);
3679 COPY_NODE_FIELD(into);
3680 COPY_NODE_FIELD(params);
3685 static DeallocateStmt *
3686 _copyDeallocateStmt(DeallocateStmt *from)
3688 DeallocateStmt *newnode = makeNode(DeallocateStmt);
3690 COPY_STRING_FIELD(name);
3695 static DropOwnedStmt *
3696 _copyDropOwnedStmt(DropOwnedStmt *from)
3698 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3700 COPY_NODE_FIELD(roles);
3701 COPY_SCALAR_FIELD(behavior);
3706 static ReassignOwnedStmt *
3707 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
3709 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3711 COPY_NODE_FIELD(roles);
3712 COPY_SCALAR_FIELD(newrole);
3717 static AlterTSDictionaryStmt *
3718 _copyAlterTSDictionaryStmt(AlterTSDictionaryStmt *from)
3720 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3722 COPY_NODE_FIELD(dictname);
3723 COPY_NODE_FIELD(options);
3728 static AlterTSConfigurationStmt *
3729 _copyAlterTSConfigurationStmt(AlterTSConfigurationStmt *from)
3731 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3733 COPY_NODE_FIELD(cfgname);
3734 COPY_NODE_FIELD(tokentype);
3735 COPY_NODE_FIELD(dicts);
3736 COPY_SCALAR_FIELD(override);
3737 COPY_SCALAR_FIELD(replace);
3738 COPY_SCALAR_FIELD(missing_ok);
3743 /* ****************************************************************
3744 * pg_list.h copy functions
3745 * ****************************************************************
3749 * Perform a deep copy of the specified list, using copyObject(). The
3750 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
3751 * need deep copies, so they should be copied via list_copy()
3753 #define COPY_NODE_CELL(new, old) \
3754 (new) = (ListCell *) palloc(sizeof(ListCell)); \
3755 lfirst(new) = copyObject(lfirst(old));
3758 _copyList(List *from)
3764 Assert(list_length(from) >= 1);
3766 new = makeNode(List);
3767 new->length = from->length;
3769 COPY_NODE_CELL(new->head, from->head);
3770 prev_new = new->head;
3771 curr_old = lnext(from->head);
3775 COPY_NODE_CELL(prev_new->next, curr_old);
3776 prev_new = prev_new->next;
3777 curr_old = curr_old->next;
3779 prev_new->next = NULL;
3780 new->tail = prev_new;
3785 /* ****************************************************************
3786 * value.h copy functions
3787 * ****************************************************************
3790 _copyValue(Value *from)
3792 Value *newnode = makeNode(Value);
3794 /* See also _copyAConst when changing this code! */
3796 COPY_SCALAR_FIELD(type);
3800 COPY_SCALAR_FIELD(val.ival);
3805 COPY_STRING_FIELD(val.str);
3811 elog(ERROR, "unrecognized node type: %d",
3821 * Create a copy of a Node tree or list. This is a "deep" copy: all
3822 * substructure is copied too, recursively.
3825 copyObject(void *from)
3832 /* Guard against stack overflow due to overly complex expressions */
3833 check_stack_depth();
3835 switch (nodeTag(from))
3841 retval = _copyPlannedStmt(from);
3844 retval = _copyPlan(from);
3847 retval = _copyResult(from);
3850 retval = _copyModifyTable(from);
3853 retval = _copyAppend(from);
3856 retval = _copyMergeAppend(from);
3858 case T_RecursiveUnion:
3859 retval = _copyRecursiveUnion(from);
3862 retval = _copyBitmapAnd(from);
3865 retval = _copyBitmapOr(from);
3868 retval = _copyScan(from);
3871 retval = _copySeqScan(from);
3874 retval = _copyIndexScan(from);
3876 case T_BitmapIndexScan:
3877 retval = _copyBitmapIndexScan(from);
3879 case T_BitmapHeapScan:
3880 retval = _copyBitmapHeapScan(from);
3883 retval = _copyTidScan(from);
3885 case T_SubqueryScan:
3886 retval = _copySubqueryScan(from);
3888 case T_FunctionScan:
3889 retval = _copyFunctionScan(from);
3892 retval = _copyValuesScan(from);
3895 retval = _copyCteScan(from);
3897 case T_WorkTableScan:
3898 retval = _copyWorkTableScan(from);
3901 retval = _copyForeignScan(from);
3904 retval = _copyFdwPlan(from);
3907 retval = _copyJoin(from);
3910 retval = _copyNestLoop(from);
3913 retval = _copyMergeJoin(from);
3916 retval = _copyHashJoin(from);
3919 retval = _copyMaterial(from);
3922 retval = _copySort(from);
3925 retval = _copyGroup(from);
3928 retval = _copyAgg(from);
3931 retval = _copyWindowAgg(from);
3934 retval = _copyUnique(from);
3937 retval = _copyHash(from);
3940 retval = _copySetOp(from);
3943 retval = _copyLockRows(from);
3946 retval = _copyLimit(from);
3948 case T_NestLoopParam:
3949 retval = _copyNestLoopParam(from);
3952 retval = _copyPlanRowMark(from);
3954 case T_PlanInvalItem:
3955 retval = _copyPlanInvalItem(from);
3962 retval = _copyAlias(from);
3965 retval = _copyRangeVar(from);
3968 retval = _copyIntoClause(from);
3971 retval = _copyVar(from);
3974 retval = _copyConst(from);
3977 retval = _copyParam(from);
3980 retval = _copyAggref(from);
3983 retval = _copyWindowFunc(from);
3986 retval = _copyArrayRef(from);
3989 retval = _copyFuncExpr(from);
3991 case T_NamedArgExpr:
3992 retval = _copyNamedArgExpr(from);
3995 retval = _copyOpExpr(from);
3997 case T_DistinctExpr:
3998 retval = _copyDistinctExpr(from);
4001 retval = _copyNullIfExpr(from);
4003 case T_ScalarArrayOpExpr:
4004 retval = _copyScalarArrayOpExpr(from);
4007 retval = _copyBoolExpr(from);
4010 retval = _copySubLink(from);
4013 retval = _copySubPlan(from);
4015 case T_AlternativeSubPlan:
4016 retval = _copyAlternativeSubPlan(from);
4019 retval = _copyFieldSelect(from);
4022 retval = _copyFieldStore(from);
4025 retval = _copyRelabelType(from);
4028 retval = _copyCoerceViaIO(from);
4030 case T_ArrayCoerceExpr:
4031 retval = _copyArrayCoerceExpr(from);
4033 case T_ConvertRowtypeExpr:
4034 retval = _copyConvertRowtypeExpr(from);
4037 retval = _copyCollateExpr(from);
4040 retval = _copyCaseExpr(from);
4043 retval = _copyCaseWhen(from);
4045 case T_CaseTestExpr:
4046 retval = _copyCaseTestExpr(from);
4049 retval = _copyArrayExpr(from);
4052 retval = _copyRowExpr(from);
4054 case T_RowCompareExpr:
4055 retval = _copyRowCompareExpr(from);
4057 case T_CoalesceExpr:
4058 retval = _copyCoalesceExpr(from);
4061 retval = _copyMinMaxExpr(from);
4064 retval = _copyXmlExpr(from);
4067 retval = _copyNullTest(from);
4070 retval = _copyBooleanTest(from);
4072 case T_CoerceToDomain:
4073 retval = _copyCoerceToDomain(from);
4075 case T_CoerceToDomainValue:
4076 retval = _copyCoerceToDomainValue(from);
4078 case T_SetToDefault:
4079 retval = _copySetToDefault(from);
4081 case T_CurrentOfExpr:
4082 retval = _copyCurrentOfExpr(from);
4085 retval = _copyTargetEntry(from);
4088 retval = _copyRangeTblRef(from);
4091 retval = _copyJoinExpr(from);
4094 retval = _copyFromExpr(from);
4101 retval = _copyPathKey(from);
4103 case T_RestrictInfo:
4104 retval = _copyRestrictInfo(from);
4106 case T_PlaceHolderVar:
4107 retval = _copyPlaceHolderVar(from);
4109 case T_SpecialJoinInfo:
4110 retval = _copySpecialJoinInfo(from);
4112 case T_AppendRelInfo:
4113 retval = _copyAppendRelInfo(from);
4115 case T_PlaceHolderInfo:
4116 retval = _copyPlaceHolderInfo(from);
4127 retval = _copyValue(from);
4134 retval = _copyList(from);
4138 * Lists of integers and OIDs don't need to be deep-copied, so we
4139 * perform a shallow copy via list_copy()
4143 retval = list_copy(from);
4150 retval = _copyQuery(from);
4153 retval = _copyInsertStmt(from);
4156 retval = _copyDeleteStmt(from);
4159 retval = _copyUpdateStmt(from);
4162 retval = _copySelectStmt(from);
4164 case T_SetOperationStmt:
4165 retval = _copySetOperationStmt(from);
4167 case T_AlterTableStmt:
4168 retval = _copyAlterTableStmt(from);
4170 case T_AlterTableCmd:
4171 retval = _copyAlterTableCmd(from);
4173 case T_AlterDomainStmt:
4174 retval = _copyAlterDomainStmt(from);
4177 retval = _copyGrantStmt(from);
4179 case T_GrantRoleStmt:
4180 retval = _copyGrantRoleStmt(from);
4182 case T_AlterDefaultPrivilegesStmt:
4183 retval = _copyAlterDefaultPrivilegesStmt(from);
4185 case T_DeclareCursorStmt:
4186 retval = _copyDeclareCursorStmt(from);
4188 case T_ClosePortalStmt:
4189 retval = _copyClosePortalStmt(from);
4192 retval = _copyClusterStmt(from);
4195 retval = _copyCopyStmt(from);
4198 retval = _copyCreateStmt(from);
4201 retval = _copyInhRelation(from);
4204 retval = _copyDefineStmt(from);
4207 retval = _copyDropStmt(from);
4209 case T_TruncateStmt:
4210 retval = _copyTruncateStmt(from);
4213 retval = _copyCommentStmt(from);
4215 case T_SecLabelStmt:
4216 retval = _copySecLabelStmt(from);
4219 retval = _copyFetchStmt(from);
4222 retval = _copyIndexStmt(from);
4224 case T_CreateFunctionStmt:
4225 retval = _copyCreateFunctionStmt(from);
4227 case T_FunctionParameter:
4228 retval = _copyFunctionParameter(from);
4230 case T_AlterFunctionStmt:
4231 retval = _copyAlterFunctionStmt(from);
4233 case T_RemoveFuncStmt:
4234 retval = _copyRemoveFuncStmt(from);
4237 retval = _copyDoStmt(from);
4239 case T_RemoveOpClassStmt:
4240 retval = _copyRemoveOpClassStmt(from);
4242 case T_RemoveOpFamilyStmt:
4243 retval = _copyRemoveOpFamilyStmt(from);
4246 retval = _copyRenameStmt(from);
4248 case T_AlterObjectSchemaStmt:
4249 retval = _copyAlterObjectSchemaStmt(from);
4251 case T_AlterOwnerStmt:
4252 retval = _copyAlterOwnerStmt(from);
4255 retval = _copyRuleStmt(from);
4258 retval = _copyNotifyStmt(from);
4261 retval = _copyListenStmt(from);
4263 case T_UnlistenStmt:
4264 retval = _copyUnlistenStmt(from);
4266 case T_TransactionStmt:
4267 retval = _copyTransactionStmt(from);
4269 case T_CompositeTypeStmt:
4270 retval = _copyCompositeTypeStmt(from);
4272 case T_CreateEnumStmt:
4273 retval = _copyCreateEnumStmt(from);
4275 case T_AlterEnumStmt:
4276 retval = _copyAlterEnumStmt(from);
4279 retval = _copyViewStmt(from);
4282 retval = _copyLoadStmt(from);
4284 case T_CreateDomainStmt:
4285 retval = _copyCreateDomainStmt(from);
4287 case T_CreateOpClassStmt:
4288 retval = _copyCreateOpClassStmt(from);
4290 case T_CreateOpClassItem:
4291 retval = _copyCreateOpClassItem(from);
4293 case T_CreateOpFamilyStmt:
4294 retval = _copyCreateOpFamilyStmt(from);
4296 case T_AlterOpFamilyStmt:
4297 retval = _copyAlterOpFamilyStmt(from);
4299 case T_CreatedbStmt:
4300 retval = _copyCreatedbStmt(from);
4302 case T_AlterDatabaseStmt:
4303 retval = _copyAlterDatabaseStmt(from);
4305 case T_AlterDatabaseSetStmt:
4306 retval = _copyAlterDatabaseSetStmt(from);
4309 retval = _copyDropdbStmt(from);
4312 retval = _copyVacuumStmt(from);
4315 retval = _copyExplainStmt(from);
4317 case T_CreateSeqStmt:
4318 retval = _copyCreateSeqStmt(from);
4320 case T_AlterSeqStmt:
4321 retval = _copyAlterSeqStmt(from);
4323 case T_VariableSetStmt:
4324 retval = _copyVariableSetStmt(from);
4326 case T_VariableShowStmt:
4327 retval = _copyVariableShowStmt(from);
4330 retval = _copyDiscardStmt(from);
4332 case T_CreateTableSpaceStmt:
4333 retval = _copyCreateTableSpaceStmt(from);
4335 case T_DropTableSpaceStmt:
4336 retval = _copyDropTableSpaceStmt(from);
4338 case T_AlterTableSpaceOptionsStmt:
4339 retval = _copyAlterTableSpaceOptionsStmt(from);
4341 case T_CreateExtensionStmt:
4342 retval = _copyCreateExtensionStmt(from);
4344 case T_AlterExtensionStmt:
4345 retval = _copyAlterExtensionStmt(from);
4347 case T_AlterExtensionContentsStmt:
4348 retval = _copyAlterExtensionContentsStmt(from);
4350 case T_CreateFdwStmt:
4351 retval = _copyCreateFdwStmt(from);
4353 case T_AlterFdwStmt:
4354 retval = _copyAlterFdwStmt(from);
4357 retval = _copyDropFdwStmt(from);
4359 case T_CreateForeignServerStmt:
4360 retval = _copyCreateForeignServerStmt(from);
4362 case T_AlterForeignServerStmt:
4363 retval = _copyAlterForeignServerStmt(from);
4365 case T_DropForeignServerStmt:
4366 retval = _copyDropForeignServerStmt(from);
4368 case T_CreateUserMappingStmt:
4369 retval = _copyCreateUserMappingStmt(from);
4371 case T_AlterUserMappingStmt:
4372 retval = _copyAlterUserMappingStmt(from);
4374 case T_DropUserMappingStmt:
4375 retval = _copyDropUserMappingStmt(from);
4377 case T_CreateForeignTableStmt:
4378 retval = _copyCreateForeignTableStmt(from);
4380 case T_CreateTrigStmt:
4381 retval = _copyCreateTrigStmt(from);
4383 case T_DropPropertyStmt:
4384 retval = _copyDropPropertyStmt(from);
4386 case T_CreatePLangStmt:
4387 retval = _copyCreatePLangStmt(from);
4389 case T_DropPLangStmt:
4390 retval = _copyDropPLangStmt(from);
4392 case T_CreateRoleStmt:
4393 retval = _copyCreateRoleStmt(from);
4395 case T_AlterRoleStmt:
4396 retval = _copyAlterRoleStmt(from);
4398 case T_AlterRoleSetStmt:
4399 retval = _copyAlterRoleSetStmt(from);
4401 case T_DropRoleStmt:
4402 retval = _copyDropRoleStmt(from);
4405 retval = _copyLockStmt(from);
4407 case T_ConstraintsSetStmt:
4408 retval = _copyConstraintsSetStmt(from);
4411 retval = _copyReindexStmt(from);
4413 case T_CheckPointStmt:
4414 retval = (void *) makeNode(CheckPointStmt);
4416 case T_CreateSchemaStmt:
4417 retval = _copyCreateSchemaStmt(from);
4419 case T_CreateConversionStmt:
4420 retval = _copyCreateConversionStmt(from);
4422 case T_CreateCastStmt:
4423 retval = _copyCreateCastStmt(from);
4425 case T_DropCastStmt:
4426 retval = _copyDropCastStmt(from);
4429 retval = _copyPrepareStmt(from);
4432 retval = _copyExecuteStmt(from);
4434 case T_DeallocateStmt:
4435 retval = _copyDeallocateStmt(from);
4437 case T_DropOwnedStmt:
4438 retval = _copyDropOwnedStmt(from);
4440 case T_ReassignOwnedStmt:
4441 retval = _copyReassignOwnedStmt(from);
4443 case T_AlterTSDictionaryStmt:
4444 retval = _copyAlterTSDictionaryStmt(from);
4446 case T_AlterTSConfigurationStmt:
4447 retval = _copyAlterTSConfigurationStmt(from);
4451 retval = _copyAExpr(from);
4454 retval = _copyColumnRef(from);
4457 retval = _copyParamRef(from);
4460 retval = _copyAConst(from);
4463 retval = _copyFuncCall(from);
4466 retval = _copyAStar(from);
4469 retval = _copyAIndices(from);
4471 case T_A_Indirection:
4472 retval = _copyA_Indirection(from);
4475 retval = _copyA_ArrayExpr(from);
4478 retval = _copyResTarget(from);
4481 retval = _copyTypeCast(from);
4483 case T_CollateClause:
4484 retval = _copyCollateClause(from);
4487 retval = _copySortBy(from);
4490 retval = _copyWindowDef(from);
4492 case T_RangeSubselect:
4493 retval = _copyRangeSubselect(from);
4495 case T_RangeFunction:
4496 retval = _copyRangeFunction(from);
4499 retval = _copyTypeName(from);
4502 retval = _copyIndexElem(from);
4505 retval = _copyColumnDef(from);
4508 retval = _copyConstraint(from);
4511 retval = _copyDefElem(from);
4513 case T_LockingClause:
4514 retval = _copyLockingClause(from);
4516 case T_RangeTblEntry:
4517 retval = _copyRangeTblEntry(from);
4519 case T_SortGroupClause:
4520 retval = _copySortGroupClause(from);
4522 case T_WindowClause:
4523 retval = _copyWindowClause(from);
4525 case T_RowMarkClause:
4526 retval = _copyRowMarkClause(from);
4529 retval = _copyWithClause(from);
4531 case T_CommonTableExpr:
4532 retval = _copyCommonTableExpr(from);
4535 retval = _copyPrivGrantee(from);
4537 case T_FuncWithArgs:
4538 retval = _copyFuncWithArgs(from);
4541 retval = _copyAccessPriv(from);
4543 case T_XmlSerialize:
4544 retval = _copyXmlSerialize(from);
4548 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4549 retval = from; /* keep compiler quiet */