1 /*-------------------------------------------------------------------------
4 * Copy functions for Postgres tree nodes.
6 * NOTE: we currently support copying all node types found in parse and
7 * plan trees. We do not support copying executor state trees; there
8 * is no need for that, and no point in maintaining all the code that
9 * would be needed. We also do not support copying Path trees, mainly
10 * because the circular linkages between RelOptInfo and Path nodes can't
11 * be handled easily in a simple depth-first traversal.
14 * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
18 * src/backend/nodes/copyfuncs.c
20 *-------------------------------------------------------------------------
25 #include "miscadmin.h"
26 #include "nodes/plannodes.h"
27 #include "nodes/relation.h"
28 #include "utils/datum.h"
32 * Macros to simplify copying of different kinds of fields. Use these
33 * wherever possible to reduce the chance for silly typos. Note that these
34 * hard-wire the convention that the local variables in a Copy routine are
35 * named 'newnode' and 'from'.
38 /* Copy a simple scalar field (int, float, bool, enum, etc) */
39 #define COPY_SCALAR_FIELD(fldname) \
40 (newnode->fldname = from->fldname)
42 /* Copy a field that is a pointer to some kind of Node or Node tree */
43 #define COPY_NODE_FIELD(fldname) \
44 (newnode->fldname = copyObject(from->fldname))
46 /* Copy a field that is a pointer to a Bitmapset */
47 #define COPY_BITMAPSET_FIELD(fldname) \
48 (newnode->fldname = bms_copy(from->fldname))
50 /* Copy a field that is a pointer to a C string, or perhaps NULL */
51 #define COPY_STRING_FIELD(fldname) \
52 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
54 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
55 #define COPY_POINTER_FIELD(fldname, sz) \
58 newnode->fldname = palloc(_size); \
59 memcpy(newnode->fldname, from->fldname, _size); \
62 /* Copy a parse location field (for Copy, this is same as scalar case) */
63 #define COPY_LOCATION_FIELD(fldname) \
64 (newnode->fldname = from->fldname)
67 /* ****************************************************************
68 * plannodes.h copy functions
69 * ****************************************************************
76 _copyPlannedStmt(const PlannedStmt *from)
78 PlannedStmt *newnode = makeNode(PlannedStmt);
80 COPY_SCALAR_FIELD(commandType);
81 COPY_SCALAR_FIELD(queryId);
82 COPY_SCALAR_FIELD(hasReturning);
83 COPY_SCALAR_FIELD(hasModifyingCTE);
84 COPY_SCALAR_FIELD(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);
96 COPY_SCALAR_FIELD(hasRowSecurity);
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(const 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(const Plan *from)
129 Plan *newnode = makeNode(Plan);
132 * copy node superclass fields
134 CopyPlanFields(from, newnode);
144 _copyResult(const Result *from)
146 Result *newnode = makeNode(Result);
149 * copy node superclass fields
151 CopyPlanFields((const Plan *) from, (Plan *) newnode);
154 * copy remainder of node
156 COPY_NODE_FIELD(resconstantqual);
165 _copyModifyTable(const ModifyTable *from)
167 ModifyTable *newnode = makeNode(ModifyTable);
170 * copy node superclass fields
172 CopyPlanFields((const Plan *) from, (Plan *) newnode);
175 * copy remainder of node
177 COPY_SCALAR_FIELD(operation);
178 COPY_SCALAR_FIELD(canSetTag);
179 COPY_SCALAR_FIELD(nominalRelation);
180 COPY_NODE_FIELD(resultRelations);
181 COPY_SCALAR_FIELD(resultRelIndex);
182 COPY_NODE_FIELD(plans);
183 COPY_NODE_FIELD(withCheckOptionLists);
184 COPY_NODE_FIELD(returningLists);
185 COPY_NODE_FIELD(fdwPrivLists);
186 COPY_NODE_FIELD(rowMarks);
187 COPY_SCALAR_FIELD(epqParam);
196 _copyAppend(const Append *from)
198 Append *newnode = makeNode(Append);
201 * copy node superclass fields
203 CopyPlanFields((const Plan *) from, (Plan *) newnode);
206 * copy remainder of node
208 COPY_NODE_FIELD(appendplans);
217 _copyMergeAppend(const MergeAppend *from)
219 MergeAppend *newnode = makeNode(MergeAppend);
222 * copy node superclass fields
224 CopyPlanFields((const Plan *) from, (Plan *) newnode);
227 * copy remainder of node
229 COPY_NODE_FIELD(mergeplans);
230 COPY_SCALAR_FIELD(numCols);
231 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
232 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
233 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
234 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
240 * _copyRecursiveUnion
242 static RecursiveUnion *
243 _copyRecursiveUnion(const RecursiveUnion *from)
245 RecursiveUnion *newnode = makeNode(RecursiveUnion);
248 * copy node superclass fields
250 CopyPlanFields((const Plan *) from, (Plan *) newnode);
253 * copy remainder of node
255 COPY_SCALAR_FIELD(wtParam);
256 COPY_SCALAR_FIELD(numCols);
257 if (from->numCols > 0)
259 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
260 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
262 COPY_SCALAR_FIELD(numGroups);
271 _copyBitmapAnd(const BitmapAnd *from)
273 BitmapAnd *newnode = makeNode(BitmapAnd);
276 * copy node superclass fields
278 CopyPlanFields((const Plan *) from, (Plan *) newnode);
281 * copy remainder of node
283 COPY_NODE_FIELD(bitmapplans);
292 _copyBitmapOr(const BitmapOr *from)
294 BitmapOr *newnode = makeNode(BitmapOr);
297 * copy node superclass fields
299 CopyPlanFields((const Plan *) from, (Plan *) newnode);
302 * copy remainder of node
304 COPY_NODE_FIELD(bitmapplans);
313 * This function copies the fields of the Scan node. It is used by
314 * all the copy functions for classes which inherit from Scan.
317 CopyScanFields(const Scan *from, Scan *newnode)
319 CopyPlanFields((const Plan *) from, (Plan *) newnode);
321 COPY_SCALAR_FIELD(scanrelid);
328 _copyScan(const Scan *from)
330 Scan *newnode = makeNode(Scan);
333 * copy node superclass fields
335 CopyScanFields((const Scan *) from, (Scan *) newnode);
344 _copySeqScan(const SeqScan *from)
346 SeqScan *newnode = makeNode(SeqScan);
349 * copy node superclass fields
351 CopyScanFields((const Scan *) from, (Scan *) newnode);
360 _copyIndexScan(const IndexScan *from)
362 IndexScan *newnode = makeNode(IndexScan);
365 * copy node superclass fields
367 CopyScanFields((const Scan *) from, (Scan *) newnode);
370 * copy remainder of node
372 COPY_SCALAR_FIELD(indexid);
373 COPY_NODE_FIELD(indexqual);
374 COPY_NODE_FIELD(indexqualorig);
375 COPY_NODE_FIELD(indexorderby);
376 COPY_NODE_FIELD(indexorderbyorig);
377 COPY_SCALAR_FIELD(indexorderdir);
385 static IndexOnlyScan *
386 _copyIndexOnlyScan(const IndexOnlyScan *from)
388 IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
391 * copy node superclass fields
393 CopyScanFields((const Scan *) from, (Scan *) newnode);
396 * copy remainder of node
398 COPY_SCALAR_FIELD(indexid);
399 COPY_NODE_FIELD(indexqual);
400 COPY_NODE_FIELD(indexorderby);
401 COPY_NODE_FIELD(indextlist);
402 COPY_SCALAR_FIELD(indexorderdir);
408 * _copyBitmapIndexScan
410 static BitmapIndexScan *
411 _copyBitmapIndexScan(const BitmapIndexScan *from)
413 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
416 * copy node superclass fields
418 CopyScanFields((const Scan *) from, (Scan *) newnode);
421 * copy remainder of node
423 COPY_SCALAR_FIELD(indexid);
424 COPY_NODE_FIELD(indexqual);
425 COPY_NODE_FIELD(indexqualorig);
431 * _copyBitmapHeapScan
433 static BitmapHeapScan *
434 _copyBitmapHeapScan(const BitmapHeapScan *from)
436 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
439 * copy node superclass fields
441 CopyScanFields((const Scan *) from, (Scan *) newnode);
444 * copy remainder of node
446 COPY_NODE_FIELD(bitmapqualorig);
455 _copyTidScan(const TidScan *from)
457 TidScan *newnode = makeNode(TidScan);
460 * copy node superclass fields
462 CopyScanFields((const Scan *) from, (Scan *) newnode);
465 * copy remainder of node
467 COPY_NODE_FIELD(tidquals);
475 static SubqueryScan *
476 _copySubqueryScan(const SubqueryScan *from)
478 SubqueryScan *newnode = makeNode(SubqueryScan);
481 * copy node superclass fields
483 CopyScanFields((const Scan *) from, (Scan *) newnode);
486 * copy remainder of node
488 COPY_NODE_FIELD(subplan);
496 static FunctionScan *
497 _copyFunctionScan(const FunctionScan *from)
499 FunctionScan *newnode = makeNode(FunctionScan);
502 * copy node superclass fields
504 CopyScanFields((const Scan *) from, (Scan *) newnode);
507 * copy remainder of node
509 COPY_NODE_FIELD(functions);
510 COPY_SCALAR_FIELD(funcordinality);
519 _copyValuesScan(const ValuesScan *from)
521 ValuesScan *newnode = makeNode(ValuesScan);
524 * copy node superclass fields
526 CopyScanFields((const Scan *) from, (Scan *) newnode);
529 * copy remainder of node
531 COPY_NODE_FIELD(values_lists);
540 _copyCteScan(const CteScan *from)
542 CteScan *newnode = makeNode(CteScan);
545 * copy node superclass fields
547 CopyScanFields((const Scan *) from, (Scan *) newnode);
550 * copy remainder of node
552 COPY_SCALAR_FIELD(ctePlanId);
553 COPY_SCALAR_FIELD(cteParam);
561 static WorkTableScan *
562 _copyWorkTableScan(const WorkTableScan *from)
564 WorkTableScan *newnode = makeNode(WorkTableScan);
567 * copy node superclass fields
569 CopyScanFields((const Scan *) from, (Scan *) newnode);
572 * copy remainder of node
574 COPY_SCALAR_FIELD(wtParam);
583 _copyForeignScan(const ForeignScan *from)
585 ForeignScan *newnode = makeNode(ForeignScan);
588 * copy node superclass fields
590 CopyScanFields((const Scan *) from, (Scan *) newnode);
593 * copy remainder of node
595 COPY_SCALAR_FIELD(fdw_handler);
596 COPY_NODE_FIELD(fdw_exprs);
597 COPY_NODE_FIELD(fdw_ps_tlist);
598 COPY_NODE_FIELD(fdw_private);
599 COPY_BITMAPSET_FIELD(fdw_relids);
600 COPY_SCALAR_FIELD(fsSystemCol);
609 _copyCustomScan(const CustomScan *from)
611 CustomScan *newnode = makeNode(CustomScan);
614 * copy node superclass fields
616 CopyScanFields((const Scan *) from, (Scan *) newnode);
619 * copy remainder of node
621 COPY_SCALAR_FIELD(flags);
622 COPY_NODE_FIELD(custom_exprs);
623 COPY_NODE_FIELD(custom_ps_tlist);
624 COPY_NODE_FIELD(custom_private);
625 COPY_BITMAPSET_FIELD(custom_relids);
628 * NOTE: The method field of CustomScan is required to be a pointer to a
629 * static table of callback functions. So we don't copy the table itself,
630 * just reference the original one.
632 COPY_SCALAR_FIELD(methods);
640 * This function copies the fields of the Join node. It is used by
641 * all the copy functions for classes which inherit from Join.
644 CopyJoinFields(const Join *from, Join *newnode)
646 CopyPlanFields((const Plan *) from, (Plan *) newnode);
648 COPY_SCALAR_FIELD(jointype);
649 COPY_NODE_FIELD(joinqual);
657 _copyJoin(const Join *from)
659 Join *newnode = makeNode(Join);
662 * copy node superclass fields
664 CopyJoinFields(from, newnode);
674 _copyNestLoop(const NestLoop *from)
676 NestLoop *newnode = makeNode(NestLoop);
679 * copy node superclass fields
681 CopyJoinFields((const Join *) from, (Join *) newnode);
684 * copy remainder of node
686 COPY_NODE_FIELD(nestParams);
696 _copyMergeJoin(const MergeJoin *from)
698 MergeJoin *newnode = makeNode(MergeJoin);
702 * copy node superclass fields
704 CopyJoinFields((const Join *) from, (Join *) newnode);
707 * copy remainder of node
709 COPY_NODE_FIELD(mergeclauses);
710 numCols = list_length(from->mergeclauses);
713 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
714 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
715 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
716 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
726 _copyHashJoin(const HashJoin *from)
728 HashJoin *newnode = makeNode(HashJoin);
731 * copy node superclass fields
733 CopyJoinFields((const Join *) from, (Join *) newnode);
736 * copy remainder of node
738 COPY_NODE_FIELD(hashclauses);
748 _copyMaterial(const Material *from)
750 Material *newnode = makeNode(Material);
753 * copy node superclass fields
755 CopyPlanFields((const Plan *) from, (Plan *) newnode);
765 _copySort(const Sort *from)
767 Sort *newnode = makeNode(Sort);
770 * copy node superclass fields
772 CopyPlanFields((const Plan *) from, (Plan *) newnode);
774 COPY_SCALAR_FIELD(numCols);
775 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
776 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
777 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
778 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
788 _copyGroup(const Group *from)
790 Group *newnode = makeNode(Group);
792 CopyPlanFields((const Plan *) from, (Plan *) newnode);
794 COPY_SCALAR_FIELD(numCols);
795 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
796 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
805 _copyAgg(const Agg *from)
807 Agg *newnode = makeNode(Agg);
809 CopyPlanFields((const Plan *) from, (Plan *) newnode);
811 COPY_SCALAR_FIELD(aggstrategy);
812 COPY_SCALAR_FIELD(numCols);
813 if (from->numCols > 0)
815 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
816 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
818 COPY_SCALAR_FIELD(numGroups);
827 _copyWindowAgg(const WindowAgg *from)
829 WindowAgg *newnode = makeNode(WindowAgg);
831 CopyPlanFields((const Plan *) from, (Plan *) newnode);
833 COPY_SCALAR_FIELD(winref);
834 COPY_SCALAR_FIELD(partNumCols);
835 if (from->partNumCols > 0)
837 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
838 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
840 COPY_SCALAR_FIELD(ordNumCols);
841 if (from->ordNumCols > 0)
843 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
844 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
846 COPY_SCALAR_FIELD(frameOptions);
847 COPY_NODE_FIELD(startOffset);
848 COPY_NODE_FIELD(endOffset);
857 _copyUnique(const Unique *from)
859 Unique *newnode = makeNode(Unique);
862 * copy node superclass fields
864 CopyPlanFields((const Plan *) from, (Plan *) newnode);
867 * copy remainder of node
869 COPY_SCALAR_FIELD(numCols);
870 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
871 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
880 _copyHash(const Hash *from)
882 Hash *newnode = makeNode(Hash);
885 * copy node superclass fields
887 CopyPlanFields((const Plan *) from, (Plan *) newnode);
890 * copy remainder of node
892 COPY_SCALAR_FIELD(skewTable);
893 COPY_SCALAR_FIELD(skewColumn);
894 COPY_SCALAR_FIELD(skewInherit);
895 COPY_SCALAR_FIELD(skewColType);
896 COPY_SCALAR_FIELD(skewColTypmod);
905 _copySetOp(const SetOp *from)
907 SetOp *newnode = makeNode(SetOp);
910 * copy node superclass fields
912 CopyPlanFields((const Plan *) from, (Plan *) newnode);
915 * copy remainder of node
917 COPY_SCALAR_FIELD(cmd);
918 COPY_SCALAR_FIELD(strategy);
919 COPY_SCALAR_FIELD(numCols);
920 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
921 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
922 COPY_SCALAR_FIELD(flagColIdx);
923 COPY_SCALAR_FIELD(firstFlag);
924 COPY_SCALAR_FIELD(numGroups);
933 _copyLockRows(const LockRows *from)
935 LockRows *newnode = makeNode(LockRows);
938 * copy node superclass fields
940 CopyPlanFields((const Plan *) from, (Plan *) newnode);
943 * copy remainder of node
945 COPY_NODE_FIELD(rowMarks);
946 COPY_SCALAR_FIELD(epqParam);
955 _copyLimit(const Limit *from)
957 Limit *newnode = makeNode(Limit);
960 * copy node superclass fields
962 CopyPlanFields((const Plan *) from, (Plan *) newnode);
965 * copy remainder of node
967 COPY_NODE_FIELD(limitOffset);
968 COPY_NODE_FIELD(limitCount);
976 static NestLoopParam *
977 _copyNestLoopParam(const NestLoopParam *from)
979 NestLoopParam *newnode = makeNode(NestLoopParam);
981 COPY_SCALAR_FIELD(paramno);
982 COPY_NODE_FIELD(paramval);
991 _copyPlanRowMark(const PlanRowMark *from)
993 PlanRowMark *newnode = makeNode(PlanRowMark);
995 COPY_SCALAR_FIELD(rti);
996 COPY_SCALAR_FIELD(prti);
997 COPY_SCALAR_FIELD(rowmarkId);
998 COPY_SCALAR_FIELD(markType);
999 COPY_SCALAR_FIELD(allMarkTypes);
1000 COPY_SCALAR_FIELD(strength);
1001 COPY_SCALAR_FIELD(waitPolicy);
1002 COPY_SCALAR_FIELD(isParent);
1008 * _copyPlanInvalItem
1010 static PlanInvalItem *
1011 _copyPlanInvalItem(const PlanInvalItem *from)
1013 PlanInvalItem *newnode = makeNode(PlanInvalItem);
1015 COPY_SCALAR_FIELD(cacheId);
1016 COPY_SCALAR_FIELD(hashValue);
1021 /* ****************************************************************
1022 * primnodes.h copy functions
1023 * ****************************************************************
1030 _copyAlias(const Alias *from)
1032 Alias *newnode = makeNode(Alias);
1034 COPY_STRING_FIELD(aliasname);
1035 COPY_NODE_FIELD(colnames);
1044 _copyRangeVar(const RangeVar *from)
1046 RangeVar *newnode = makeNode(RangeVar);
1048 COPY_STRING_FIELD(catalogname);
1049 COPY_STRING_FIELD(schemaname);
1050 COPY_STRING_FIELD(relname);
1051 COPY_SCALAR_FIELD(inhOpt);
1052 COPY_SCALAR_FIELD(relpersistence);
1053 COPY_NODE_FIELD(alias);
1054 COPY_LOCATION_FIELD(location);
1063 _copyIntoClause(const IntoClause *from)
1065 IntoClause *newnode = makeNode(IntoClause);
1067 COPY_NODE_FIELD(rel);
1068 COPY_NODE_FIELD(colNames);
1069 COPY_NODE_FIELD(options);
1070 COPY_SCALAR_FIELD(onCommit);
1071 COPY_STRING_FIELD(tableSpaceName);
1072 COPY_NODE_FIELD(viewQuery);
1073 COPY_SCALAR_FIELD(skipData);
1079 * We don't need a _copyExpr because Expr is an abstract supertype which
1080 * should never actually get instantiated. Also, since it has no common
1081 * fields except NodeTag, there's no need for a helper routine to factor
1082 * out copying the common fields...
1089 _copyVar(const Var *from)
1091 Var *newnode = makeNode(Var);
1093 COPY_SCALAR_FIELD(varno);
1094 COPY_SCALAR_FIELD(varattno);
1095 COPY_SCALAR_FIELD(vartype);
1096 COPY_SCALAR_FIELD(vartypmod);
1097 COPY_SCALAR_FIELD(varcollid);
1098 COPY_SCALAR_FIELD(varlevelsup);
1099 COPY_SCALAR_FIELD(varnoold);
1100 COPY_SCALAR_FIELD(varoattno);
1101 COPY_LOCATION_FIELD(location);
1110 _copyConst(const Const *from)
1112 Const *newnode = makeNode(Const);
1114 COPY_SCALAR_FIELD(consttype);
1115 COPY_SCALAR_FIELD(consttypmod);
1116 COPY_SCALAR_FIELD(constcollid);
1117 COPY_SCALAR_FIELD(constlen);
1119 if (from->constbyval || from->constisnull)
1122 * passed by value so just copy the datum. Also, don't try to copy
1123 * struct when value is null!
1125 newnode->constvalue = from->constvalue;
1130 * passed by reference. We need a palloc'd copy.
1132 newnode->constvalue = datumCopy(from->constvalue,
1137 COPY_SCALAR_FIELD(constisnull);
1138 COPY_SCALAR_FIELD(constbyval);
1139 COPY_LOCATION_FIELD(location);
1148 _copyParam(const Param *from)
1150 Param *newnode = makeNode(Param);
1152 COPY_SCALAR_FIELD(paramkind);
1153 COPY_SCALAR_FIELD(paramid);
1154 COPY_SCALAR_FIELD(paramtype);
1155 COPY_SCALAR_FIELD(paramtypmod);
1156 COPY_SCALAR_FIELD(paramcollid);
1157 COPY_LOCATION_FIELD(location);
1166 _copyAggref(const Aggref *from)
1168 Aggref *newnode = makeNode(Aggref);
1170 COPY_SCALAR_FIELD(aggfnoid);
1171 COPY_SCALAR_FIELD(aggtype);
1172 COPY_SCALAR_FIELD(aggcollid);
1173 COPY_SCALAR_FIELD(inputcollid);
1174 COPY_NODE_FIELD(aggdirectargs);
1175 COPY_NODE_FIELD(args);
1176 COPY_NODE_FIELD(aggorder);
1177 COPY_NODE_FIELD(aggdistinct);
1178 COPY_NODE_FIELD(aggfilter);
1179 COPY_SCALAR_FIELD(aggstar);
1180 COPY_SCALAR_FIELD(aggvariadic);
1181 COPY_SCALAR_FIELD(aggkind);
1182 COPY_SCALAR_FIELD(agglevelsup);
1183 COPY_LOCATION_FIELD(location);
1192 _copyWindowFunc(const WindowFunc *from)
1194 WindowFunc *newnode = makeNode(WindowFunc);
1196 COPY_SCALAR_FIELD(winfnoid);
1197 COPY_SCALAR_FIELD(wintype);
1198 COPY_SCALAR_FIELD(wincollid);
1199 COPY_SCALAR_FIELD(inputcollid);
1200 COPY_NODE_FIELD(args);
1201 COPY_NODE_FIELD(aggfilter);
1202 COPY_SCALAR_FIELD(winref);
1203 COPY_SCALAR_FIELD(winstar);
1204 COPY_SCALAR_FIELD(winagg);
1205 COPY_LOCATION_FIELD(location);
1214 _copyArrayRef(const ArrayRef *from)
1216 ArrayRef *newnode = makeNode(ArrayRef);
1218 COPY_SCALAR_FIELD(refarraytype);
1219 COPY_SCALAR_FIELD(refelemtype);
1220 COPY_SCALAR_FIELD(reftypmod);
1221 COPY_SCALAR_FIELD(refcollid);
1222 COPY_NODE_FIELD(refupperindexpr);
1223 COPY_NODE_FIELD(reflowerindexpr);
1224 COPY_NODE_FIELD(refexpr);
1225 COPY_NODE_FIELD(refassgnexpr);
1234 _copyFuncExpr(const FuncExpr *from)
1236 FuncExpr *newnode = makeNode(FuncExpr);
1238 COPY_SCALAR_FIELD(funcid);
1239 COPY_SCALAR_FIELD(funcresulttype);
1240 COPY_SCALAR_FIELD(funcretset);
1241 COPY_SCALAR_FIELD(funcvariadic);
1242 COPY_SCALAR_FIELD(funcformat);
1243 COPY_SCALAR_FIELD(funccollid);
1244 COPY_SCALAR_FIELD(inputcollid);
1245 COPY_NODE_FIELD(args);
1246 COPY_LOCATION_FIELD(location);
1252 * _copyNamedArgExpr *
1254 static NamedArgExpr *
1255 _copyNamedArgExpr(const NamedArgExpr *from)
1257 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1259 COPY_NODE_FIELD(arg);
1260 COPY_STRING_FIELD(name);
1261 COPY_SCALAR_FIELD(argnumber);
1262 COPY_LOCATION_FIELD(location);
1271 _copyOpExpr(const OpExpr *from)
1273 OpExpr *newnode = makeNode(OpExpr);
1275 COPY_SCALAR_FIELD(opno);
1276 COPY_SCALAR_FIELD(opfuncid);
1277 COPY_SCALAR_FIELD(opresulttype);
1278 COPY_SCALAR_FIELD(opretset);
1279 COPY_SCALAR_FIELD(opcollid);
1280 COPY_SCALAR_FIELD(inputcollid);
1281 COPY_NODE_FIELD(args);
1282 COPY_LOCATION_FIELD(location);
1288 * _copyDistinctExpr (same as OpExpr)
1290 static DistinctExpr *
1291 _copyDistinctExpr(const DistinctExpr *from)
1293 DistinctExpr *newnode = makeNode(DistinctExpr);
1295 COPY_SCALAR_FIELD(opno);
1296 COPY_SCALAR_FIELD(opfuncid);
1297 COPY_SCALAR_FIELD(opresulttype);
1298 COPY_SCALAR_FIELD(opretset);
1299 COPY_SCALAR_FIELD(opcollid);
1300 COPY_SCALAR_FIELD(inputcollid);
1301 COPY_NODE_FIELD(args);
1302 COPY_LOCATION_FIELD(location);
1308 * _copyNullIfExpr (same as OpExpr)
1311 _copyNullIfExpr(const NullIfExpr *from)
1313 NullIfExpr *newnode = makeNode(NullIfExpr);
1315 COPY_SCALAR_FIELD(opno);
1316 COPY_SCALAR_FIELD(opfuncid);
1317 COPY_SCALAR_FIELD(opresulttype);
1318 COPY_SCALAR_FIELD(opretset);
1319 COPY_SCALAR_FIELD(opcollid);
1320 COPY_SCALAR_FIELD(inputcollid);
1321 COPY_NODE_FIELD(args);
1322 COPY_LOCATION_FIELD(location);
1328 * _copyScalarArrayOpExpr
1330 static ScalarArrayOpExpr *
1331 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
1333 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1335 COPY_SCALAR_FIELD(opno);
1336 COPY_SCALAR_FIELD(opfuncid);
1337 COPY_SCALAR_FIELD(useOr);
1338 COPY_SCALAR_FIELD(inputcollid);
1339 COPY_NODE_FIELD(args);
1340 COPY_LOCATION_FIELD(location);
1349 _copyBoolExpr(const BoolExpr *from)
1351 BoolExpr *newnode = makeNode(BoolExpr);
1353 COPY_SCALAR_FIELD(boolop);
1354 COPY_NODE_FIELD(args);
1355 COPY_LOCATION_FIELD(location);
1364 _copySubLink(const SubLink *from)
1366 SubLink *newnode = makeNode(SubLink);
1368 COPY_SCALAR_FIELD(subLinkType);
1369 COPY_SCALAR_FIELD(subLinkId);
1370 COPY_NODE_FIELD(testexpr);
1371 COPY_NODE_FIELD(operName);
1372 COPY_NODE_FIELD(subselect);
1373 COPY_LOCATION_FIELD(location);
1382 _copySubPlan(const SubPlan *from)
1384 SubPlan *newnode = makeNode(SubPlan);
1386 COPY_SCALAR_FIELD(subLinkType);
1387 COPY_NODE_FIELD(testexpr);
1388 COPY_NODE_FIELD(paramIds);
1389 COPY_SCALAR_FIELD(plan_id);
1390 COPY_STRING_FIELD(plan_name);
1391 COPY_SCALAR_FIELD(firstColType);
1392 COPY_SCALAR_FIELD(firstColTypmod);
1393 COPY_SCALAR_FIELD(firstColCollation);
1394 COPY_SCALAR_FIELD(useHashTable);
1395 COPY_SCALAR_FIELD(unknownEqFalse);
1396 COPY_NODE_FIELD(setParam);
1397 COPY_NODE_FIELD(parParam);
1398 COPY_NODE_FIELD(args);
1399 COPY_SCALAR_FIELD(startup_cost);
1400 COPY_SCALAR_FIELD(per_call_cost);
1406 * _copyAlternativeSubPlan
1408 static AlternativeSubPlan *
1409 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
1411 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1413 COPY_NODE_FIELD(subplans);
1421 static FieldSelect *
1422 _copyFieldSelect(const FieldSelect *from)
1424 FieldSelect *newnode = makeNode(FieldSelect);
1426 COPY_NODE_FIELD(arg);
1427 COPY_SCALAR_FIELD(fieldnum);
1428 COPY_SCALAR_FIELD(resulttype);
1429 COPY_SCALAR_FIELD(resulttypmod);
1430 COPY_SCALAR_FIELD(resultcollid);
1439 _copyFieldStore(const FieldStore *from)
1441 FieldStore *newnode = makeNode(FieldStore);
1443 COPY_NODE_FIELD(arg);
1444 COPY_NODE_FIELD(newvals);
1445 COPY_NODE_FIELD(fieldnums);
1446 COPY_SCALAR_FIELD(resulttype);
1454 static RelabelType *
1455 _copyRelabelType(const RelabelType *from)
1457 RelabelType *newnode = makeNode(RelabelType);
1459 COPY_NODE_FIELD(arg);
1460 COPY_SCALAR_FIELD(resulttype);
1461 COPY_SCALAR_FIELD(resulttypmod);
1462 COPY_SCALAR_FIELD(resultcollid);
1463 COPY_SCALAR_FIELD(relabelformat);
1464 COPY_LOCATION_FIELD(location);
1472 static CoerceViaIO *
1473 _copyCoerceViaIO(const CoerceViaIO *from)
1475 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1477 COPY_NODE_FIELD(arg);
1478 COPY_SCALAR_FIELD(resulttype);
1479 COPY_SCALAR_FIELD(resultcollid);
1480 COPY_SCALAR_FIELD(coerceformat);
1481 COPY_LOCATION_FIELD(location);
1487 * _copyArrayCoerceExpr
1489 static ArrayCoerceExpr *
1490 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
1492 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1494 COPY_NODE_FIELD(arg);
1495 COPY_SCALAR_FIELD(elemfuncid);
1496 COPY_SCALAR_FIELD(resulttype);
1497 COPY_SCALAR_FIELD(resulttypmod);
1498 COPY_SCALAR_FIELD(resultcollid);
1499 COPY_SCALAR_FIELD(isExplicit);
1500 COPY_SCALAR_FIELD(coerceformat);
1501 COPY_LOCATION_FIELD(location);
1507 * _copyConvertRowtypeExpr
1509 static ConvertRowtypeExpr *
1510 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
1512 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1514 COPY_NODE_FIELD(arg);
1515 COPY_SCALAR_FIELD(resulttype);
1516 COPY_SCALAR_FIELD(convertformat);
1517 COPY_LOCATION_FIELD(location);
1525 static CollateExpr *
1526 _copyCollateExpr(const CollateExpr *from)
1528 CollateExpr *newnode = makeNode(CollateExpr);
1530 COPY_NODE_FIELD(arg);
1531 COPY_SCALAR_FIELD(collOid);
1532 COPY_LOCATION_FIELD(location);
1541 _copyCaseExpr(const CaseExpr *from)
1543 CaseExpr *newnode = makeNode(CaseExpr);
1545 COPY_SCALAR_FIELD(casetype);
1546 COPY_SCALAR_FIELD(casecollid);
1547 COPY_NODE_FIELD(arg);
1548 COPY_NODE_FIELD(args);
1549 COPY_NODE_FIELD(defresult);
1550 COPY_LOCATION_FIELD(location);
1559 _copyCaseWhen(const CaseWhen *from)
1561 CaseWhen *newnode = makeNode(CaseWhen);
1563 COPY_NODE_FIELD(expr);
1564 COPY_NODE_FIELD(result);
1565 COPY_LOCATION_FIELD(location);
1573 static CaseTestExpr *
1574 _copyCaseTestExpr(const CaseTestExpr *from)
1576 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1578 COPY_SCALAR_FIELD(typeId);
1579 COPY_SCALAR_FIELD(typeMod);
1580 COPY_SCALAR_FIELD(collation);
1589 _copyArrayExpr(const ArrayExpr *from)
1591 ArrayExpr *newnode = makeNode(ArrayExpr);
1593 COPY_SCALAR_FIELD(array_typeid);
1594 COPY_SCALAR_FIELD(array_collid);
1595 COPY_SCALAR_FIELD(element_typeid);
1596 COPY_NODE_FIELD(elements);
1597 COPY_SCALAR_FIELD(multidims);
1598 COPY_LOCATION_FIELD(location);
1607 _copyRowExpr(const RowExpr *from)
1609 RowExpr *newnode = makeNode(RowExpr);
1611 COPY_NODE_FIELD(args);
1612 COPY_SCALAR_FIELD(row_typeid);
1613 COPY_SCALAR_FIELD(row_format);
1614 COPY_NODE_FIELD(colnames);
1615 COPY_LOCATION_FIELD(location);
1621 * _copyRowCompareExpr
1623 static RowCompareExpr *
1624 _copyRowCompareExpr(const RowCompareExpr *from)
1626 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1628 COPY_SCALAR_FIELD(rctype);
1629 COPY_NODE_FIELD(opnos);
1630 COPY_NODE_FIELD(opfamilies);
1631 COPY_NODE_FIELD(inputcollids);
1632 COPY_NODE_FIELD(largs);
1633 COPY_NODE_FIELD(rargs);
1641 static CoalesceExpr *
1642 _copyCoalesceExpr(const CoalesceExpr *from)
1644 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1646 COPY_SCALAR_FIELD(coalescetype);
1647 COPY_SCALAR_FIELD(coalescecollid);
1648 COPY_NODE_FIELD(args);
1649 COPY_LOCATION_FIELD(location);
1658 _copyMinMaxExpr(const MinMaxExpr *from)
1660 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1662 COPY_SCALAR_FIELD(minmaxtype);
1663 COPY_SCALAR_FIELD(minmaxcollid);
1664 COPY_SCALAR_FIELD(inputcollid);
1665 COPY_SCALAR_FIELD(op);
1666 COPY_NODE_FIELD(args);
1667 COPY_LOCATION_FIELD(location);
1676 _copyXmlExpr(const XmlExpr *from)
1678 XmlExpr *newnode = makeNode(XmlExpr);
1680 COPY_SCALAR_FIELD(op);
1681 COPY_STRING_FIELD(name);
1682 COPY_NODE_FIELD(named_args);
1683 COPY_NODE_FIELD(arg_names);
1684 COPY_NODE_FIELD(args);
1685 COPY_SCALAR_FIELD(xmloption);
1686 COPY_SCALAR_FIELD(type);
1687 COPY_SCALAR_FIELD(typmod);
1688 COPY_LOCATION_FIELD(location);
1697 _copyNullTest(const NullTest *from)
1699 NullTest *newnode = makeNode(NullTest);
1701 COPY_NODE_FIELD(arg);
1702 COPY_SCALAR_FIELD(nulltesttype);
1703 COPY_SCALAR_FIELD(argisrow);
1704 COPY_LOCATION_FIELD(location);
1712 static BooleanTest *
1713 _copyBooleanTest(const BooleanTest *from)
1715 BooleanTest *newnode = makeNode(BooleanTest);
1717 COPY_NODE_FIELD(arg);
1718 COPY_SCALAR_FIELD(booltesttype);
1719 COPY_LOCATION_FIELD(location);
1725 * _copyCoerceToDomain
1727 static CoerceToDomain *
1728 _copyCoerceToDomain(const CoerceToDomain *from)
1730 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1732 COPY_NODE_FIELD(arg);
1733 COPY_SCALAR_FIELD(resulttype);
1734 COPY_SCALAR_FIELD(resulttypmod);
1735 COPY_SCALAR_FIELD(resultcollid);
1736 COPY_SCALAR_FIELD(coercionformat);
1737 COPY_LOCATION_FIELD(location);
1743 * _copyCoerceToDomainValue
1745 static CoerceToDomainValue *
1746 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
1748 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1750 COPY_SCALAR_FIELD(typeId);
1751 COPY_SCALAR_FIELD(typeMod);
1752 COPY_SCALAR_FIELD(collation);
1753 COPY_LOCATION_FIELD(location);
1761 static SetToDefault *
1762 _copySetToDefault(const SetToDefault *from)
1764 SetToDefault *newnode = makeNode(SetToDefault);
1766 COPY_SCALAR_FIELD(typeId);
1767 COPY_SCALAR_FIELD(typeMod);
1768 COPY_SCALAR_FIELD(collation);
1769 COPY_LOCATION_FIELD(location);
1775 * _copyCurrentOfExpr
1777 static CurrentOfExpr *
1778 _copyCurrentOfExpr(const CurrentOfExpr *from)
1780 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1782 COPY_SCALAR_FIELD(cvarno);
1783 COPY_STRING_FIELD(cursor_name);
1784 COPY_SCALAR_FIELD(cursor_param);
1792 static TargetEntry *
1793 _copyTargetEntry(const TargetEntry *from)
1795 TargetEntry *newnode = makeNode(TargetEntry);
1797 COPY_NODE_FIELD(expr);
1798 COPY_SCALAR_FIELD(resno);
1799 COPY_STRING_FIELD(resname);
1800 COPY_SCALAR_FIELD(ressortgroupref);
1801 COPY_SCALAR_FIELD(resorigtbl);
1802 COPY_SCALAR_FIELD(resorigcol);
1803 COPY_SCALAR_FIELD(resjunk);
1811 static RangeTblRef *
1812 _copyRangeTblRef(const RangeTblRef *from)
1814 RangeTblRef *newnode = makeNode(RangeTblRef);
1816 COPY_SCALAR_FIELD(rtindex);
1825 _copyJoinExpr(const JoinExpr *from)
1827 JoinExpr *newnode = makeNode(JoinExpr);
1829 COPY_SCALAR_FIELD(jointype);
1830 COPY_SCALAR_FIELD(isNatural);
1831 COPY_NODE_FIELD(larg);
1832 COPY_NODE_FIELD(rarg);
1833 COPY_NODE_FIELD(usingClause);
1834 COPY_NODE_FIELD(quals);
1835 COPY_NODE_FIELD(alias);
1836 COPY_SCALAR_FIELD(rtindex);
1845 _copyFromExpr(const FromExpr *from)
1847 FromExpr *newnode = makeNode(FromExpr);
1849 COPY_NODE_FIELD(fromlist);
1850 COPY_NODE_FIELD(quals);
1855 /* ****************************************************************
1856 * relation.h copy functions
1858 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1859 * There are some subsidiary structs that are useful to copy, though.
1860 * ****************************************************************
1867 _copyPathKey(const PathKey *from)
1869 PathKey *newnode = makeNode(PathKey);
1871 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1872 COPY_SCALAR_FIELD(pk_eclass);
1873 COPY_SCALAR_FIELD(pk_opfamily);
1874 COPY_SCALAR_FIELD(pk_strategy);
1875 COPY_SCALAR_FIELD(pk_nulls_first);
1883 static RestrictInfo *
1884 _copyRestrictInfo(const RestrictInfo *from)
1886 RestrictInfo *newnode = makeNode(RestrictInfo);
1888 COPY_NODE_FIELD(clause);
1889 COPY_SCALAR_FIELD(is_pushed_down);
1890 COPY_SCALAR_FIELD(outerjoin_delayed);
1891 COPY_SCALAR_FIELD(can_join);
1892 COPY_SCALAR_FIELD(pseudoconstant);
1893 COPY_BITMAPSET_FIELD(clause_relids);
1894 COPY_BITMAPSET_FIELD(required_relids);
1895 COPY_BITMAPSET_FIELD(outer_relids);
1896 COPY_BITMAPSET_FIELD(nullable_relids);
1897 COPY_BITMAPSET_FIELD(left_relids);
1898 COPY_BITMAPSET_FIELD(right_relids);
1899 COPY_NODE_FIELD(orclause);
1900 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1901 COPY_SCALAR_FIELD(parent_ec);
1902 COPY_SCALAR_FIELD(eval_cost);
1903 COPY_SCALAR_FIELD(norm_selec);
1904 COPY_SCALAR_FIELD(outer_selec);
1905 COPY_NODE_FIELD(mergeopfamilies);
1906 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1907 COPY_SCALAR_FIELD(left_ec);
1908 COPY_SCALAR_FIELD(right_ec);
1909 COPY_SCALAR_FIELD(left_em);
1910 COPY_SCALAR_FIELD(right_em);
1911 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1912 newnode->scansel_cache = NIL;
1913 COPY_SCALAR_FIELD(outer_is_left);
1914 COPY_SCALAR_FIELD(hashjoinoperator);
1915 COPY_SCALAR_FIELD(left_bucketsize);
1916 COPY_SCALAR_FIELD(right_bucketsize);
1922 * _copyPlaceHolderVar
1924 static PlaceHolderVar *
1925 _copyPlaceHolderVar(const PlaceHolderVar *from)
1927 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
1929 COPY_NODE_FIELD(phexpr);
1930 COPY_BITMAPSET_FIELD(phrels);
1931 COPY_SCALAR_FIELD(phid);
1932 COPY_SCALAR_FIELD(phlevelsup);
1938 * _copySpecialJoinInfo
1940 static SpecialJoinInfo *
1941 _copySpecialJoinInfo(const SpecialJoinInfo *from)
1943 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
1945 COPY_BITMAPSET_FIELD(min_lefthand);
1946 COPY_BITMAPSET_FIELD(min_righthand);
1947 COPY_BITMAPSET_FIELD(syn_lefthand);
1948 COPY_BITMAPSET_FIELD(syn_righthand);
1949 COPY_SCALAR_FIELD(jointype);
1950 COPY_SCALAR_FIELD(lhs_strict);
1951 COPY_SCALAR_FIELD(delay_upper_joins);
1952 COPY_SCALAR_FIELD(semi_can_btree);
1953 COPY_SCALAR_FIELD(semi_can_hash);
1954 COPY_NODE_FIELD(semi_operators);
1955 COPY_NODE_FIELD(semi_rhs_exprs);
1961 * _copyLateralJoinInfo
1963 static LateralJoinInfo *
1964 _copyLateralJoinInfo(const LateralJoinInfo *from)
1966 LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
1968 COPY_BITMAPSET_FIELD(lateral_lhs);
1969 COPY_BITMAPSET_FIELD(lateral_rhs);
1975 * _copyAppendRelInfo
1977 static AppendRelInfo *
1978 _copyAppendRelInfo(const AppendRelInfo *from)
1980 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1982 COPY_SCALAR_FIELD(parent_relid);
1983 COPY_SCALAR_FIELD(child_relid);
1984 COPY_SCALAR_FIELD(parent_reltype);
1985 COPY_SCALAR_FIELD(child_reltype);
1986 COPY_NODE_FIELD(translated_vars);
1987 COPY_SCALAR_FIELD(parent_reloid);
1993 * _copyPlaceHolderInfo
1995 static PlaceHolderInfo *
1996 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
1998 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
2000 COPY_SCALAR_FIELD(phid);
2001 COPY_NODE_FIELD(ph_var);
2002 COPY_BITMAPSET_FIELD(ph_eval_at);
2003 COPY_BITMAPSET_FIELD(ph_lateral);
2004 COPY_BITMAPSET_FIELD(ph_needed);
2005 COPY_SCALAR_FIELD(ph_width);
2010 /* ****************************************************************
2011 * parsenodes.h copy functions
2012 * ****************************************************************
2015 static RangeTblEntry *
2016 _copyRangeTblEntry(const RangeTblEntry *from)
2018 RangeTblEntry *newnode = makeNode(RangeTblEntry);
2020 COPY_SCALAR_FIELD(rtekind);
2021 COPY_SCALAR_FIELD(relid);
2022 COPY_SCALAR_FIELD(relkind);
2023 COPY_NODE_FIELD(subquery);
2024 COPY_SCALAR_FIELD(security_barrier);
2025 COPY_SCALAR_FIELD(jointype);
2026 COPY_NODE_FIELD(joinaliasvars);
2027 COPY_NODE_FIELD(functions);
2028 COPY_SCALAR_FIELD(funcordinality);
2029 COPY_NODE_FIELD(values_lists);
2030 COPY_NODE_FIELD(values_collations);
2031 COPY_STRING_FIELD(ctename);
2032 COPY_SCALAR_FIELD(ctelevelsup);
2033 COPY_SCALAR_FIELD(self_reference);
2034 COPY_NODE_FIELD(ctecoltypes);
2035 COPY_NODE_FIELD(ctecoltypmods);
2036 COPY_NODE_FIELD(ctecolcollations);
2037 COPY_NODE_FIELD(alias);
2038 COPY_NODE_FIELD(eref);
2039 COPY_SCALAR_FIELD(lateral);
2040 COPY_SCALAR_FIELD(inh);
2041 COPY_SCALAR_FIELD(inFromCl);
2042 COPY_SCALAR_FIELD(requiredPerms);
2043 COPY_SCALAR_FIELD(checkAsUser);
2044 COPY_BITMAPSET_FIELD(selectedCols);
2045 COPY_BITMAPSET_FIELD(modifiedCols);
2046 COPY_NODE_FIELD(securityQuals);
2051 static RangeTblFunction *
2052 _copyRangeTblFunction(const RangeTblFunction *from)
2054 RangeTblFunction *newnode = makeNode(RangeTblFunction);
2056 COPY_NODE_FIELD(funcexpr);
2057 COPY_SCALAR_FIELD(funccolcount);
2058 COPY_NODE_FIELD(funccolnames);
2059 COPY_NODE_FIELD(funccoltypes);
2060 COPY_NODE_FIELD(funccoltypmods);
2061 COPY_NODE_FIELD(funccolcollations);
2062 COPY_BITMAPSET_FIELD(funcparams);
2067 static WithCheckOption *
2068 _copyWithCheckOption(const WithCheckOption *from)
2070 WithCheckOption *newnode = makeNode(WithCheckOption);
2072 COPY_SCALAR_FIELD(kind);
2073 COPY_STRING_FIELD(relname);
2074 COPY_NODE_FIELD(qual);
2075 COPY_SCALAR_FIELD(cascaded);
2080 static SortGroupClause *
2081 _copySortGroupClause(const SortGroupClause *from)
2083 SortGroupClause *newnode = makeNode(SortGroupClause);
2085 COPY_SCALAR_FIELD(tleSortGroupRef);
2086 COPY_SCALAR_FIELD(eqop);
2087 COPY_SCALAR_FIELD(sortop);
2088 COPY_SCALAR_FIELD(nulls_first);
2089 COPY_SCALAR_FIELD(hashable);
2094 static WindowClause *
2095 _copyWindowClause(const WindowClause *from)
2097 WindowClause *newnode = makeNode(WindowClause);
2099 COPY_STRING_FIELD(name);
2100 COPY_STRING_FIELD(refname);
2101 COPY_NODE_FIELD(partitionClause);
2102 COPY_NODE_FIELD(orderClause);
2103 COPY_SCALAR_FIELD(frameOptions);
2104 COPY_NODE_FIELD(startOffset);
2105 COPY_NODE_FIELD(endOffset);
2106 COPY_SCALAR_FIELD(winref);
2107 COPY_SCALAR_FIELD(copiedOrder);
2112 static RowMarkClause *
2113 _copyRowMarkClause(const RowMarkClause *from)
2115 RowMarkClause *newnode = makeNode(RowMarkClause);
2117 COPY_SCALAR_FIELD(rti);
2118 COPY_SCALAR_FIELD(strength);
2119 COPY_SCALAR_FIELD(waitPolicy);
2120 COPY_SCALAR_FIELD(pushedDown);
2126 _copyWithClause(const WithClause *from)
2128 WithClause *newnode = makeNode(WithClause);
2130 COPY_NODE_FIELD(ctes);
2131 COPY_SCALAR_FIELD(recursive);
2132 COPY_LOCATION_FIELD(location);
2137 static CommonTableExpr *
2138 _copyCommonTableExpr(const CommonTableExpr *from)
2140 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2142 COPY_STRING_FIELD(ctename);
2143 COPY_NODE_FIELD(aliascolnames);
2144 COPY_NODE_FIELD(ctequery);
2145 COPY_LOCATION_FIELD(location);
2146 COPY_SCALAR_FIELD(cterecursive);
2147 COPY_SCALAR_FIELD(cterefcount);
2148 COPY_NODE_FIELD(ctecolnames);
2149 COPY_NODE_FIELD(ctecoltypes);
2150 COPY_NODE_FIELD(ctecoltypmods);
2151 COPY_NODE_FIELD(ctecolcollations);
2157 _copyAExpr(const A_Expr *from)
2159 A_Expr *newnode = makeNode(A_Expr);
2161 COPY_SCALAR_FIELD(kind);
2162 COPY_NODE_FIELD(name);
2163 COPY_NODE_FIELD(lexpr);
2164 COPY_NODE_FIELD(rexpr);
2165 COPY_LOCATION_FIELD(location);
2171 _copyColumnRef(const ColumnRef *from)
2173 ColumnRef *newnode = makeNode(ColumnRef);
2175 COPY_NODE_FIELD(fields);
2176 COPY_LOCATION_FIELD(location);
2182 _copyParamRef(const ParamRef *from)
2184 ParamRef *newnode = makeNode(ParamRef);
2186 COPY_SCALAR_FIELD(number);
2187 COPY_LOCATION_FIELD(location);
2193 _copyAConst(const A_Const *from)
2195 A_Const *newnode = makeNode(A_Const);
2197 /* This part must duplicate _copyValue */
2198 COPY_SCALAR_FIELD(val.type);
2199 switch (from->val.type)
2202 COPY_SCALAR_FIELD(val.val.ival);
2207 COPY_STRING_FIELD(val.val.str);
2213 elog(ERROR, "unrecognized node type: %d",
2214 (int) from->val.type);
2218 COPY_LOCATION_FIELD(location);
2224 _copyFuncCall(const FuncCall *from)
2226 FuncCall *newnode = makeNode(FuncCall);
2228 COPY_NODE_FIELD(funcname);
2229 COPY_NODE_FIELD(args);
2230 COPY_NODE_FIELD(agg_order);
2231 COPY_NODE_FIELD(agg_filter);
2232 COPY_SCALAR_FIELD(agg_within_group);
2233 COPY_SCALAR_FIELD(agg_star);
2234 COPY_SCALAR_FIELD(agg_distinct);
2235 COPY_SCALAR_FIELD(func_variadic);
2236 COPY_NODE_FIELD(over);
2237 COPY_LOCATION_FIELD(location);
2243 _copyAStar(const A_Star *from)
2245 A_Star *newnode = makeNode(A_Star);
2251 _copyAIndices(const A_Indices *from)
2253 A_Indices *newnode = makeNode(A_Indices);
2255 COPY_NODE_FIELD(lidx);
2256 COPY_NODE_FIELD(uidx);
2261 static A_Indirection *
2262 _copyA_Indirection(const A_Indirection *from)
2264 A_Indirection *newnode = makeNode(A_Indirection);
2266 COPY_NODE_FIELD(arg);
2267 COPY_NODE_FIELD(indirection);
2272 static A_ArrayExpr *
2273 _copyA_ArrayExpr(const A_ArrayExpr *from)
2275 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2277 COPY_NODE_FIELD(elements);
2278 COPY_LOCATION_FIELD(location);
2284 _copyResTarget(const ResTarget *from)
2286 ResTarget *newnode = makeNode(ResTarget);
2288 COPY_STRING_FIELD(name);
2289 COPY_NODE_FIELD(indirection);
2290 COPY_NODE_FIELD(val);
2291 COPY_LOCATION_FIELD(location);
2296 static MultiAssignRef *
2297 _copyMultiAssignRef(const MultiAssignRef *from)
2299 MultiAssignRef *newnode = makeNode(MultiAssignRef);
2301 COPY_NODE_FIELD(source);
2302 COPY_SCALAR_FIELD(colno);
2303 COPY_SCALAR_FIELD(ncolumns);
2309 _copyTypeName(const TypeName *from)
2311 TypeName *newnode = makeNode(TypeName);
2313 COPY_NODE_FIELD(names);
2314 COPY_SCALAR_FIELD(typeOid);
2315 COPY_SCALAR_FIELD(setof);
2316 COPY_SCALAR_FIELD(pct_type);
2317 COPY_NODE_FIELD(typmods);
2318 COPY_SCALAR_FIELD(typemod);
2319 COPY_NODE_FIELD(arrayBounds);
2320 COPY_LOCATION_FIELD(location);
2326 _copySortBy(const SortBy *from)
2328 SortBy *newnode = makeNode(SortBy);
2330 COPY_NODE_FIELD(node);
2331 COPY_SCALAR_FIELD(sortby_dir);
2332 COPY_SCALAR_FIELD(sortby_nulls);
2333 COPY_NODE_FIELD(useOp);
2334 COPY_LOCATION_FIELD(location);
2340 _copyWindowDef(const WindowDef *from)
2342 WindowDef *newnode = makeNode(WindowDef);
2344 COPY_STRING_FIELD(name);
2345 COPY_STRING_FIELD(refname);
2346 COPY_NODE_FIELD(partitionClause);
2347 COPY_NODE_FIELD(orderClause);
2348 COPY_SCALAR_FIELD(frameOptions);
2349 COPY_NODE_FIELD(startOffset);
2350 COPY_NODE_FIELD(endOffset);
2351 COPY_LOCATION_FIELD(location);
2356 static RangeSubselect *
2357 _copyRangeSubselect(const RangeSubselect *from)
2359 RangeSubselect *newnode = makeNode(RangeSubselect);
2361 COPY_SCALAR_FIELD(lateral);
2362 COPY_NODE_FIELD(subquery);
2363 COPY_NODE_FIELD(alias);
2368 static RangeFunction *
2369 _copyRangeFunction(const RangeFunction *from)
2371 RangeFunction *newnode = makeNode(RangeFunction);
2373 COPY_SCALAR_FIELD(lateral);
2374 COPY_SCALAR_FIELD(ordinality);
2375 COPY_SCALAR_FIELD(is_rowsfrom);
2376 COPY_NODE_FIELD(functions);
2377 COPY_NODE_FIELD(alias);
2378 COPY_NODE_FIELD(coldeflist);
2384 _copyTypeCast(const TypeCast *from)
2386 TypeCast *newnode = makeNode(TypeCast);
2388 COPY_NODE_FIELD(arg);
2389 COPY_NODE_FIELD(typeName);
2390 COPY_LOCATION_FIELD(location);
2395 static CollateClause *
2396 _copyCollateClause(const CollateClause *from)
2398 CollateClause *newnode = makeNode(CollateClause);
2400 COPY_NODE_FIELD(arg);
2401 COPY_NODE_FIELD(collname);
2402 COPY_LOCATION_FIELD(location);
2408 _copyIndexElem(const IndexElem *from)
2410 IndexElem *newnode = makeNode(IndexElem);
2412 COPY_STRING_FIELD(name);
2413 COPY_NODE_FIELD(expr);
2414 COPY_STRING_FIELD(indexcolname);
2415 COPY_NODE_FIELD(collation);
2416 COPY_NODE_FIELD(opclass);
2417 COPY_SCALAR_FIELD(ordering);
2418 COPY_SCALAR_FIELD(nulls_ordering);
2424 _copyColumnDef(const ColumnDef *from)
2426 ColumnDef *newnode = makeNode(ColumnDef);
2428 COPY_STRING_FIELD(colname);
2429 COPY_NODE_FIELD(typeName);
2430 COPY_SCALAR_FIELD(inhcount);
2431 COPY_SCALAR_FIELD(is_local);
2432 COPY_SCALAR_FIELD(is_not_null);
2433 COPY_SCALAR_FIELD(is_from_type);
2434 COPY_SCALAR_FIELD(storage);
2435 COPY_NODE_FIELD(raw_default);
2436 COPY_NODE_FIELD(cooked_default);
2437 COPY_NODE_FIELD(collClause);
2438 COPY_SCALAR_FIELD(collOid);
2439 COPY_NODE_FIELD(constraints);
2440 COPY_NODE_FIELD(fdwoptions);
2441 COPY_LOCATION_FIELD(location);
2447 _copyConstraint(const Constraint *from)
2449 Constraint *newnode = makeNode(Constraint);
2451 COPY_SCALAR_FIELD(contype);
2452 COPY_STRING_FIELD(conname);
2453 COPY_SCALAR_FIELD(deferrable);
2454 COPY_SCALAR_FIELD(initdeferred);
2455 COPY_LOCATION_FIELD(location);
2456 COPY_SCALAR_FIELD(is_no_inherit);
2457 COPY_NODE_FIELD(raw_expr);
2458 COPY_STRING_FIELD(cooked_expr);
2459 COPY_NODE_FIELD(keys);
2460 COPY_NODE_FIELD(exclusions);
2461 COPY_NODE_FIELD(options);
2462 COPY_STRING_FIELD(indexname);
2463 COPY_STRING_FIELD(indexspace);
2464 COPY_STRING_FIELD(access_method);
2465 COPY_NODE_FIELD(where_clause);
2466 COPY_NODE_FIELD(pktable);
2467 COPY_NODE_FIELD(fk_attrs);
2468 COPY_NODE_FIELD(pk_attrs);
2469 COPY_SCALAR_FIELD(fk_matchtype);
2470 COPY_SCALAR_FIELD(fk_upd_action);
2471 COPY_SCALAR_FIELD(fk_del_action);
2472 COPY_NODE_FIELD(old_conpfeqop);
2473 COPY_SCALAR_FIELD(old_pktable_oid);
2474 COPY_SCALAR_FIELD(skip_validation);
2475 COPY_SCALAR_FIELD(initially_valid);
2481 _copyDefElem(const DefElem *from)
2483 DefElem *newnode = makeNode(DefElem);
2485 COPY_STRING_FIELD(defnamespace);
2486 COPY_STRING_FIELD(defname);
2487 COPY_NODE_FIELD(arg);
2488 COPY_SCALAR_FIELD(defaction);
2493 static LockingClause *
2494 _copyLockingClause(const LockingClause *from)
2496 LockingClause *newnode = makeNode(LockingClause);
2498 COPY_NODE_FIELD(lockedRels);
2499 COPY_SCALAR_FIELD(strength);
2500 COPY_SCALAR_FIELD(waitPolicy);
2505 static XmlSerialize *
2506 _copyXmlSerialize(const XmlSerialize *from)
2508 XmlSerialize *newnode = makeNode(XmlSerialize);
2510 COPY_SCALAR_FIELD(xmloption);
2511 COPY_NODE_FIELD(expr);
2512 COPY_NODE_FIELD(typeName);
2513 COPY_LOCATION_FIELD(location);
2519 _copyRoleSpec(const RoleSpec *from)
2521 RoleSpec *newnode = makeNode(RoleSpec);
2523 COPY_SCALAR_FIELD(roletype);
2524 COPY_STRING_FIELD(rolename);
2525 COPY_LOCATION_FIELD(location);
2531 _copyQuery(const Query *from)
2533 Query *newnode = makeNode(Query);
2535 COPY_SCALAR_FIELD(commandType);
2536 COPY_SCALAR_FIELD(querySource);
2537 COPY_SCALAR_FIELD(queryId);
2538 COPY_SCALAR_FIELD(canSetTag);
2539 COPY_NODE_FIELD(utilityStmt);
2540 COPY_SCALAR_FIELD(resultRelation);
2541 COPY_SCALAR_FIELD(hasAggs);
2542 COPY_SCALAR_FIELD(hasWindowFuncs);
2543 COPY_SCALAR_FIELD(hasSubLinks);
2544 COPY_SCALAR_FIELD(hasDistinctOn);
2545 COPY_SCALAR_FIELD(hasRecursive);
2546 COPY_SCALAR_FIELD(hasModifyingCTE);
2547 COPY_SCALAR_FIELD(hasForUpdate);
2548 COPY_SCALAR_FIELD(hasRowSecurity);
2549 COPY_NODE_FIELD(cteList);
2550 COPY_NODE_FIELD(rtable);
2551 COPY_NODE_FIELD(jointree);
2552 COPY_NODE_FIELD(targetList);
2553 COPY_NODE_FIELD(withCheckOptions);
2554 COPY_NODE_FIELD(returningList);
2555 COPY_NODE_FIELD(groupClause);
2556 COPY_NODE_FIELD(havingQual);
2557 COPY_NODE_FIELD(windowClause);
2558 COPY_NODE_FIELD(distinctClause);
2559 COPY_NODE_FIELD(sortClause);
2560 COPY_NODE_FIELD(limitOffset);
2561 COPY_NODE_FIELD(limitCount);
2562 COPY_NODE_FIELD(rowMarks);
2563 COPY_NODE_FIELD(setOperations);
2564 COPY_NODE_FIELD(constraintDeps);
2570 _copyInsertStmt(const InsertStmt *from)
2572 InsertStmt *newnode = makeNode(InsertStmt);
2574 COPY_NODE_FIELD(relation);
2575 COPY_NODE_FIELD(cols);
2576 COPY_NODE_FIELD(selectStmt);
2577 COPY_NODE_FIELD(returningList);
2578 COPY_NODE_FIELD(withClause);
2584 _copyDeleteStmt(const DeleteStmt *from)
2586 DeleteStmt *newnode = makeNode(DeleteStmt);
2588 COPY_NODE_FIELD(relation);
2589 COPY_NODE_FIELD(usingClause);
2590 COPY_NODE_FIELD(whereClause);
2591 COPY_NODE_FIELD(returningList);
2592 COPY_NODE_FIELD(withClause);
2598 _copyUpdateStmt(const UpdateStmt *from)
2600 UpdateStmt *newnode = makeNode(UpdateStmt);
2602 COPY_NODE_FIELD(relation);
2603 COPY_NODE_FIELD(targetList);
2604 COPY_NODE_FIELD(whereClause);
2605 COPY_NODE_FIELD(fromClause);
2606 COPY_NODE_FIELD(returningList);
2607 COPY_NODE_FIELD(withClause);
2613 _copySelectStmt(const SelectStmt *from)
2615 SelectStmt *newnode = makeNode(SelectStmt);
2617 COPY_NODE_FIELD(distinctClause);
2618 COPY_NODE_FIELD(intoClause);
2619 COPY_NODE_FIELD(targetList);
2620 COPY_NODE_FIELD(fromClause);
2621 COPY_NODE_FIELD(whereClause);
2622 COPY_NODE_FIELD(groupClause);
2623 COPY_NODE_FIELD(havingClause);
2624 COPY_NODE_FIELD(windowClause);
2625 COPY_NODE_FIELD(valuesLists);
2626 COPY_NODE_FIELD(sortClause);
2627 COPY_NODE_FIELD(limitOffset);
2628 COPY_NODE_FIELD(limitCount);
2629 COPY_NODE_FIELD(lockingClause);
2630 COPY_NODE_FIELD(withClause);
2631 COPY_SCALAR_FIELD(op);
2632 COPY_SCALAR_FIELD(all);
2633 COPY_NODE_FIELD(larg);
2634 COPY_NODE_FIELD(rarg);
2639 static SetOperationStmt *
2640 _copySetOperationStmt(const SetOperationStmt *from)
2642 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2644 COPY_SCALAR_FIELD(op);
2645 COPY_SCALAR_FIELD(all);
2646 COPY_NODE_FIELD(larg);
2647 COPY_NODE_FIELD(rarg);
2648 COPY_NODE_FIELD(colTypes);
2649 COPY_NODE_FIELD(colTypmods);
2650 COPY_NODE_FIELD(colCollations);
2651 COPY_NODE_FIELD(groupClauses);
2656 static AlterTableStmt *
2657 _copyAlterTableStmt(const AlterTableStmt *from)
2659 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2661 COPY_NODE_FIELD(relation);
2662 COPY_NODE_FIELD(cmds);
2663 COPY_SCALAR_FIELD(relkind);
2664 COPY_SCALAR_FIELD(missing_ok);
2669 static AlterTableCmd *
2670 _copyAlterTableCmd(const AlterTableCmd *from)
2672 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2674 COPY_SCALAR_FIELD(subtype);
2675 COPY_STRING_FIELD(name);
2676 COPY_NODE_FIELD(newowner);
2677 COPY_NODE_FIELD(def);
2678 COPY_SCALAR_FIELD(behavior);
2679 COPY_SCALAR_FIELD(missing_ok);
2684 static AlterDomainStmt *
2685 _copyAlterDomainStmt(const AlterDomainStmt *from)
2687 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2689 COPY_SCALAR_FIELD(subtype);
2690 COPY_NODE_FIELD(typeName);
2691 COPY_STRING_FIELD(name);
2692 COPY_NODE_FIELD(def);
2693 COPY_SCALAR_FIELD(behavior);
2694 COPY_SCALAR_FIELD(missing_ok);
2700 _copyGrantStmt(const GrantStmt *from)
2702 GrantStmt *newnode = makeNode(GrantStmt);
2704 COPY_SCALAR_FIELD(is_grant);
2705 COPY_SCALAR_FIELD(targtype);
2706 COPY_SCALAR_FIELD(objtype);
2707 COPY_NODE_FIELD(objects);
2708 COPY_NODE_FIELD(privileges);
2709 COPY_NODE_FIELD(grantees);
2710 COPY_SCALAR_FIELD(grant_option);
2711 COPY_SCALAR_FIELD(behavior);
2716 static FuncWithArgs *
2717 _copyFuncWithArgs(const FuncWithArgs *from)
2719 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2721 COPY_NODE_FIELD(funcname);
2722 COPY_NODE_FIELD(funcargs);
2728 _copyAccessPriv(const AccessPriv *from)
2730 AccessPriv *newnode = makeNode(AccessPriv);
2732 COPY_STRING_FIELD(priv_name);
2733 COPY_NODE_FIELD(cols);
2738 static GrantRoleStmt *
2739 _copyGrantRoleStmt(const GrantRoleStmt *from)
2741 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2743 COPY_NODE_FIELD(granted_roles);
2744 COPY_NODE_FIELD(grantee_roles);
2745 COPY_SCALAR_FIELD(is_grant);
2746 COPY_SCALAR_FIELD(admin_opt);
2747 COPY_NODE_FIELD(grantor);
2748 COPY_SCALAR_FIELD(behavior);
2753 static AlterDefaultPrivilegesStmt *
2754 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
2756 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2758 COPY_NODE_FIELD(options);
2759 COPY_NODE_FIELD(action);
2764 static DeclareCursorStmt *
2765 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
2767 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2769 COPY_STRING_FIELD(portalname);
2770 COPY_SCALAR_FIELD(options);
2771 COPY_NODE_FIELD(query);
2776 static ClosePortalStmt *
2777 _copyClosePortalStmt(const ClosePortalStmt *from)
2779 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2781 COPY_STRING_FIELD(portalname);
2786 static ClusterStmt *
2787 _copyClusterStmt(const ClusterStmt *from)
2789 ClusterStmt *newnode = makeNode(ClusterStmt);
2791 COPY_NODE_FIELD(relation);
2792 COPY_STRING_FIELD(indexname);
2793 COPY_SCALAR_FIELD(verbose);
2799 _copyCopyStmt(const CopyStmt *from)
2801 CopyStmt *newnode = makeNode(CopyStmt);
2803 COPY_NODE_FIELD(relation);
2804 COPY_NODE_FIELD(query);
2805 COPY_NODE_FIELD(attlist);
2806 COPY_SCALAR_FIELD(is_from);
2807 COPY_SCALAR_FIELD(is_program);
2808 COPY_STRING_FIELD(filename);
2809 COPY_NODE_FIELD(options);
2815 * CopyCreateStmtFields
2817 * This function copies the fields of the CreateStmt node. It is used by
2818 * copy functions for classes which inherit from CreateStmt.
2821 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
2823 COPY_NODE_FIELD(relation);
2824 COPY_NODE_FIELD(tableElts);
2825 COPY_NODE_FIELD(inhRelations);
2826 COPY_NODE_FIELD(ofTypename);
2827 COPY_NODE_FIELD(constraints);
2828 COPY_NODE_FIELD(options);
2829 COPY_SCALAR_FIELD(oncommit);
2830 COPY_STRING_FIELD(tablespacename);
2831 COPY_SCALAR_FIELD(if_not_exists);
2835 _copyCreateStmt(const CreateStmt *from)
2837 CreateStmt *newnode = makeNode(CreateStmt);
2839 CopyCreateStmtFields(from, newnode);
2844 static TableLikeClause *
2845 _copyTableLikeClause(const TableLikeClause *from)
2847 TableLikeClause *newnode = makeNode(TableLikeClause);
2849 COPY_NODE_FIELD(relation);
2850 COPY_SCALAR_FIELD(options);
2856 _copyDefineStmt(const DefineStmt *from)
2858 DefineStmt *newnode = makeNode(DefineStmt);
2860 COPY_SCALAR_FIELD(kind);
2861 COPY_SCALAR_FIELD(oldstyle);
2862 COPY_NODE_FIELD(defnames);
2863 COPY_NODE_FIELD(args);
2864 COPY_NODE_FIELD(definition);
2870 _copyDropStmt(const DropStmt *from)
2872 DropStmt *newnode = makeNode(DropStmt);
2874 COPY_NODE_FIELD(objects);
2875 COPY_NODE_FIELD(arguments);
2876 COPY_SCALAR_FIELD(removeType);
2877 COPY_SCALAR_FIELD(behavior);
2878 COPY_SCALAR_FIELD(missing_ok);
2879 COPY_SCALAR_FIELD(concurrent);
2884 static TruncateStmt *
2885 _copyTruncateStmt(const TruncateStmt *from)
2887 TruncateStmt *newnode = makeNode(TruncateStmt);
2889 COPY_NODE_FIELD(relations);
2890 COPY_SCALAR_FIELD(restart_seqs);
2891 COPY_SCALAR_FIELD(behavior);
2896 static CommentStmt *
2897 _copyCommentStmt(const CommentStmt *from)
2899 CommentStmt *newnode = makeNode(CommentStmt);
2901 COPY_SCALAR_FIELD(objtype);
2902 COPY_NODE_FIELD(objname);
2903 COPY_NODE_FIELD(objargs);
2904 COPY_STRING_FIELD(comment);
2909 static SecLabelStmt *
2910 _copySecLabelStmt(const SecLabelStmt *from)
2912 SecLabelStmt *newnode = makeNode(SecLabelStmt);
2914 COPY_SCALAR_FIELD(objtype);
2915 COPY_NODE_FIELD(objname);
2916 COPY_NODE_FIELD(objargs);
2917 COPY_STRING_FIELD(provider);
2918 COPY_STRING_FIELD(label);
2924 _copyFetchStmt(const FetchStmt *from)
2926 FetchStmt *newnode = makeNode(FetchStmt);
2928 COPY_SCALAR_FIELD(direction);
2929 COPY_SCALAR_FIELD(howMany);
2930 COPY_STRING_FIELD(portalname);
2931 COPY_SCALAR_FIELD(ismove);
2937 _copyIndexStmt(const IndexStmt *from)
2939 IndexStmt *newnode = makeNode(IndexStmt);
2941 COPY_STRING_FIELD(idxname);
2942 COPY_NODE_FIELD(relation);
2943 COPY_STRING_FIELD(accessMethod);
2944 COPY_STRING_FIELD(tableSpace);
2945 COPY_NODE_FIELD(indexParams);
2946 COPY_NODE_FIELD(options);
2947 COPY_NODE_FIELD(whereClause);
2948 COPY_NODE_FIELD(excludeOpNames);
2949 COPY_STRING_FIELD(idxcomment);
2950 COPY_SCALAR_FIELD(indexOid);
2951 COPY_SCALAR_FIELD(oldNode);
2952 COPY_SCALAR_FIELD(unique);
2953 COPY_SCALAR_FIELD(primary);
2954 COPY_SCALAR_FIELD(isconstraint);
2955 COPY_SCALAR_FIELD(deferrable);
2956 COPY_SCALAR_FIELD(initdeferred);
2957 COPY_SCALAR_FIELD(transformed);
2958 COPY_SCALAR_FIELD(concurrent);
2959 COPY_SCALAR_FIELD(if_not_exists);
2964 static CreateFunctionStmt *
2965 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
2967 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2969 COPY_SCALAR_FIELD(replace);
2970 COPY_NODE_FIELD(funcname);
2971 COPY_NODE_FIELD(parameters);
2972 COPY_NODE_FIELD(returnType);
2973 COPY_NODE_FIELD(options);
2974 COPY_NODE_FIELD(withClause);
2979 static FunctionParameter *
2980 _copyFunctionParameter(const FunctionParameter *from)
2982 FunctionParameter *newnode = makeNode(FunctionParameter);
2984 COPY_STRING_FIELD(name);
2985 COPY_NODE_FIELD(argType);
2986 COPY_SCALAR_FIELD(mode);
2987 COPY_NODE_FIELD(defexpr);
2992 static AlterFunctionStmt *
2993 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
2995 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2997 COPY_NODE_FIELD(func);
2998 COPY_NODE_FIELD(actions);
3004 _copyDoStmt(const DoStmt *from)
3006 DoStmt *newnode = makeNode(DoStmt);
3008 COPY_NODE_FIELD(args);
3014 _copyRenameStmt(const RenameStmt *from)
3016 RenameStmt *newnode = makeNode(RenameStmt);
3018 COPY_SCALAR_FIELD(renameType);
3019 COPY_SCALAR_FIELD(relationType);
3020 COPY_NODE_FIELD(relation);
3021 COPY_NODE_FIELD(object);
3022 COPY_NODE_FIELD(objarg);
3023 COPY_STRING_FIELD(subname);
3024 COPY_STRING_FIELD(newname);
3025 COPY_SCALAR_FIELD(behavior);
3026 COPY_SCALAR_FIELD(missing_ok);
3031 static AlterObjectSchemaStmt *
3032 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
3034 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
3036 COPY_SCALAR_FIELD(objectType);
3037 COPY_NODE_FIELD(relation);
3038 COPY_NODE_FIELD(object);
3039 COPY_NODE_FIELD(objarg);
3040 COPY_STRING_FIELD(newschema);
3041 COPY_SCALAR_FIELD(missing_ok);
3046 static AlterOwnerStmt *
3047 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
3049 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
3051 COPY_SCALAR_FIELD(objectType);
3052 COPY_NODE_FIELD(relation);
3053 COPY_NODE_FIELD(object);
3054 COPY_NODE_FIELD(objarg);
3055 COPY_NODE_FIELD(newowner);
3061 _copyRuleStmt(const RuleStmt *from)
3063 RuleStmt *newnode = makeNode(RuleStmt);
3065 COPY_NODE_FIELD(relation);
3066 COPY_STRING_FIELD(rulename);
3067 COPY_NODE_FIELD(whereClause);
3068 COPY_SCALAR_FIELD(event);
3069 COPY_SCALAR_FIELD(instead);
3070 COPY_NODE_FIELD(actions);
3071 COPY_SCALAR_FIELD(replace);
3077 _copyNotifyStmt(const NotifyStmt *from)
3079 NotifyStmt *newnode = makeNode(NotifyStmt);
3081 COPY_STRING_FIELD(conditionname);
3082 COPY_STRING_FIELD(payload);
3088 _copyListenStmt(const ListenStmt *from)
3090 ListenStmt *newnode = makeNode(ListenStmt);
3092 COPY_STRING_FIELD(conditionname);
3097 static UnlistenStmt *
3098 _copyUnlistenStmt(const UnlistenStmt *from)
3100 UnlistenStmt *newnode = makeNode(UnlistenStmt);
3102 COPY_STRING_FIELD(conditionname);
3107 static TransactionStmt *
3108 _copyTransactionStmt(const TransactionStmt *from)
3110 TransactionStmt *newnode = makeNode(TransactionStmt);
3112 COPY_SCALAR_FIELD(kind);
3113 COPY_NODE_FIELD(options);
3114 COPY_STRING_FIELD(gid);
3119 static CompositeTypeStmt *
3120 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3122 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3124 COPY_NODE_FIELD(typevar);
3125 COPY_NODE_FIELD(coldeflist);
3130 static CreateEnumStmt *
3131 _copyCreateEnumStmt(const CreateEnumStmt *from)
3133 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3135 COPY_NODE_FIELD(typeName);
3136 COPY_NODE_FIELD(vals);
3141 static CreateRangeStmt *
3142 _copyCreateRangeStmt(const CreateRangeStmt *from)
3144 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3146 COPY_NODE_FIELD(typeName);
3147 COPY_NODE_FIELD(params);
3152 static AlterEnumStmt *
3153 _copyAlterEnumStmt(const AlterEnumStmt *from)
3155 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3157 COPY_NODE_FIELD(typeName);
3158 COPY_STRING_FIELD(newVal);
3159 COPY_STRING_FIELD(newValNeighbor);
3160 COPY_SCALAR_FIELD(newValIsAfter);
3161 COPY_SCALAR_FIELD(skipIfExists);
3167 _copyViewStmt(const ViewStmt *from)
3169 ViewStmt *newnode = makeNode(ViewStmt);
3171 COPY_NODE_FIELD(view);
3172 COPY_NODE_FIELD(aliases);
3173 COPY_NODE_FIELD(query);
3174 COPY_SCALAR_FIELD(replace);
3175 COPY_NODE_FIELD(options);
3176 COPY_SCALAR_FIELD(withCheckOption);
3182 _copyLoadStmt(const LoadStmt *from)
3184 LoadStmt *newnode = makeNode(LoadStmt);
3186 COPY_STRING_FIELD(filename);
3191 static CreateDomainStmt *
3192 _copyCreateDomainStmt(const CreateDomainStmt *from)
3194 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3196 COPY_NODE_FIELD(domainname);
3197 COPY_NODE_FIELD(typeName);
3198 COPY_NODE_FIELD(collClause);
3199 COPY_NODE_FIELD(constraints);
3204 static CreateOpClassStmt *
3205 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3207 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3209 COPY_NODE_FIELD(opclassname);
3210 COPY_NODE_FIELD(opfamilyname);
3211 COPY_STRING_FIELD(amname);
3212 COPY_NODE_FIELD(datatype);
3213 COPY_NODE_FIELD(items);
3214 COPY_SCALAR_FIELD(isDefault);
3219 static CreateOpClassItem *
3220 _copyCreateOpClassItem(const CreateOpClassItem *from)
3222 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3224 COPY_SCALAR_FIELD(itemtype);
3225 COPY_NODE_FIELD(name);
3226 COPY_NODE_FIELD(args);
3227 COPY_SCALAR_FIELD(number);
3228 COPY_NODE_FIELD(order_family);
3229 COPY_NODE_FIELD(class_args);
3230 COPY_NODE_FIELD(storedtype);
3235 static CreateOpFamilyStmt *
3236 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3238 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3240 COPY_NODE_FIELD(opfamilyname);
3241 COPY_STRING_FIELD(amname);
3246 static AlterOpFamilyStmt *
3247 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3249 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3251 COPY_NODE_FIELD(opfamilyname);
3252 COPY_STRING_FIELD(amname);
3253 COPY_SCALAR_FIELD(isDrop);
3254 COPY_NODE_FIELD(items);
3259 static CreatedbStmt *
3260 _copyCreatedbStmt(const CreatedbStmt *from)
3262 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3264 COPY_STRING_FIELD(dbname);
3265 COPY_NODE_FIELD(options);
3270 static AlterDatabaseStmt *
3271 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3273 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3275 COPY_STRING_FIELD(dbname);
3276 COPY_NODE_FIELD(options);
3281 static AlterDatabaseSetStmt *
3282 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3284 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3286 COPY_STRING_FIELD(dbname);
3287 COPY_NODE_FIELD(setstmt);
3293 _copyDropdbStmt(const DropdbStmt *from)
3295 DropdbStmt *newnode = makeNode(DropdbStmt);
3297 COPY_STRING_FIELD(dbname);
3298 COPY_SCALAR_FIELD(missing_ok);
3304 _copyVacuumStmt(const VacuumStmt *from)
3306 VacuumStmt *newnode = makeNode(VacuumStmt);
3308 COPY_SCALAR_FIELD(options);
3309 COPY_NODE_FIELD(relation);
3310 COPY_NODE_FIELD(va_cols);
3315 static ExplainStmt *
3316 _copyExplainStmt(const ExplainStmt *from)
3318 ExplainStmt *newnode = makeNode(ExplainStmt);
3320 COPY_NODE_FIELD(query);
3321 COPY_NODE_FIELD(options);
3326 static CreateTableAsStmt *
3327 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3329 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3331 COPY_NODE_FIELD(query);
3332 COPY_NODE_FIELD(into);
3333 COPY_SCALAR_FIELD(relkind);
3334 COPY_SCALAR_FIELD(is_select_into);
3335 COPY_SCALAR_FIELD(if_not_exists);
3340 static RefreshMatViewStmt *
3341 _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
3343 RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
3345 COPY_SCALAR_FIELD(concurrent);
3346 COPY_SCALAR_FIELD(skipData);
3347 COPY_NODE_FIELD(relation);
3352 static ReplicaIdentityStmt *
3353 _copyReplicaIdentityStmt(const ReplicaIdentityStmt *from)
3355 ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt);
3357 COPY_SCALAR_FIELD(identity_type);
3358 COPY_STRING_FIELD(name);
3363 static AlterSystemStmt *
3364 _copyAlterSystemStmt(const AlterSystemStmt *from)
3366 AlterSystemStmt *newnode = makeNode(AlterSystemStmt);
3368 COPY_NODE_FIELD(setstmt);
3373 static CreateSeqStmt *
3374 _copyCreateSeqStmt(const CreateSeqStmt *from)
3376 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3378 COPY_NODE_FIELD(sequence);
3379 COPY_NODE_FIELD(options);
3380 COPY_SCALAR_FIELD(ownerId);
3381 COPY_SCALAR_FIELD(if_not_exists);
3386 static AlterSeqStmt *
3387 _copyAlterSeqStmt(const AlterSeqStmt *from)
3389 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3391 COPY_NODE_FIELD(sequence);
3392 COPY_NODE_FIELD(options);
3393 COPY_SCALAR_FIELD(missing_ok);
3398 static VariableSetStmt *
3399 _copyVariableSetStmt(const VariableSetStmt *from)
3401 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3403 COPY_SCALAR_FIELD(kind);
3404 COPY_STRING_FIELD(name);
3405 COPY_NODE_FIELD(args);
3406 COPY_SCALAR_FIELD(is_local);
3411 static VariableShowStmt *
3412 _copyVariableShowStmt(const VariableShowStmt *from)
3414 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3416 COPY_STRING_FIELD(name);
3421 static DiscardStmt *
3422 _copyDiscardStmt(const DiscardStmt *from)
3424 DiscardStmt *newnode = makeNode(DiscardStmt);
3426 COPY_SCALAR_FIELD(target);
3431 static CreateTableSpaceStmt *
3432 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3434 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3436 COPY_STRING_FIELD(tablespacename);
3437 COPY_NODE_FIELD(owner);
3438 COPY_STRING_FIELD(location);
3439 COPY_NODE_FIELD(options);
3444 static DropTableSpaceStmt *
3445 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
3447 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3449 COPY_STRING_FIELD(tablespacename);
3450 COPY_SCALAR_FIELD(missing_ok);
3455 static AlterTableSpaceOptionsStmt *
3456 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
3458 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3460 COPY_STRING_FIELD(tablespacename);
3461 COPY_NODE_FIELD(options);
3462 COPY_SCALAR_FIELD(isReset);
3467 static AlterTableMoveAllStmt *
3468 _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
3470 AlterTableMoveAllStmt *newnode = makeNode(AlterTableMoveAllStmt);
3472 COPY_STRING_FIELD(orig_tablespacename);
3473 COPY_SCALAR_FIELD(objtype);
3474 COPY_NODE_FIELD(roles);
3475 COPY_STRING_FIELD(new_tablespacename);
3476 COPY_SCALAR_FIELD(nowait);
3481 static CreateExtensionStmt *
3482 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
3484 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3486 COPY_STRING_FIELD(extname);
3487 COPY_SCALAR_FIELD(if_not_exists);
3488 COPY_NODE_FIELD(options);
3493 static AlterExtensionStmt *
3494 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
3496 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3498 COPY_STRING_FIELD(extname);
3499 COPY_NODE_FIELD(options);
3504 static AlterExtensionContentsStmt *
3505 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
3507 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3509 COPY_STRING_FIELD(extname);
3510 COPY_SCALAR_FIELD(action);
3511 COPY_SCALAR_FIELD(objtype);
3512 COPY_NODE_FIELD(objname);
3513 COPY_NODE_FIELD(objargs);
3518 static CreateFdwStmt *
3519 _copyCreateFdwStmt(const CreateFdwStmt *from)
3521 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3523 COPY_STRING_FIELD(fdwname);
3524 COPY_NODE_FIELD(func_options);
3525 COPY_NODE_FIELD(options);
3530 static AlterFdwStmt *
3531 _copyAlterFdwStmt(const AlterFdwStmt *from)
3533 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3535 COPY_STRING_FIELD(fdwname);
3536 COPY_NODE_FIELD(func_options);
3537 COPY_NODE_FIELD(options);
3542 static CreateForeignServerStmt *
3543 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
3545 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3547 COPY_STRING_FIELD(servername);
3548 COPY_STRING_FIELD(servertype);
3549 COPY_STRING_FIELD(version);
3550 COPY_STRING_FIELD(fdwname);
3551 COPY_NODE_FIELD(options);
3556 static AlterForeignServerStmt *
3557 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
3559 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3561 COPY_STRING_FIELD(servername);
3562 COPY_STRING_FIELD(version);
3563 COPY_NODE_FIELD(options);
3564 COPY_SCALAR_FIELD(has_version);
3569 static CreateUserMappingStmt *
3570 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
3572 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3574 COPY_NODE_FIELD(user);
3575 COPY_STRING_FIELD(servername);
3576 COPY_NODE_FIELD(options);
3581 static AlterUserMappingStmt *
3582 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
3584 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3586 COPY_NODE_FIELD(user);
3587 COPY_STRING_FIELD(servername);
3588 COPY_NODE_FIELD(options);
3593 static DropUserMappingStmt *
3594 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
3596 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3598 COPY_NODE_FIELD(user);
3599 COPY_STRING_FIELD(servername);
3600 COPY_SCALAR_FIELD(missing_ok);
3605 static CreateForeignTableStmt *
3606 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
3608 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3610 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
3612 COPY_STRING_FIELD(servername);
3613 COPY_NODE_FIELD(options);
3618 static ImportForeignSchemaStmt *
3619 _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
3621 ImportForeignSchemaStmt *newnode = makeNode(ImportForeignSchemaStmt);
3623 COPY_STRING_FIELD(server_name);
3624 COPY_STRING_FIELD(remote_schema);
3625 COPY_STRING_FIELD(local_schema);
3626 COPY_SCALAR_FIELD(list_type);
3627 COPY_NODE_FIELD(table_list);
3628 COPY_NODE_FIELD(options);
3633 static CreateTransformStmt *
3634 _copyCreateTransformStmt(const CreateTransformStmt *from)
3636 CreateTransformStmt *newnode = makeNode(CreateTransformStmt);
3638 COPY_SCALAR_FIELD(replace);
3639 COPY_NODE_FIELD(type_name);
3640 COPY_STRING_FIELD(lang);
3641 COPY_NODE_FIELD(fromsql);
3642 COPY_NODE_FIELD(tosql);
3647 static CreateTrigStmt *
3648 _copyCreateTrigStmt(const CreateTrigStmt *from)
3650 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3652 COPY_STRING_FIELD(trigname);
3653 COPY_NODE_FIELD(relation);
3654 COPY_NODE_FIELD(funcname);
3655 COPY_NODE_FIELD(args);
3656 COPY_SCALAR_FIELD(row);
3657 COPY_SCALAR_FIELD(timing);
3658 COPY_SCALAR_FIELD(events);
3659 COPY_NODE_FIELD(columns);
3660 COPY_NODE_FIELD(whenClause);
3661 COPY_SCALAR_FIELD(isconstraint);
3662 COPY_SCALAR_FIELD(deferrable);
3663 COPY_SCALAR_FIELD(initdeferred);
3664 COPY_NODE_FIELD(constrrel);
3669 static CreateEventTrigStmt *
3670 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
3672 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
3674 COPY_STRING_FIELD(trigname);
3675 COPY_STRING_FIELD(eventname);
3676 COPY_NODE_FIELD(whenclause);
3677 COPY_NODE_FIELD(funcname);
3682 static AlterEventTrigStmt *
3683 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
3685 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
3687 COPY_STRING_FIELD(trigname);
3688 COPY_SCALAR_FIELD(tgenabled);
3693 static CreatePLangStmt *
3694 _copyCreatePLangStmt(const CreatePLangStmt *from)
3696 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3698 COPY_SCALAR_FIELD(replace);
3699 COPY_STRING_FIELD(plname);
3700 COPY_NODE_FIELD(plhandler);
3701 COPY_NODE_FIELD(plinline);
3702 COPY_NODE_FIELD(plvalidator);
3703 COPY_SCALAR_FIELD(pltrusted);
3708 static CreateRoleStmt *
3709 _copyCreateRoleStmt(const CreateRoleStmt *from)
3711 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3713 COPY_SCALAR_FIELD(stmt_type);
3714 COPY_STRING_FIELD(role);
3715 COPY_NODE_FIELD(options);
3720 static AlterRoleStmt *
3721 _copyAlterRoleStmt(const AlterRoleStmt *from)
3723 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3725 COPY_NODE_FIELD(role);
3726 COPY_NODE_FIELD(options);
3727 COPY_SCALAR_FIELD(action);
3732 static AlterRoleSetStmt *
3733 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
3735 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3737 COPY_NODE_FIELD(role);
3738 COPY_STRING_FIELD(database);
3739 COPY_NODE_FIELD(setstmt);
3744 static DropRoleStmt *
3745 _copyDropRoleStmt(const DropRoleStmt *from)
3747 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3749 COPY_NODE_FIELD(roles);
3750 COPY_SCALAR_FIELD(missing_ok);
3756 _copyLockStmt(const LockStmt *from)
3758 LockStmt *newnode = makeNode(LockStmt);
3760 COPY_NODE_FIELD(relations);
3761 COPY_SCALAR_FIELD(mode);
3762 COPY_SCALAR_FIELD(nowait);
3767 static ConstraintsSetStmt *
3768 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
3770 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3772 COPY_NODE_FIELD(constraints);
3773 COPY_SCALAR_FIELD(deferred);
3778 static ReindexStmt *
3779 _copyReindexStmt(const ReindexStmt *from)
3781 ReindexStmt *newnode = makeNode(ReindexStmt);
3783 COPY_SCALAR_FIELD(kind);
3784 COPY_NODE_FIELD(relation);
3785 COPY_STRING_FIELD(name);
3790 static CreateSchemaStmt *
3791 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
3793 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3795 COPY_STRING_FIELD(schemaname);
3796 COPY_NODE_FIELD(authrole);
3797 COPY_NODE_FIELD(schemaElts);
3798 COPY_SCALAR_FIELD(if_not_exists);
3803 static CreateConversionStmt *
3804 _copyCreateConversionStmt(const CreateConversionStmt *from)
3806 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3808 COPY_NODE_FIELD(conversion_name);
3809 COPY_STRING_FIELD(for_encoding_name);
3810 COPY_STRING_FIELD(to_encoding_name);
3811 COPY_NODE_FIELD(func_name);
3812 COPY_SCALAR_FIELD(def);
3817 static CreateCastStmt *
3818 _copyCreateCastStmt(const CreateCastStmt *from)
3820 CreateCastStmt *newnode = makeNode(CreateCastStmt);
3822 COPY_NODE_FIELD(sourcetype);
3823 COPY_NODE_FIELD(targettype);
3824 COPY_NODE_FIELD(func);
3825 COPY_SCALAR_FIELD(context);
3826 COPY_SCALAR_FIELD(inout);
3831 static PrepareStmt *
3832 _copyPrepareStmt(const PrepareStmt *from)
3834 PrepareStmt *newnode = makeNode(PrepareStmt);
3836 COPY_STRING_FIELD(name);
3837 COPY_NODE_FIELD(argtypes);
3838 COPY_NODE_FIELD(query);
3843 static ExecuteStmt *
3844 _copyExecuteStmt(const ExecuteStmt *from)
3846 ExecuteStmt *newnode = makeNode(ExecuteStmt);
3848 COPY_STRING_FIELD(name);
3849 COPY_NODE_FIELD(params);
3854 static DeallocateStmt *
3855 _copyDeallocateStmt(const DeallocateStmt *from)
3857 DeallocateStmt *newnode = makeNode(DeallocateStmt);
3859 COPY_STRING_FIELD(name);
3864 static DropOwnedStmt *
3865 _copyDropOwnedStmt(const DropOwnedStmt *from)
3867 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3869 COPY_NODE_FIELD(roles);
3870 COPY_SCALAR_FIELD(behavior);
3875 static ReassignOwnedStmt *
3876 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
3878 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3880 COPY_NODE_FIELD(roles);
3881 COPY_NODE_FIELD(newrole);
3886 static AlterTSDictionaryStmt *
3887 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
3889 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3891 COPY_NODE_FIELD(dictname);
3892 COPY_NODE_FIELD(options);
3897 static AlterTSConfigurationStmt *
3898 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
3900 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3902 COPY_NODE_FIELD(cfgname);
3903 COPY_NODE_FIELD(tokentype);
3904 COPY_NODE_FIELD(dicts);
3905 COPY_SCALAR_FIELD(override);
3906 COPY_SCALAR_FIELD(replace);
3907 COPY_SCALAR_FIELD(missing_ok);
3912 static CreatePolicyStmt *
3913 _copyCreatePolicyStmt(const CreatePolicyStmt *from)
3915 CreatePolicyStmt *newnode = makeNode(CreatePolicyStmt);
3917 COPY_STRING_FIELD(policy_name);
3918 COPY_NODE_FIELD(table);
3919 COPY_SCALAR_FIELD(cmd);
3920 COPY_NODE_FIELD(roles);
3921 COPY_NODE_FIELD(qual);
3922 COPY_NODE_FIELD(with_check);
3927 static AlterPolicyStmt *
3928 _copyAlterPolicyStmt(const AlterPolicyStmt *from)
3930 AlterPolicyStmt *newnode = makeNode(AlterPolicyStmt);
3932 COPY_STRING_FIELD(policy_name);
3933 COPY_NODE_FIELD(table);
3934 COPY_NODE_FIELD(roles);
3935 COPY_NODE_FIELD(qual);
3936 COPY_NODE_FIELD(with_check);
3941 /* ****************************************************************
3942 * pg_list.h copy functions
3943 * ****************************************************************
3947 * Perform a deep copy of the specified list, using copyObject(). The
3948 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
3949 * need deep copies, so they should be copied via list_copy()
3951 #define COPY_NODE_CELL(new, old) \
3952 (new) = (ListCell *) palloc(sizeof(ListCell)); \
3953 lfirst(new) = copyObject(lfirst(old));
3956 _copyList(const List *from)
3962 Assert(list_length(from) >= 1);
3964 new = makeNode(List);
3965 new->length = from->length;
3967 COPY_NODE_CELL(new->head, from->head);
3968 prev_new = new->head;
3969 curr_old = lnext(from->head);
3973 COPY_NODE_CELL(prev_new->next, curr_old);
3974 prev_new = prev_new->next;
3975 curr_old = curr_old->next;
3977 prev_new->next = NULL;
3978 new->tail = prev_new;
3983 /* ****************************************************************
3984 * value.h copy functions
3985 * ****************************************************************
3988 _copyValue(const Value *from)
3990 Value *newnode = makeNode(Value);
3992 /* See also _copyAConst when changing this code! */
3994 COPY_SCALAR_FIELD(type);
3998 COPY_SCALAR_FIELD(val.ival);
4003 COPY_STRING_FIELD(val.str);
4009 elog(ERROR, "unrecognized node type: %d",
4019 * Create a copy of a Node tree or list. This is a "deep" copy: all
4020 * substructure is copied too, recursively.
4023 copyObject(const void *from)
4030 /* Guard against stack overflow due to overly complex expressions */
4031 check_stack_depth();
4033 switch (nodeTag(from))
4039 retval = _copyPlannedStmt(from);
4042 retval = _copyPlan(from);
4045 retval = _copyResult(from);
4048 retval = _copyModifyTable(from);
4051 retval = _copyAppend(from);
4054 retval = _copyMergeAppend(from);
4056 case T_RecursiveUnion:
4057 retval = _copyRecursiveUnion(from);
4060 retval = _copyBitmapAnd(from);
4063 retval = _copyBitmapOr(from);
4066 retval = _copyScan(from);
4069 retval = _copySeqScan(from);
4072 retval = _copyIndexScan(from);
4074 case T_IndexOnlyScan:
4075 retval = _copyIndexOnlyScan(from);
4077 case T_BitmapIndexScan:
4078 retval = _copyBitmapIndexScan(from);
4080 case T_BitmapHeapScan:
4081 retval = _copyBitmapHeapScan(from);
4084 retval = _copyTidScan(from);
4086 case T_SubqueryScan:
4087 retval = _copySubqueryScan(from);
4089 case T_FunctionScan:
4090 retval = _copyFunctionScan(from);
4093 retval = _copyValuesScan(from);
4096 retval = _copyCteScan(from);
4098 case T_WorkTableScan:
4099 retval = _copyWorkTableScan(from);
4102 retval = _copyForeignScan(from);
4105 retval = _copyCustomScan(from);
4108 retval = _copyJoin(from);
4111 retval = _copyNestLoop(from);
4114 retval = _copyMergeJoin(from);
4117 retval = _copyHashJoin(from);
4120 retval = _copyMaterial(from);
4123 retval = _copySort(from);
4126 retval = _copyGroup(from);
4129 retval = _copyAgg(from);
4132 retval = _copyWindowAgg(from);
4135 retval = _copyUnique(from);
4138 retval = _copyHash(from);
4141 retval = _copySetOp(from);
4144 retval = _copyLockRows(from);
4147 retval = _copyLimit(from);
4149 case T_NestLoopParam:
4150 retval = _copyNestLoopParam(from);
4153 retval = _copyPlanRowMark(from);
4155 case T_PlanInvalItem:
4156 retval = _copyPlanInvalItem(from);
4163 retval = _copyAlias(from);
4166 retval = _copyRangeVar(from);
4169 retval = _copyIntoClause(from);
4172 retval = _copyVar(from);
4175 retval = _copyConst(from);
4178 retval = _copyParam(from);
4181 retval = _copyAggref(from);
4184 retval = _copyWindowFunc(from);
4187 retval = _copyArrayRef(from);
4190 retval = _copyFuncExpr(from);
4192 case T_NamedArgExpr:
4193 retval = _copyNamedArgExpr(from);
4196 retval = _copyOpExpr(from);
4198 case T_DistinctExpr:
4199 retval = _copyDistinctExpr(from);
4202 retval = _copyNullIfExpr(from);
4204 case T_ScalarArrayOpExpr:
4205 retval = _copyScalarArrayOpExpr(from);
4208 retval = _copyBoolExpr(from);
4211 retval = _copySubLink(from);
4214 retval = _copySubPlan(from);
4216 case T_AlternativeSubPlan:
4217 retval = _copyAlternativeSubPlan(from);
4220 retval = _copyFieldSelect(from);
4223 retval = _copyFieldStore(from);
4226 retval = _copyRelabelType(from);
4229 retval = _copyCoerceViaIO(from);
4231 case T_ArrayCoerceExpr:
4232 retval = _copyArrayCoerceExpr(from);
4234 case T_ConvertRowtypeExpr:
4235 retval = _copyConvertRowtypeExpr(from);
4238 retval = _copyCollateExpr(from);
4241 retval = _copyCaseExpr(from);
4244 retval = _copyCaseWhen(from);
4246 case T_CaseTestExpr:
4247 retval = _copyCaseTestExpr(from);
4250 retval = _copyArrayExpr(from);
4253 retval = _copyRowExpr(from);
4255 case T_RowCompareExpr:
4256 retval = _copyRowCompareExpr(from);
4258 case T_CoalesceExpr:
4259 retval = _copyCoalesceExpr(from);
4262 retval = _copyMinMaxExpr(from);
4265 retval = _copyXmlExpr(from);
4268 retval = _copyNullTest(from);
4271 retval = _copyBooleanTest(from);
4273 case T_CoerceToDomain:
4274 retval = _copyCoerceToDomain(from);
4276 case T_CoerceToDomainValue:
4277 retval = _copyCoerceToDomainValue(from);
4279 case T_SetToDefault:
4280 retval = _copySetToDefault(from);
4282 case T_CurrentOfExpr:
4283 retval = _copyCurrentOfExpr(from);
4286 retval = _copyTargetEntry(from);
4289 retval = _copyRangeTblRef(from);
4292 retval = _copyJoinExpr(from);
4295 retval = _copyFromExpr(from);
4302 retval = _copyPathKey(from);
4304 case T_RestrictInfo:
4305 retval = _copyRestrictInfo(from);
4307 case T_PlaceHolderVar:
4308 retval = _copyPlaceHolderVar(from);
4310 case T_SpecialJoinInfo:
4311 retval = _copySpecialJoinInfo(from);
4313 case T_LateralJoinInfo:
4314 retval = _copyLateralJoinInfo(from);
4316 case T_AppendRelInfo:
4317 retval = _copyAppendRelInfo(from);
4319 case T_PlaceHolderInfo:
4320 retval = _copyPlaceHolderInfo(from);
4331 retval = _copyValue(from);
4338 retval = _copyList(from);
4342 * Lists of integers and OIDs don't need to be deep-copied, so we
4343 * perform a shallow copy via list_copy()
4347 retval = list_copy(from);
4354 retval = _copyQuery(from);
4357 retval = _copyInsertStmt(from);
4360 retval = _copyDeleteStmt(from);
4363 retval = _copyUpdateStmt(from);
4366 retval = _copySelectStmt(from);
4368 case T_SetOperationStmt:
4369 retval = _copySetOperationStmt(from);
4371 case T_AlterTableStmt:
4372 retval = _copyAlterTableStmt(from);
4374 case T_AlterTableCmd:
4375 retval = _copyAlterTableCmd(from);
4377 case T_AlterDomainStmt:
4378 retval = _copyAlterDomainStmt(from);
4381 retval = _copyGrantStmt(from);
4383 case T_GrantRoleStmt:
4384 retval = _copyGrantRoleStmt(from);
4386 case T_AlterDefaultPrivilegesStmt:
4387 retval = _copyAlterDefaultPrivilegesStmt(from);
4389 case T_DeclareCursorStmt:
4390 retval = _copyDeclareCursorStmt(from);
4392 case T_ClosePortalStmt:
4393 retval = _copyClosePortalStmt(from);
4396 retval = _copyClusterStmt(from);
4399 retval = _copyCopyStmt(from);
4402 retval = _copyCreateStmt(from);
4404 case T_TableLikeClause:
4405 retval = _copyTableLikeClause(from);
4408 retval = _copyDefineStmt(from);
4411 retval = _copyDropStmt(from);
4413 case T_TruncateStmt:
4414 retval = _copyTruncateStmt(from);
4417 retval = _copyCommentStmt(from);
4419 case T_SecLabelStmt:
4420 retval = _copySecLabelStmt(from);
4423 retval = _copyFetchStmt(from);
4426 retval = _copyIndexStmt(from);
4428 case T_CreateFunctionStmt:
4429 retval = _copyCreateFunctionStmt(from);
4431 case T_FunctionParameter:
4432 retval = _copyFunctionParameter(from);
4434 case T_AlterFunctionStmt:
4435 retval = _copyAlterFunctionStmt(from);
4438 retval = _copyDoStmt(from);
4441 retval = _copyRenameStmt(from);
4443 case T_AlterObjectSchemaStmt:
4444 retval = _copyAlterObjectSchemaStmt(from);
4446 case T_AlterOwnerStmt:
4447 retval = _copyAlterOwnerStmt(from);
4450 retval = _copyRuleStmt(from);
4453 retval = _copyNotifyStmt(from);
4456 retval = _copyListenStmt(from);
4458 case T_UnlistenStmt:
4459 retval = _copyUnlistenStmt(from);
4461 case T_TransactionStmt:
4462 retval = _copyTransactionStmt(from);
4464 case T_CompositeTypeStmt:
4465 retval = _copyCompositeTypeStmt(from);
4467 case T_CreateEnumStmt:
4468 retval = _copyCreateEnumStmt(from);
4470 case T_CreateRangeStmt:
4471 retval = _copyCreateRangeStmt(from);
4473 case T_AlterEnumStmt:
4474 retval = _copyAlterEnumStmt(from);
4477 retval = _copyViewStmt(from);
4480 retval = _copyLoadStmt(from);
4482 case T_CreateDomainStmt:
4483 retval = _copyCreateDomainStmt(from);
4485 case T_CreateOpClassStmt:
4486 retval = _copyCreateOpClassStmt(from);
4488 case T_CreateOpClassItem:
4489 retval = _copyCreateOpClassItem(from);
4491 case T_CreateOpFamilyStmt:
4492 retval = _copyCreateOpFamilyStmt(from);
4494 case T_AlterOpFamilyStmt:
4495 retval = _copyAlterOpFamilyStmt(from);
4497 case T_CreatedbStmt:
4498 retval = _copyCreatedbStmt(from);
4500 case T_AlterDatabaseStmt:
4501 retval = _copyAlterDatabaseStmt(from);
4503 case T_AlterDatabaseSetStmt:
4504 retval = _copyAlterDatabaseSetStmt(from);
4507 retval = _copyDropdbStmt(from);
4510 retval = _copyVacuumStmt(from);
4513 retval = _copyExplainStmt(from);
4515 case T_CreateTableAsStmt:
4516 retval = _copyCreateTableAsStmt(from);
4518 case T_RefreshMatViewStmt:
4519 retval = _copyRefreshMatViewStmt(from);
4521 case T_ReplicaIdentityStmt:
4522 retval = _copyReplicaIdentityStmt(from);
4524 case T_AlterSystemStmt:
4525 retval = _copyAlterSystemStmt(from);
4527 case T_CreateSeqStmt:
4528 retval = _copyCreateSeqStmt(from);
4530 case T_AlterSeqStmt:
4531 retval = _copyAlterSeqStmt(from);
4533 case T_VariableSetStmt:
4534 retval = _copyVariableSetStmt(from);
4536 case T_VariableShowStmt:
4537 retval = _copyVariableShowStmt(from);
4540 retval = _copyDiscardStmt(from);
4542 case T_CreateTableSpaceStmt:
4543 retval = _copyCreateTableSpaceStmt(from);
4545 case T_DropTableSpaceStmt:
4546 retval = _copyDropTableSpaceStmt(from);
4548 case T_AlterTableSpaceOptionsStmt:
4549 retval = _copyAlterTableSpaceOptionsStmt(from);
4551 case T_AlterTableMoveAllStmt:
4552 retval = _copyAlterTableMoveAllStmt(from);
4554 case T_CreateExtensionStmt:
4555 retval = _copyCreateExtensionStmt(from);
4557 case T_AlterExtensionStmt:
4558 retval = _copyAlterExtensionStmt(from);
4560 case T_AlterExtensionContentsStmt:
4561 retval = _copyAlterExtensionContentsStmt(from);
4563 case T_CreateFdwStmt:
4564 retval = _copyCreateFdwStmt(from);
4566 case T_AlterFdwStmt:
4567 retval = _copyAlterFdwStmt(from);
4569 case T_CreateForeignServerStmt:
4570 retval = _copyCreateForeignServerStmt(from);
4572 case T_AlterForeignServerStmt:
4573 retval = _copyAlterForeignServerStmt(from);
4575 case T_CreateUserMappingStmt:
4576 retval = _copyCreateUserMappingStmt(from);
4578 case T_AlterUserMappingStmt:
4579 retval = _copyAlterUserMappingStmt(from);
4581 case T_DropUserMappingStmt:
4582 retval = _copyDropUserMappingStmt(from);
4584 case T_CreateForeignTableStmt:
4585 retval = _copyCreateForeignTableStmt(from);
4587 case T_ImportForeignSchemaStmt:
4588 retval = _copyImportForeignSchemaStmt(from);
4590 case T_CreateTransformStmt:
4591 retval = _copyCreateTransformStmt(from);
4593 case T_CreateTrigStmt:
4594 retval = _copyCreateTrigStmt(from);
4596 case T_CreateEventTrigStmt:
4597 retval = _copyCreateEventTrigStmt(from);
4599 case T_AlterEventTrigStmt:
4600 retval = _copyAlterEventTrigStmt(from);
4602 case T_CreatePLangStmt:
4603 retval = _copyCreatePLangStmt(from);
4605 case T_CreateRoleStmt:
4606 retval = _copyCreateRoleStmt(from);
4608 case T_AlterRoleStmt:
4609 retval = _copyAlterRoleStmt(from);
4611 case T_AlterRoleSetStmt:
4612 retval = _copyAlterRoleSetStmt(from);
4614 case T_DropRoleStmt:
4615 retval = _copyDropRoleStmt(from);
4618 retval = _copyLockStmt(from);
4620 case T_ConstraintsSetStmt:
4621 retval = _copyConstraintsSetStmt(from);
4624 retval = _copyReindexStmt(from);
4626 case T_CheckPointStmt:
4627 retval = (void *) makeNode(CheckPointStmt);
4629 case T_CreateSchemaStmt:
4630 retval = _copyCreateSchemaStmt(from);
4632 case T_CreateConversionStmt:
4633 retval = _copyCreateConversionStmt(from);
4635 case T_CreateCastStmt:
4636 retval = _copyCreateCastStmt(from);
4639 retval = _copyPrepareStmt(from);
4642 retval = _copyExecuteStmt(from);
4644 case T_DeallocateStmt:
4645 retval = _copyDeallocateStmt(from);
4647 case T_DropOwnedStmt:
4648 retval = _copyDropOwnedStmt(from);
4650 case T_ReassignOwnedStmt:
4651 retval = _copyReassignOwnedStmt(from);
4653 case T_AlterTSDictionaryStmt:
4654 retval = _copyAlterTSDictionaryStmt(from);
4656 case T_AlterTSConfigurationStmt:
4657 retval = _copyAlterTSConfigurationStmt(from);
4659 case T_CreatePolicyStmt:
4660 retval = _copyCreatePolicyStmt(from);
4662 case T_AlterPolicyStmt:
4663 retval = _copyAlterPolicyStmt(from);
4666 retval = _copyAExpr(from);
4669 retval = _copyColumnRef(from);
4672 retval = _copyParamRef(from);
4675 retval = _copyAConst(from);
4678 retval = _copyFuncCall(from);
4681 retval = _copyAStar(from);
4684 retval = _copyAIndices(from);
4686 case T_A_Indirection:
4687 retval = _copyA_Indirection(from);
4690 retval = _copyA_ArrayExpr(from);
4693 retval = _copyResTarget(from);
4695 case T_MultiAssignRef:
4696 retval = _copyMultiAssignRef(from);
4699 retval = _copyTypeCast(from);
4701 case T_CollateClause:
4702 retval = _copyCollateClause(from);
4705 retval = _copySortBy(from);
4708 retval = _copyWindowDef(from);
4710 case T_RangeSubselect:
4711 retval = _copyRangeSubselect(from);
4713 case T_RangeFunction:
4714 retval = _copyRangeFunction(from);
4717 retval = _copyTypeName(from);
4720 retval = _copyIndexElem(from);
4723 retval = _copyColumnDef(from);
4726 retval = _copyConstraint(from);
4729 retval = _copyDefElem(from);
4731 case T_LockingClause:
4732 retval = _copyLockingClause(from);
4734 case T_RangeTblEntry:
4735 retval = _copyRangeTblEntry(from);
4737 case T_RangeTblFunction:
4738 retval = _copyRangeTblFunction(from);
4740 case T_WithCheckOption:
4741 retval = _copyWithCheckOption(from);
4743 case T_SortGroupClause:
4744 retval = _copySortGroupClause(from);
4746 case T_WindowClause:
4747 retval = _copyWindowClause(from);
4749 case T_RowMarkClause:
4750 retval = _copyRowMarkClause(from);
4753 retval = _copyWithClause(from);
4755 case T_CommonTableExpr:
4756 retval = _copyCommonTableExpr(from);
4758 case T_FuncWithArgs:
4759 retval = _copyFuncWithArgs(from);
4762 retval = _copyAccessPriv(from);
4764 case T_XmlSerialize:
4765 retval = _copyXmlSerialize(from);
4768 retval = _copyRoleSpec(from);
4772 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4773 retval = 0; /* keep compiler quiet */