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);
97 COPY_SCALAR_FIELD(parallelModeNeeded);
105 * This function copies the fields of the Plan node. It is used by
106 * all the copy functions for classes which inherit from Plan.
109 CopyPlanFields(const Plan *from, Plan *newnode)
111 COPY_SCALAR_FIELD(startup_cost);
112 COPY_SCALAR_FIELD(total_cost);
113 COPY_SCALAR_FIELD(plan_rows);
114 COPY_SCALAR_FIELD(plan_width);
115 COPY_SCALAR_FIELD(plan_node_id);
116 COPY_NODE_FIELD(targetlist);
117 COPY_NODE_FIELD(qual);
118 COPY_NODE_FIELD(lefttree);
119 COPY_NODE_FIELD(righttree);
120 COPY_NODE_FIELD(initPlan);
121 COPY_BITMAPSET_FIELD(extParam);
122 COPY_BITMAPSET_FIELD(allParam);
129 _copyPlan(const Plan *from)
131 Plan *newnode = makeNode(Plan);
134 * copy node superclass fields
136 CopyPlanFields(from, newnode);
146 _copyResult(const Result *from)
148 Result *newnode = makeNode(Result);
151 * copy node superclass fields
153 CopyPlanFields((const Plan *) from, (Plan *) newnode);
156 * copy remainder of node
158 COPY_NODE_FIELD(resconstantqual);
167 _copyModifyTable(const ModifyTable *from)
169 ModifyTable *newnode = makeNode(ModifyTable);
172 * copy node superclass fields
174 CopyPlanFields((const Plan *) from, (Plan *) newnode);
177 * copy remainder of node
179 COPY_SCALAR_FIELD(operation);
180 COPY_SCALAR_FIELD(canSetTag);
181 COPY_SCALAR_FIELD(nominalRelation);
182 COPY_NODE_FIELD(resultRelations);
183 COPY_SCALAR_FIELD(resultRelIndex);
184 COPY_NODE_FIELD(plans);
185 COPY_NODE_FIELD(withCheckOptionLists);
186 COPY_NODE_FIELD(returningLists);
187 COPY_NODE_FIELD(fdwPrivLists);
188 COPY_NODE_FIELD(rowMarks);
189 COPY_SCALAR_FIELD(epqParam);
190 COPY_SCALAR_FIELD(onConflictAction);
191 COPY_NODE_FIELD(arbiterIndexes);
192 COPY_NODE_FIELD(onConflictSet);
193 COPY_NODE_FIELD(onConflictWhere);
194 COPY_SCALAR_FIELD(exclRelRTI);
195 COPY_NODE_FIELD(exclRelTlist);
204 _copyAppend(const Append *from)
206 Append *newnode = makeNode(Append);
209 * copy node superclass fields
211 CopyPlanFields((const Plan *) from, (Plan *) newnode);
214 * copy remainder of node
216 COPY_NODE_FIELD(appendplans);
225 _copyMergeAppend(const MergeAppend *from)
227 MergeAppend *newnode = makeNode(MergeAppend);
230 * copy node superclass fields
232 CopyPlanFields((const Plan *) from, (Plan *) newnode);
235 * copy remainder of node
237 COPY_NODE_FIELD(mergeplans);
238 COPY_SCALAR_FIELD(numCols);
239 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
240 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
241 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
242 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
248 * _copyRecursiveUnion
250 static RecursiveUnion *
251 _copyRecursiveUnion(const RecursiveUnion *from)
253 RecursiveUnion *newnode = makeNode(RecursiveUnion);
256 * copy node superclass fields
258 CopyPlanFields((const Plan *) from, (Plan *) newnode);
261 * copy remainder of node
263 COPY_SCALAR_FIELD(wtParam);
264 COPY_SCALAR_FIELD(numCols);
265 if (from->numCols > 0)
267 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
268 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
270 COPY_SCALAR_FIELD(numGroups);
279 _copyBitmapAnd(const BitmapAnd *from)
281 BitmapAnd *newnode = makeNode(BitmapAnd);
284 * copy node superclass fields
286 CopyPlanFields((const Plan *) from, (Plan *) newnode);
289 * copy remainder of node
291 COPY_NODE_FIELD(bitmapplans);
300 _copyBitmapOr(const BitmapOr *from)
302 BitmapOr *newnode = makeNode(BitmapOr);
305 * copy node superclass fields
307 CopyPlanFields((const Plan *) from, (Plan *) newnode);
310 * copy remainder of node
312 COPY_NODE_FIELD(bitmapplans);
321 _copyGather(const Gather *from)
323 Gather *newnode = makeNode(Gather);
326 * copy node superclass fields
328 CopyPlanFields((const Plan *) from, (Plan *) newnode);
331 * copy remainder of node
333 COPY_SCALAR_FIELD(num_workers);
334 COPY_SCALAR_FIELD(single_copy);
343 * This function copies the fields of the Scan node. It is used by
344 * all the copy functions for classes which inherit from Scan.
347 CopyScanFields(const Scan *from, Scan *newnode)
349 CopyPlanFields((const Plan *) from, (Plan *) newnode);
351 COPY_SCALAR_FIELD(scanrelid);
358 _copyScan(const Scan *from)
360 Scan *newnode = makeNode(Scan);
363 * copy node superclass fields
365 CopyScanFields((const Scan *) from, (Scan *) newnode);
374 _copySeqScan(const SeqScan *from)
376 SeqScan *newnode = makeNode(SeqScan);
379 * copy node superclass fields
381 CopyScanFields((const Scan *) from, (Scan *) newnode);
390 _copySampleScan(const SampleScan *from)
392 SampleScan *newnode = makeNode(SampleScan);
395 * copy node superclass fields
397 CopyScanFields((const Scan *) from, (Scan *) newnode);
400 * copy remainder of node
402 COPY_NODE_FIELD(tablesample);
411 _copyIndexScan(const IndexScan *from)
413 IndexScan *newnode = makeNode(IndexScan);
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);
426 COPY_NODE_FIELD(indexorderby);
427 COPY_NODE_FIELD(indexorderbyorig);
428 COPY_NODE_FIELD(indexorderbyops);
429 COPY_SCALAR_FIELD(indexorderdir);
437 static IndexOnlyScan *
438 _copyIndexOnlyScan(const IndexOnlyScan *from)
440 IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
443 * copy node superclass fields
445 CopyScanFields((const Scan *) from, (Scan *) newnode);
448 * copy remainder of node
450 COPY_SCALAR_FIELD(indexid);
451 COPY_NODE_FIELD(indexqual);
452 COPY_NODE_FIELD(indexorderby);
453 COPY_NODE_FIELD(indextlist);
454 COPY_SCALAR_FIELD(indexorderdir);
460 * _copyBitmapIndexScan
462 static BitmapIndexScan *
463 _copyBitmapIndexScan(const BitmapIndexScan *from)
465 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
468 * copy node superclass fields
470 CopyScanFields((const Scan *) from, (Scan *) newnode);
473 * copy remainder of node
475 COPY_SCALAR_FIELD(indexid);
476 COPY_NODE_FIELD(indexqual);
477 COPY_NODE_FIELD(indexqualorig);
483 * _copyBitmapHeapScan
485 static BitmapHeapScan *
486 _copyBitmapHeapScan(const BitmapHeapScan *from)
488 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
491 * copy node superclass fields
493 CopyScanFields((const Scan *) from, (Scan *) newnode);
496 * copy remainder of node
498 COPY_NODE_FIELD(bitmapqualorig);
507 _copyTidScan(const TidScan *from)
509 TidScan *newnode = makeNode(TidScan);
512 * copy node superclass fields
514 CopyScanFields((const Scan *) from, (Scan *) newnode);
517 * copy remainder of node
519 COPY_NODE_FIELD(tidquals);
527 static SubqueryScan *
528 _copySubqueryScan(const SubqueryScan *from)
530 SubqueryScan *newnode = makeNode(SubqueryScan);
533 * copy node superclass fields
535 CopyScanFields((const Scan *) from, (Scan *) newnode);
538 * copy remainder of node
540 COPY_NODE_FIELD(subplan);
548 static FunctionScan *
549 _copyFunctionScan(const FunctionScan *from)
551 FunctionScan *newnode = makeNode(FunctionScan);
554 * copy node superclass fields
556 CopyScanFields((const Scan *) from, (Scan *) newnode);
559 * copy remainder of node
561 COPY_NODE_FIELD(functions);
562 COPY_SCALAR_FIELD(funcordinality);
571 _copyValuesScan(const ValuesScan *from)
573 ValuesScan *newnode = makeNode(ValuesScan);
576 * copy node superclass fields
578 CopyScanFields((const Scan *) from, (Scan *) newnode);
581 * copy remainder of node
583 COPY_NODE_FIELD(values_lists);
592 _copyCteScan(const CteScan *from)
594 CteScan *newnode = makeNode(CteScan);
597 * copy node superclass fields
599 CopyScanFields((const Scan *) from, (Scan *) newnode);
602 * copy remainder of node
604 COPY_SCALAR_FIELD(ctePlanId);
605 COPY_SCALAR_FIELD(cteParam);
613 static WorkTableScan *
614 _copyWorkTableScan(const WorkTableScan *from)
616 WorkTableScan *newnode = makeNode(WorkTableScan);
619 * copy node superclass fields
621 CopyScanFields((const Scan *) from, (Scan *) newnode);
624 * copy remainder of node
626 COPY_SCALAR_FIELD(wtParam);
635 _copyForeignScan(const ForeignScan *from)
637 ForeignScan *newnode = makeNode(ForeignScan);
640 * copy node superclass fields
642 CopyScanFields((const Scan *) from, (Scan *) newnode);
645 * copy remainder of node
647 COPY_SCALAR_FIELD(fs_server);
648 COPY_NODE_FIELD(fdw_exprs);
649 COPY_NODE_FIELD(fdw_private);
650 COPY_NODE_FIELD(fdw_scan_tlist);
651 COPY_BITMAPSET_FIELD(fs_relids);
652 COPY_SCALAR_FIELD(fsSystemCol);
661 _copyCustomScan(const CustomScan *from)
663 CustomScan *newnode = makeNode(CustomScan);
666 * copy node superclass fields
668 CopyScanFields((const Scan *) from, (Scan *) newnode);
671 * copy remainder of node
673 COPY_SCALAR_FIELD(flags);
674 COPY_NODE_FIELD(custom_plans);
675 COPY_NODE_FIELD(custom_exprs);
676 COPY_NODE_FIELD(custom_private);
677 COPY_NODE_FIELD(custom_scan_tlist);
678 COPY_BITMAPSET_FIELD(custom_relids);
681 * NOTE: The method field of CustomScan is required to be a pointer to a
682 * static table of callback functions. So we don't copy the table itself,
683 * just reference the original one.
685 COPY_SCALAR_FIELD(methods);
693 * This function copies the fields of the Join node. It is used by
694 * all the copy functions for classes which inherit from Join.
697 CopyJoinFields(const Join *from, Join *newnode)
699 CopyPlanFields((const Plan *) from, (Plan *) newnode);
701 COPY_SCALAR_FIELD(jointype);
702 COPY_NODE_FIELD(joinqual);
710 _copyJoin(const Join *from)
712 Join *newnode = makeNode(Join);
715 * copy node superclass fields
717 CopyJoinFields(from, newnode);
727 _copyNestLoop(const NestLoop *from)
729 NestLoop *newnode = makeNode(NestLoop);
732 * copy node superclass fields
734 CopyJoinFields((const Join *) from, (Join *) newnode);
737 * copy remainder of node
739 COPY_NODE_FIELD(nestParams);
749 _copyMergeJoin(const MergeJoin *from)
751 MergeJoin *newnode = makeNode(MergeJoin);
755 * copy node superclass fields
757 CopyJoinFields((const Join *) from, (Join *) newnode);
760 * copy remainder of node
762 COPY_NODE_FIELD(mergeclauses);
763 numCols = list_length(from->mergeclauses);
766 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
767 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
768 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
769 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
779 _copyHashJoin(const HashJoin *from)
781 HashJoin *newnode = makeNode(HashJoin);
784 * copy node superclass fields
786 CopyJoinFields((const Join *) from, (Join *) newnode);
789 * copy remainder of node
791 COPY_NODE_FIELD(hashclauses);
801 _copyMaterial(const Material *from)
803 Material *newnode = makeNode(Material);
806 * copy node superclass fields
808 CopyPlanFields((const Plan *) from, (Plan *) newnode);
818 _copySort(const Sort *from)
820 Sort *newnode = makeNode(Sort);
823 * copy node superclass fields
825 CopyPlanFields((const Plan *) from, (Plan *) newnode);
827 COPY_SCALAR_FIELD(numCols);
828 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
829 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
830 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
831 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
841 _copyGroup(const Group *from)
843 Group *newnode = makeNode(Group);
845 CopyPlanFields((const Plan *) from, (Plan *) newnode);
847 COPY_SCALAR_FIELD(numCols);
848 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
849 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
858 _copyAgg(const Agg *from)
860 Agg *newnode = makeNode(Agg);
862 CopyPlanFields((const Plan *) from, (Plan *) newnode);
864 COPY_SCALAR_FIELD(aggstrategy);
865 COPY_SCALAR_FIELD(numCols);
866 if (from->numCols > 0)
868 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
869 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
871 COPY_SCALAR_FIELD(numGroups);
872 COPY_NODE_FIELD(groupingSets);
873 COPY_NODE_FIELD(chain);
882 _copyWindowAgg(const WindowAgg *from)
884 WindowAgg *newnode = makeNode(WindowAgg);
886 CopyPlanFields((const Plan *) from, (Plan *) newnode);
888 COPY_SCALAR_FIELD(winref);
889 COPY_SCALAR_FIELD(partNumCols);
890 if (from->partNumCols > 0)
892 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
893 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
895 COPY_SCALAR_FIELD(ordNumCols);
896 if (from->ordNumCols > 0)
898 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
899 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
901 COPY_SCALAR_FIELD(frameOptions);
902 COPY_NODE_FIELD(startOffset);
903 COPY_NODE_FIELD(endOffset);
912 _copyUnique(const Unique *from)
914 Unique *newnode = makeNode(Unique);
917 * copy node superclass fields
919 CopyPlanFields((const Plan *) from, (Plan *) newnode);
922 * copy remainder of node
924 COPY_SCALAR_FIELD(numCols);
925 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
926 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
935 _copyHash(const Hash *from)
937 Hash *newnode = makeNode(Hash);
940 * copy node superclass fields
942 CopyPlanFields((const Plan *) from, (Plan *) newnode);
945 * copy remainder of node
947 COPY_SCALAR_FIELD(skewTable);
948 COPY_SCALAR_FIELD(skewColumn);
949 COPY_SCALAR_FIELD(skewInherit);
950 COPY_SCALAR_FIELD(skewColType);
951 COPY_SCALAR_FIELD(skewColTypmod);
960 _copySetOp(const SetOp *from)
962 SetOp *newnode = makeNode(SetOp);
965 * copy node superclass fields
967 CopyPlanFields((const Plan *) from, (Plan *) newnode);
970 * copy remainder of node
972 COPY_SCALAR_FIELD(cmd);
973 COPY_SCALAR_FIELD(strategy);
974 COPY_SCALAR_FIELD(numCols);
975 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
976 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
977 COPY_SCALAR_FIELD(flagColIdx);
978 COPY_SCALAR_FIELD(firstFlag);
979 COPY_SCALAR_FIELD(numGroups);
988 _copyLockRows(const LockRows *from)
990 LockRows *newnode = makeNode(LockRows);
993 * copy node superclass fields
995 CopyPlanFields((const Plan *) from, (Plan *) newnode);
998 * copy remainder of node
1000 COPY_NODE_FIELD(rowMarks);
1001 COPY_SCALAR_FIELD(epqParam);
1010 _copyLimit(const Limit *from)
1012 Limit *newnode = makeNode(Limit);
1015 * copy node superclass fields
1017 CopyPlanFields((const Plan *) from, (Plan *) newnode);
1020 * copy remainder of node
1022 COPY_NODE_FIELD(limitOffset);
1023 COPY_NODE_FIELD(limitCount);
1029 * _copyNestLoopParam
1031 static NestLoopParam *
1032 _copyNestLoopParam(const NestLoopParam *from)
1034 NestLoopParam *newnode = makeNode(NestLoopParam);
1036 COPY_SCALAR_FIELD(paramno);
1037 COPY_NODE_FIELD(paramval);
1045 static PlanRowMark *
1046 _copyPlanRowMark(const PlanRowMark *from)
1048 PlanRowMark *newnode = makeNode(PlanRowMark);
1050 COPY_SCALAR_FIELD(rti);
1051 COPY_SCALAR_FIELD(prti);
1052 COPY_SCALAR_FIELD(rowmarkId);
1053 COPY_SCALAR_FIELD(markType);
1054 COPY_SCALAR_FIELD(allMarkTypes);
1055 COPY_SCALAR_FIELD(strength);
1056 COPY_SCALAR_FIELD(waitPolicy);
1057 COPY_SCALAR_FIELD(isParent);
1063 * _copyPlanInvalItem
1065 static PlanInvalItem *
1066 _copyPlanInvalItem(const PlanInvalItem *from)
1068 PlanInvalItem *newnode = makeNode(PlanInvalItem);
1070 COPY_SCALAR_FIELD(cacheId);
1071 COPY_SCALAR_FIELD(hashValue);
1076 /* ****************************************************************
1077 * primnodes.h copy functions
1078 * ****************************************************************
1085 _copyAlias(const Alias *from)
1087 Alias *newnode = makeNode(Alias);
1089 COPY_STRING_FIELD(aliasname);
1090 COPY_NODE_FIELD(colnames);
1099 _copyRangeVar(const RangeVar *from)
1101 RangeVar *newnode = makeNode(RangeVar);
1103 COPY_STRING_FIELD(catalogname);
1104 COPY_STRING_FIELD(schemaname);
1105 COPY_STRING_FIELD(relname);
1106 COPY_SCALAR_FIELD(inhOpt);
1107 COPY_SCALAR_FIELD(relpersistence);
1108 COPY_NODE_FIELD(alias);
1109 COPY_LOCATION_FIELD(location);
1118 _copyIntoClause(const IntoClause *from)
1120 IntoClause *newnode = makeNode(IntoClause);
1122 COPY_NODE_FIELD(rel);
1123 COPY_NODE_FIELD(colNames);
1124 COPY_NODE_FIELD(options);
1125 COPY_SCALAR_FIELD(onCommit);
1126 COPY_STRING_FIELD(tableSpaceName);
1127 COPY_NODE_FIELD(viewQuery);
1128 COPY_SCALAR_FIELD(skipData);
1134 * We don't need a _copyExpr because Expr is an abstract supertype which
1135 * should never actually get instantiated. Also, since it has no common
1136 * fields except NodeTag, there's no need for a helper routine to factor
1137 * out copying the common fields...
1144 _copyVar(const Var *from)
1146 Var *newnode = makeNode(Var);
1148 COPY_SCALAR_FIELD(varno);
1149 COPY_SCALAR_FIELD(varattno);
1150 COPY_SCALAR_FIELD(vartype);
1151 COPY_SCALAR_FIELD(vartypmod);
1152 COPY_SCALAR_FIELD(varcollid);
1153 COPY_SCALAR_FIELD(varlevelsup);
1154 COPY_SCALAR_FIELD(varnoold);
1155 COPY_SCALAR_FIELD(varoattno);
1156 COPY_LOCATION_FIELD(location);
1165 _copyConst(const Const *from)
1167 Const *newnode = makeNode(Const);
1169 COPY_SCALAR_FIELD(consttype);
1170 COPY_SCALAR_FIELD(consttypmod);
1171 COPY_SCALAR_FIELD(constcollid);
1172 COPY_SCALAR_FIELD(constlen);
1174 if (from->constbyval || from->constisnull)
1177 * passed by value so just copy the datum. Also, don't try to copy
1178 * struct when value is null!
1180 newnode->constvalue = from->constvalue;
1185 * passed by reference. We need a palloc'd copy.
1187 newnode->constvalue = datumCopy(from->constvalue,
1192 COPY_SCALAR_FIELD(constisnull);
1193 COPY_SCALAR_FIELD(constbyval);
1194 COPY_LOCATION_FIELD(location);
1203 _copyParam(const Param *from)
1205 Param *newnode = makeNode(Param);
1207 COPY_SCALAR_FIELD(paramkind);
1208 COPY_SCALAR_FIELD(paramid);
1209 COPY_SCALAR_FIELD(paramtype);
1210 COPY_SCALAR_FIELD(paramtypmod);
1211 COPY_SCALAR_FIELD(paramcollid);
1212 COPY_LOCATION_FIELD(location);
1221 _copyAggref(const Aggref *from)
1223 Aggref *newnode = makeNode(Aggref);
1225 COPY_SCALAR_FIELD(aggfnoid);
1226 COPY_SCALAR_FIELD(aggtype);
1227 COPY_SCALAR_FIELD(aggcollid);
1228 COPY_SCALAR_FIELD(inputcollid);
1229 COPY_NODE_FIELD(aggdirectargs);
1230 COPY_NODE_FIELD(args);
1231 COPY_NODE_FIELD(aggorder);
1232 COPY_NODE_FIELD(aggdistinct);
1233 COPY_NODE_FIELD(aggfilter);
1234 COPY_SCALAR_FIELD(aggstar);
1235 COPY_SCALAR_FIELD(aggvariadic);
1236 COPY_SCALAR_FIELD(aggkind);
1237 COPY_SCALAR_FIELD(agglevelsup);
1238 COPY_LOCATION_FIELD(location);
1246 static GroupingFunc *
1247 _copyGroupingFunc(const GroupingFunc *from)
1249 GroupingFunc *newnode = makeNode(GroupingFunc);
1251 COPY_NODE_FIELD(args);
1252 COPY_NODE_FIELD(refs);
1253 COPY_NODE_FIELD(cols);
1254 COPY_SCALAR_FIELD(agglevelsup);
1255 COPY_LOCATION_FIELD(location);
1264 _copyWindowFunc(const WindowFunc *from)
1266 WindowFunc *newnode = makeNode(WindowFunc);
1268 COPY_SCALAR_FIELD(winfnoid);
1269 COPY_SCALAR_FIELD(wintype);
1270 COPY_SCALAR_FIELD(wincollid);
1271 COPY_SCALAR_FIELD(inputcollid);
1272 COPY_NODE_FIELD(args);
1273 COPY_NODE_FIELD(aggfilter);
1274 COPY_SCALAR_FIELD(winref);
1275 COPY_SCALAR_FIELD(winstar);
1276 COPY_SCALAR_FIELD(winagg);
1277 COPY_LOCATION_FIELD(location);
1286 _copyArrayRef(const ArrayRef *from)
1288 ArrayRef *newnode = makeNode(ArrayRef);
1290 COPY_SCALAR_FIELD(refarraytype);
1291 COPY_SCALAR_FIELD(refelemtype);
1292 COPY_SCALAR_FIELD(reftypmod);
1293 COPY_SCALAR_FIELD(refcollid);
1294 COPY_NODE_FIELD(refupperindexpr);
1295 COPY_NODE_FIELD(reflowerindexpr);
1296 COPY_NODE_FIELD(refexpr);
1297 COPY_NODE_FIELD(refassgnexpr);
1306 _copyFuncExpr(const FuncExpr *from)
1308 FuncExpr *newnode = makeNode(FuncExpr);
1310 COPY_SCALAR_FIELD(funcid);
1311 COPY_SCALAR_FIELD(funcresulttype);
1312 COPY_SCALAR_FIELD(funcretset);
1313 COPY_SCALAR_FIELD(funcvariadic);
1314 COPY_SCALAR_FIELD(funcformat);
1315 COPY_SCALAR_FIELD(funccollid);
1316 COPY_SCALAR_FIELD(inputcollid);
1317 COPY_NODE_FIELD(args);
1318 COPY_LOCATION_FIELD(location);
1324 * _copyNamedArgExpr *
1326 static NamedArgExpr *
1327 _copyNamedArgExpr(const NamedArgExpr *from)
1329 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1331 COPY_NODE_FIELD(arg);
1332 COPY_STRING_FIELD(name);
1333 COPY_SCALAR_FIELD(argnumber);
1334 COPY_LOCATION_FIELD(location);
1343 _copyOpExpr(const OpExpr *from)
1345 OpExpr *newnode = makeNode(OpExpr);
1347 COPY_SCALAR_FIELD(opno);
1348 COPY_SCALAR_FIELD(opfuncid);
1349 COPY_SCALAR_FIELD(opresulttype);
1350 COPY_SCALAR_FIELD(opretset);
1351 COPY_SCALAR_FIELD(opcollid);
1352 COPY_SCALAR_FIELD(inputcollid);
1353 COPY_NODE_FIELD(args);
1354 COPY_LOCATION_FIELD(location);
1360 * _copyDistinctExpr (same as OpExpr)
1362 static DistinctExpr *
1363 _copyDistinctExpr(const DistinctExpr *from)
1365 DistinctExpr *newnode = makeNode(DistinctExpr);
1367 COPY_SCALAR_FIELD(opno);
1368 COPY_SCALAR_FIELD(opfuncid);
1369 COPY_SCALAR_FIELD(opresulttype);
1370 COPY_SCALAR_FIELD(opretset);
1371 COPY_SCALAR_FIELD(opcollid);
1372 COPY_SCALAR_FIELD(inputcollid);
1373 COPY_NODE_FIELD(args);
1374 COPY_LOCATION_FIELD(location);
1380 * _copyNullIfExpr (same as OpExpr)
1383 _copyNullIfExpr(const NullIfExpr *from)
1385 NullIfExpr *newnode = makeNode(NullIfExpr);
1387 COPY_SCALAR_FIELD(opno);
1388 COPY_SCALAR_FIELD(opfuncid);
1389 COPY_SCALAR_FIELD(opresulttype);
1390 COPY_SCALAR_FIELD(opretset);
1391 COPY_SCALAR_FIELD(opcollid);
1392 COPY_SCALAR_FIELD(inputcollid);
1393 COPY_NODE_FIELD(args);
1394 COPY_LOCATION_FIELD(location);
1400 * _copyScalarArrayOpExpr
1402 static ScalarArrayOpExpr *
1403 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
1405 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1407 COPY_SCALAR_FIELD(opno);
1408 COPY_SCALAR_FIELD(opfuncid);
1409 COPY_SCALAR_FIELD(useOr);
1410 COPY_SCALAR_FIELD(inputcollid);
1411 COPY_NODE_FIELD(args);
1412 COPY_LOCATION_FIELD(location);
1421 _copyBoolExpr(const BoolExpr *from)
1423 BoolExpr *newnode = makeNode(BoolExpr);
1425 COPY_SCALAR_FIELD(boolop);
1426 COPY_NODE_FIELD(args);
1427 COPY_LOCATION_FIELD(location);
1436 _copySubLink(const SubLink *from)
1438 SubLink *newnode = makeNode(SubLink);
1440 COPY_SCALAR_FIELD(subLinkType);
1441 COPY_SCALAR_FIELD(subLinkId);
1442 COPY_NODE_FIELD(testexpr);
1443 COPY_NODE_FIELD(operName);
1444 COPY_NODE_FIELD(subselect);
1445 COPY_LOCATION_FIELD(location);
1454 _copySubPlan(const SubPlan *from)
1456 SubPlan *newnode = makeNode(SubPlan);
1458 COPY_SCALAR_FIELD(subLinkType);
1459 COPY_NODE_FIELD(testexpr);
1460 COPY_NODE_FIELD(paramIds);
1461 COPY_SCALAR_FIELD(plan_id);
1462 COPY_STRING_FIELD(plan_name);
1463 COPY_SCALAR_FIELD(firstColType);
1464 COPY_SCALAR_FIELD(firstColTypmod);
1465 COPY_SCALAR_FIELD(firstColCollation);
1466 COPY_SCALAR_FIELD(useHashTable);
1467 COPY_SCALAR_FIELD(unknownEqFalse);
1468 COPY_NODE_FIELD(setParam);
1469 COPY_NODE_FIELD(parParam);
1470 COPY_NODE_FIELD(args);
1471 COPY_SCALAR_FIELD(startup_cost);
1472 COPY_SCALAR_FIELD(per_call_cost);
1478 * _copyAlternativeSubPlan
1480 static AlternativeSubPlan *
1481 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
1483 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1485 COPY_NODE_FIELD(subplans);
1493 static FieldSelect *
1494 _copyFieldSelect(const FieldSelect *from)
1496 FieldSelect *newnode = makeNode(FieldSelect);
1498 COPY_NODE_FIELD(arg);
1499 COPY_SCALAR_FIELD(fieldnum);
1500 COPY_SCALAR_FIELD(resulttype);
1501 COPY_SCALAR_FIELD(resulttypmod);
1502 COPY_SCALAR_FIELD(resultcollid);
1511 _copyFieldStore(const FieldStore *from)
1513 FieldStore *newnode = makeNode(FieldStore);
1515 COPY_NODE_FIELD(arg);
1516 COPY_NODE_FIELD(newvals);
1517 COPY_NODE_FIELD(fieldnums);
1518 COPY_SCALAR_FIELD(resulttype);
1526 static RelabelType *
1527 _copyRelabelType(const RelabelType *from)
1529 RelabelType *newnode = makeNode(RelabelType);
1531 COPY_NODE_FIELD(arg);
1532 COPY_SCALAR_FIELD(resulttype);
1533 COPY_SCALAR_FIELD(resulttypmod);
1534 COPY_SCALAR_FIELD(resultcollid);
1535 COPY_SCALAR_FIELD(relabelformat);
1536 COPY_LOCATION_FIELD(location);
1544 static CoerceViaIO *
1545 _copyCoerceViaIO(const CoerceViaIO *from)
1547 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1549 COPY_NODE_FIELD(arg);
1550 COPY_SCALAR_FIELD(resulttype);
1551 COPY_SCALAR_FIELD(resultcollid);
1552 COPY_SCALAR_FIELD(coerceformat);
1553 COPY_LOCATION_FIELD(location);
1559 * _copyArrayCoerceExpr
1561 static ArrayCoerceExpr *
1562 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
1564 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1566 COPY_NODE_FIELD(arg);
1567 COPY_SCALAR_FIELD(elemfuncid);
1568 COPY_SCALAR_FIELD(resulttype);
1569 COPY_SCALAR_FIELD(resulttypmod);
1570 COPY_SCALAR_FIELD(resultcollid);
1571 COPY_SCALAR_FIELD(isExplicit);
1572 COPY_SCALAR_FIELD(coerceformat);
1573 COPY_LOCATION_FIELD(location);
1579 * _copyConvertRowtypeExpr
1581 static ConvertRowtypeExpr *
1582 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
1584 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1586 COPY_NODE_FIELD(arg);
1587 COPY_SCALAR_FIELD(resulttype);
1588 COPY_SCALAR_FIELD(convertformat);
1589 COPY_LOCATION_FIELD(location);
1597 static CollateExpr *
1598 _copyCollateExpr(const CollateExpr *from)
1600 CollateExpr *newnode = makeNode(CollateExpr);
1602 COPY_NODE_FIELD(arg);
1603 COPY_SCALAR_FIELD(collOid);
1604 COPY_LOCATION_FIELD(location);
1613 _copyCaseExpr(const CaseExpr *from)
1615 CaseExpr *newnode = makeNode(CaseExpr);
1617 COPY_SCALAR_FIELD(casetype);
1618 COPY_SCALAR_FIELD(casecollid);
1619 COPY_NODE_FIELD(arg);
1620 COPY_NODE_FIELD(args);
1621 COPY_NODE_FIELD(defresult);
1622 COPY_LOCATION_FIELD(location);
1631 _copyCaseWhen(const CaseWhen *from)
1633 CaseWhen *newnode = makeNode(CaseWhen);
1635 COPY_NODE_FIELD(expr);
1636 COPY_NODE_FIELD(result);
1637 COPY_LOCATION_FIELD(location);
1645 static CaseTestExpr *
1646 _copyCaseTestExpr(const CaseTestExpr *from)
1648 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1650 COPY_SCALAR_FIELD(typeId);
1651 COPY_SCALAR_FIELD(typeMod);
1652 COPY_SCALAR_FIELD(collation);
1661 _copyArrayExpr(const ArrayExpr *from)
1663 ArrayExpr *newnode = makeNode(ArrayExpr);
1665 COPY_SCALAR_FIELD(array_typeid);
1666 COPY_SCALAR_FIELD(array_collid);
1667 COPY_SCALAR_FIELD(element_typeid);
1668 COPY_NODE_FIELD(elements);
1669 COPY_SCALAR_FIELD(multidims);
1670 COPY_LOCATION_FIELD(location);
1679 _copyRowExpr(const RowExpr *from)
1681 RowExpr *newnode = makeNode(RowExpr);
1683 COPY_NODE_FIELD(args);
1684 COPY_SCALAR_FIELD(row_typeid);
1685 COPY_SCALAR_FIELD(row_format);
1686 COPY_NODE_FIELD(colnames);
1687 COPY_LOCATION_FIELD(location);
1693 * _copyRowCompareExpr
1695 static RowCompareExpr *
1696 _copyRowCompareExpr(const RowCompareExpr *from)
1698 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1700 COPY_SCALAR_FIELD(rctype);
1701 COPY_NODE_FIELD(opnos);
1702 COPY_NODE_FIELD(opfamilies);
1703 COPY_NODE_FIELD(inputcollids);
1704 COPY_NODE_FIELD(largs);
1705 COPY_NODE_FIELD(rargs);
1713 static CoalesceExpr *
1714 _copyCoalesceExpr(const CoalesceExpr *from)
1716 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1718 COPY_SCALAR_FIELD(coalescetype);
1719 COPY_SCALAR_FIELD(coalescecollid);
1720 COPY_NODE_FIELD(args);
1721 COPY_LOCATION_FIELD(location);
1730 _copyMinMaxExpr(const MinMaxExpr *from)
1732 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1734 COPY_SCALAR_FIELD(minmaxtype);
1735 COPY_SCALAR_FIELD(minmaxcollid);
1736 COPY_SCALAR_FIELD(inputcollid);
1737 COPY_SCALAR_FIELD(op);
1738 COPY_NODE_FIELD(args);
1739 COPY_LOCATION_FIELD(location);
1748 _copyXmlExpr(const XmlExpr *from)
1750 XmlExpr *newnode = makeNode(XmlExpr);
1752 COPY_SCALAR_FIELD(op);
1753 COPY_STRING_FIELD(name);
1754 COPY_NODE_FIELD(named_args);
1755 COPY_NODE_FIELD(arg_names);
1756 COPY_NODE_FIELD(args);
1757 COPY_SCALAR_FIELD(xmloption);
1758 COPY_SCALAR_FIELD(type);
1759 COPY_SCALAR_FIELD(typmod);
1760 COPY_LOCATION_FIELD(location);
1769 _copyNullTest(const NullTest *from)
1771 NullTest *newnode = makeNode(NullTest);
1773 COPY_NODE_FIELD(arg);
1774 COPY_SCALAR_FIELD(nulltesttype);
1775 COPY_SCALAR_FIELD(argisrow);
1776 COPY_LOCATION_FIELD(location);
1784 static BooleanTest *
1785 _copyBooleanTest(const BooleanTest *from)
1787 BooleanTest *newnode = makeNode(BooleanTest);
1789 COPY_NODE_FIELD(arg);
1790 COPY_SCALAR_FIELD(booltesttype);
1791 COPY_LOCATION_FIELD(location);
1797 * _copyCoerceToDomain
1799 static CoerceToDomain *
1800 _copyCoerceToDomain(const CoerceToDomain *from)
1802 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1804 COPY_NODE_FIELD(arg);
1805 COPY_SCALAR_FIELD(resulttype);
1806 COPY_SCALAR_FIELD(resulttypmod);
1807 COPY_SCALAR_FIELD(resultcollid);
1808 COPY_SCALAR_FIELD(coercionformat);
1809 COPY_LOCATION_FIELD(location);
1815 * _copyCoerceToDomainValue
1817 static CoerceToDomainValue *
1818 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
1820 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1822 COPY_SCALAR_FIELD(typeId);
1823 COPY_SCALAR_FIELD(typeMod);
1824 COPY_SCALAR_FIELD(collation);
1825 COPY_LOCATION_FIELD(location);
1833 static SetToDefault *
1834 _copySetToDefault(const SetToDefault *from)
1836 SetToDefault *newnode = makeNode(SetToDefault);
1838 COPY_SCALAR_FIELD(typeId);
1839 COPY_SCALAR_FIELD(typeMod);
1840 COPY_SCALAR_FIELD(collation);
1841 COPY_LOCATION_FIELD(location);
1847 * _copyCurrentOfExpr
1849 static CurrentOfExpr *
1850 _copyCurrentOfExpr(const CurrentOfExpr *from)
1852 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1854 COPY_SCALAR_FIELD(cvarno);
1855 COPY_STRING_FIELD(cursor_name);
1856 COPY_SCALAR_FIELD(cursor_param);
1862 * _copyInferenceElem
1864 static InferenceElem *
1865 _copyInferenceElem(const InferenceElem *from)
1867 InferenceElem *newnode = makeNode(InferenceElem);
1869 COPY_NODE_FIELD(expr);
1870 COPY_SCALAR_FIELD(infercollid);
1871 COPY_SCALAR_FIELD(inferopclass);
1879 static TargetEntry *
1880 _copyTargetEntry(const TargetEntry *from)
1882 TargetEntry *newnode = makeNode(TargetEntry);
1884 COPY_NODE_FIELD(expr);
1885 COPY_SCALAR_FIELD(resno);
1886 COPY_STRING_FIELD(resname);
1887 COPY_SCALAR_FIELD(ressortgroupref);
1888 COPY_SCALAR_FIELD(resorigtbl);
1889 COPY_SCALAR_FIELD(resorigcol);
1890 COPY_SCALAR_FIELD(resjunk);
1898 static RangeTblRef *
1899 _copyRangeTblRef(const RangeTblRef *from)
1901 RangeTblRef *newnode = makeNode(RangeTblRef);
1903 COPY_SCALAR_FIELD(rtindex);
1912 _copyJoinExpr(const JoinExpr *from)
1914 JoinExpr *newnode = makeNode(JoinExpr);
1916 COPY_SCALAR_FIELD(jointype);
1917 COPY_SCALAR_FIELD(isNatural);
1918 COPY_NODE_FIELD(larg);
1919 COPY_NODE_FIELD(rarg);
1920 COPY_NODE_FIELD(usingClause);
1921 COPY_NODE_FIELD(quals);
1922 COPY_NODE_FIELD(alias);
1923 COPY_SCALAR_FIELD(rtindex);
1932 _copyFromExpr(const FromExpr *from)
1934 FromExpr *newnode = makeNode(FromExpr);
1936 COPY_NODE_FIELD(fromlist);
1937 COPY_NODE_FIELD(quals);
1943 * _copyOnConflictExpr
1945 static OnConflictExpr *
1946 _copyOnConflictExpr(const OnConflictExpr *from)
1948 OnConflictExpr *newnode = makeNode(OnConflictExpr);
1950 COPY_SCALAR_FIELD(action);
1951 COPY_NODE_FIELD(arbiterElems);
1952 COPY_NODE_FIELD(arbiterWhere);
1953 COPY_SCALAR_FIELD(constraint);
1954 COPY_NODE_FIELD(onConflictSet);
1955 COPY_NODE_FIELD(onConflictWhere);
1956 COPY_SCALAR_FIELD(exclRelIndex);
1957 COPY_NODE_FIELD(exclRelTlist);
1962 /* ****************************************************************
1963 * relation.h copy functions
1965 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1966 * There are some subsidiary structs that are useful to copy, though.
1967 * ****************************************************************
1974 _copyPathKey(const PathKey *from)
1976 PathKey *newnode = makeNode(PathKey);
1978 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1979 COPY_SCALAR_FIELD(pk_eclass);
1980 COPY_SCALAR_FIELD(pk_opfamily);
1981 COPY_SCALAR_FIELD(pk_strategy);
1982 COPY_SCALAR_FIELD(pk_nulls_first);
1990 static RestrictInfo *
1991 _copyRestrictInfo(const RestrictInfo *from)
1993 RestrictInfo *newnode = makeNode(RestrictInfo);
1995 COPY_NODE_FIELD(clause);
1996 COPY_SCALAR_FIELD(is_pushed_down);
1997 COPY_SCALAR_FIELD(outerjoin_delayed);
1998 COPY_SCALAR_FIELD(can_join);
1999 COPY_SCALAR_FIELD(pseudoconstant);
2000 COPY_BITMAPSET_FIELD(clause_relids);
2001 COPY_BITMAPSET_FIELD(required_relids);
2002 COPY_BITMAPSET_FIELD(outer_relids);
2003 COPY_BITMAPSET_FIELD(nullable_relids);
2004 COPY_BITMAPSET_FIELD(left_relids);
2005 COPY_BITMAPSET_FIELD(right_relids);
2006 COPY_NODE_FIELD(orclause);
2007 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2008 COPY_SCALAR_FIELD(parent_ec);
2009 COPY_SCALAR_FIELD(eval_cost);
2010 COPY_SCALAR_FIELD(norm_selec);
2011 COPY_SCALAR_FIELD(outer_selec);
2012 COPY_NODE_FIELD(mergeopfamilies);
2013 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2014 COPY_SCALAR_FIELD(left_ec);
2015 COPY_SCALAR_FIELD(right_ec);
2016 COPY_SCALAR_FIELD(left_em);
2017 COPY_SCALAR_FIELD(right_em);
2018 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
2019 newnode->scansel_cache = NIL;
2020 COPY_SCALAR_FIELD(outer_is_left);
2021 COPY_SCALAR_FIELD(hashjoinoperator);
2022 COPY_SCALAR_FIELD(left_bucketsize);
2023 COPY_SCALAR_FIELD(right_bucketsize);
2029 * _copyPlaceHolderVar
2031 static PlaceHolderVar *
2032 _copyPlaceHolderVar(const PlaceHolderVar *from)
2034 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
2036 COPY_NODE_FIELD(phexpr);
2037 COPY_BITMAPSET_FIELD(phrels);
2038 COPY_SCALAR_FIELD(phid);
2039 COPY_SCALAR_FIELD(phlevelsup);
2045 * _copySpecialJoinInfo
2047 static SpecialJoinInfo *
2048 _copySpecialJoinInfo(const SpecialJoinInfo *from)
2050 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
2052 COPY_BITMAPSET_FIELD(min_lefthand);
2053 COPY_BITMAPSET_FIELD(min_righthand);
2054 COPY_BITMAPSET_FIELD(syn_lefthand);
2055 COPY_BITMAPSET_FIELD(syn_righthand);
2056 COPY_SCALAR_FIELD(jointype);
2057 COPY_SCALAR_FIELD(lhs_strict);
2058 COPY_SCALAR_FIELD(delay_upper_joins);
2059 COPY_SCALAR_FIELD(semi_can_btree);
2060 COPY_SCALAR_FIELD(semi_can_hash);
2061 COPY_NODE_FIELD(semi_operators);
2062 COPY_NODE_FIELD(semi_rhs_exprs);
2068 * _copyLateralJoinInfo
2070 static LateralJoinInfo *
2071 _copyLateralJoinInfo(const LateralJoinInfo *from)
2073 LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
2075 COPY_BITMAPSET_FIELD(lateral_lhs);
2076 COPY_BITMAPSET_FIELD(lateral_rhs);
2082 * _copyAppendRelInfo
2084 static AppendRelInfo *
2085 _copyAppendRelInfo(const AppendRelInfo *from)
2087 AppendRelInfo *newnode = makeNode(AppendRelInfo);
2089 COPY_SCALAR_FIELD(parent_relid);
2090 COPY_SCALAR_FIELD(child_relid);
2091 COPY_SCALAR_FIELD(parent_reltype);
2092 COPY_SCALAR_FIELD(child_reltype);
2093 COPY_NODE_FIELD(translated_vars);
2094 COPY_SCALAR_FIELD(parent_reloid);
2100 * _copyPlaceHolderInfo
2102 static PlaceHolderInfo *
2103 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
2105 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
2107 COPY_SCALAR_FIELD(phid);
2108 COPY_NODE_FIELD(ph_var);
2109 COPY_BITMAPSET_FIELD(ph_eval_at);
2110 COPY_BITMAPSET_FIELD(ph_lateral);
2111 COPY_BITMAPSET_FIELD(ph_needed);
2112 COPY_SCALAR_FIELD(ph_width);
2117 /* ****************************************************************
2118 * parsenodes.h copy functions
2119 * ****************************************************************
2122 static RangeTblEntry *
2123 _copyRangeTblEntry(const RangeTblEntry *from)
2125 RangeTblEntry *newnode = makeNode(RangeTblEntry);
2127 COPY_SCALAR_FIELD(rtekind);
2128 COPY_SCALAR_FIELD(relid);
2129 COPY_SCALAR_FIELD(relkind);
2130 COPY_NODE_FIELD(tablesample);
2131 COPY_NODE_FIELD(subquery);
2132 COPY_SCALAR_FIELD(security_barrier);
2133 COPY_SCALAR_FIELD(jointype);
2134 COPY_NODE_FIELD(joinaliasvars);
2135 COPY_NODE_FIELD(functions);
2136 COPY_SCALAR_FIELD(funcordinality);
2137 COPY_NODE_FIELD(values_lists);
2138 COPY_NODE_FIELD(values_collations);
2139 COPY_STRING_FIELD(ctename);
2140 COPY_SCALAR_FIELD(ctelevelsup);
2141 COPY_SCALAR_FIELD(self_reference);
2142 COPY_NODE_FIELD(ctecoltypes);
2143 COPY_NODE_FIELD(ctecoltypmods);
2144 COPY_NODE_FIELD(ctecolcollations);
2145 COPY_NODE_FIELD(alias);
2146 COPY_NODE_FIELD(eref);
2147 COPY_SCALAR_FIELD(lateral);
2148 COPY_SCALAR_FIELD(inh);
2149 COPY_SCALAR_FIELD(inFromCl);
2150 COPY_SCALAR_FIELD(requiredPerms);
2151 COPY_SCALAR_FIELD(checkAsUser);
2152 COPY_BITMAPSET_FIELD(selectedCols);
2153 COPY_BITMAPSET_FIELD(insertedCols);
2154 COPY_BITMAPSET_FIELD(updatedCols);
2155 COPY_NODE_FIELD(securityQuals);
2160 static RangeTblFunction *
2161 _copyRangeTblFunction(const RangeTblFunction *from)
2163 RangeTblFunction *newnode = makeNode(RangeTblFunction);
2165 COPY_NODE_FIELD(funcexpr);
2166 COPY_SCALAR_FIELD(funccolcount);
2167 COPY_NODE_FIELD(funccolnames);
2168 COPY_NODE_FIELD(funccoltypes);
2169 COPY_NODE_FIELD(funccoltypmods);
2170 COPY_NODE_FIELD(funccolcollations);
2171 COPY_BITMAPSET_FIELD(funcparams);
2176 static TableSampleClause *
2177 _copyTableSampleClause(const TableSampleClause *from)
2179 TableSampleClause *newnode = makeNode(TableSampleClause);
2181 COPY_SCALAR_FIELD(tsmhandler);
2182 COPY_NODE_FIELD(args);
2183 COPY_NODE_FIELD(repeatable);
2188 static WithCheckOption *
2189 _copyWithCheckOption(const WithCheckOption *from)
2191 WithCheckOption *newnode = makeNode(WithCheckOption);
2193 COPY_SCALAR_FIELD(kind);
2194 COPY_STRING_FIELD(relname);
2195 COPY_STRING_FIELD(polname);
2196 COPY_NODE_FIELD(qual);
2197 COPY_SCALAR_FIELD(cascaded);
2202 static SortGroupClause *
2203 _copySortGroupClause(const SortGroupClause *from)
2205 SortGroupClause *newnode = makeNode(SortGroupClause);
2207 COPY_SCALAR_FIELD(tleSortGroupRef);
2208 COPY_SCALAR_FIELD(eqop);
2209 COPY_SCALAR_FIELD(sortop);
2210 COPY_SCALAR_FIELD(nulls_first);
2211 COPY_SCALAR_FIELD(hashable);
2216 static GroupingSet *
2217 _copyGroupingSet(const GroupingSet *from)
2219 GroupingSet *newnode = makeNode(GroupingSet);
2221 COPY_SCALAR_FIELD(kind);
2222 COPY_NODE_FIELD(content);
2223 COPY_LOCATION_FIELD(location);
2228 static WindowClause *
2229 _copyWindowClause(const WindowClause *from)
2231 WindowClause *newnode = makeNode(WindowClause);
2233 COPY_STRING_FIELD(name);
2234 COPY_STRING_FIELD(refname);
2235 COPY_NODE_FIELD(partitionClause);
2236 COPY_NODE_FIELD(orderClause);
2237 COPY_SCALAR_FIELD(frameOptions);
2238 COPY_NODE_FIELD(startOffset);
2239 COPY_NODE_FIELD(endOffset);
2240 COPY_SCALAR_FIELD(winref);
2241 COPY_SCALAR_FIELD(copiedOrder);
2246 static RowMarkClause *
2247 _copyRowMarkClause(const RowMarkClause *from)
2249 RowMarkClause *newnode = makeNode(RowMarkClause);
2251 COPY_SCALAR_FIELD(rti);
2252 COPY_SCALAR_FIELD(strength);
2253 COPY_SCALAR_FIELD(waitPolicy);
2254 COPY_SCALAR_FIELD(pushedDown);
2260 _copyWithClause(const WithClause *from)
2262 WithClause *newnode = makeNode(WithClause);
2264 COPY_NODE_FIELD(ctes);
2265 COPY_SCALAR_FIELD(recursive);
2266 COPY_LOCATION_FIELD(location);
2271 static InferClause *
2272 _copyInferClause(const InferClause *from)
2274 InferClause *newnode = makeNode(InferClause);
2276 COPY_NODE_FIELD(indexElems);
2277 COPY_NODE_FIELD(whereClause);
2278 COPY_STRING_FIELD(conname);
2279 COPY_LOCATION_FIELD(location);
2284 static OnConflictClause *
2285 _copyOnConflictClause(const OnConflictClause *from)
2287 OnConflictClause *newnode = makeNode(OnConflictClause);
2289 COPY_SCALAR_FIELD(action);
2290 COPY_NODE_FIELD(infer);
2291 COPY_NODE_FIELD(targetList);
2292 COPY_NODE_FIELD(whereClause);
2293 COPY_LOCATION_FIELD(location);
2298 static CommonTableExpr *
2299 _copyCommonTableExpr(const CommonTableExpr *from)
2301 CommonTableExpr *newnode = makeNode(CommonTableExpr);
2303 COPY_STRING_FIELD(ctename);
2304 COPY_NODE_FIELD(aliascolnames);
2305 COPY_NODE_FIELD(ctequery);
2306 COPY_LOCATION_FIELD(location);
2307 COPY_SCALAR_FIELD(cterecursive);
2308 COPY_SCALAR_FIELD(cterefcount);
2309 COPY_NODE_FIELD(ctecolnames);
2310 COPY_NODE_FIELD(ctecoltypes);
2311 COPY_NODE_FIELD(ctecoltypmods);
2312 COPY_NODE_FIELD(ctecolcollations);
2318 _copyAExpr(const A_Expr *from)
2320 A_Expr *newnode = makeNode(A_Expr);
2322 COPY_SCALAR_FIELD(kind);
2323 COPY_NODE_FIELD(name);
2324 COPY_NODE_FIELD(lexpr);
2325 COPY_NODE_FIELD(rexpr);
2326 COPY_LOCATION_FIELD(location);
2332 _copyColumnRef(const ColumnRef *from)
2334 ColumnRef *newnode = makeNode(ColumnRef);
2336 COPY_NODE_FIELD(fields);
2337 COPY_LOCATION_FIELD(location);
2343 _copyParamRef(const ParamRef *from)
2345 ParamRef *newnode = makeNode(ParamRef);
2347 COPY_SCALAR_FIELD(number);
2348 COPY_LOCATION_FIELD(location);
2354 _copyAConst(const A_Const *from)
2356 A_Const *newnode = makeNode(A_Const);
2358 /* This part must duplicate _copyValue */
2359 COPY_SCALAR_FIELD(val.type);
2360 switch (from->val.type)
2363 COPY_SCALAR_FIELD(val.val.ival);
2368 COPY_STRING_FIELD(val.val.str);
2374 elog(ERROR, "unrecognized node type: %d",
2375 (int) from->val.type);
2379 COPY_LOCATION_FIELD(location);
2385 _copyFuncCall(const FuncCall *from)
2387 FuncCall *newnode = makeNode(FuncCall);
2389 COPY_NODE_FIELD(funcname);
2390 COPY_NODE_FIELD(args);
2391 COPY_NODE_FIELD(agg_order);
2392 COPY_NODE_FIELD(agg_filter);
2393 COPY_SCALAR_FIELD(agg_within_group);
2394 COPY_SCALAR_FIELD(agg_star);
2395 COPY_SCALAR_FIELD(agg_distinct);
2396 COPY_SCALAR_FIELD(func_variadic);
2397 COPY_NODE_FIELD(over);
2398 COPY_LOCATION_FIELD(location);
2404 _copyAStar(const A_Star *from)
2406 A_Star *newnode = makeNode(A_Star);
2412 _copyAIndices(const A_Indices *from)
2414 A_Indices *newnode = makeNode(A_Indices);
2416 COPY_NODE_FIELD(lidx);
2417 COPY_NODE_FIELD(uidx);
2422 static A_Indirection *
2423 _copyA_Indirection(const A_Indirection *from)
2425 A_Indirection *newnode = makeNode(A_Indirection);
2427 COPY_NODE_FIELD(arg);
2428 COPY_NODE_FIELD(indirection);
2433 static A_ArrayExpr *
2434 _copyA_ArrayExpr(const A_ArrayExpr *from)
2436 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2438 COPY_NODE_FIELD(elements);
2439 COPY_LOCATION_FIELD(location);
2445 _copyResTarget(const ResTarget *from)
2447 ResTarget *newnode = makeNode(ResTarget);
2449 COPY_STRING_FIELD(name);
2450 COPY_NODE_FIELD(indirection);
2451 COPY_NODE_FIELD(val);
2452 COPY_LOCATION_FIELD(location);
2457 static MultiAssignRef *
2458 _copyMultiAssignRef(const MultiAssignRef *from)
2460 MultiAssignRef *newnode = makeNode(MultiAssignRef);
2462 COPY_NODE_FIELD(source);
2463 COPY_SCALAR_FIELD(colno);
2464 COPY_SCALAR_FIELD(ncolumns);
2470 _copyTypeName(const TypeName *from)
2472 TypeName *newnode = makeNode(TypeName);
2474 COPY_NODE_FIELD(names);
2475 COPY_SCALAR_FIELD(typeOid);
2476 COPY_SCALAR_FIELD(setof);
2477 COPY_SCALAR_FIELD(pct_type);
2478 COPY_NODE_FIELD(typmods);
2479 COPY_SCALAR_FIELD(typemod);
2480 COPY_NODE_FIELD(arrayBounds);
2481 COPY_LOCATION_FIELD(location);
2487 _copySortBy(const SortBy *from)
2489 SortBy *newnode = makeNode(SortBy);
2491 COPY_NODE_FIELD(node);
2492 COPY_SCALAR_FIELD(sortby_dir);
2493 COPY_SCALAR_FIELD(sortby_nulls);
2494 COPY_NODE_FIELD(useOp);
2495 COPY_LOCATION_FIELD(location);
2501 _copyWindowDef(const WindowDef *from)
2503 WindowDef *newnode = makeNode(WindowDef);
2505 COPY_STRING_FIELD(name);
2506 COPY_STRING_FIELD(refname);
2507 COPY_NODE_FIELD(partitionClause);
2508 COPY_NODE_FIELD(orderClause);
2509 COPY_SCALAR_FIELD(frameOptions);
2510 COPY_NODE_FIELD(startOffset);
2511 COPY_NODE_FIELD(endOffset);
2512 COPY_LOCATION_FIELD(location);
2517 static RangeSubselect *
2518 _copyRangeSubselect(const RangeSubselect *from)
2520 RangeSubselect *newnode = makeNode(RangeSubselect);
2522 COPY_SCALAR_FIELD(lateral);
2523 COPY_NODE_FIELD(subquery);
2524 COPY_NODE_FIELD(alias);
2529 static RangeFunction *
2530 _copyRangeFunction(const RangeFunction *from)
2532 RangeFunction *newnode = makeNode(RangeFunction);
2534 COPY_SCALAR_FIELD(lateral);
2535 COPY_SCALAR_FIELD(ordinality);
2536 COPY_SCALAR_FIELD(is_rowsfrom);
2537 COPY_NODE_FIELD(functions);
2538 COPY_NODE_FIELD(alias);
2539 COPY_NODE_FIELD(coldeflist);
2544 static RangeTableSample *
2545 _copyRangeTableSample(const RangeTableSample *from)
2547 RangeTableSample *newnode = makeNode(RangeTableSample);
2549 COPY_NODE_FIELD(relation);
2550 COPY_NODE_FIELD(method);
2551 COPY_NODE_FIELD(args);
2552 COPY_NODE_FIELD(repeatable);
2553 COPY_LOCATION_FIELD(location);
2559 _copyTypeCast(const TypeCast *from)
2561 TypeCast *newnode = makeNode(TypeCast);
2563 COPY_NODE_FIELD(arg);
2564 COPY_NODE_FIELD(typeName);
2565 COPY_LOCATION_FIELD(location);
2570 static CollateClause *
2571 _copyCollateClause(const CollateClause *from)
2573 CollateClause *newnode = makeNode(CollateClause);
2575 COPY_NODE_FIELD(arg);
2576 COPY_NODE_FIELD(collname);
2577 COPY_LOCATION_FIELD(location);
2583 _copyIndexElem(const IndexElem *from)
2585 IndexElem *newnode = makeNode(IndexElem);
2587 COPY_STRING_FIELD(name);
2588 COPY_NODE_FIELD(expr);
2589 COPY_STRING_FIELD(indexcolname);
2590 COPY_NODE_FIELD(collation);
2591 COPY_NODE_FIELD(opclass);
2592 COPY_SCALAR_FIELD(ordering);
2593 COPY_SCALAR_FIELD(nulls_ordering);
2599 _copyColumnDef(const ColumnDef *from)
2601 ColumnDef *newnode = makeNode(ColumnDef);
2603 COPY_STRING_FIELD(colname);
2604 COPY_NODE_FIELD(typeName);
2605 COPY_SCALAR_FIELD(inhcount);
2606 COPY_SCALAR_FIELD(is_local);
2607 COPY_SCALAR_FIELD(is_not_null);
2608 COPY_SCALAR_FIELD(is_from_type);
2609 COPY_SCALAR_FIELD(storage);
2610 COPY_NODE_FIELD(raw_default);
2611 COPY_NODE_FIELD(cooked_default);
2612 COPY_NODE_FIELD(collClause);
2613 COPY_SCALAR_FIELD(collOid);
2614 COPY_NODE_FIELD(constraints);
2615 COPY_NODE_FIELD(fdwoptions);
2616 COPY_LOCATION_FIELD(location);
2622 _copyConstraint(const Constraint *from)
2624 Constraint *newnode = makeNode(Constraint);
2626 COPY_SCALAR_FIELD(contype);
2627 COPY_STRING_FIELD(conname);
2628 COPY_SCALAR_FIELD(deferrable);
2629 COPY_SCALAR_FIELD(initdeferred);
2630 COPY_LOCATION_FIELD(location);
2631 COPY_SCALAR_FIELD(is_no_inherit);
2632 COPY_NODE_FIELD(raw_expr);
2633 COPY_STRING_FIELD(cooked_expr);
2634 COPY_NODE_FIELD(keys);
2635 COPY_NODE_FIELD(exclusions);
2636 COPY_NODE_FIELD(options);
2637 COPY_STRING_FIELD(indexname);
2638 COPY_STRING_FIELD(indexspace);
2639 COPY_STRING_FIELD(access_method);
2640 COPY_NODE_FIELD(where_clause);
2641 COPY_NODE_FIELD(pktable);
2642 COPY_NODE_FIELD(fk_attrs);
2643 COPY_NODE_FIELD(pk_attrs);
2644 COPY_SCALAR_FIELD(fk_matchtype);
2645 COPY_SCALAR_FIELD(fk_upd_action);
2646 COPY_SCALAR_FIELD(fk_del_action);
2647 COPY_NODE_FIELD(old_conpfeqop);
2648 COPY_SCALAR_FIELD(old_pktable_oid);
2649 COPY_SCALAR_FIELD(skip_validation);
2650 COPY_SCALAR_FIELD(initially_valid);
2656 _copyDefElem(const DefElem *from)
2658 DefElem *newnode = makeNode(DefElem);
2660 COPY_STRING_FIELD(defnamespace);
2661 COPY_STRING_FIELD(defname);
2662 COPY_NODE_FIELD(arg);
2663 COPY_SCALAR_FIELD(defaction);
2668 static LockingClause *
2669 _copyLockingClause(const LockingClause *from)
2671 LockingClause *newnode = makeNode(LockingClause);
2673 COPY_NODE_FIELD(lockedRels);
2674 COPY_SCALAR_FIELD(strength);
2675 COPY_SCALAR_FIELD(waitPolicy);
2680 static XmlSerialize *
2681 _copyXmlSerialize(const XmlSerialize *from)
2683 XmlSerialize *newnode = makeNode(XmlSerialize);
2685 COPY_SCALAR_FIELD(xmloption);
2686 COPY_NODE_FIELD(expr);
2687 COPY_NODE_FIELD(typeName);
2688 COPY_LOCATION_FIELD(location);
2694 _copyRoleSpec(const RoleSpec *from)
2696 RoleSpec *newnode = makeNode(RoleSpec);
2698 COPY_SCALAR_FIELD(roletype);
2699 COPY_STRING_FIELD(rolename);
2700 COPY_LOCATION_FIELD(location);
2706 _copyQuery(const Query *from)
2708 Query *newnode = makeNode(Query);
2710 COPY_SCALAR_FIELD(commandType);
2711 COPY_SCALAR_FIELD(querySource);
2712 COPY_SCALAR_FIELD(queryId);
2713 COPY_SCALAR_FIELD(canSetTag);
2714 COPY_NODE_FIELD(utilityStmt);
2715 COPY_SCALAR_FIELD(resultRelation);
2716 COPY_SCALAR_FIELD(hasAggs);
2717 COPY_SCALAR_FIELD(hasWindowFuncs);
2718 COPY_SCALAR_FIELD(hasSubLinks);
2719 COPY_SCALAR_FIELD(hasDistinctOn);
2720 COPY_SCALAR_FIELD(hasRecursive);
2721 COPY_SCALAR_FIELD(hasModifyingCTE);
2722 COPY_SCALAR_FIELD(hasForUpdate);
2723 COPY_SCALAR_FIELD(hasRowSecurity);
2724 COPY_NODE_FIELD(cteList);
2725 COPY_NODE_FIELD(rtable);
2726 COPY_NODE_FIELD(jointree);
2727 COPY_NODE_FIELD(targetList);
2728 COPY_NODE_FIELD(withCheckOptions);
2729 COPY_NODE_FIELD(onConflict);
2730 COPY_NODE_FIELD(returningList);
2731 COPY_NODE_FIELD(groupClause);
2732 COPY_NODE_FIELD(groupingSets);
2733 COPY_NODE_FIELD(havingQual);
2734 COPY_NODE_FIELD(windowClause);
2735 COPY_NODE_FIELD(distinctClause);
2736 COPY_NODE_FIELD(sortClause);
2737 COPY_NODE_FIELD(limitOffset);
2738 COPY_NODE_FIELD(limitCount);
2739 COPY_NODE_FIELD(rowMarks);
2740 COPY_NODE_FIELD(setOperations);
2741 COPY_NODE_FIELD(constraintDeps);
2747 _copyInsertStmt(const InsertStmt *from)
2749 InsertStmt *newnode = makeNode(InsertStmt);
2751 COPY_NODE_FIELD(relation);
2752 COPY_NODE_FIELD(cols);
2753 COPY_NODE_FIELD(selectStmt);
2754 COPY_NODE_FIELD(onConflictClause);
2755 COPY_NODE_FIELD(returningList);
2756 COPY_NODE_FIELD(withClause);
2762 _copyDeleteStmt(const DeleteStmt *from)
2764 DeleteStmt *newnode = makeNode(DeleteStmt);
2766 COPY_NODE_FIELD(relation);
2767 COPY_NODE_FIELD(usingClause);
2768 COPY_NODE_FIELD(whereClause);
2769 COPY_NODE_FIELD(returningList);
2770 COPY_NODE_FIELD(withClause);
2776 _copyUpdateStmt(const UpdateStmt *from)
2778 UpdateStmt *newnode = makeNode(UpdateStmt);
2780 COPY_NODE_FIELD(relation);
2781 COPY_NODE_FIELD(targetList);
2782 COPY_NODE_FIELD(whereClause);
2783 COPY_NODE_FIELD(fromClause);
2784 COPY_NODE_FIELD(returningList);
2785 COPY_NODE_FIELD(withClause);
2791 _copySelectStmt(const SelectStmt *from)
2793 SelectStmt *newnode = makeNode(SelectStmt);
2795 COPY_NODE_FIELD(distinctClause);
2796 COPY_NODE_FIELD(intoClause);
2797 COPY_NODE_FIELD(targetList);
2798 COPY_NODE_FIELD(fromClause);
2799 COPY_NODE_FIELD(whereClause);
2800 COPY_NODE_FIELD(groupClause);
2801 COPY_NODE_FIELD(havingClause);
2802 COPY_NODE_FIELD(windowClause);
2803 COPY_NODE_FIELD(valuesLists);
2804 COPY_NODE_FIELD(sortClause);
2805 COPY_NODE_FIELD(limitOffset);
2806 COPY_NODE_FIELD(limitCount);
2807 COPY_NODE_FIELD(lockingClause);
2808 COPY_NODE_FIELD(withClause);
2809 COPY_SCALAR_FIELD(op);
2810 COPY_SCALAR_FIELD(all);
2811 COPY_NODE_FIELD(larg);
2812 COPY_NODE_FIELD(rarg);
2817 static SetOperationStmt *
2818 _copySetOperationStmt(const SetOperationStmt *from)
2820 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2822 COPY_SCALAR_FIELD(op);
2823 COPY_SCALAR_FIELD(all);
2824 COPY_NODE_FIELD(larg);
2825 COPY_NODE_FIELD(rarg);
2826 COPY_NODE_FIELD(colTypes);
2827 COPY_NODE_FIELD(colTypmods);
2828 COPY_NODE_FIELD(colCollations);
2829 COPY_NODE_FIELD(groupClauses);
2834 static AlterTableStmt *
2835 _copyAlterTableStmt(const AlterTableStmt *from)
2837 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2839 COPY_NODE_FIELD(relation);
2840 COPY_NODE_FIELD(cmds);
2841 COPY_SCALAR_FIELD(relkind);
2842 COPY_SCALAR_FIELD(missing_ok);
2847 static AlterTableCmd *
2848 _copyAlterTableCmd(const AlterTableCmd *from)
2850 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2852 COPY_SCALAR_FIELD(subtype);
2853 COPY_STRING_FIELD(name);
2854 COPY_NODE_FIELD(newowner);
2855 COPY_NODE_FIELD(def);
2856 COPY_SCALAR_FIELD(behavior);
2857 COPY_SCALAR_FIELD(missing_ok);
2862 static AlterDomainStmt *
2863 _copyAlterDomainStmt(const AlterDomainStmt *from)
2865 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2867 COPY_SCALAR_FIELD(subtype);
2868 COPY_NODE_FIELD(typeName);
2869 COPY_STRING_FIELD(name);
2870 COPY_NODE_FIELD(def);
2871 COPY_SCALAR_FIELD(behavior);
2872 COPY_SCALAR_FIELD(missing_ok);
2878 _copyGrantStmt(const GrantStmt *from)
2880 GrantStmt *newnode = makeNode(GrantStmt);
2882 COPY_SCALAR_FIELD(is_grant);
2883 COPY_SCALAR_FIELD(targtype);
2884 COPY_SCALAR_FIELD(objtype);
2885 COPY_NODE_FIELD(objects);
2886 COPY_NODE_FIELD(privileges);
2887 COPY_NODE_FIELD(grantees);
2888 COPY_SCALAR_FIELD(grant_option);
2889 COPY_SCALAR_FIELD(behavior);
2894 static FuncWithArgs *
2895 _copyFuncWithArgs(const FuncWithArgs *from)
2897 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2899 COPY_NODE_FIELD(funcname);
2900 COPY_NODE_FIELD(funcargs);
2906 _copyAccessPriv(const AccessPriv *from)
2908 AccessPriv *newnode = makeNode(AccessPriv);
2910 COPY_STRING_FIELD(priv_name);
2911 COPY_NODE_FIELD(cols);
2916 static GrantRoleStmt *
2917 _copyGrantRoleStmt(const GrantRoleStmt *from)
2919 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2921 COPY_NODE_FIELD(granted_roles);
2922 COPY_NODE_FIELD(grantee_roles);
2923 COPY_SCALAR_FIELD(is_grant);
2924 COPY_SCALAR_FIELD(admin_opt);
2925 COPY_NODE_FIELD(grantor);
2926 COPY_SCALAR_FIELD(behavior);
2931 static AlterDefaultPrivilegesStmt *
2932 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
2934 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2936 COPY_NODE_FIELD(options);
2937 COPY_NODE_FIELD(action);
2942 static DeclareCursorStmt *
2943 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
2945 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2947 COPY_STRING_FIELD(portalname);
2948 COPY_SCALAR_FIELD(options);
2949 COPY_NODE_FIELD(query);
2954 static ClosePortalStmt *
2955 _copyClosePortalStmt(const ClosePortalStmt *from)
2957 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2959 COPY_STRING_FIELD(portalname);
2964 static ClusterStmt *
2965 _copyClusterStmt(const ClusterStmt *from)
2967 ClusterStmt *newnode = makeNode(ClusterStmt);
2969 COPY_NODE_FIELD(relation);
2970 COPY_STRING_FIELD(indexname);
2971 COPY_SCALAR_FIELD(verbose);
2977 _copyCopyStmt(const CopyStmt *from)
2979 CopyStmt *newnode = makeNode(CopyStmt);
2981 COPY_NODE_FIELD(relation);
2982 COPY_NODE_FIELD(query);
2983 COPY_NODE_FIELD(attlist);
2984 COPY_SCALAR_FIELD(is_from);
2985 COPY_SCALAR_FIELD(is_program);
2986 COPY_STRING_FIELD(filename);
2987 COPY_NODE_FIELD(options);
2993 * CopyCreateStmtFields
2995 * This function copies the fields of the CreateStmt node. It is used by
2996 * copy functions for classes which inherit from CreateStmt.
2999 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
3001 COPY_NODE_FIELD(relation);
3002 COPY_NODE_FIELD(tableElts);
3003 COPY_NODE_FIELD(inhRelations);
3004 COPY_NODE_FIELD(ofTypename);
3005 COPY_NODE_FIELD(constraints);
3006 COPY_NODE_FIELD(options);
3007 COPY_SCALAR_FIELD(oncommit);
3008 COPY_STRING_FIELD(tablespacename);
3009 COPY_SCALAR_FIELD(if_not_exists);
3013 _copyCreateStmt(const CreateStmt *from)
3015 CreateStmt *newnode = makeNode(CreateStmt);
3017 CopyCreateStmtFields(from, newnode);
3022 static TableLikeClause *
3023 _copyTableLikeClause(const TableLikeClause *from)
3025 TableLikeClause *newnode = makeNode(TableLikeClause);
3027 COPY_NODE_FIELD(relation);
3028 COPY_SCALAR_FIELD(options);
3034 _copyDefineStmt(const DefineStmt *from)
3036 DefineStmt *newnode = makeNode(DefineStmt);
3038 COPY_SCALAR_FIELD(kind);
3039 COPY_SCALAR_FIELD(oldstyle);
3040 COPY_NODE_FIELD(defnames);
3041 COPY_NODE_FIELD(args);
3042 COPY_NODE_FIELD(definition);
3048 _copyDropStmt(const DropStmt *from)
3050 DropStmt *newnode = makeNode(DropStmt);
3052 COPY_NODE_FIELD(objects);
3053 COPY_NODE_FIELD(arguments);
3054 COPY_SCALAR_FIELD(removeType);
3055 COPY_SCALAR_FIELD(behavior);
3056 COPY_SCALAR_FIELD(missing_ok);
3057 COPY_SCALAR_FIELD(concurrent);
3062 static TruncateStmt *
3063 _copyTruncateStmt(const TruncateStmt *from)
3065 TruncateStmt *newnode = makeNode(TruncateStmt);
3067 COPY_NODE_FIELD(relations);
3068 COPY_SCALAR_FIELD(restart_seqs);
3069 COPY_SCALAR_FIELD(behavior);
3074 static CommentStmt *
3075 _copyCommentStmt(const CommentStmt *from)
3077 CommentStmt *newnode = makeNode(CommentStmt);
3079 COPY_SCALAR_FIELD(objtype);
3080 COPY_NODE_FIELD(objname);
3081 COPY_NODE_FIELD(objargs);
3082 COPY_STRING_FIELD(comment);
3087 static SecLabelStmt *
3088 _copySecLabelStmt(const SecLabelStmt *from)
3090 SecLabelStmt *newnode = makeNode(SecLabelStmt);
3092 COPY_SCALAR_FIELD(objtype);
3093 COPY_NODE_FIELD(objname);
3094 COPY_NODE_FIELD(objargs);
3095 COPY_STRING_FIELD(provider);
3096 COPY_STRING_FIELD(label);
3102 _copyFetchStmt(const FetchStmt *from)
3104 FetchStmt *newnode = makeNode(FetchStmt);
3106 COPY_SCALAR_FIELD(direction);
3107 COPY_SCALAR_FIELD(howMany);
3108 COPY_STRING_FIELD(portalname);
3109 COPY_SCALAR_FIELD(ismove);
3115 _copyIndexStmt(const IndexStmt *from)
3117 IndexStmt *newnode = makeNode(IndexStmt);
3119 COPY_STRING_FIELD(idxname);
3120 COPY_NODE_FIELD(relation);
3121 COPY_STRING_FIELD(accessMethod);
3122 COPY_STRING_FIELD(tableSpace);
3123 COPY_NODE_FIELD(indexParams);
3124 COPY_NODE_FIELD(options);
3125 COPY_NODE_FIELD(whereClause);
3126 COPY_NODE_FIELD(excludeOpNames);
3127 COPY_STRING_FIELD(idxcomment);
3128 COPY_SCALAR_FIELD(indexOid);
3129 COPY_SCALAR_FIELD(oldNode);
3130 COPY_SCALAR_FIELD(unique);
3131 COPY_SCALAR_FIELD(primary);
3132 COPY_SCALAR_FIELD(isconstraint);
3133 COPY_SCALAR_FIELD(deferrable);
3134 COPY_SCALAR_FIELD(initdeferred);
3135 COPY_SCALAR_FIELD(transformed);
3136 COPY_SCALAR_FIELD(concurrent);
3137 COPY_SCALAR_FIELD(if_not_exists);
3142 static CreateFunctionStmt *
3143 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
3145 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
3147 COPY_SCALAR_FIELD(replace);
3148 COPY_NODE_FIELD(funcname);
3149 COPY_NODE_FIELD(parameters);
3150 COPY_NODE_FIELD(returnType);
3151 COPY_NODE_FIELD(options);
3152 COPY_NODE_FIELD(withClause);
3157 static FunctionParameter *
3158 _copyFunctionParameter(const FunctionParameter *from)
3160 FunctionParameter *newnode = makeNode(FunctionParameter);
3162 COPY_STRING_FIELD(name);
3163 COPY_NODE_FIELD(argType);
3164 COPY_SCALAR_FIELD(mode);
3165 COPY_NODE_FIELD(defexpr);
3170 static AlterFunctionStmt *
3171 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
3173 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
3175 COPY_NODE_FIELD(func);
3176 COPY_NODE_FIELD(actions);
3182 _copyDoStmt(const DoStmt *from)
3184 DoStmt *newnode = makeNode(DoStmt);
3186 COPY_NODE_FIELD(args);
3192 _copyRenameStmt(const RenameStmt *from)
3194 RenameStmt *newnode = makeNode(RenameStmt);
3196 COPY_SCALAR_FIELD(renameType);
3197 COPY_SCALAR_FIELD(relationType);
3198 COPY_NODE_FIELD(relation);
3199 COPY_NODE_FIELD(object);
3200 COPY_NODE_FIELD(objarg);
3201 COPY_STRING_FIELD(subname);
3202 COPY_STRING_FIELD(newname);
3203 COPY_SCALAR_FIELD(behavior);
3204 COPY_SCALAR_FIELD(missing_ok);
3209 static AlterObjectSchemaStmt *
3210 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
3212 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
3214 COPY_SCALAR_FIELD(objectType);
3215 COPY_NODE_FIELD(relation);
3216 COPY_NODE_FIELD(object);
3217 COPY_NODE_FIELD(objarg);
3218 COPY_STRING_FIELD(newschema);
3219 COPY_SCALAR_FIELD(missing_ok);
3224 static AlterOwnerStmt *
3225 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
3227 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
3229 COPY_SCALAR_FIELD(objectType);
3230 COPY_NODE_FIELD(relation);
3231 COPY_NODE_FIELD(object);
3232 COPY_NODE_FIELD(objarg);
3233 COPY_NODE_FIELD(newowner);
3238 static AlterOperatorStmt *
3239 _copyAlterOperatorStmt(const AlterOperatorStmt *from)
3241 AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt);
3243 COPY_NODE_FIELD(opername);
3244 COPY_NODE_FIELD(operargs);
3245 COPY_NODE_FIELD(options);
3251 _copyRuleStmt(const RuleStmt *from)
3253 RuleStmt *newnode = makeNode(RuleStmt);
3255 COPY_NODE_FIELD(relation);
3256 COPY_STRING_FIELD(rulename);
3257 COPY_NODE_FIELD(whereClause);
3258 COPY_SCALAR_FIELD(event);
3259 COPY_SCALAR_FIELD(instead);
3260 COPY_NODE_FIELD(actions);
3261 COPY_SCALAR_FIELD(replace);
3267 _copyNotifyStmt(const NotifyStmt *from)
3269 NotifyStmt *newnode = makeNode(NotifyStmt);
3271 COPY_STRING_FIELD(conditionname);
3272 COPY_STRING_FIELD(payload);
3278 _copyListenStmt(const ListenStmt *from)
3280 ListenStmt *newnode = makeNode(ListenStmt);
3282 COPY_STRING_FIELD(conditionname);
3287 static UnlistenStmt *
3288 _copyUnlistenStmt(const UnlistenStmt *from)
3290 UnlistenStmt *newnode = makeNode(UnlistenStmt);
3292 COPY_STRING_FIELD(conditionname);
3297 static TransactionStmt *
3298 _copyTransactionStmt(const TransactionStmt *from)
3300 TransactionStmt *newnode = makeNode(TransactionStmt);
3302 COPY_SCALAR_FIELD(kind);
3303 COPY_NODE_FIELD(options);
3304 COPY_STRING_FIELD(gid);
3309 static CompositeTypeStmt *
3310 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
3312 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3314 COPY_NODE_FIELD(typevar);
3315 COPY_NODE_FIELD(coldeflist);
3320 static CreateEnumStmt *
3321 _copyCreateEnumStmt(const CreateEnumStmt *from)
3323 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3325 COPY_NODE_FIELD(typeName);
3326 COPY_NODE_FIELD(vals);
3331 static CreateRangeStmt *
3332 _copyCreateRangeStmt(const CreateRangeStmt *from)
3334 CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
3336 COPY_NODE_FIELD(typeName);
3337 COPY_NODE_FIELD(params);
3342 static AlterEnumStmt *
3343 _copyAlterEnumStmt(const AlterEnumStmt *from)
3345 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3347 COPY_NODE_FIELD(typeName);
3348 COPY_STRING_FIELD(newVal);
3349 COPY_STRING_FIELD(newValNeighbor);
3350 COPY_SCALAR_FIELD(newValIsAfter);
3351 COPY_SCALAR_FIELD(skipIfExists);
3357 _copyViewStmt(const ViewStmt *from)
3359 ViewStmt *newnode = makeNode(ViewStmt);
3361 COPY_NODE_FIELD(view);
3362 COPY_NODE_FIELD(aliases);
3363 COPY_NODE_FIELD(query);
3364 COPY_SCALAR_FIELD(replace);
3365 COPY_NODE_FIELD(options);
3366 COPY_SCALAR_FIELD(withCheckOption);
3372 _copyLoadStmt(const LoadStmt *from)
3374 LoadStmt *newnode = makeNode(LoadStmt);
3376 COPY_STRING_FIELD(filename);
3381 static CreateDomainStmt *
3382 _copyCreateDomainStmt(const CreateDomainStmt *from)
3384 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3386 COPY_NODE_FIELD(domainname);
3387 COPY_NODE_FIELD(typeName);
3388 COPY_NODE_FIELD(collClause);
3389 COPY_NODE_FIELD(constraints);
3394 static CreateOpClassStmt *
3395 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
3397 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3399 COPY_NODE_FIELD(opclassname);
3400 COPY_NODE_FIELD(opfamilyname);
3401 COPY_STRING_FIELD(amname);
3402 COPY_NODE_FIELD(datatype);
3403 COPY_NODE_FIELD(items);
3404 COPY_SCALAR_FIELD(isDefault);
3409 static CreateOpClassItem *
3410 _copyCreateOpClassItem(const CreateOpClassItem *from)
3412 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3414 COPY_SCALAR_FIELD(itemtype);
3415 COPY_NODE_FIELD(name);
3416 COPY_NODE_FIELD(args);
3417 COPY_SCALAR_FIELD(number);
3418 COPY_NODE_FIELD(order_family);
3419 COPY_NODE_FIELD(class_args);
3420 COPY_NODE_FIELD(storedtype);
3425 static CreateOpFamilyStmt *
3426 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
3428 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3430 COPY_NODE_FIELD(opfamilyname);
3431 COPY_STRING_FIELD(amname);
3436 static AlterOpFamilyStmt *
3437 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
3439 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3441 COPY_NODE_FIELD(opfamilyname);
3442 COPY_STRING_FIELD(amname);
3443 COPY_SCALAR_FIELD(isDrop);
3444 COPY_NODE_FIELD(items);
3449 static CreatedbStmt *
3450 _copyCreatedbStmt(const CreatedbStmt *from)
3452 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3454 COPY_STRING_FIELD(dbname);
3455 COPY_NODE_FIELD(options);
3460 static AlterDatabaseStmt *
3461 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
3463 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3465 COPY_STRING_FIELD(dbname);
3466 COPY_NODE_FIELD(options);
3471 static AlterDatabaseSetStmt *
3472 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
3474 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3476 COPY_STRING_FIELD(dbname);
3477 COPY_NODE_FIELD(setstmt);
3483 _copyDropdbStmt(const DropdbStmt *from)
3485 DropdbStmt *newnode = makeNode(DropdbStmt);
3487 COPY_STRING_FIELD(dbname);
3488 COPY_SCALAR_FIELD(missing_ok);
3494 _copyVacuumStmt(const VacuumStmt *from)
3496 VacuumStmt *newnode = makeNode(VacuumStmt);
3498 COPY_SCALAR_FIELD(options);
3499 COPY_NODE_FIELD(relation);
3500 COPY_NODE_FIELD(va_cols);
3505 static ExplainStmt *
3506 _copyExplainStmt(const ExplainStmt *from)
3508 ExplainStmt *newnode = makeNode(ExplainStmt);
3510 COPY_NODE_FIELD(query);
3511 COPY_NODE_FIELD(options);
3516 static CreateTableAsStmt *
3517 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
3519 CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
3521 COPY_NODE_FIELD(query);
3522 COPY_NODE_FIELD(into);
3523 COPY_SCALAR_FIELD(relkind);
3524 COPY_SCALAR_FIELD(is_select_into);
3525 COPY_SCALAR_FIELD(if_not_exists);
3530 static RefreshMatViewStmt *
3531 _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
3533 RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
3535 COPY_SCALAR_FIELD(concurrent);
3536 COPY_SCALAR_FIELD(skipData);
3537 COPY_NODE_FIELD(relation);
3542 static ReplicaIdentityStmt *
3543 _copyReplicaIdentityStmt(const ReplicaIdentityStmt *from)
3545 ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt);
3547 COPY_SCALAR_FIELD(identity_type);
3548 COPY_STRING_FIELD(name);
3553 static AlterSystemStmt *
3554 _copyAlterSystemStmt(const AlterSystemStmt *from)
3556 AlterSystemStmt *newnode = makeNode(AlterSystemStmt);
3558 COPY_NODE_FIELD(setstmt);
3563 static CreateSeqStmt *
3564 _copyCreateSeqStmt(const CreateSeqStmt *from)
3566 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3568 COPY_NODE_FIELD(sequence);
3569 COPY_NODE_FIELD(options);
3570 COPY_SCALAR_FIELD(ownerId);
3571 COPY_SCALAR_FIELD(if_not_exists);
3576 static AlterSeqStmt *
3577 _copyAlterSeqStmt(const AlterSeqStmt *from)
3579 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3581 COPY_NODE_FIELD(sequence);
3582 COPY_NODE_FIELD(options);
3583 COPY_SCALAR_FIELD(missing_ok);
3588 static VariableSetStmt *
3589 _copyVariableSetStmt(const VariableSetStmt *from)
3591 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3593 COPY_SCALAR_FIELD(kind);
3594 COPY_STRING_FIELD(name);
3595 COPY_NODE_FIELD(args);
3596 COPY_SCALAR_FIELD(is_local);
3601 static VariableShowStmt *
3602 _copyVariableShowStmt(const VariableShowStmt *from)
3604 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3606 COPY_STRING_FIELD(name);
3611 static DiscardStmt *
3612 _copyDiscardStmt(const DiscardStmt *from)
3614 DiscardStmt *newnode = makeNode(DiscardStmt);
3616 COPY_SCALAR_FIELD(target);
3621 static CreateTableSpaceStmt *
3622 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
3624 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3626 COPY_STRING_FIELD(tablespacename);
3627 COPY_NODE_FIELD(owner);
3628 COPY_STRING_FIELD(location);
3629 COPY_NODE_FIELD(options);
3634 static DropTableSpaceStmt *
3635 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
3637 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3639 COPY_STRING_FIELD(tablespacename);
3640 COPY_SCALAR_FIELD(missing_ok);
3645 static AlterTableSpaceOptionsStmt *
3646 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
3648 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3650 COPY_STRING_FIELD(tablespacename);
3651 COPY_NODE_FIELD(options);
3652 COPY_SCALAR_FIELD(isReset);
3657 static AlterTableMoveAllStmt *
3658 _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
3660 AlterTableMoveAllStmt *newnode = makeNode(AlterTableMoveAllStmt);
3662 COPY_STRING_FIELD(orig_tablespacename);
3663 COPY_SCALAR_FIELD(objtype);
3664 COPY_NODE_FIELD(roles);
3665 COPY_STRING_FIELD(new_tablespacename);
3666 COPY_SCALAR_FIELD(nowait);
3671 static CreateExtensionStmt *
3672 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
3674 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3676 COPY_STRING_FIELD(extname);
3677 COPY_SCALAR_FIELD(if_not_exists);
3678 COPY_NODE_FIELD(options);
3683 static AlterExtensionStmt *
3684 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
3686 AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3688 COPY_STRING_FIELD(extname);
3689 COPY_NODE_FIELD(options);
3694 static AlterExtensionContentsStmt *
3695 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
3697 AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3699 COPY_STRING_FIELD(extname);
3700 COPY_SCALAR_FIELD(action);
3701 COPY_SCALAR_FIELD(objtype);
3702 COPY_NODE_FIELD(objname);
3703 COPY_NODE_FIELD(objargs);
3708 static CreateFdwStmt *
3709 _copyCreateFdwStmt(const CreateFdwStmt *from)
3711 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3713 COPY_STRING_FIELD(fdwname);
3714 COPY_NODE_FIELD(func_options);
3715 COPY_NODE_FIELD(options);
3720 static AlterFdwStmt *
3721 _copyAlterFdwStmt(const AlterFdwStmt *from)
3723 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3725 COPY_STRING_FIELD(fdwname);
3726 COPY_NODE_FIELD(func_options);
3727 COPY_NODE_FIELD(options);
3732 static CreateForeignServerStmt *
3733 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
3735 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3737 COPY_STRING_FIELD(servername);
3738 COPY_STRING_FIELD(servertype);
3739 COPY_STRING_FIELD(version);
3740 COPY_STRING_FIELD(fdwname);
3741 COPY_NODE_FIELD(options);
3746 static AlterForeignServerStmt *
3747 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
3749 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3751 COPY_STRING_FIELD(servername);
3752 COPY_STRING_FIELD(version);
3753 COPY_NODE_FIELD(options);
3754 COPY_SCALAR_FIELD(has_version);
3759 static CreateUserMappingStmt *
3760 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
3762 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3764 COPY_NODE_FIELD(user);
3765 COPY_STRING_FIELD(servername);
3766 COPY_NODE_FIELD(options);
3771 static AlterUserMappingStmt *
3772 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
3774 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3776 COPY_NODE_FIELD(user);
3777 COPY_STRING_FIELD(servername);
3778 COPY_NODE_FIELD(options);
3783 static DropUserMappingStmt *
3784 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
3786 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3788 COPY_NODE_FIELD(user);
3789 COPY_STRING_FIELD(servername);
3790 COPY_SCALAR_FIELD(missing_ok);
3795 static CreateForeignTableStmt *
3796 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
3798 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3800 CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
3802 COPY_STRING_FIELD(servername);
3803 COPY_NODE_FIELD(options);
3808 static ImportForeignSchemaStmt *
3809 _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
3811 ImportForeignSchemaStmt *newnode = makeNode(ImportForeignSchemaStmt);
3813 COPY_STRING_FIELD(server_name);
3814 COPY_STRING_FIELD(remote_schema);
3815 COPY_STRING_FIELD(local_schema);
3816 COPY_SCALAR_FIELD(list_type);
3817 COPY_NODE_FIELD(table_list);
3818 COPY_NODE_FIELD(options);
3823 static CreateTransformStmt *
3824 _copyCreateTransformStmt(const CreateTransformStmt *from)
3826 CreateTransformStmt *newnode = makeNode(CreateTransformStmt);
3828 COPY_SCALAR_FIELD(replace);
3829 COPY_NODE_FIELD(type_name);
3830 COPY_STRING_FIELD(lang);
3831 COPY_NODE_FIELD(fromsql);
3832 COPY_NODE_FIELD(tosql);
3837 static CreateTrigStmt *
3838 _copyCreateTrigStmt(const CreateTrigStmt *from)
3840 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3842 COPY_STRING_FIELD(trigname);
3843 COPY_NODE_FIELD(relation);
3844 COPY_NODE_FIELD(funcname);
3845 COPY_NODE_FIELD(args);
3846 COPY_SCALAR_FIELD(row);
3847 COPY_SCALAR_FIELD(timing);
3848 COPY_SCALAR_FIELD(events);
3849 COPY_NODE_FIELD(columns);
3850 COPY_NODE_FIELD(whenClause);
3851 COPY_SCALAR_FIELD(isconstraint);
3852 COPY_SCALAR_FIELD(deferrable);
3853 COPY_SCALAR_FIELD(initdeferred);
3854 COPY_NODE_FIELD(constrrel);
3859 static CreateEventTrigStmt *
3860 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
3862 CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
3864 COPY_STRING_FIELD(trigname);
3865 COPY_STRING_FIELD(eventname);
3866 COPY_NODE_FIELD(whenclause);
3867 COPY_NODE_FIELD(funcname);
3872 static AlterEventTrigStmt *
3873 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
3875 AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
3877 COPY_STRING_FIELD(trigname);
3878 COPY_SCALAR_FIELD(tgenabled);
3883 static CreatePLangStmt *
3884 _copyCreatePLangStmt(const CreatePLangStmt *from)
3886 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3888 COPY_SCALAR_FIELD(replace);
3889 COPY_STRING_FIELD(plname);
3890 COPY_NODE_FIELD(plhandler);
3891 COPY_NODE_FIELD(plinline);
3892 COPY_NODE_FIELD(plvalidator);
3893 COPY_SCALAR_FIELD(pltrusted);
3898 static CreateRoleStmt *
3899 _copyCreateRoleStmt(const CreateRoleStmt *from)
3901 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3903 COPY_SCALAR_FIELD(stmt_type);
3904 COPY_STRING_FIELD(role);
3905 COPY_NODE_FIELD(options);
3910 static AlterRoleStmt *
3911 _copyAlterRoleStmt(const AlterRoleStmt *from)
3913 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3915 COPY_NODE_FIELD(role);
3916 COPY_NODE_FIELD(options);
3917 COPY_SCALAR_FIELD(action);
3922 static AlterRoleSetStmt *
3923 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
3925 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3927 COPY_NODE_FIELD(role);
3928 COPY_STRING_FIELD(database);
3929 COPY_NODE_FIELD(setstmt);
3934 static DropRoleStmt *
3935 _copyDropRoleStmt(const DropRoleStmt *from)
3937 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3939 COPY_NODE_FIELD(roles);
3940 COPY_SCALAR_FIELD(missing_ok);
3946 _copyLockStmt(const LockStmt *from)
3948 LockStmt *newnode = makeNode(LockStmt);
3950 COPY_NODE_FIELD(relations);
3951 COPY_SCALAR_FIELD(mode);
3952 COPY_SCALAR_FIELD(nowait);
3957 static ConstraintsSetStmt *
3958 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
3960 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3962 COPY_NODE_FIELD(constraints);
3963 COPY_SCALAR_FIELD(deferred);
3968 static ReindexStmt *
3969 _copyReindexStmt(const ReindexStmt *from)
3971 ReindexStmt *newnode = makeNode(ReindexStmt);
3973 COPY_SCALAR_FIELD(kind);
3974 COPY_NODE_FIELD(relation);
3975 COPY_STRING_FIELD(name);
3976 COPY_SCALAR_FIELD(options);
3981 static CreateSchemaStmt *
3982 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
3984 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3986 COPY_STRING_FIELD(schemaname);
3987 COPY_NODE_FIELD(authrole);
3988 COPY_NODE_FIELD(schemaElts);
3989 COPY_SCALAR_FIELD(if_not_exists);
3994 static CreateConversionStmt *
3995 _copyCreateConversionStmt(const CreateConversionStmt *from)
3997 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3999 COPY_NODE_FIELD(conversion_name);
4000 COPY_STRING_FIELD(for_encoding_name);
4001 COPY_STRING_FIELD(to_encoding_name);
4002 COPY_NODE_FIELD(func_name);
4003 COPY_SCALAR_FIELD(def);
4008 static CreateCastStmt *
4009 _copyCreateCastStmt(const CreateCastStmt *from)
4011 CreateCastStmt *newnode = makeNode(CreateCastStmt);
4013 COPY_NODE_FIELD(sourcetype);
4014 COPY_NODE_FIELD(targettype);
4015 COPY_NODE_FIELD(func);
4016 COPY_SCALAR_FIELD(context);
4017 COPY_SCALAR_FIELD(inout);
4022 static PrepareStmt *
4023 _copyPrepareStmt(const PrepareStmt *from)
4025 PrepareStmt *newnode = makeNode(PrepareStmt);
4027 COPY_STRING_FIELD(name);
4028 COPY_NODE_FIELD(argtypes);
4029 COPY_NODE_FIELD(query);
4034 static ExecuteStmt *
4035 _copyExecuteStmt(const ExecuteStmt *from)
4037 ExecuteStmt *newnode = makeNode(ExecuteStmt);
4039 COPY_STRING_FIELD(name);
4040 COPY_NODE_FIELD(params);
4045 static DeallocateStmt *
4046 _copyDeallocateStmt(const DeallocateStmt *from)
4048 DeallocateStmt *newnode = makeNode(DeallocateStmt);
4050 COPY_STRING_FIELD(name);
4055 static DropOwnedStmt *
4056 _copyDropOwnedStmt(const DropOwnedStmt *from)
4058 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
4060 COPY_NODE_FIELD(roles);
4061 COPY_SCALAR_FIELD(behavior);
4066 static ReassignOwnedStmt *
4067 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
4069 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
4071 COPY_NODE_FIELD(roles);
4072 COPY_NODE_FIELD(newrole);
4077 static AlterTSDictionaryStmt *
4078 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
4080 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
4082 COPY_NODE_FIELD(dictname);
4083 COPY_NODE_FIELD(options);
4088 static AlterTSConfigurationStmt *
4089 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
4091 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
4093 COPY_SCALAR_FIELD(kind);
4094 COPY_NODE_FIELD(cfgname);
4095 COPY_NODE_FIELD(tokentype);
4096 COPY_NODE_FIELD(dicts);
4097 COPY_SCALAR_FIELD(override);
4098 COPY_SCALAR_FIELD(replace);
4099 COPY_SCALAR_FIELD(missing_ok);
4104 static CreatePolicyStmt *
4105 _copyCreatePolicyStmt(const CreatePolicyStmt *from)
4107 CreatePolicyStmt *newnode = makeNode(CreatePolicyStmt);
4109 COPY_STRING_FIELD(policy_name);
4110 COPY_NODE_FIELD(table);
4111 COPY_STRING_FIELD(cmd_name);
4112 COPY_NODE_FIELD(roles);
4113 COPY_NODE_FIELD(qual);
4114 COPY_NODE_FIELD(with_check);
4119 static AlterPolicyStmt *
4120 _copyAlterPolicyStmt(const AlterPolicyStmt *from)
4122 AlterPolicyStmt *newnode = makeNode(AlterPolicyStmt);
4124 COPY_STRING_FIELD(policy_name);
4125 COPY_NODE_FIELD(table);
4126 COPY_NODE_FIELD(roles);
4127 COPY_NODE_FIELD(qual);
4128 COPY_NODE_FIELD(with_check);
4133 /* ****************************************************************
4134 * pg_list.h copy functions
4135 * ****************************************************************
4139 * Perform a deep copy of the specified list, using copyObject(). The
4140 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
4141 * need deep copies, so they should be copied via list_copy()
4143 #define COPY_NODE_CELL(new, old) \
4144 (new) = (ListCell *) palloc(sizeof(ListCell)); \
4145 lfirst(new) = copyObject(lfirst(old));
4148 _copyList(const List *from)
4154 Assert(list_length(from) >= 1);
4156 new = makeNode(List);
4157 new->length = from->length;
4159 COPY_NODE_CELL(new->head, from->head);
4160 prev_new = new->head;
4161 curr_old = lnext(from->head);
4165 COPY_NODE_CELL(prev_new->next, curr_old);
4166 prev_new = prev_new->next;
4167 curr_old = curr_old->next;
4169 prev_new->next = NULL;
4170 new->tail = prev_new;
4175 /* ****************************************************************
4176 * value.h copy functions
4177 * ****************************************************************
4180 _copyValue(const Value *from)
4182 Value *newnode = makeNode(Value);
4184 /* See also _copyAConst when changing this code! */
4186 COPY_SCALAR_FIELD(type);
4190 COPY_SCALAR_FIELD(val.ival);
4195 COPY_STRING_FIELD(val.str);
4201 elog(ERROR, "unrecognized node type: %d",
4211 * Create a copy of a Node tree or list. This is a "deep" copy: all
4212 * substructure is copied too, recursively.
4215 copyObject(const void *from)
4222 /* Guard against stack overflow due to overly complex expressions */
4223 check_stack_depth();
4225 switch (nodeTag(from))
4231 retval = _copyPlannedStmt(from);
4234 retval = _copyPlan(from);
4237 retval = _copyResult(from);
4240 retval = _copyModifyTable(from);
4243 retval = _copyAppend(from);
4246 retval = _copyMergeAppend(from);
4248 case T_RecursiveUnion:
4249 retval = _copyRecursiveUnion(from);
4252 retval = _copyBitmapAnd(from);
4255 retval = _copyBitmapOr(from);
4258 retval = _copyScan(from);
4261 retval = _copyGather(from);
4264 retval = _copySeqScan(from);
4267 retval = _copySampleScan(from);
4270 retval = _copyIndexScan(from);
4272 case T_IndexOnlyScan:
4273 retval = _copyIndexOnlyScan(from);
4275 case T_BitmapIndexScan:
4276 retval = _copyBitmapIndexScan(from);
4278 case T_BitmapHeapScan:
4279 retval = _copyBitmapHeapScan(from);
4282 retval = _copyTidScan(from);
4284 case T_SubqueryScan:
4285 retval = _copySubqueryScan(from);
4287 case T_FunctionScan:
4288 retval = _copyFunctionScan(from);
4291 retval = _copyValuesScan(from);
4294 retval = _copyCteScan(from);
4296 case T_WorkTableScan:
4297 retval = _copyWorkTableScan(from);
4300 retval = _copyForeignScan(from);
4303 retval = _copyCustomScan(from);
4306 retval = _copyJoin(from);
4309 retval = _copyNestLoop(from);
4312 retval = _copyMergeJoin(from);
4315 retval = _copyHashJoin(from);
4318 retval = _copyMaterial(from);
4321 retval = _copySort(from);
4324 retval = _copyGroup(from);
4327 retval = _copyAgg(from);
4330 retval = _copyWindowAgg(from);
4333 retval = _copyUnique(from);
4336 retval = _copyHash(from);
4339 retval = _copySetOp(from);
4342 retval = _copyLockRows(from);
4345 retval = _copyLimit(from);
4347 case T_NestLoopParam:
4348 retval = _copyNestLoopParam(from);
4351 retval = _copyPlanRowMark(from);
4353 case T_PlanInvalItem:
4354 retval = _copyPlanInvalItem(from);
4361 retval = _copyAlias(from);
4364 retval = _copyRangeVar(from);
4367 retval = _copyIntoClause(from);
4370 retval = _copyVar(from);
4373 retval = _copyConst(from);
4376 retval = _copyParam(from);
4379 retval = _copyAggref(from);
4381 case T_GroupingFunc:
4382 retval = _copyGroupingFunc(from);
4385 retval = _copyWindowFunc(from);
4388 retval = _copyArrayRef(from);
4391 retval = _copyFuncExpr(from);
4393 case T_NamedArgExpr:
4394 retval = _copyNamedArgExpr(from);
4397 retval = _copyOpExpr(from);
4399 case T_DistinctExpr:
4400 retval = _copyDistinctExpr(from);
4403 retval = _copyNullIfExpr(from);
4405 case T_ScalarArrayOpExpr:
4406 retval = _copyScalarArrayOpExpr(from);
4409 retval = _copyBoolExpr(from);
4412 retval = _copySubLink(from);
4415 retval = _copySubPlan(from);
4417 case T_AlternativeSubPlan:
4418 retval = _copyAlternativeSubPlan(from);
4421 retval = _copyFieldSelect(from);
4424 retval = _copyFieldStore(from);
4427 retval = _copyRelabelType(from);
4430 retval = _copyCoerceViaIO(from);
4432 case T_ArrayCoerceExpr:
4433 retval = _copyArrayCoerceExpr(from);
4435 case T_ConvertRowtypeExpr:
4436 retval = _copyConvertRowtypeExpr(from);
4439 retval = _copyCollateExpr(from);
4442 retval = _copyCaseExpr(from);
4445 retval = _copyCaseWhen(from);
4447 case T_CaseTestExpr:
4448 retval = _copyCaseTestExpr(from);
4451 retval = _copyArrayExpr(from);
4454 retval = _copyRowExpr(from);
4456 case T_RowCompareExpr:
4457 retval = _copyRowCompareExpr(from);
4459 case T_CoalesceExpr:
4460 retval = _copyCoalesceExpr(from);
4463 retval = _copyMinMaxExpr(from);
4466 retval = _copyXmlExpr(from);
4469 retval = _copyNullTest(from);
4472 retval = _copyBooleanTest(from);
4474 case T_CoerceToDomain:
4475 retval = _copyCoerceToDomain(from);
4477 case T_CoerceToDomainValue:
4478 retval = _copyCoerceToDomainValue(from);
4480 case T_SetToDefault:
4481 retval = _copySetToDefault(from);
4483 case T_CurrentOfExpr:
4484 retval = _copyCurrentOfExpr(from);
4486 case T_InferenceElem:
4487 retval = _copyInferenceElem(from);
4490 retval = _copyTargetEntry(from);
4493 retval = _copyRangeTblRef(from);
4496 retval = _copyJoinExpr(from);
4499 retval = _copyFromExpr(from);
4501 case T_OnConflictExpr:
4502 retval = _copyOnConflictExpr(from);
4509 retval = _copyPathKey(from);
4511 case T_RestrictInfo:
4512 retval = _copyRestrictInfo(from);
4514 case T_PlaceHolderVar:
4515 retval = _copyPlaceHolderVar(from);
4517 case T_SpecialJoinInfo:
4518 retval = _copySpecialJoinInfo(from);
4520 case T_LateralJoinInfo:
4521 retval = _copyLateralJoinInfo(from);
4523 case T_AppendRelInfo:
4524 retval = _copyAppendRelInfo(from);
4526 case T_PlaceHolderInfo:
4527 retval = _copyPlaceHolderInfo(from);
4538 retval = _copyValue(from);
4545 retval = _copyList(from);
4549 * Lists of integers and OIDs don't need to be deep-copied, so we
4550 * perform a shallow copy via list_copy()
4554 retval = list_copy(from);
4561 retval = _copyQuery(from);
4564 retval = _copyInsertStmt(from);
4567 retval = _copyDeleteStmt(from);
4570 retval = _copyUpdateStmt(from);
4573 retval = _copySelectStmt(from);
4575 case T_SetOperationStmt:
4576 retval = _copySetOperationStmt(from);
4578 case T_AlterTableStmt:
4579 retval = _copyAlterTableStmt(from);
4581 case T_AlterTableCmd:
4582 retval = _copyAlterTableCmd(from);
4584 case T_AlterDomainStmt:
4585 retval = _copyAlterDomainStmt(from);
4588 retval = _copyGrantStmt(from);
4590 case T_GrantRoleStmt:
4591 retval = _copyGrantRoleStmt(from);
4593 case T_AlterDefaultPrivilegesStmt:
4594 retval = _copyAlterDefaultPrivilegesStmt(from);
4596 case T_DeclareCursorStmt:
4597 retval = _copyDeclareCursorStmt(from);
4599 case T_ClosePortalStmt:
4600 retval = _copyClosePortalStmt(from);
4603 retval = _copyClusterStmt(from);
4606 retval = _copyCopyStmt(from);
4609 retval = _copyCreateStmt(from);
4611 case T_TableLikeClause:
4612 retval = _copyTableLikeClause(from);
4615 retval = _copyDefineStmt(from);
4618 retval = _copyDropStmt(from);
4620 case T_TruncateStmt:
4621 retval = _copyTruncateStmt(from);
4624 retval = _copyCommentStmt(from);
4626 case T_SecLabelStmt:
4627 retval = _copySecLabelStmt(from);
4630 retval = _copyFetchStmt(from);
4633 retval = _copyIndexStmt(from);
4635 case T_CreateFunctionStmt:
4636 retval = _copyCreateFunctionStmt(from);
4638 case T_FunctionParameter:
4639 retval = _copyFunctionParameter(from);
4641 case T_AlterFunctionStmt:
4642 retval = _copyAlterFunctionStmt(from);
4645 retval = _copyDoStmt(from);
4648 retval = _copyRenameStmt(from);
4650 case T_AlterObjectSchemaStmt:
4651 retval = _copyAlterObjectSchemaStmt(from);
4653 case T_AlterOwnerStmt:
4654 retval = _copyAlterOwnerStmt(from);
4656 case T_AlterOperatorStmt:
4657 retval = _copyAlterOperatorStmt(from);
4660 retval = _copyRuleStmt(from);
4663 retval = _copyNotifyStmt(from);
4666 retval = _copyListenStmt(from);
4668 case T_UnlistenStmt:
4669 retval = _copyUnlistenStmt(from);
4671 case T_TransactionStmt:
4672 retval = _copyTransactionStmt(from);
4674 case T_CompositeTypeStmt:
4675 retval = _copyCompositeTypeStmt(from);
4677 case T_CreateEnumStmt:
4678 retval = _copyCreateEnumStmt(from);
4680 case T_CreateRangeStmt:
4681 retval = _copyCreateRangeStmt(from);
4683 case T_AlterEnumStmt:
4684 retval = _copyAlterEnumStmt(from);
4687 retval = _copyViewStmt(from);
4690 retval = _copyLoadStmt(from);
4692 case T_CreateDomainStmt:
4693 retval = _copyCreateDomainStmt(from);
4695 case T_CreateOpClassStmt:
4696 retval = _copyCreateOpClassStmt(from);
4698 case T_CreateOpClassItem:
4699 retval = _copyCreateOpClassItem(from);
4701 case T_CreateOpFamilyStmt:
4702 retval = _copyCreateOpFamilyStmt(from);
4704 case T_AlterOpFamilyStmt:
4705 retval = _copyAlterOpFamilyStmt(from);
4707 case T_CreatedbStmt:
4708 retval = _copyCreatedbStmt(from);
4710 case T_AlterDatabaseStmt:
4711 retval = _copyAlterDatabaseStmt(from);
4713 case T_AlterDatabaseSetStmt:
4714 retval = _copyAlterDatabaseSetStmt(from);
4717 retval = _copyDropdbStmt(from);
4720 retval = _copyVacuumStmt(from);
4723 retval = _copyExplainStmt(from);
4725 case T_CreateTableAsStmt:
4726 retval = _copyCreateTableAsStmt(from);
4728 case T_RefreshMatViewStmt:
4729 retval = _copyRefreshMatViewStmt(from);
4731 case T_ReplicaIdentityStmt:
4732 retval = _copyReplicaIdentityStmt(from);
4734 case T_AlterSystemStmt:
4735 retval = _copyAlterSystemStmt(from);
4737 case T_CreateSeqStmt:
4738 retval = _copyCreateSeqStmt(from);
4740 case T_AlterSeqStmt:
4741 retval = _copyAlterSeqStmt(from);
4743 case T_VariableSetStmt:
4744 retval = _copyVariableSetStmt(from);
4746 case T_VariableShowStmt:
4747 retval = _copyVariableShowStmt(from);
4750 retval = _copyDiscardStmt(from);
4752 case T_CreateTableSpaceStmt:
4753 retval = _copyCreateTableSpaceStmt(from);
4755 case T_DropTableSpaceStmt:
4756 retval = _copyDropTableSpaceStmt(from);
4758 case T_AlterTableSpaceOptionsStmt:
4759 retval = _copyAlterTableSpaceOptionsStmt(from);
4761 case T_AlterTableMoveAllStmt:
4762 retval = _copyAlterTableMoveAllStmt(from);
4764 case T_CreateExtensionStmt:
4765 retval = _copyCreateExtensionStmt(from);
4767 case T_AlterExtensionStmt:
4768 retval = _copyAlterExtensionStmt(from);
4770 case T_AlterExtensionContentsStmt:
4771 retval = _copyAlterExtensionContentsStmt(from);
4773 case T_CreateFdwStmt:
4774 retval = _copyCreateFdwStmt(from);
4776 case T_AlterFdwStmt:
4777 retval = _copyAlterFdwStmt(from);
4779 case T_CreateForeignServerStmt:
4780 retval = _copyCreateForeignServerStmt(from);
4782 case T_AlterForeignServerStmt:
4783 retval = _copyAlterForeignServerStmt(from);
4785 case T_CreateUserMappingStmt:
4786 retval = _copyCreateUserMappingStmt(from);
4788 case T_AlterUserMappingStmt:
4789 retval = _copyAlterUserMappingStmt(from);
4791 case T_DropUserMappingStmt:
4792 retval = _copyDropUserMappingStmt(from);
4794 case T_CreateForeignTableStmt:
4795 retval = _copyCreateForeignTableStmt(from);
4797 case T_ImportForeignSchemaStmt:
4798 retval = _copyImportForeignSchemaStmt(from);
4800 case T_CreateTransformStmt:
4801 retval = _copyCreateTransformStmt(from);
4803 case T_CreateTrigStmt:
4804 retval = _copyCreateTrigStmt(from);
4806 case T_CreateEventTrigStmt:
4807 retval = _copyCreateEventTrigStmt(from);
4809 case T_AlterEventTrigStmt:
4810 retval = _copyAlterEventTrigStmt(from);
4812 case T_CreatePLangStmt:
4813 retval = _copyCreatePLangStmt(from);
4815 case T_CreateRoleStmt:
4816 retval = _copyCreateRoleStmt(from);
4818 case T_AlterRoleStmt:
4819 retval = _copyAlterRoleStmt(from);
4821 case T_AlterRoleSetStmt:
4822 retval = _copyAlterRoleSetStmt(from);
4824 case T_DropRoleStmt:
4825 retval = _copyDropRoleStmt(from);
4828 retval = _copyLockStmt(from);
4830 case T_ConstraintsSetStmt:
4831 retval = _copyConstraintsSetStmt(from);
4834 retval = _copyReindexStmt(from);
4836 case T_CheckPointStmt:
4837 retval = (void *) makeNode(CheckPointStmt);
4839 case T_CreateSchemaStmt:
4840 retval = _copyCreateSchemaStmt(from);
4842 case T_CreateConversionStmt:
4843 retval = _copyCreateConversionStmt(from);
4845 case T_CreateCastStmt:
4846 retval = _copyCreateCastStmt(from);
4849 retval = _copyPrepareStmt(from);
4852 retval = _copyExecuteStmt(from);
4854 case T_DeallocateStmt:
4855 retval = _copyDeallocateStmt(from);
4857 case T_DropOwnedStmt:
4858 retval = _copyDropOwnedStmt(from);
4860 case T_ReassignOwnedStmt:
4861 retval = _copyReassignOwnedStmt(from);
4863 case T_AlterTSDictionaryStmt:
4864 retval = _copyAlterTSDictionaryStmt(from);
4866 case T_AlterTSConfigurationStmt:
4867 retval = _copyAlterTSConfigurationStmt(from);
4869 case T_CreatePolicyStmt:
4870 retval = _copyCreatePolicyStmt(from);
4872 case T_AlterPolicyStmt:
4873 retval = _copyAlterPolicyStmt(from);
4876 retval = _copyAExpr(from);
4879 retval = _copyColumnRef(from);
4882 retval = _copyParamRef(from);
4885 retval = _copyAConst(from);
4888 retval = _copyFuncCall(from);
4891 retval = _copyAStar(from);
4894 retval = _copyAIndices(from);
4896 case T_A_Indirection:
4897 retval = _copyA_Indirection(from);
4900 retval = _copyA_ArrayExpr(from);
4903 retval = _copyResTarget(from);
4905 case T_MultiAssignRef:
4906 retval = _copyMultiAssignRef(from);
4909 retval = _copyTypeCast(from);
4911 case T_CollateClause:
4912 retval = _copyCollateClause(from);
4915 retval = _copySortBy(from);
4918 retval = _copyWindowDef(from);
4920 case T_RangeSubselect:
4921 retval = _copyRangeSubselect(from);
4923 case T_RangeFunction:
4924 retval = _copyRangeFunction(from);
4926 case T_RangeTableSample:
4927 retval = _copyRangeTableSample(from);
4930 retval = _copyTypeName(from);
4933 retval = _copyIndexElem(from);
4936 retval = _copyColumnDef(from);
4939 retval = _copyConstraint(from);
4942 retval = _copyDefElem(from);
4944 case T_LockingClause:
4945 retval = _copyLockingClause(from);
4947 case T_RangeTblEntry:
4948 retval = _copyRangeTblEntry(from);
4950 case T_RangeTblFunction:
4951 retval = _copyRangeTblFunction(from);
4953 case T_TableSampleClause:
4954 retval = _copyTableSampleClause(from);
4956 case T_WithCheckOption:
4957 retval = _copyWithCheckOption(from);
4959 case T_SortGroupClause:
4960 retval = _copySortGroupClause(from);
4963 retval = _copyGroupingSet(from);
4965 case T_WindowClause:
4966 retval = _copyWindowClause(from);
4968 case T_RowMarkClause:
4969 retval = _copyRowMarkClause(from);
4972 retval = _copyWithClause(from);
4975 retval = _copyInferClause(from);
4977 case T_OnConflictClause:
4978 retval = _copyOnConflictClause(from);
4980 case T_CommonTableExpr:
4981 retval = _copyCommonTableExpr(from);
4983 case T_FuncWithArgs:
4984 retval = _copyFuncWithArgs(from);
4987 retval = _copyAccessPriv(from);
4989 case T_XmlSerialize:
4990 retval = _copyXmlSerialize(from);
4993 retval = _copyRoleSpec(from);
4997 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4998 retval = 0; /* keep compiler quiet */