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-2007, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
18 * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.373 2007/04/02 03:49:38 tgl Exp $
20 *-------------------------------------------------------------------------
25 #include "nodes/plannodes.h"
26 #include "nodes/relation.h"
27 #include "utils/datum.h"
31 * Macros to simplify copying of different kinds of fields. Use these
32 * wherever possible to reduce the chance for silly typos. Note that these
33 * hard-wire the convention that the local variables in a Copy routine are
34 * named 'newnode' and 'from'.
37 /* Copy a simple scalar field (int, float, bool, enum, etc) */
38 #define COPY_SCALAR_FIELD(fldname) \
39 (newnode->fldname = from->fldname)
41 /* Copy a field that is a pointer to some kind of Node or Node tree */
42 #define COPY_NODE_FIELD(fldname) \
43 (newnode->fldname = copyObject(from->fldname))
45 /* Copy a field that is a pointer to a Bitmapset */
46 #define COPY_BITMAPSET_FIELD(fldname) \
47 (newnode->fldname = bms_copy(from->fldname))
49 /* Copy a field that is a pointer to a C string, or perhaps NULL */
50 #define COPY_STRING_FIELD(fldname) \
51 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
53 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
54 #define COPY_POINTER_FIELD(fldname, sz) \
57 newnode->fldname = palloc(_size); \
58 memcpy(newnode->fldname, from->fldname, _size); \
62 /* ****************************************************************
63 * plannodes.h copy functions
64 * ****************************************************************
71 _copyPlannedStmt(PlannedStmt *from)
73 PlannedStmt *newnode = makeNode(PlannedStmt);
75 COPY_SCALAR_FIELD(commandType);
76 COPY_SCALAR_FIELD(canSetTag);
77 COPY_NODE_FIELD(planTree);
78 COPY_NODE_FIELD(rtable);
79 COPY_NODE_FIELD(resultRelations);
80 COPY_NODE_FIELD(into);
81 COPY_NODE_FIELD(subplans);
82 COPY_BITMAPSET_FIELD(rewindPlanIDs);
83 COPY_NODE_FIELD(returningLists);
84 COPY_NODE_FIELD(rowMarks);
85 COPY_SCALAR_FIELD(nParamExec);
93 * This function copies the fields of the Plan node. It is used by
94 * all the copy functions for classes which inherit from Plan.
97 CopyPlanFields(Plan *from, Plan *newnode)
99 COPY_SCALAR_FIELD(startup_cost);
100 COPY_SCALAR_FIELD(total_cost);
101 COPY_SCALAR_FIELD(plan_rows);
102 COPY_SCALAR_FIELD(plan_width);
103 COPY_NODE_FIELD(targetlist);
104 COPY_NODE_FIELD(qual);
105 COPY_NODE_FIELD(lefttree);
106 COPY_NODE_FIELD(righttree);
107 COPY_NODE_FIELD(initPlan);
108 COPY_BITMAPSET_FIELD(extParam);
109 COPY_BITMAPSET_FIELD(allParam);
116 _copyPlan(Plan *from)
118 Plan *newnode = makeNode(Plan);
121 * copy node superclass fields
123 CopyPlanFields(from, newnode);
133 _copyResult(Result *from)
135 Result *newnode = makeNode(Result);
138 * copy node superclass fields
140 CopyPlanFields((Plan *) from, (Plan *) newnode);
143 * copy remainder of node
145 COPY_NODE_FIELD(resconstantqual);
154 _copyAppend(Append *from)
156 Append *newnode = makeNode(Append);
159 * copy node superclass fields
161 CopyPlanFields((Plan *) from, (Plan *) newnode);
164 * copy remainder of node
166 COPY_NODE_FIELD(appendplans);
167 COPY_SCALAR_FIELD(isTarget);
176 _copyBitmapAnd(BitmapAnd *from)
178 BitmapAnd *newnode = makeNode(BitmapAnd);
181 * copy node superclass fields
183 CopyPlanFields((Plan *) from, (Plan *) newnode);
186 * copy remainder of node
188 COPY_NODE_FIELD(bitmapplans);
197 _copyBitmapOr(BitmapOr *from)
199 BitmapOr *newnode = makeNode(BitmapOr);
202 * copy node superclass fields
204 CopyPlanFields((Plan *) from, (Plan *) newnode);
207 * copy remainder of node
209 COPY_NODE_FIELD(bitmapplans);
218 * This function copies the fields of the Scan node. It is used by
219 * all the copy functions for classes which inherit from Scan.
222 CopyScanFields(Scan *from, Scan *newnode)
224 CopyPlanFields((Plan *) from, (Plan *) newnode);
226 COPY_SCALAR_FIELD(scanrelid);
233 _copyScan(Scan *from)
235 Scan *newnode = makeNode(Scan);
238 * copy node superclass fields
240 CopyScanFields((Scan *) from, (Scan *) newnode);
249 _copySeqScan(SeqScan *from)
251 SeqScan *newnode = makeNode(SeqScan);
254 * copy node superclass fields
256 CopyScanFields((Scan *) from, (Scan *) newnode);
265 _copyIndexScan(IndexScan *from)
267 IndexScan *newnode = makeNode(IndexScan);
270 * copy node superclass fields
272 CopyScanFields((Scan *) from, (Scan *) newnode);
275 * copy remainder of node
277 COPY_SCALAR_FIELD(indexid);
278 COPY_NODE_FIELD(indexqual);
279 COPY_NODE_FIELD(indexqualorig);
280 COPY_NODE_FIELD(indexstrategy);
281 COPY_NODE_FIELD(indexsubtype);
282 COPY_SCALAR_FIELD(indexorderdir);
288 * _copyBitmapIndexScan
290 static BitmapIndexScan *
291 _copyBitmapIndexScan(BitmapIndexScan *from)
293 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
296 * copy node superclass fields
298 CopyScanFields((Scan *) from, (Scan *) newnode);
301 * copy remainder of node
303 COPY_SCALAR_FIELD(indexid);
304 COPY_NODE_FIELD(indexqual);
305 COPY_NODE_FIELD(indexqualorig);
306 COPY_NODE_FIELD(indexstrategy);
307 COPY_NODE_FIELD(indexsubtype);
313 * _copyBitmapHeapScan
315 static BitmapHeapScan *
316 _copyBitmapHeapScan(BitmapHeapScan *from)
318 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
321 * copy node superclass fields
323 CopyScanFields((Scan *) from, (Scan *) newnode);
326 * copy remainder of node
328 COPY_NODE_FIELD(bitmapqualorig);
337 _copyTidScan(TidScan *from)
339 TidScan *newnode = makeNode(TidScan);
342 * copy node superclass fields
344 CopyScanFields((Scan *) from, (Scan *) newnode);
347 * copy remainder of node
349 COPY_NODE_FIELD(tidquals);
357 static SubqueryScan *
358 _copySubqueryScan(SubqueryScan *from)
360 SubqueryScan *newnode = makeNode(SubqueryScan);
363 * copy node superclass fields
365 CopyScanFields((Scan *) from, (Scan *) newnode);
368 * copy remainder of node
370 COPY_NODE_FIELD(subplan);
371 COPY_NODE_FIELD(subrtable);
379 static FunctionScan *
380 _copyFunctionScan(FunctionScan *from)
382 FunctionScan *newnode = makeNode(FunctionScan);
385 * copy node superclass fields
387 CopyScanFields((Scan *) from, (Scan *) newnode);
390 * copy remainder of node
392 COPY_NODE_FIELD(funcexpr);
393 COPY_NODE_FIELD(funccolnames);
394 COPY_NODE_FIELD(funccoltypes);
395 COPY_NODE_FIELD(funccoltypmods);
404 _copyValuesScan(ValuesScan *from)
406 ValuesScan *newnode = makeNode(ValuesScan);
409 * copy node superclass fields
411 CopyScanFields((Scan *) from, (Scan *) newnode);
414 * copy remainder of node
416 COPY_NODE_FIELD(values_lists);
424 * This function copies the fields of the Join node. It is used by
425 * all the copy functions for classes which inherit from Join.
428 CopyJoinFields(Join *from, Join *newnode)
430 CopyPlanFields((Plan *) from, (Plan *) newnode);
432 COPY_SCALAR_FIELD(jointype);
433 COPY_NODE_FIELD(joinqual);
441 _copyJoin(Join *from)
443 Join *newnode = makeNode(Join);
446 * copy node superclass fields
448 CopyJoinFields(from, newnode);
458 _copyNestLoop(NestLoop *from)
460 NestLoop *newnode = makeNode(NestLoop);
463 * copy node superclass fields
465 CopyJoinFields((Join *) from, (Join *) newnode);
475 _copyMergeJoin(MergeJoin *from)
477 MergeJoin *newnode = makeNode(MergeJoin);
481 * copy node superclass fields
483 CopyJoinFields((Join *) from, (Join *) newnode);
486 * copy remainder of node
488 COPY_NODE_FIELD(mergeclauses);
489 numCols = list_length(from->mergeclauses);
490 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
491 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
492 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
501 _copyHashJoin(HashJoin *from)
503 HashJoin *newnode = makeNode(HashJoin);
506 * copy node superclass fields
508 CopyJoinFields((Join *) from, (Join *) newnode);
511 * copy remainder of node
513 COPY_NODE_FIELD(hashclauses);
523 _copyMaterial(Material *from)
525 Material *newnode = makeNode(Material);
528 * copy node superclass fields
530 CopyPlanFields((Plan *) from, (Plan *) newnode);
540 _copySort(Sort *from)
542 Sort *newnode = makeNode(Sort);
545 * copy node superclass fields
547 CopyPlanFields((Plan *) from, (Plan *) newnode);
549 COPY_SCALAR_FIELD(numCols);
550 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
551 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
552 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
562 _copyGroup(Group *from)
564 Group *newnode = makeNode(Group);
566 CopyPlanFields((Plan *) from, (Plan *) newnode);
568 COPY_SCALAR_FIELD(numCols);
569 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
570 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
581 Agg *newnode = makeNode(Agg);
583 CopyPlanFields((Plan *) from, (Plan *) newnode);
585 COPY_SCALAR_FIELD(aggstrategy);
586 COPY_SCALAR_FIELD(numCols);
587 if (from->numCols > 0)
589 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
590 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
592 COPY_SCALAR_FIELD(numGroups);
601 _copyUnique(Unique *from)
603 Unique *newnode = makeNode(Unique);
606 * copy node superclass fields
608 CopyPlanFields((Plan *) from, (Plan *) newnode);
611 * copy remainder of node
613 COPY_SCALAR_FIELD(numCols);
614 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
615 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
624 _copyHash(Hash *from)
626 Hash *newnode = makeNode(Hash);
629 * copy node superclass fields
631 CopyPlanFields((Plan *) from, (Plan *) newnode);
634 * copy remainder of node
644 _copySetOp(SetOp *from)
646 SetOp *newnode = makeNode(SetOp);
649 * copy node superclass fields
651 CopyPlanFields((Plan *) from, (Plan *) newnode);
654 * copy remainder of node
656 COPY_SCALAR_FIELD(cmd);
657 COPY_SCALAR_FIELD(numCols);
658 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
659 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
660 COPY_SCALAR_FIELD(flagColIdx);
669 _copyLimit(Limit *from)
671 Limit *newnode = makeNode(Limit);
674 * copy node superclass fields
676 CopyPlanFields((Plan *) from, (Plan *) newnode);
679 * copy remainder of node
681 COPY_NODE_FIELD(limitOffset);
682 COPY_NODE_FIELD(limitCount);
687 /* ****************************************************************
688 * primnodes.h copy functions
689 * ****************************************************************
696 _copyAlias(Alias *from)
698 Alias *newnode = makeNode(Alias);
700 COPY_STRING_FIELD(aliasname);
701 COPY_NODE_FIELD(colnames);
710 _copyRangeVar(RangeVar *from)
712 RangeVar *newnode = makeNode(RangeVar);
714 COPY_STRING_FIELD(catalogname);
715 COPY_STRING_FIELD(schemaname);
716 COPY_STRING_FIELD(relname);
717 COPY_SCALAR_FIELD(inhOpt);
718 COPY_SCALAR_FIELD(istemp);
719 COPY_NODE_FIELD(alias);
728 _copyIntoClause(IntoClause *from)
730 IntoClause *newnode = makeNode(IntoClause);
732 COPY_NODE_FIELD(rel);
733 COPY_NODE_FIELD(colNames);
734 COPY_NODE_FIELD(options);
735 COPY_SCALAR_FIELD(onCommit);
736 COPY_STRING_FIELD(tableSpaceName);
742 * We don't need a _copyExpr because Expr is an abstract supertype which
743 * should never actually get instantiated. Also, since it has no common
744 * fields except NodeTag, there's no need for a helper routine to factor
745 * out copying the common fields...
754 Var *newnode = makeNode(Var);
756 COPY_SCALAR_FIELD(varno);
757 COPY_SCALAR_FIELD(varattno);
758 COPY_SCALAR_FIELD(vartype);
759 COPY_SCALAR_FIELD(vartypmod);
760 COPY_SCALAR_FIELD(varlevelsup);
761 COPY_SCALAR_FIELD(varnoold);
762 COPY_SCALAR_FIELD(varoattno);
771 _copyConst(Const *from)
773 Const *newnode = makeNode(Const);
775 COPY_SCALAR_FIELD(consttype);
776 COPY_SCALAR_FIELD(consttypmod);
777 COPY_SCALAR_FIELD(constlen);
779 if (from->constbyval || from->constisnull)
782 * passed by value so just copy the datum. Also, don't try to copy
783 * struct when value is null!
785 newnode->constvalue = from->constvalue;
790 * passed by reference. We need a palloc'd copy.
792 newnode->constvalue = datumCopy(from->constvalue,
797 COPY_SCALAR_FIELD(constisnull);
798 COPY_SCALAR_FIELD(constbyval);
807 _copyParam(Param *from)
809 Param *newnode = makeNode(Param);
811 COPY_SCALAR_FIELD(paramkind);
812 COPY_SCALAR_FIELD(paramid);
813 COPY_SCALAR_FIELD(paramtype);
814 COPY_SCALAR_FIELD(paramtypmod);
823 _copyAggref(Aggref *from)
825 Aggref *newnode = makeNode(Aggref);
827 COPY_SCALAR_FIELD(aggfnoid);
828 COPY_SCALAR_FIELD(aggtype);
829 COPY_NODE_FIELD(args);
830 COPY_SCALAR_FIELD(agglevelsup);
831 COPY_SCALAR_FIELD(aggstar);
832 COPY_SCALAR_FIELD(aggdistinct);
841 _copyArrayRef(ArrayRef *from)
843 ArrayRef *newnode = makeNode(ArrayRef);
845 COPY_SCALAR_FIELD(refarraytype);
846 COPY_SCALAR_FIELD(refelemtype);
847 COPY_SCALAR_FIELD(reftypmod);
848 COPY_NODE_FIELD(refupperindexpr);
849 COPY_NODE_FIELD(reflowerindexpr);
850 COPY_NODE_FIELD(refexpr);
851 COPY_NODE_FIELD(refassgnexpr);
860 _copyFuncExpr(FuncExpr *from)
862 FuncExpr *newnode = makeNode(FuncExpr);
864 COPY_SCALAR_FIELD(funcid);
865 COPY_SCALAR_FIELD(funcresulttype);
866 COPY_SCALAR_FIELD(funcretset);
867 COPY_SCALAR_FIELD(funcformat);
868 COPY_NODE_FIELD(args);
877 _copyOpExpr(OpExpr *from)
879 OpExpr *newnode = makeNode(OpExpr);
881 COPY_SCALAR_FIELD(opno);
882 COPY_SCALAR_FIELD(opfuncid);
883 COPY_SCALAR_FIELD(opresulttype);
884 COPY_SCALAR_FIELD(opretset);
885 COPY_NODE_FIELD(args);
891 * _copyDistinctExpr (same as OpExpr)
893 static DistinctExpr *
894 _copyDistinctExpr(DistinctExpr *from)
896 DistinctExpr *newnode = makeNode(DistinctExpr);
898 COPY_SCALAR_FIELD(opno);
899 COPY_SCALAR_FIELD(opfuncid);
900 COPY_SCALAR_FIELD(opresulttype);
901 COPY_SCALAR_FIELD(opretset);
902 COPY_NODE_FIELD(args);
908 * _copyScalarArrayOpExpr
910 static ScalarArrayOpExpr *
911 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
913 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
915 COPY_SCALAR_FIELD(opno);
916 COPY_SCALAR_FIELD(opfuncid);
917 COPY_SCALAR_FIELD(useOr);
918 COPY_NODE_FIELD(args);
927 _copyBoolExpr(BoolExpr *from)
929 BoolExpr *newnode = makeNode(BoolExpr);
931 COPY_SCALAR_FIELD(boolop);
932 COPY_NODE_FIELD(args);
941 _copySubLink(SubLink *from)
943 SubLink *newnode = makeNode(SubLink);
945 COPY_SCALAR_FIELD(subLinkType);
946 COPY_NODE_FIELD(testexpr);
947 COPY_NODE_FIELD(operName);
948 COPY_NODE_FIELD(subselect);
957 _copySubPlan(SubPlan *from)
959 SubPlan *newnode = makeNode(SubPlan);
961 COPY_SCALAR_FIELD(subLinkType);
962 COPY_NODE_FIELD(testexpr);
963 COPY_NODE_FIELD(paramIds);
964 COPY_SCALAR_FIELD(plan_id);
965 COPY_SCALAR_FIELD(firstColType);
966 COPY_SCALAR_FIELD(useHashTable);
967 COPY_SCALAR_FIELD(unknownEqFalse);
968 COPY_NODE_FIELD(setParam);
969 COPY_NODE_FIELD(parParam);
970 COPY_NODE_FIELD(args);
979 _copyFieldSelect(FieldSelect *from)
981 FieldSelect *newnode = makeNode(FieldSelect);
983 COPY_NODE_FIELD(arg);
984 COPY_SCALAR_FIELD(fieldnum);
985 COPY_SCALAR_FIELD(resulttype);
986 COPY_SCALAR_FIELD(resulttypmod);
995 _copyFieldStore(FieldStore *from)
997 FieldStore *newnode = makeNode(FieldStore);
999 COPY_NODE_FIELD(arg);
1000 COPY_NODE_FIELD(newvals);
1001 COPY_NODE_FIELD(fieldnums);
1002 COPY_SCALAR_FIELD(resulttype);
1010 static RelabelType *
1011 _copyRelabelType(RelabelType *from)
1013 RelabelType *newnode = makeNode(RelabelType);
1015 COPY_NODE_FIELD(arg);
1016 COPY_SCALAR_FIELD(resulttype);
1017 COPY_SCALAR_FIELD(resulttypmod);
1018 COPY_SCALAR_FIELD(relabelformat);
1024 * _copyArrayCoerceExpr
1026 static ArrayCoerceExpr *
1027 _copyArrayCoerceExpr(ArrayCoerceExpr *from)
1029 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1031 COPY_NODE_FIELD(arg);
1032 COPY_SCALAR_FIELD(elemfuncid);
1033 COPY_SCALAR_FIELD(resulttype);
1034 COPY_SCALAR_FIELD(resulttypmod);
1035 COPY_SCALAR_FIELD(isExplicit);
1036 COPY_SCALAR_FIELD(coerceformat);
1042 * _copyConvertRowtypeExpr
1044 static ConvertRowtypeExpr *
1045 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
1047 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1049 COPY_NODE_FIELD(arg);
1050 COPY_SCALAR_FIELD(resulttype);
1051 COPY_SCALAR_FIELD(convertformat);
1060 _copyCaseExpr(CaseExpr *from)
1062 CaseExpr *newnode = makeNode(CaseExpr);
1064 COPY_SCALAR_FIELD(casetype);
1065 COPY_NODE_FIELD(arg);
1066 COPY_NODE_FIELD(args);
1067 COPY_NODE_FIELD(defresult);
1076 _copyCaseWhen(CaseWhen *from)
1078 CaseWhen *newnode = makeNode(CaseWhen);
1080 COPY_NODE_FIELD(expr);
1081 COPY_NODE_FIELD(result);
1089 static CaseTestExpr *
1090 _copyCaseTestExpr(CaseTestExpr *from)
1092 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1094 COPY_SCALAR_FIELD(typeId);
1095 COPY_SCALAR_FIELD(typeMod);
1104 _copyArrayExpr(ArrayExpr *from)
1106 ArrayExpr *newnode = makeNode(ArrayExpr);
1108 COPY_SCALAR_FIELD(array_typeid);
1109 COPY_SCALAR_FIELD(element_typeid);
1110 COPY_NODE_FIELD(elements);
1111 COPY_SCALAR_FIELD(multidims);
1120 _copyRowExpr(RowExpr *from)
1122 RowExpr *newnode = makeNode(RowExpr);
1124 COPY_NODE_FIELD(args);
1125 COPY_SCALAR_FIELD(row_typeid);
1126 COPY_SCALAR_FIELD(row_format);
1132 * _copyRowCompareExpr
1134 static RowCompareExpr *
1135 _copyRowCompareExpr(RowCompareExpr *from)
1137 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1139 COPY_SCALAR_FIELD(rctype);
1140 COPY_NODE_FIELD(opnos);
1141 COPY_NODE_FIELD(opfamilies);
1142 COPY_NODE_FIELD(largs);
1143 COPY_NODE_FIELD(rargs);
1151 static CoalesceExpr *
1152 _copyCoalesceExpr(CoalesceExpr *from)
1154 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1156 COPY_SCALAR_FIELD(coalescetype);
1157 COPY_NODE_FIELD(args);
1166 _copyMinMaxExpr(MinMaxExpr *from)
1168 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1170 COPY_SCALAR_FIELD(minmaxtype);
1171 COPY_SCALAR_FIELD(op);
1172 COPY_NODE_FIELD(args);
1181 _copyXmlExpr(XmlExpr *from)
1183 XmlExpr *newnode = makeNode(XmlExpr);
1185 COPY_SCALAR_FIELD(op);
1186 COPY_STRING_FIELD(name);
1187 COPY_NODE_FIELD(named_args);
1188 COPY_NODE_FIELD(arg_names);
1189 COPY_NODE_FIELD(args);
1190 COPY_SCALAR_FIELD(xmloption);
1191 COPY_SCALAR_FIELD(type);
1192 COPY_SCALAR_FIELD(typmod);
1198 * _copyNullIfExpr (same as OpExpr)
1201 _copyNullIfExpr(NullIfExpr *from)
1203 NullIfExpr *newnode = makeNode(NullIfExpr);
1205 COPY_SCALAR_FIELD(opno);
1206 COPY_SCALAR_FIELD(opfuncid);
1207 COPY_SCALAR_FIELD(opresulttype);
1208 COPY_SCALAR_FIELD(opretset);
1209 COPY_NODE_FIELD(args);
1218 _copyNullTest(NullTest *from)
1220 NullTest *newnode = makeNode(NullTest);
1222 COPY_NODE_FIELD(arg);
1223 COPY_SCALAR_FIELD(nulltesttype);
1231 static BooleanTest *
1232 _copyBooleanTest(BooleanTest *from)
1234 BooleanTest *newnode = makeNode(BooleanTest);
1236 COPY_NODE_FIELD(arg);
1237 COPY_SCALAR_FIELD(booltesttype);
1243 * _copyCoerceToDomain
1245 static CoerceToDomain *
1246 _copyCoerceToDomain(CoerceToDomain *from)
1248 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1250 COPY_NODE_FIELD(arg);
1251 COPY_SCALAR_FIELD(resulttype);
1252 COPY_SCALAR_FIELD(resulttypmod);
1253 COPY_SCALAR_FIELD(coercionformat);
1259 * _copyCoerceToDomainValue
1261 static CoerceToDomainValue *
1262 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1264 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1266 COPY_SCALAR_FIELD(typeId);
1267 COPY_SCALAR_FIELD(typeMod);
1275 static SetToDefault *
1276 _copySetToDefault(SetToDefault *from)
1278 SetToDefault *newnode = makeNode(SetToDefault);
1280 COPY_SCALAR_FIELD(typeId);
1281 COPY_SCALAR_FIELD(typeMod);
1289 static TargetEntry *
1290 _copyTargetEntry(TargetEntry *from)
1292 TargetEntry *newnode = makeNode(TargetEntry);
1294 COPY_NODE_FIELD(expr);
1295 COPY_SCALAR_FIELD(resno);
1296 COPY_STRING_FIELD(resname);
1297 COPY_SCALAR_FIELD(ressortgroupref);
1298 COPY_SCALAR_FIELD(resorigtbl);
1299 COPY_SCALAR_FIELD(resorigcol);
1300 COPY_SCALAR_FIELD(resjunk);
1308 static RangeTblRef *
1309 _copyRangeTblRef(RangeTblRef *from)
1311 RangeTblRef *newnode = makeNode(RangeTblRef);
1313 COPY_SCALAR_FIELD(rtindex);
1322 _copyJoinExpr(JoinExpr *from)
1324 JoinExpr *newnode = makeNode(JoinExpr);
1326 COPY_SCALAR_FIELD(jointype);
1327 COPY_SCALAR_FIELD(isNatural);
1328 COPY_NODE_FIELD(larg);
1329 COPY_NODE_FIELD(rarg);
1330 COPY_NODE_FIELD(using);
1331 COPY_NODE_FIELD(quals);
1332 COPY_NODE_FIELD(alias);
1333 COPY_SCALAR_FIELD(rtindex);
1342 _copyFromExpr(FromExpr *from)
1344 FromExpr *newnode = makeNode(FromExpr);
1346 COPY_NODE_FIELD(fromlist);
1347 COPY_NODE_FIELD(quals);
1352 /* ****************************************************************
1353 * relation.h copy functions
1355 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1356 * There are some subsidiary structs that are useful to copy, though.
1357 * ****************************************************************
1364 _copyPathKey(PathKey *from)
1366 PathKey *newnode = makeNode(PathKey);
1368 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1369 COPY_SCALAR_FIELD(pk_eclass);
1370 COPY_SCALAR_FIELD(pk_opfamily);
1371 COPY_SCALAR_FIELD(pk_strategy);
1372 COPY_SCALAR_FIELD(pk_nulls_first);
1380 static RestrictInfo *
1381 _copyRestrictInfo(RestrictInfo *from)
1383 RestrictInfo *newnode = makeNode(RestrictInfo);
1385 COPY_NODE_FIELD(clause);
1386 COPY_SCALAR_FIELD(is_pushed_down);
1387 COPY_SCALAR_FIELD(outerjoin_delayed);
1388 COPY_SCALAR_FIELD(can_join);
1389 COPY_SCALAR_FIELD(pseudoconstant);
1390 COPY_BITMAPSET_FIELD(clause_relids);
1391 COPY_BITMAPSET_FIELD(required_relids);
1392 COPY_BITMAPSET_FIELD(left_relids);
1393 COPY_BITMAPSET_FIELD(right_relids);
1394 COPY_NODE_FIELD(orclause);
1395 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1396 COPY_SCALAR_FIELD(parent_ec);
1397 COPY_SCALAR_FIELD(eval_cost);
1398 COPY_SCALAR_FIELD(this_selec);
1399 COPY_NODE_FIELD(mergeopfamilies);
1400 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1401 COPY_SCALAR_FIELD(left_ec);
1402 COPY_SCALAR_FIELD(right_ec);
1403 COPY_SCALAR_FIELD(left_em);
1404 COPY_SCALAR_FIELD(right_em);
1405 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1406 newnode->scansel_cache = NIL;
1407 COPY_SCALAR_FIELD(outer_is_left);
1408 COPY_SCALAR_FIELD(hashjoinoperator);
1409 COPY_SCALAR_FIELD(left_bucketsize);
1410 COPY_SCALAR_FIELD(right_bucketsize);
1416 * _copyOuterJoinInfo
1418 static OuterJoinInfo *
1419 _copyOuterJoinInfo(OuterJoinInfo *from)
1421 OuterJoinInfo *newnode = makeNode(OuterJoinInfo);
1423 COPY_BITMAPSET_FIELD(min_lefthand);
1424 COPY_BITMAPSET_FIELD(min_righthand);
1425 COPY_SCALAR_FIELD(is_full_join);
1426 COPY_SCALAR_FIELD(lhs_strict);
1434 static InClauseInfo *
1435 _copyInClauseInfo(InClauseInfo *from)
1437 InClauseInfo *newnode = makeNode(InClauseInfo);
1439 COPY_BITMAPSET_FIELD(lefthand);
1440 COPY_BITMAPSET_FIELD(righthand);
1441 COPY_NODE_FIELD(sub_targetlist);
1442 COPY_NODE_FIELD(in_operators);
1448 * _copyAppendRelInfo
1450 static AppendRelInfo *
1451 _copyAppendRelInfo(AppendRelInfo *from)
1453 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1455 COPY_SCALAR_FIELD(parent_relid);
1456 COPY_SCALAR_FIELD(child_relid);
1457 COPY_SCALAR_FIELD(parent_reltype);
1458 COPY_SCALAR_FIELD(child_reltype);
1459 COPY_NODE_FIELD(col_mappings);
1460 COPY_NODE_FIELD(translated_vars);
1461 COPY_SCALAR_FIELD(parent_reloid);
1466 /* ****************************************************************
1467 * parsenodes.h copy functions
1468 * ****************************************************************
1471 static RangeTblEntry *
1472 _copyRangeTblEntry(RangeTblEntry *from)
1474 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1476 COPY_SCALAR_FIELD(rtekind);
1477 COPY_SCALAR_FIELD(relid);
1478 COPY_NODE_FIELD(subquery);
1479 COPY_NODE_FIELD(funcexpr);
1480 COPY_NODE_FIELD(funccoltypes);
1481 COPY_NODE_FIELD(funccoltypmods);
1482 COPY_NODE_FIELD(values_lists);
1483 COPY_SCALAR_FIELD(jointype);
1484 COPY_NODE_FIELD(joinaliasvars);
1485 COPY_NODE_FIELD(alias);
1486 COPY_NODE_FIELD(eref);
1487 COPY_SCALAR_FIELD(inh);
1488 COPY_SCALAR_FIELD(inFromCl);
1489 COPY_SCALAR_FIELD(requiredPerms);
1490 COPY_SCALAR_FIELD(checkAsUser);
1495 static FkConstraint *
1496 _copyFkConstraint(FkConstraint *from)
1498 FkConstraint *newnode = makeNode(FkConstraint);
1500 COPY_STRING_FIELD(constr_name);
1501 COPY_NODE_FIELD(pktable);
1502 COPY_NODE_FIELD(fk_attrs);
1503 COPY_NODE_FIELD(pk_attrs);
1504 COPY_SCALAR_FIELD(fk_matchtype);
1505 COPY_SCALAR_FIELD(fk_upd_action);
1506 COPY_SCALAR_FIELD(fk_del_action);
1507 COPY_SCALAR_FIELD(deferrable);
1508 COPY_SCALAR_FIELD(initdeferred);
1509 COPY_SCALAR_FIELD(skip_validation);
1515 _copySortClause(SortClause *from)
1517 SortClause *newnode = makeNode(SortClause);
1519 COPY_SCALAR_FIELD(tleSortGroupRef);
1520 COPY_SCALAR_FIELD(sortop);
1521 COPY_SCALAR_FIELD(nulls_first);
1526 static GroupClause *
1527 _copyGroupClause(GroupClause *from)
1529 GroupClause *newnode = makeNode(GroupClause);
1531 COPY_SCALAR_FIELD(tleSortGroupRef);
1532 COPY_SCALAR_FIELD(sortop);
1533 COPY_SCALAR_FIELD(nulls_first);
1538 static RowMarkClause *
1539 _copyRowMarkClause(RowMarkClause *from)
1541 RowMarkClause *newnode = makeNode(RowMarkClause);
1543 COPY_SCALAR_FIELD(rti);
1544 COPY_SCALAR_FIELD(forUpdate);
1545 COPY_SCALAR_FIELD(noWait);
1551 _copyAExpr(A_Expr *from)
1553 A_Expr *newnode = makeNode(A_Expr);
1555 COPY_SCALAR_FIELD(kind);
1556 COPY_NODE_FIELD(name);
1557 COPY_NODE_FIELD(lexpr);
1558 COPY_NODE_FIELD(rexpr);
1559 COPY_SCALAR_FIELD(location);
1565 _copyColumnRef(ColumnRef *from)
1567 ColumnRef *newnode = makeNode(ColumnRef);
1569 COPY_NODE_FIELD(fields);
1570 COPY_SCALAR_FIELD(location);
1576 _copyParamRef(ParamRef *from)
1578 ParamRef *newnode = makeNode(ParamRef);
1580 COPY_SCALAR_FIELD(number);
1586 _copyAConst(A_Const *from)
1588 A_Const *newnode = makeNode(A_Const);
1590 /* This part must duplicate _copyValue */
1591 COPY_SCALAR_FIELD(val.type);
1592 switch (from->val.type)
1595 COPY_SCALAR_FIELD(val.val.ival);
1600 COPY_STRING_FIELD(val.val.str);
1606 elog(ERROR, "unrecognized node type: %d",
1607 (int) from->val.type);
1611 COPY_NODE_FIELD(typename);
1617 _copyFuncCall(FuncCall *from)
1619 FuncCall *newnode = makeNode(FuncCall);
1621 COPY_NODE_FIELD(funcname);
1622 COPY_NODE_FIELD(args);
1623 COPY_SCALAR_FIELD(agg_star);
1624 COPY_SCALAR_FIELD(agg_distinct);
1625 COPY_SCALAR_FIELD(location);
1631 _copyAIndices(A_Indices *from)
1633 A_Indices *newnode = makeNode(A_Indices);
1635 COPY_NODE_FIELD(lidx);
1636 COPY_NODE_FIELD(uidx);
1641 static A_Indirection *
1642 _copyA_Indirection(A_Indirection *from)
1644 A_Indirection *newnode = makeNode(A_Indirection);
1646 COPY_NODE_FIELD(arg);
1647 COPY_NODE_FIELD(indirection);
1653 _copyResTarget(ResTarget *from)
1655 ResTarget *newnode = makeNode(ResTarget);
1657 COPY_STRING_FIELD(name);
1658 COPY_NODE_FIELD(indirection);
1659 COPY_NODE_FIELD(val);
1660 COPY_SCALAR_FIELD(location);
1666 _copyTypeName(TypeName *from)
1668 TypeName *newnode = makeNode(TypeName);
1670 COPY_NODE_FIELD(names);
1671 COPY_SCALAR_FIELD(typeid);
1672 COPY_SCALAR_FIELD(timezone);
1673 COPY_SCALAR_FIELD(setof);
1674 COPY_SCALAR_FIELD(pct_type);
1675 COPY_NODE_FIELD(typmods);
1676 COPY_SCALAR_FIELD(typemod);
1677 COPY_NODE_FIELD(arrayBounds);
1678 COPY_SCALAR_FIELD(location);
1684 _copySortBy(SortBy *from)
1686 SortBy *newnode = makeNode(SortBy);
1688 COPY_SCALAR_FIELD(sortby_dir);
1689 COPY_SCALAR_FIELD(sortby_nulls);
1690 COPY_NODE_FIELD(useOp);
1691 COPY_NODE_FIELD(node);
1696 static RangeSubselect *
1697 _copyRangeSubselect(RangeSubselect *from)
1699 RangeSubselect *newnode = makeNode(RangeSubselect);
1701 COPY_NODE_FIELD(subquery);
1702 COPY_NODE_FIELD(alias);
1707 static RangeFunction *
1708 _copyRangeFunction(RangeFunction *from)
1710 RangeFunction *newnode = makeNode(RangeFunction);
1712 COPY_NODE_FIELD(funccallnode);
1713 COPY_NODE_FIELD(alias);
1714 COPY_NODE_FIELD(coldeflist);
1720 _copyTypeCast(TypeCast *from)
1722 TypeCast *newnode = makeNode(TypeCast);
1724 COPY_NODE_FIELD(arg);
1725 COPY_NODE_FIELD(typename);
1731 _copyIndexElem(IndexElem *from)
1733 IndexElem *newnode = makeNode(IndexElem);
1735 COPY_STRING_FIELD(name);
1736 COPY_NODE_FIELD(expr);
1737 COPY_NODE_FIELD(opclass);
1738 COPY_SCALAR_FIELD(ordering);
1739 COPY_SCALAR_FIELD(nulls_ordering);
1745 _copyColumnDef(ColumnDef *from)
1747 ColumnDef *newnode = makeNode(ColumnDef);
1749 COPY_STRING_FIELD(colname);
1750 COPY_NODE_FIELD(typename);
1751 COPY_SCALAR_FIELD(inhcount);
1752 COPY_SCALAR_FIELD(is_local);
1753 COPY_SCALAR_FIELD(is_not_null);
1754 COPY_NODE_FIELD(raw_default);
1755 COPY_STRING_FIELD(cooked_default);
1756 COPY_NODE_FIELD(constraints);
1762 _copyConstraint(Constraint *from)
1764 Constraint *newnode = makeNode(Constraint);
1766 COPY_SCALAR_FIELD(contype);
1767 COPY_STRING_FIELD(name);
1768 COPY_NODE_FIELD(raw_expr);
1769 COPY_STRING_FIELD(cooked_expr);
1770 COPY_NODE_FIELD(keys);
1771 COPY_NODE_FIELD(options);
1772 COPY_STRING_FIELD(indexspace);
1778 _copyDefElem(DefElem *from)
1780 DefElem *newnode = makeNode(DefElem);
1782 COPY_STRING_FIELD(defname);
1783 COPY_NODE_FIELD(arg);
1788 static LockingClause *
1789 _copyLockingClause(LockingClause *from)
1791 LockingClause *newnode = makeNode(LockingClause);
1793 COPY_NODE_FIELD(lockedRels);
1794 COPY_SCALAR_FIELD(forUpdate);
1795 COPY_SCALAR_FIELD(noWait);
1800 static XmlSerialize *
1801 _copyXmlSerialize(XmlSerialize *from)
1803 XmlSerialize *newnode = makeNode(XmlSerialize);
1805 COPY_SCALAR_FIELD(xmloption);
1806 COPY_NODE_FIELD(expr);
1807 COPY_NODE_FIELD(typename);
1813 _copyQuery(Query *from)
1815 Query *newnode = makeNode(Query);
1817 COPY_SCALAR_FIELD(commandType);
1818 COPY_SCALAR_FIELD(querySource);
1819 COPY_SCALAR_FIELD(canSetTag);
1820 COPY_NODE_FIELD(utilityStmt);
1821 COPY_SCALAR_FIELD(resultRelation);
1822 COPY_NODE_FIELD(into);
1823 COPY_SCALAR_FIELD(hasAggs);
1824 COPY_SCALAR_FIELD(hasSubLinks);
1825 COPY_NODE_FIELD(rtable);
1826 COPY_NODE_FIELD(jointree);
1827 COPY_NODE_FIELD(targetList);
1828 COPY_NODE_FIELD(returningList);
1829 COPY_NODE_FIELD(groupClause);
1830 COPY_NODE_FIELD(havingQual);
1831 COPY_NODE_FIELD(distinctClause);
1832 COPY_NODE_FIELD(sortClause);
1833 COPY_NODE_FIELD(limitOffset);
1834 COPY_NODE_FIELD(limitCount);
1835 COPY_NODE_FIELD(rowMarks);
1836 COPY_NODE_FIELD(setOperations);
1842 _copyInsertStmt(InsertStmt *from)
1844 InsertStmt *newnode = makeNode(InsertStmt);
1846 COPY_NODE_FIELD(relation);
1847 COPY_NODE_FIELD(cols);
1848 COPY_NODE_FIELD(selectStmt);
1849 COPY_NODE_FIELD(returningList);
1855 _copyDeleteStmt(DeleteStmt *from)
1857 DeleteStmt *newnode = makeNode(DeleteStmt);
1859 COPY_NODE_FIELD(relation);
1860 COPY_NODE_FIELD(usingClause);
1861 COPY_NODE_FIELD(whereClause);
1862 COPY_NODE_FIELD(returningList);
1868 _copyUpdateStmt(UpdateStmt *from)
1870 UpdateStmt *newnode = makeNode(UpdateStmt);
1872 COPY_NODE_FIELD(relation);
1873 COPY_NODE_FIELD(targetList);
1874 COPY_NODE_FIELD(whereClause);
1875 COPY_NODE_FIELD(fromClause);
1876 COPY_NODE_FIELD(returningList);
1882 _copySelectStmt(SelectStmt *from)
1884 SelectStmt *newnode = makeNode(SelectStmt);
1886 COPY_NODE_FIELD(distinctClause);
1887 COPY_NODE_FIELD(into);
1888 COPY_NODE_FIELD(targetList);
1889 COPY_NODE_FIELD(fromClause);
1890 COPY_NODE_FIELD(whereClause);
1891 COPY_NODE_FIELD(groupClause);
1892 COPY_NODE_FIELD(havingClause);
1893 COPY_NODE_FIELD(valuesLists);
1894 COPY_NODE_FIELD(sortClause);
1895 COPY_NODE_FIELD(limitOffset);
1896 COPY_NODE_FIELD(limitCount);
1897 COPY_NODE_FIELD(lockingClause);
1898 COPY_SCALAR_FIELD(op);
1899 COPY_SCALAR_FIELD(all);
1900 COPY_NODE_FIELD(larg);
1901 COPY_NODE_FIELD(rarg);
1906 static SetOperationStmt *
1907 _copySetOperationStmt(SetOperationStmt *from)
1909 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1911 COPY_SCALAR_FIELD(op);
1912 COPY_SCALAR_FIELD(all);
1913 COPY_NODE_FIELD(larg);
1914 COPY_NODE_FIELD(rarg);
1915 COPY_NODE_FIELD(colTypes);
1916 COPY_NODE_FIELD(colTypmods);
1921 static AlterTableStmt *
1922 _copyAlterTableStmt(AlterTableStmt *from)
1924 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1926 COPY_NODE_FIELD(relation);
1927 COPY_NODE_FIELD(cmds);
1928 COPY_SCALAR_FIELD(relkind);
1933 static AlterTableCmd *
1934 _copyAlterTableCmd(AlterTableCmd *from)
1936 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1938 COPY_SCALAR_FIELD(subtype);
1939 COPY_STRING_FIELD(name);
1940 COPY_NODE_FIELD(def);
1941 COPY_NODE_FIELD(transform);
1942 COPY_SCALAR_FIELD(behavior);
1947 static AlterDomainStmt *
1948 _copyAlterDomainStmt(AlterDomainStmt *from)
1950 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1952 COPY_SCALAR_FIELD(subtype);
1953 COPY_NODE_FIELD(typename);
1954 COPY_STRING_FIELD(name);
1955 COPY_NODE_FIELD(def);
1956 COPY_SCALAR_FIELD(behavior);
1962 _copyGrantStmt(GrantStmt *from)
1964 GrantStmt *newnode = makeNode(GrantStmt);
1966 COPY_SCALAR_FIELD(is_grant);
1967 COPY_SCALAR_FIELD(objtype);
1968 COPY_NODE_FIELD(objects);
1969 COPY_NODE_FIELD(privileges);
1970 COPY_NODE_FIELD(grantees);
1971 COPY_SCALAR_FIELD(grant_option);
1972 COPY_SCALAR_FIELD(behavior);
1977 static PrivGrantee *
1978 _copyPrivGrantee(PrivGrantee *from)
1980 PrivGrantee *newnode = makeNode(PrivGrantee);
1982 COPY_STRING_FIELD(rolname);
1987 static FuncWithArgs *
1988 _copyFuncWithArgs(FuncWithArgs *from)
1990 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1992 COPY_NODE_FIELD(funcname);
1993 COPY_NODE_FIELD(funcargs);
1998 static GrantRoleStmt *
1999 _copyGrantRoleStmt(GrantRoleStmt *from)
2001 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2003 COPY_NODE_FIELD(granted_roles);
2004 COPY_NODE_FIELD(grantee_roles);
2005 COPY_SCALAR_FIELD(is_grant);
2006 COPY_SCALAR_FIELD(admin_opt);
2007 COPY_STRING_FIELD(grantor);
2008 COPY_SCALAR_FIELD(behavior);
2013 static DeclareCursorStmt *
2014 _copyDeclareCursorStmt(DeclareCursorStmt *from)
2016 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2018 COPY_STRING_FIELD(portalname);
2019 COPY_SCALAR_FIELD(options);
2020 COPY_NODE_FIELD(query);
2025 static ClosePortalStmt *
2026 _copyClosePortalStmt(ClosePortalStmt *from)
2028 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2030 COPY_STRING_FIELD(portalname);
2035 static ClusterStmt *
2036 _copyClusterStmt(ClusterStmt *from)
2038 ClusterStmt *newnode = makeNode(ClusterStmt);
2040 COPY_NODE_FIELD(relation);
2041 COPY_STRING_FIELD(indexname);
2047 _copyCopyStmt(CopyStmt *from)
2049 CopyStmt *newnode = makeNode(CopyStmt);
2051 COPY_NODE_FIELD(relation);
2052 COPY_NODE_FIELD(query);
2053 COPY_NODE_FIELD(attlist);
2054 COPY_SCALAR_FIELD(is_from);
2055 COPY_STRING_FIELD(filename);
2056 COPY_NODE_FIELD(options);
2062 _copyCreateStmt(CreateStmt *from)
2064 CreateStmt *newnode = makeNode(CreateStmt);
2066 COPY_NODE_FIELD(relation);
2067 COPY_NODE_FIELD(tableElts);
2068 COPY_NODE_FIELD(inhRelations);
2069 COPY_NODE_FIELD(constraints);
2070 COPY_NODE_FIELD(options);
2071 COPY_SCALAR_FIELD(oncommit);
2072 COPY_STRING_FIELD(tablespacename);
2077 static InhRelation *
2078 _copyInhRelation(InhRelation *from)
2080 InhRelation *newnode = makeNode(InhRelation);
2082 COPY_NODE_FIELD(relation);
2083 COPY_NODE_FIELD(options);
2089 _copyDefineStmt(DefineStmt *from)
2091 DefineStmt *newnode = makeNode(DefineStmt);
2093 COPY_SCALAR_FIELD(kind);
2094 COPY_SCALAR_FIELD(oldstyle);
2095 COPY_NODE_FIELD(defnames);
2096 COPY_NODE_FIELD(args);
2097 COPY_NODE_FIELD(definition);
2103 _copyDropStmt(DropStmt *from)
2105 DropStmt *newnode = makeNode(DropStmt);
2107 COPY_NODE_FIELD(objects);
2108 COPY_SCALAR_FIELD(removeType);
2109 COPY_SCALAR_FIELD(behavior);
2110 COPY_SCALAR_FIELD(missing_ok);
2115 static TruncateStmt *
2116 _copyTruncateStmt(TruncateStmt *from)
2118 TruncateStmt *newnode = makeNode(TruncateStmt);
2120 COPY_NODE_FIELD(relations);
2121 COPY_SCALAR_FIELD(behavior);
2126 static CommentStmt *
2127 _copyCommentStmt(CommentStmt *from)
2129 CommentStmt *newnode = makeNode(CommentStmt);
2131 COPY_SCALAR_FIELD(objtype);
2132 COPY_NODE_FIELD(objname);
2133 COPY_NODE_FIELD(objargs);
2134 COPY_STRING_FIELD(comment);
2140 _copyFetchStmt(FetchStmt *from)
2142 FetchStmt *newnode = makeNode(FetchStmt);
2144 COPY_SCALAR_FIELD(direction);
2145 COPY_SCALAR_FIELD(howMany);
2146 COPY_STRING_FIELD(portalname);
2147 COPY_SCALAR_FIELD(ismove);
2153 _copyIndexStmt(IndexStmt *from)
2155 IndexStmt *newnode = makeNode(IndexStmt);
2157 COPY_STRING_FIELD(idxname);
2158 COPY_NODE_FIELD(relation);
2159 COPY_STRING_FIELD(accessMethod);
2160 COPY_STRING_FIELD(tableSpace);
2161 COPY_NODE_FIELD(indexParams);
2162 COPY_NODE_FIELD(options);
2163 COPY_NODE_FIELD(whereClause);
2164 COPY_SCALAR_FIELD(unique);
2165 COPY_SCALAR_FIELD(primary);
2166 COPY_SCALAR_FIELD(isconstraint);
2167 COPY_SCALAR_FIELD(concurrent);
2172 static CreateFunctionStmt *
2173 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2175 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2177 COPY_SCALAR_FIELD(replace);
2178 COPY_NODE_FIELD(funcname);
2179 COPY_NODE_FIELD(parameters);
2180 COPY_NODE_FIELD(returnType);
2181 COPY_NODE_FIELD(options);
2182 COPY_NODE_FIELD(withClause);
2187 static FunctionParameter *
2188 _copyFunctionParameter(FunctionParameter *from)
2190 FunctionParameter *newnode = makeNode(FunctionParameter);
2192 COPY_STRING_FIELD(name);
2193 COPY_NODE_FIELD(argType);
2194 COPY_SCALAR_FIELD(mode);
2199 static AlterFunctionStmt *
2200 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2202 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2204 COPY_NODE_FIELD(func);
2205 COPY_NODE_FIELD(actions);
2210 static RemoveFuncStmt *
2211 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2213 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2215 COPY_SCALAR_FIELD(kind);
2216 COPY_NODE_FIELD(name);
2217 COPY_NODE_FIELD(args);
2218 COPY_SCALAR_FIELD(behavior);
2219 COPY_SCALAR_FIELD(missing_ok);
2224 static RemoveOpClassStmt *
2225 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2227 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2229 COPY_NODE_FIELD(opclassname);
2230 COPY_STRING_FIELD(amname);
2231 COPY_SCALAR_FIELD(behavior);
2232 COPY_SCALAR_FIELD(missing_ok);
2237 static RemoveOpFamilyStmt *
2238 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2240 RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2242 COPY_NODE_FIELD(opfamilyname);
2243 COPY_STRING_FIELD(amname);
2244 COPY_SCALAR_FIELD(behavior);
2245 COPY_SCALAR_FIELD(missing_ok);
2251 _copyRenameStmt(RenameStmt *from)
2253 RenameStmt *newnode = makeNode(RenameStmt);
2255 COPY_SCALAR_FIELD(renameType);
2256 COPY_NODE_FIELD(relation);
2257 COPY_NODE_FIELD(object);
2258 COPY_NODE_FIELD(objarg);
2259 COPY_STRING_FIELD(subname);
2260 COPY_STRING_FIELD(newname);
2265 static AlterObjectSchemaStmt *
2266 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2268 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2270 COPY_SCALAR_FIELD(objectType);
2271 COPY_NODE_FIELD(relation);
2272 COPY_NODE_FIELD(object);
2273 COPY_NODE_FIELD(objarg);
2274 COPY_STRING_FIELD(addname);
2275 COPY_STRING_FIELD(newschema);
2280 static AlterOwnerStmt *
2281 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2283 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2285 COPY_SCALAR_FIELD(objectType);
2286 COPY_NODE_FIELD(relation);
2287 COPY_NODE_FIELD(object);
2288 COPY_NODE_FIELD(objarg);
2289 COPY_STRING_FIELD(addname);
2290 COPY_STRING_FIELD(newowner);
2296 _copyRuleStmt(RuleStmt *from)
2298 RuleStmt *newnode = makeNode(RuleStmt);
2300 COPY_NODE_FIELD(relation);
2301 COPY_STRING_FIELD(rulename);
2302 COPY_NODE_FIELD(whereClause);
2303 COPY_SCALAR_FIELD(event);
2304 COPY_SCALAR_FIELD(instead);
2305 COPY_NODE_FIELD(actions);
2306 COPY_SCALAR_FIELD(replace);
2312 _copyNotifyStmt(NotifyStmt *from)
2314 NotifyStmt *newnode = makeNode(NotifyStmt);
2316 COPY_NODE_FIELD(relation);
2322 _copyListenStmt(ListenStmt *from)
2324 ListenStmt *newnode = makeNode(ListenStmt);
2326 COPY_NODE_FIELD(relation);
2331 static UnlistenStmt *
2332 _copyUnlistenStmt(UnlistenStmt *from)
2334 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2336 COPY_NODE_FIELD(relation);
2341 static TransactionStmt *
2342 _copyTransactionStmt(TransactionStmt *from)
2344 TransactionStmt *newnode = makeNode(TransactionStmt);
2346 COPY_SCALAR_FIELD(kind);
2347 COPY_NODE_FIELD(options);
2348 COPY_STRING_FIELD(gid);
2353 static CompositeTypeStmt *
2354 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2356 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2358 COPY_NODE_FIELD(typevar);
2359 COPY_NODE_FIELD(coldeflist);
2364 static CreateEnumStmt *
2365 _copyCreateEnumStmt(CreateEnumStmt *from)
2367 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
2369 COPY_NODE_FIELD(typename);
2370 COPY_NODE_FIELD(vals);
2376 _copyViewStmt(ViewStmt *from)
2378 ViewStmt *newnode = makeNode(ViewStmt);
2380 COPY_NODE_FIELD(view);
2381 COPY_NODE_FIELD(aliases);
2382 COPY_NODE_FIELD(query);
2383 COPY_SCALAR_FIELD(replace);
2389 _copyLoadStmt(LoadStmt *from)
2391 LoadStmt *newnode = makeNode(LoadStmt);
2393 COPY_STRING_FIELD(filename);
2398 static CreateDomainStmt *
2399 _copyCreateDomainStmt(CreateDomainStmt *from)
2401 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2403 COPY_NODE_FIELD(domainname);
2404 COPY_NODE_FIELD(typename);
2405 COPY_NODE_FIELD(constraints);
2410 static CreateOpClassStmt *
2411 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2413 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2415 COPY_NODE_FIELD(opclassname);
2416 COPY_NODE_FIELD(opfamilyname);
2417 COPY_STRING_FIELD(amname);
2418 COPY_NODE_FIELD(datatype);
2419 COPY_NODE_FIELD(items);
2420 COPY_SCALAR_FIELD(isDefault);
2425 static CreateOpClassItem *
2426 _copyCreateOpClassItem(CreateOpClassItem *from)
2428 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2430 COPY_SCALAR_FIELD(itemtype);
2431 COPY_NODE_FIELD(name);
2432 COPY_NODE_FIELD(args);
2433 COPY_SCALAR_FIELD(number);
2434 COPY_SCALAR_FIELD(recheck);
2435 COPY_NODE_FIELD(class_args);
2436 COPY_NODE_FIELD(storedtype);
2441 static CreateOpFamilyStmt *
2442 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
2444 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
2446 COPY_NODE_FIELD(opfamilyname);
2447 COPY_STRING_FIELD(amname);
2452 static AlterOpFamilyStmt *
2453 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
2455 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
2457 COPY_NODE_FIELD(opfamilyname);
2458 COPY_STRING_FIELD(amname);
2459 COPY_SCALAR_FIELD(isDrop);
2460 COPY_NODE_FIELD(items);
2465 static CreatedbStmt *
2466 _copyCreatedbStmt(CreatedbStmt *from)
2468 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2470 COPY_STRING_FIELD(dbname);
2471 COPY_NODE_FIELD(options);
2476 static AlterDatabaseStmt *
2477 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2479 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2481 COPY_STRING_FIELD(dbname);
2482 COPY_NODE_FIELD(options);
2487 static AlterDatabaseSetStmt *
2488 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2490 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2492 COPY_STRING_FIELD(dbname);
2493 COPY_STRING_FIELD(variable);
2494 COPY_NODE_FIELD(value);
2500 _copyDropdbStmt(DropdbStmt *from)
2502 DropdbStmt *newnode = makeNode(DropdbStmt);
2504 COPY_STRING_FIELD(dbname);
2505 COPY_SCALAR_FIELD(missing_ok);
2511 _copyVacuumStmt(VacuumStmt *from)
2513 VacuumStmt *newnode = makeNode(VacuumStmt);
2515 COPY_SCALAR_FIELD(vacuum);
2516 COPY_SCALAR_FIELD(full);
2517 COPY_SCALAR_FIELD(analyze);
2518 COPY_SCALAR_FIELD(verbose);
2519 COPY_SCALAR_FIELD(freeze_min_age);
2520 COPY_NODE_FIELD(relation);
2521 COPY_NODE_FIELD(va_cols);
2526 static ExplainStmt *
2527 _copyExplainStmt(ExplainStmt *from)
2529 ExplainStmt *newnode = makeNode(ExplainStmt);
2531 COPY_NODE_FIELD(query);
2532 COPY_SCALAR_FIELD(verbose);
2533 COPY_SCALAR_FIELD(analyze);
2538 static CreateSeqStmt *
2539 _copyCreateSeqStmt(CreateSeqStmt *from)
2541 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2543 COPY_NODE_FIELD(sequence);
2544 COPY_NODE_FIELD(options);
2549 static AlterSeqStmt *
2550 _copyAlterSeqStmt(AlterSeqStmt *from)
2552 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2554 COPY_NODE_FIELD(sequence);
2555 COPY_NODE_FIELD(options);
2560 static VariableSetStmt *
2561 _copyVariableSetStmt(VariableSetStmt *from)
2563 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2565 COPY_STRING_FIELD(name);
2566 COPY_NODE_FIELD(args);
2567 COPY_SCALAR_FIELD(is_local);
2572 static VariableShowStmt *
2573 _copyVariableShowStmt(VariableShowStmt *from)
2575 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2577 COPY_STRING_FIELD(name);
2582 static VariableResetStmt *
2583 _copyVariableResetStmt(VariableResetStmt *from)
2585 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2587 COPY_STRING_FIELD(name);
2592 static CreateTableSpaceStmt *
2593 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2595 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2597 COPY_STRING_FIELD(tablespacename);
2598 COPY_STRING_FIELD(owner);
2599 COPY_STRING_FIELD(location);
2604 static DropTableSpaceStmt *
2605 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2607 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2609 COPY_STRING_FIELD(tablespacename);
2610 COPY_SCALAR_FIELD(missing_ok);
2615 static CreateTrigStmt *
2616 _copyCreateTrigStmt(CreateTrigStmt *from)
2618 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2620 COPY_STRING_FIELD(trigname);
2621 COPY_NODE_FIELD(relation);
2622 COPY_NODE_FIELD(funcname);
2623 COPY_NODE_FIELD(args);
2624 COPY_SCALAR_FIELD(before);
2625 COPY_SCALAR_FIELD(row);
2626 strcpy(newnode->actions, from->actions); /* in-line string field */
2627 COPY_SCALAR_FIELD(isconstraint);
2628 COPY_SCALAR_FIELD(deferrable);
2629 COPY_SCALAR_FIELD(initdeferred);
2630 COPY_NODE_FIELD(constrrel);
2635 static DropPropertyStmt *
2636 _copyDropPropertyStmt(DropPropertyStmt *from)
2638 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2640 COPY_NODE_FIELD(relation);
2641 COPY_STRING_FIELD(property);
2642 COPY_SCALAR_FIELD(removeType);
2643 COPY_SCALAR_FIELD(behavior);
2644 COPY_SCALAR_FIELD(missing_ok);
2649 static CreatePLangStmt *
2650 _copyCreatePLangStmt(CreatePLangStmt *from)
2652 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2654 COPY_STRING_FIELD(plname);
2655 COPY_NODE_FIELD(plhandler);
2656 COPY_NODE_FIELD(plvalidator);
2657 COPY_SCALAR_FIELD(pltrusted);
2662 static DropPLangStmt *
2663 _copyDropPLangStmt(DropPLangStmt *from)
2665 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2667 COPY_STRING_FIELD(plname);
2668 COPY_SCALAR_FIELD(behavior);
2669 COPY_SCALAR_FIELD(missing_ok);
2674 static CreateRoleStmt *
2675 _copyCreateRoleStmt(CreateRoleStmt *from)
2677 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2679 COPY_SCALAR_FIELD(stmt_type);
2680 COPY_STRING_FIELD(role);
2681 COPY_NODE_FIELD(options);
2686 static AlterRoleStmt *
2687 _copyAlterRoleStmt(AlterRoleStmt *from)
2689 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2691 COPY_STRING_FIELD(role);
2692 COPY_NODE_FIELD(options);
2693 COPY_SCALAR_FIELD(action);
2698 static AlterRoleSetStmt *
2699 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2701 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2703 COPY_STRING_FIELD(role);
2704 COPY_STRING_FIELD(variable);
2705 COPY_NODE_FIELD(value);
2710 static DropRoleStmt *
2711 _copyDropRoleStmt(DropRoleStmt *from)
2713 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2715 COPY_NODE_FIELD(roles);
2716 COPY_SCALAR_FIELD(missing_ok);
2722 _copyLockStmt(LockStmt *from)
2724 LockStmt *newnode = makeNode(LockStmt);
2726 COPY_NODE_FIELD(relations);
2727 COPY_SCALAR_FIELD(mode);
2728 COPY_SCALAR_FIELD(nowait);
2733 static ConstraintsSetStmt *
2734 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2736 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2738 COPY_NODE_FIELD(constraints);
2739 COPY_SCALAR_FIELD(deferred);
2744 static ReindexStmt *
2745 _copyReindexStmt(ReindexStmt *from)
2747 ReindexStmt *newnode = makeNode(ReindexStmt);
2749 COPY_SCALAR_FIELD(kind);
2750 COPY_NODE_FIELD(relation);
2751 COPY_STRING_FIELD(name);
2752 COPY_SCALAR_FIELD(do_system);
2753 COPY_SCALAR_FIELD(do_user);
2758 static CreateSchemaStmt *
2759 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2761 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2763 COPY_STRING_FIELD(schemaname);
2764 COPY_STRING_FIELD(authid);
2765 COPY_NODE_FIELD(schemaElts);
2770 static CreateConversionStmt *
2771 _copyCreateConversionStmt(CreateConversionStmt *from)
2773 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2775 COPY_NODE_FIELD(conversion_name);
2776 COPY_STRING_FIELD(for_encoding_name);
2777 COPY_STRING_FIELD(to_encoding_name);
2778 COPY_NODE_FIELD(func_name);
2779 COPY_SCALAR_FIELD(def);
2784 static CreateCastStmt *
2785 _copyCreateCastStmt(CreateCastStmt *from)
2787 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2789 COPY_NODE_FIELD(sourcetype);
2790 COPY_NODE_FIELD(targettype);
2791 COPY_NODE_FIELD(func);
2792 COPY_SCALAR_FIELD(context);
2797 static DropCastStmt *
2798 _copyDropCastStmt(DropCastStmt *from)
2800 DropCastStmt *newnode = makeNode(DropCastStmt);
2802 COPY_NODE_FIELD(sourcetype);
2803 COPY_NODE_FIELD(targettype);
2804 COPY_SCALAR_FIELD(behavior);
2805 COPY_SCALAR_FIELD(missing_ok);
2810 static PrepareStmt *
2811 _copyPrepareStmt(PrepareStmt *from)
2813 PrepareStmt *newnode = makeNode(PrepareStmt);
2815 COPY_STRING_FIELD(name);
2816 COPY_NODE_FIELD(argtypes);
2817 COPY_NODE_FIELD(query);
2822 static ExecuteStmt *
2823 _copyExecuteStmt(ExecuteStmt *from)
2825 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2827 COPY_STRING_FIELD(name);
2828 COPY_NODE_FIELD(into);
2829 COPY_NODE_FIELD(params);
2834 static DeallocateStmt *
2835 _copyDeallocateStmt(DeallocateStmt *from)
2837 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2839 COPY_STRING_FIELD(name);
2844 static DropOwnedStmt *
2845 _copyDropOwnedStmt(DropOwnedStmt *from)
2847 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2849 COPY_NODE_FIELD(roles);
2850 COPY_SCALAR_FIELD(behavior);
2855 static ReassignOwnedStmt *
2856 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
2858 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2860 COPY_NODE_FIELD(roles);
2861 COPY_SCALAR_FIELD(newrole);
2866 /* ****************************************************************
2867 * pg_list.h copy functions
2868 * ****************************************************************
2872 * Perform a deep copy of the specified list, using copyObject(). The
2873 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2874 * need deep copies, so they should be copied via list_copy()
2876 #define COPY_NODE_CELL(new, old) \
2877 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2878 lfirst(new) = copyObject(lfirst(old));
2881 _copyList(List *from)
2887 Assert(list_length(from) >= 1);
2889 new = makeNode(List);
2890 new->length = from->length;
2892 COPY_NODE_CELL(new->head, from->head);
2893 prev_new = new->head;
2894 curr_old = lnext(from->head);
2898 COPY_NODE_CELL(prev_new->next, curr_old);
2899 prev_new = prev_new->next;
2900 curr_old = curr_old->next;
2902 prev_new->next = NULL;
2903 new->tail = prev_new;
2908 /* ****************************************************************
2909 * value.h copy functions
2910 * ****************************************************************
2913 _copyValue(Value *from)
2915 Value *newnode = makeNode(Value);
2917 /* See also _copyAConst when changing this code! */
2919 COPY_SCALAR_FIELD(type);
2923 COPY_SCALAR_FIELD(val.ival);
2928 COPY_STRING_FIELD(val.str);
2934 elog(ERROR, "unrecognized node type: %d",
2944 * Create a copy of a Node tree or list. This is a "deep" copy: all
2945 * substructure is copied too, recursively.
2948 copyObject(void *from)
2955 switch (nodeTag(from))
2961 retval = _copyPlannedStmt(from);
2964 retval = _copyPlan(from);
2967 retval = _copyResult(from);
2970 retval = _copyAppend(from);
2973 retval = _copyBitmapAnd(from);
2976 retval = _copyBitmapOr(from);
2979 retval = _copyScan(from);
2982 retval = _copySeqScan(from);
2985 retval = _copyIndexScan(from);
2987 case T_BitmapIndexScan:
2988 retval = _copyBitmapIndexScan(from);
2990 case T_BitmapHeapScan:
2991 retval = _copyBitmapHeapScan(from);
2994 retval = _copyTidScan(from);
2996 case T_SubqueryScan:
2997 retval = _copySubqueryScan(from);
2999 case T_FunctionScan:
3000 retval = _copyFunctionScan(from);
3003 retval = _copyValuesScan(from);
3006 retval = _copyJoin(from);
3009 retval = _copyNestLoop(from);
3012 retval = _copyMergeJoin(from);
3015 retval = _copyHashJoin(from);
3018 retval = _copyMaterial(from);
3021 retval = _copySort(from);
3024 retval = _copyGroup(from);
3027 retval = _copyAgg(from);
3030 retval = _copyUnique(from);
3033 retval = _copyHash(from);
3036 retval = _copySetOp(from);
3039 retval = _copyLimit(from);
3046 retval = _copyAlias(from);
3049 retval = _copyRangeVar(from);
3052 retval = _copyIntoClause(from);
3055 retval = _copyVar(from);
3058 retval = _copyConst(from);
3061 retval = _copyParam(from);
3064 retval = _copyAggref(from);
3067 retval = _copyArrayRef(from);
3070 retval = _copyFuncExpr(from);
3073 retval = _copyOpExpr(from);
3075 case T_DistinctExpr:
3076 retval = _copyDistinctExpr(from);
3078 case T_ScalarArrayOpExpr:
3079 retval = _copyScalarArrayOpExpr(from);
3082 retval = _copyBoolExpr(from);
3085 retval = _copySubLink(from);
3088 retval = _copySubPlan(from);
3091 retval = _copyFieldSelect(from);
3094 retval = _copyFieldStore(from);
3097 retval = _copyRelabelType(from);
3099 case T_ArrayCoerceExpr:
3100 retval = _copyArrayCoerceExpr(from);
3102 case T_ConvertRowtypeExpr:
3103 retval = _copyConvertRowtypeExpr(from);
3106 retval = _copyCaseExpr(from);
3109 retval = _copyCaseWhen(from);
3111 case T_CaseTestExpr:
3112 retval = _copyCaseTestExpr(from);
3115 retval = _copyArrayExpr(from);
3118 retval = _copyRowExpr(from);
3120 case T_RowCompareExpr:
3121 retval = _copyRowCompareExpr(from);
3123 case T_CoalesceExpr:
3124 retval = _copyCoalesceExpr(from);
3127 retval = _copyMinMaxExpr(from);
3130 retval = _copyXmlExpr(from);
3133 retval = _copyNullIfExpr(from);
3136 retval = _copyNullTest(from);
3139 retval = _copyBooleanTest(from);
3141 case T_CoerceToDomain:
3142 retval = _copyCoerceToDomain(from);
3144 case T_CoerceToDomainValue:
3145 retval = _copyCoerceToDomainValue(from);
3147 case T_SetToDefault:
3148 retval = _copySetToDefault(from);
3151 retval = _copyTargetEntry(from);
3154 retval = _copyRangeTblRef(from);
3157 retval = _copyJoinExpr(from);
3160 retval = _copyFromExpr(from);
3167 retval = _copyPathKey(from);
3169 case T_RestrictInfo:
3170 retval = _copyRestrictInfo(from);
3172 case T_OuterJoinInfo:
3173 retval = _copyOuterJoinInfo(from);
3175 case T_InClauseInfo:
3176 retval = _copyInClauseInfo(from);
3178 case T_AppendRelInfo:
3179 retval = _copyAppendRelInfo(from);
3190 retval = _copyValue(from);
3197 retval = _copyList(from);
3201 * Lists of integers and OIDs don't need to be deep-copied, so we
3202 * perform a shallow copy via list_copy()
3206 retval = list_copy(from);
3213 retval = _copyQuery(from);
3216 retval = _copyInsertStmt(from);
3219 retval = _copyDeleteStmt(from);
3222 retval = _copyUpdateStmt(from);
3225 retval = _copySelectStmt(from);
3227 case T_SetOperationStmt:
3228 retval = _copySetOperationStmt(from);
3230 case T_AlterTableStmt:
3231 retval = _copyAlterTableStmt(from);
3233 case T_AlterTableCmd:
3234 retval = _copyAlterTableCmd(from);
3236 case T_AlterDomainStmt:
3237 retval = _copyAlterDomainStmt(from);
3240 retval = _copyGrantStmt(from);
3242 case T_GrantRoleStmt:
3243 retval = _copyGrantRoleStmt(from);
3245 case T_DeclareCursorStmt:
3246 retval = _copyDeclareCursorStmt(from);
3248 case T_ClosePortalStmt:
3249 retval = _copyClosePortalStmt(from);
3252 retval = _copyClusterStmt(from);
3255 retval = _copyCopyStmt(from);
3258 retval = _copyCreateStmt(from);
3261 retval = _copyInhRelation(from);
3264 retval = _copyDefineStmt(from);
3267 retval = _copyDropStmt(from);
3269 case T_TruncateStmt:
3270 retval = _copyTruncateStmt(from);
3273 retval = _copyCommentStmt(from);
3276 retval = _copyFetchStmt(from);
3279 retval = _copyIndexStmt(from);
3281 case T_CreateFunctionStmt:
3282 retval = _copyCreateFunctionStmt(from);
3284 case T_FunctionParameter:
3285 retval = _copyFunctionParameter(from);
3287 case T_AlterFunctionStmt:
3288 retval = _copyAlterFunctionStmt(from);
3290 case T_RemoveFuncStmt:
3291 retval = _copyRemoveFuncStmt(from);
3293 case T_RemoveOpClassStmt:
3294 retval = _copyRemoveOpClassStmt(from);
3296 case T_RemoveOpFamilyStmt:
3297 retval = _copyRemoveOpFamilyStmt(from);
3300 retval = _copyRenameStmt(from);
3302 case T_AlterObjectSchemaStmt:
3303 retval = _copyAlterObjectSchemaStmt(from);
3305 case T_AlterOwnerStmt:
3306 retval = _copyAlterOwnerStmt(from);
3309 retval = _copyRuleStmt(from);
3312 retval = _copyNotifyStmt(from);
3315 retval = _copyListenStmt(from);
3317 case T_UnlistenStmt:
3318 retval = _copyUnlistenStmt(from);
3320 case T_TransactionStmt:
3321 retval = _copyTransactionStmt(from);
3323 case T_CompositeTypeStmt:
3324 retval = _copyCompositeTypeStmt(from);
3326 case T_CreateEnumStmt:
3327 retval = _copyCreateEnumStmt(from);
3330 retval = _copyViewStmt(from);
3333 retval = _copyLoadStmt(from);
3335 case T_CreateDomainStmt:
3336 retval = _copyCreateDomainStmt(from);
3338 case T_CreateOpClassStmt:
3339 retval = _copyCreateOpClassStmt(from);
3341 case T_CreateOpClassItem:
3342 retval = _copyCreateOpClassItem(from);
3344 case T_CreateOpFamilyStmt:
3345 retval = _copyCreateOpFamilyStmt(from);
3347 case T_AlterOpFamilyStmt:
3348 retval = _copyAlterOpFamilyStmt(from);
3350 case T_CreatedbStmt:
3351 retval = _copyCreatedbStmt(from);
3353 case T_AlterDatabaseStmt:
3354 retval = _copyAlterDatabaseStmt(from);
3356 case T_AlterDatabaseSetStmt:
3357 retval = _copyAlterDatabaseSetStmt(from);
3360 retval = _copyDropdbStmt(from);
3363 retval = _copyVacuumStmt(from);
3366 retval = _copyExplainStmt(from);
3368 case T_CreateSeqStmt:
3369 retval = _copyCreateSeqStmt(from);
3371 case T_AlterSeqStmt:
3372 retval = _copyAlterSeqStmt(from);
3374 case T_VariableSetStmt:
3375 retval = _copyVariableSetStmt(from);
3377 case T_VariableShowStmt:
3378 retval = _copyVariableShowStmt(from);
3380 case T_VariableResetStmt:
3381 retval = _copyVariableResetStmt(from);
3383 case T_CreateTableSpaceStmt:
3384 retval = _copyCreateTableSpaceStmt(from);
3386 case T_DropTableSpaceStmt:
3387 retval = _copyDropTableSpaceStmt(from);
3389 case T_CreateTrigStmt:
3390 retval = _copyCreateTrigStmt(from);
3392 case T_DropPropertyStmt:
3393 retval = _copyDropPropertyStmt(from);
3395 case T_CreatePLangStmt:
3396 retval = _copyCreatePLangStmt(from);
3398 case T_DropPLangStmt:
3399 retval = _copyDropPLangStmt(from);
3401 case T_CreateRoleStmt:
3402 retval = _copyCreateRoleStmt(from);
3404 case T_AlterRoleStmt:
3405 retval = _copyAlterRoleStmt(from);
3407 case T_AlterRoleSetStmt:
3408 retval = _copyAlterRoleSetStmt(from);
3410 case T_DropRoleStmt:
3411 retval = _copyDropRoleStmt(from);
3414 retval = _copyLockStmt(from);
3416 case T_ConstraintsSetStmt:
3417 retval = _copyConstraintsSetStmt(from);
3420 retval = _copyReindexStmt(from);
3422 case T_CheckPointStmt:
3423 retval = (void *) makeNode(CheckPointStmt);
3425 case T_CreateSchemaStmt:
3426 retval = _copyCreateSchemaStmt(from);
3428 case T_CreateConversionStmt:
3429 retval = _copyCreateConversionStmt(from);
3431 case T_CreateCastStmt:
3432 retval = _copyCreateCastStmt(from);
3434 case T_DropCastStmt:
3435 retval = _copyDropCastStmt(from);
3438 retval = _copyPrepareStmt(from);
3441 retval = _copyExecuteStmt(from);
3443 case T_DeallocateStmt:
3444 retval = _copyDeallocateStmt(from);
3446 case T_DropOwnedStmt:
3447 retval = _copyDropOwnedStmt(from);
3449 case T_ReassignOwnedStmt:
3450 retval = _copyReassignOwnedStmt(from);
3454 retval = _copyAExpr(from);
3457 retval = _copyColumnRef(from);
3460 retval = _copyParamRef(from);
3463 retval = _copyAConst(from);
3466 retval = _copyFuncCall(from);
3469 retval = _copyAIndices(from);
3471 case T_A_Indirection:
3472 retval = _copyA_Indirection(from);
3475 retval = _copyResTarget(from);
3478 retval = _copyTypeCast(from);
3481 retval = _copySortBy(from);
3483 case T_RangeSubselect:
3484 retval = _copyRangeSubselect(from);
3486 case T_RangeFunction:
3487 retval = _copyRangeFunction(from);
3490 retval = _copyTypeName(from);
3493 retval = _copyIndexElem(from);
3496 retval = _copyColumnDef(from);
3499 retval = _copyConstraint(from);
3502 retval = _copyDefElem(from);
3504 case T_LockingClause:
3505 retval = _copyLockingClause(from);
3507 case T_RangeTblEntry:
3508 retval = _copyRangeTblEntry(from);
3511 retval = _copySortClause(from);
3514 retval = _copyGroupClause(from);
3516 case T_RowMarkClause:
3517 retval = _copyRowMarkClause(from);
3519 case T_FkConstraint:
3520 retval = _copyFkConstraint(from);
3523 retval = _copyPrivGrantee(from);
3525 case T_FuncWithArgs:
3526 retval = _copyFuncWithArgs(from);
3528 case T_XmlSerialize:
3529 retval = _copyXmlSerialize(from);
3533 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3534 retval = from; /* keep compiler quiet */