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.362 2007/01/20 20:45: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 * ****************************************************************
70 * This function copies the fields of the Plan node. It is used by
71 * all the copy functions for classes which inherit from Plan.
74 CopyPlanFields(Plan *from, Plan *newnode)
76 COPY_SCALAR_FIELD(startup_cost);
77 COPY_SCALAR_FIELD(total_cost);
78 COPY_SCALAR_FIELD(plan_rows);
79 COPY_SCALAR_FIELD(plan_width);
80 COPY_NODE_FIELD(targetlist);
81 COPY_NODE_FIELD(qual);
82 COPY_NODE_FIELD(lefttree);
83 COPY_NODE_FIELD(righttree);
84 COPY_NODE_FIELD(initPlan);
85 COPY_BITMAPSET_FIELD(extParam);
86 COPY_BITMAPSET_FIELD(allParam);
87 COPY_SCALAR_FIELD(nParamExec);
96 Plan *newnode = makeNode(Plan);
99 * copy node superclass fields
101 CopyPlanFields(from, newnode);
111 _copyResult(Result *from)
113 Result *newnode = makeNode(Result);
116 * copy node superclass fields
118 CopyPlanFields((Plan *) from, (Plan *) newnode);
121 * copy remainder of node
123 COPY_NODE_FIELD(resconstantqual);
132 _copyAppend(Append *from)
134 Append *newnode = makeNode(Append);
137 * copy node superclass fields
139 CopyPlanFields((Plan *) from, (Plan *) newnode);
142 * copy remainder of node
144 COPY_NODE_FIELD(appendplans);
145 COPY_SCALAR_FIELD(isTarget);
154 _copyBitmapAnd(BitmapAnd *from)
156 BitmapAnd *newnode = makeNode(BitmapAnd);
159 * copy node superclass fields
161 CopyPlanFields((Plan *) from, (Plan *) newnode);
164 * copy remainder of node
166 COPY_NODE_FIELD(bitmapplans);
175 _copyBitmapOr(BitmapOr *from)
177 BitmapOr *newnode = makeNode(BitmapOr);
180 * copy node superclass fields
182 CopyPlanFields((Plan *) from, (Plan *) newnode);
185 * copy remainder of node
187 COPY_NODE_FIELD(bitmapplans);
196 * This function copies the fields of the Scan node. It is used by
197 * all the copy functions for classes which inherit from Scan.
200 CopyScanFields(Scan *from, Scan *newnode)
202 CopyPlanFields((Plan *) from, (Plan *) newnode);
204 COPY_SCALAR_FIELD(scanrelid);
211 _copyScan(Scan *from)
213 Scan *newnode = makeNode(Scan);
216 * copy node superclass fields
218 CopyScanFields((Scan *) from, (Scan *) newnode);
227 _copySeqScan(SeqScan *from)
229 SeqScan *newnode = makeNode(SeqScan);
232 * copy node superclass fields
234 CopyScanFields((Scan *) from, (Scan *) newnode);
243 _copyIndexScan(IndexScan *from)
245 IndexScan *newnode = makeNode(IndexScan);
248 * copy node superclass fields
250 CopyScanFields((Scan *) from, (Scan *) newnode);
253 * copy remainder of node
255 COPY_SCALAR_FIELD(indexid);
256 COPY_NODE_FIELD(indexqual);
257 COPY_NODE_FIELD(indexqualorig);
258 COPY_NODE_FIELD(indexstrategy);
259 COPY_NODE_FIELD(indexsubtype);
260 COPY_SCALAR_FIELD(indexorderdir);
266 * _copyBitmapIndexScan
268 static BitmapIndexScan *
269 _copyBitmapIndexScan(BitmapIndexScan *from)
271 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
274 * copy node superclass fields
276 CopyScanFields((Scan *) from, (Scan *) newnode);
279 * copy remainder of node
281 COPY_SCALAR_FIELD(indexid);
282 COPY_NODE_FIELD(indexqual);
283 COPY_NODE_FIELD(indexqualorig);
284 COPY_NODE_FIELD(indexstrategy);
285 COPY_NODE_FIELD(indexsubtype);
291 * _copyBitmapHeapScan
293 static BitmapHeapScan *
294 _copyBitmapHeapScan(BitmapHeapScan *from)
296 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
299 * copy node superclass fields
301 CopyScanFields((Scan *) from, (Scan *) newnode);
304 * copy remainder of node
306 COPY_NODE_FIELD(bitmapqualorig);
315 _copyTidScan(TidScan *from)
317 TidScan *newnode = makeNode(TidScan);
320 * copy node superclass fields
322 CopyScanFields((Scan *) from, (Scan *) newnode);
325 * copy remainder of node
327 COPY_NODE_FIELD(tidquals);
335 static SubqueryScan *
336 _copySubqueryScan(SubqueryScan *from)
338 SubqueryScan *newnode = makeNode(SubqueryScan);
341 * copy node superclass fields
343 CopyScanFields((Scan *) from, (Scan *) newnode);
346 * copy remainder of node
348 COPY_NODE_FIELD(subplan);
356 static FunctionScan *
357 _copyFunctionScan(FunctionScan *from)
359 FunctionScan *newnode = makeNode(FunctionScan);
362 * copy node superclass fields
364 CopyScanFields((Scan *) from, (Scan *) newnode);
373 _copyValuesScan(ValuesScan *from)
375 ValuesScan *newnode = makeNode(ValuesScan);
378 * copy node superclass fields
380 CopyScanFields((Scan *) from, (Scan *) newnode);
388 * This function copies the fields of the Join node. It is used by
389 * all the copy functions for classes which inherit from Join.
392 CopyJoinFields(Join *from, Join *newnode)
394 CopyPlanFields((Plan *) from, (Plan *) newnode);
396 COPY_SCALAR_FIELD(jointype);
397 COPY_NODE_FIELD(joinqual);
405 _copyJoin(Join *from)
407 Join *newnode = makeNode(Join);
410 * copy node superclass fields
412 CopyJoinFields(from, newnode);
422 _copyNestLoop(NestLoop *from)
424 NestLoop *newnode = makeNode(NestLoop);
427 * copy node superclass fields
429 CopyJoinFields((Join *) from, (Join *) newnode);
439 _copyMergeJoin(MergeJoin *from)
441 MergeJoin *newnode = makeNode(MergeJoin);
445 * copy node superclass fields
447 CopyJoinFields((Join *) from, (Join *) newnode);
450 * copy remainder of node
452 COPY_NODE_FIELD(mergeclauses);
453 numCols = list_length(from->mergeclauses);
454 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
455 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
456 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
465 _copyHashJoin(HashJoin *from)
467 HashJoin *newnode = makeNode(HashJoin);
470 * copy node superclass fields
472 CopyJoinFields((Join *) from, (Join *) newnode);
475 * copy remainder of node
477 COPY_NODE_FIELD(hashclauses);
487 _copyMaterial(Material *from)
489 Material *newnode = makeNode(Material);
492 * copy node superclass fields
494 CopyPlanFields((Plan *) from, (Plan *) newnode);
504 _copySort(Sort *from)
506 Sort *newnode = makeNode(Sort);
509 * copy node superclass fields
511 CopyPlanFields((Plan *) from, (Plan *) newnode);
513 COPY_SCALAR_FIELD(numCols);
514 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
515 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
516 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
526 _copyGroup(Group *from)
528 Group *newnode = makeNode(Group);
530 CopyPlanFields((Plan *) from, (Plan *) newnode);
532 COPY_SCALAR_FIELD(numCols);
533 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
534 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
545 Agg *newnode = makeNode(Agg);
547 CopyPlanFields((Plan *) from, (Plan *) newnode);
549 COPY_SCALAR_FIELD(aggstrategy);
550 COPY_SCALAR_FIELD(numCols);
551 if (from->numCols > 0)
553 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
554 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
556 COPY_SCALAR_FIELD(numGroups);
565 _copyUnique(Unique *from)
567 Unique *newnode = makeNode(Unique);
570 * copy node superclass fields
572 CopyPlanFields((Plan *) from, (Plan *) newnode);
575 * copy remainder of node
577 COPY_SCALAR_FIELD(numCols);
578 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
579 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
588 _copyHash(Hash *from)
590 Hash *newnode = makeNode(Hash);
593 * copy node superclass fields
595 CopyPlanFields((Plan *) from, (Plan *) newnode);
598 * copy remainder of node
608 _copySetOp(SetOp *from)
610 SetOp *newnode = makeNode(SetOp);
613 * copy node superclass fields
615 CopyPlanFields((Plan *) from, (Plan *) newnode);
618 * copy remainder of node
620 COPY_SCALAR_FIELD(cmd);
621 COPY_SCALAR_FIELD(numCols);
622 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
623 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
624 COPY_SCALAR_FIELD(flagColIdx);
633 _copyLimit(Limit *from)
635 Limit *newnode = makeNode(Limit);
638 * copy node superclass fields
640 CopyPlanFields((Plan *) from, (Plan *) newnode);
643 * copy remainder of node
645 COPY_NODE_FIELD(limitOffset);
646 COPY_NODE_FIELD(limitCount);
651 /* ****************************************************************
652 * primnodes.h copy functions
653 * ****************************************************************
660 _copyAlias(Alias *from)
662 Alias *newnode = makeNode(Alias);
664 COPY_STRING_FIELD(aliasname);
665 COPY_NODE_FIELD(colnames);
674 _copyRangeVar(RangeVar *from)
676 RangeVar *newnode = makeNode(RangeVar);
678 COPY_STRING_FIELD(catalogname);
679 COPY_STRING_FIELD(schemaname);
680 COPY_STRING_FIELD(relname);
681 COPY_SCALAR_FIELD(inhOpt);
682 COPY_SCALAR_FIELD(istemp);
683 COPY_NODE_FIELD(alias);
689 * We don't need a _copyExpr because Expr is an abstract supertype which
690 * should never actually get instantiated. Also, since it has no common
691 * fields except NodeTag, there's no need for a helper routine to factor
692 * out copying the common fields...
701 Var *newnode = makeNode(Var);
703 COPY_SCALAR_FIELD(varno);
704 COPY_SCALAR_FIELD(varattno);
705 COPY_SCALAR_FIELD(vartype);
706 COPY_SCALAR_FIELD(vartypmod);
707 COPY_SCALAR_FIELD(varlevelsup);
708 COPY_SCALAR_FIELD(varnoold);
709 COPY_SCALAR_FIELD(varoattno);
718 _copyConst(Const *from)
720 Const *newnode = makeNode(Const);
722 COPY_SCALAR_FIELD(consttype);
723 COPY_SCALAR_FIELD(constlen);
725 if (from->constbyval || from->constisnull)
728 * passed by value so just copy the datum. Also, don't try to copy
729 * struct when value is null!
731 newnode->constvalue = from->constvalue;
736 * passed by reference. We need a palloc'd copy.
738 newnode->constvalue = datumCopy(from->constvalue,
743 COPY_SCALAR_FIELD(constisnull);
744 COPY_SCALAR_FIELD(constbyval);
753 _copyParam(Param *from)
755 Param *newnode = makeNode(Param);
757 COPY_SCALAR_FIELD(paramkind);
758 COPY_SCALAR_FIELD(paramid);
759 COPY_SCALAR_FIELD(paramtype);
760 COPY_SCALAR_FIELD(paramtypmod);
769 _copyAggref(Aggref *from)
771 Aggref *newnode = makeNode(Aggref);
773 COPY_SCALAR_FIELD(aggfnoid);
774 COPY_SCALAR_FIELD(aggtype);
775 COPY_NODE_FIELD(args);
776 COPY_SCALAR_FIELD(agglevelsup);
777 COPY_SCALAR_FIELD(aggstar);
778 COPY_SCALAR_FIELD(aggdistinct);
787 _copyArrayRef(ArrayRef *from)
789 ArrayRef *newnode = makeNode(ArrayRef);
791 COPY_SCALAR_FIELD(refrestype);
792 COPY_SCALAR_FIELD(refarraytype);
793 COPY_SCALAR_FIELD(refelemtype);
794 COPY_NODE_FIELD(refupperindexpr);
795 COPY_NODE_FIELD(reflowerindexpr);
796 COPY_NODE_FIELD(refexpr);
797 COPY_NODE_FIELD(refassgnexpr);
806 _copyFuncExpr(FuncExpr *from)
808 FuncExpr *newnode = makeNode(FuncExpr);
810 COPY_SCALAR_FIELD(funcid);
811 COPY_SCALAR_FIELD(funcresulttype);
812 COPY_SCALAR_FIELD(funcretset);
813 COPY_SCALAR_FIELD(funcformat);
814 COPY_NODE_FIELD(args);
823 _copyOpExpr(OpExpr *from)
825 OpExpr *newnode = makeNode(OpExpr);
827 COPY_SCALAR_FIELD(opno);
828 COPY_SCALAR_FIELD(opfuncid);
829 COPY_SCALAR_FIELD(opresulttype);
830 COPY_SCALAR_FIELD(opretset);
831 COPY_NODE_FIELD(args);
837 * _copyDistinctExpr (same as OpExpr)
839 static DistinctExpr *
840 _copyDistinctExpr(DistinctExpr *from)
842 DistinctExpr *newnode = makeNode(DistinctExpr);
844 COPY_SCALAR_FIELD(opno);
845 COPY_SCALAR_FIELD(opfuncid);
846 COPY_SCALAR_FIELD(opresulttype);
847 COPY_SCALAR_FIELD(opretset);
848 COPY_NODE_FIELD(args);
854 * _copyScalarArrayOpExpr
856 static ScalarArrayOpExpr *
857 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
859 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
861 COPY_SCALAR_FIELD(opno);
862 COPY_SCALAR_FIELD(opfuncid);
863 COPY_SCALAR_FIELD(useOr);
864 COPY_NODE_FIELD(args);
873 _copyBoolExpr(BoolExpr *from)
875 BoolExpr *newnode = makeNode(BoolExpr);
877 COPY_SCALAR_FIELD(boolop);
878 COPY_NODE_FIELD(args);
887 _copySubLink(SubLink *from)
889 SubLink *newnode = makeNode(SubLink);
891 COPY_SCALAR_FIELD(subLinkType);
892 COPY_NODE_FIELD(testexpr);
893 COPY_NODE_FIELD(operName);
894 COPY_NODE_FIELD(subselect);
903 _copySubPlan(SubPlan *from)
905 SubPlan *newnode = makeNode(SubPlan);
907 COPY_SCALAR_FIELD(subLinkType);
908 COPY_NODE_FIELD(testexpr);
909 COPY_NODE_FIELD(paramIds);
910 COPY_NODE_FIELD(plan);
911 COPY_SCALAR_FIELD(plan_id);
912 COPY_NODE_FIELD(rtable);
913 COPY_SCALAR_FIELD(useHashTable);
914 COPY_SCALAR_FIELD(unknownEqFalse);
915 COPY_NODE_FIELD(setParam);
916 COPY_NODE_FIELD(parParam);
917 COPY_NODE_FIELD(args);
926 _copyFieldSelect(FieldSelect *from)
928 FieldSelect *newnode = makeNode(FieldSelect);
930 COPY_NODE_FIELD(arg);
931 COPY_SCALAR_FIELD(fieldnum);
932 COPY_SCALAR_FIELD(resulttype);
933 COPY_SCALAR_FIELD(resulttypmod);
942 _copyFieldStore(FieldStore *from)
944 FieldStore *newnode = makeNode(FieldStore);
946 COPY_NODE_FIELD(arg);
947 COPY_NODE_FIELD(newvals);
948 COPY_NODE_FIELD(fieldnums);
949 COPY_SCALAR_FIELD(resulttype);
958 _copyRelabelType(RelabelType *from)
960 RelabelType *newnode = makeNode(RelabelType);
962 COPY_NODE_FIELD(arg);
963 COPY_SCALAR_FIELD(resulttype);
964 COPY_SCALAR_FIELD(resulttypmod);
965 COPY_SCALAR_FIELD(relabelformat);
971 * _copyConvertRowtypeExpr
973 static ConvertRowtypeExpr *
974 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
976 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
978 COPY_NODE_FIELD(arg);
979 COPY_SCALAR_FIELD(resulttype);
980 COPY_SCALAR_FIELD(convertformat);
989 _copyCaseExpr(CaseExpr *from)
991 CaseExpr *newnode = makeNode(CaseExpr);
993 COPY_SCALAR_FIELD(casetype);
994 COPY_NODE_FIELD(arg);
995 COPY_NODE_FIELD(args);
996 COPY_NODE_FIELD(defresult);
1005 _copyCaseWhen(CaseWhen *from)
1007 CaseWhen *newnode = makeNode(CaseWhen);
1009 COPY_NODE_FIELD(expr);
1010 COPY_NODE_FIELD(result);
1018 static CaseTestExpr *
1019 _copyCaseTestExpr(CaseTestExpr *from)
1021 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1023 COPY_SCALAR_FIELD(typeId);
1024 COPY_SCALAR_FIELD(typeMod);
1033 _copyArrayExpr(ArrayExpr *from)
1035 ArrayExpr *newnode = makeNode(ArrayExpr);
1037 COPY_SCALAR_FIELD(array_typeid);
1038 COPY_SCALAR_FIELD(element_typeid);
1039 COPY_NODE_FIELD(elements);
1040 COPY_SCALAR_FIELD(multidims);
1049 _copyRowExpr(RowExpr *from)
1051 RowExpr *newnode = makeNode(RowExpr);
1053 COPY_NODE_FIELD(args);
1054 COPY_SCALAR_FIELD(row_typeid);
1055 COPY_SCALAR_FIELD(row_format);
1061 * _copyRowCompareExpr
1063 static RowCompareExpr *
1064 _copyRowCompareExpr(RowCompareExpr *from)
1066 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1068 COPY_SCALAR_FIELD(rctype);
1069 COPY_NODE_FIELD(opnos);
1070 COPY_NODE_FIELD(opfamilies);
1071 COPY_NODE_FIELD(largs);
1072 COPY_NODE_FIELD(rargs);
1080 static CoalesceExpr *
1081 _copyCoalesceExpr(CoalesceExpr *from)
1083 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1085 COPY_SCALAR_FIELD(coalescetype);
1086 COPY_NODE_FIELD(args);
1095 _copyMinMaxExpr(MinMaxExpr *from)
1097 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1099 COPY_SCALAR_FIELD(minmaxtype);
1100 COPY_SCALAR_FIELD(op);
1101 COPY_NODE_FIELD(args);
1110 _copyXmlExpr(XmlExpr *from)
1112 XmlExpr *newnode = makeNode(XmlExpr);
1114 COPY_SCALAR_FIELD(op);
1115 COPY_STRING_FIELD(name);
1116 COPY_NODE_FIELD(named_args);
1117 COPY_NODE_FIELD(arg_names);
1118 COPY_NODE_FIELD(args);
1124 * _copyNullIfExpr (same as OpExpr)
1127 _copyNullIfExpr(NullIfExpr *from)
1129 NullIfExpr *newnode = makeNode(NullIfExpr);
1131 COPY_SCALAR_FIELD(opno);
1132 COPY_SCALAR_FIELD(opfuncid);
1133 COPY_SCALAR_FIELD(opresulttype);
1134 COPY_SCALAR_FIELD(opretset);
1135 COPY_NODE_FIELD(args);
1144 _copyNullTest(NullTest *from)
1146 NullTest *newnode = makeNode(NullTest);
1148 COPY_NODE_FIELD(arg);
1149 COPY_SCALAR_FIELD(nulltesttype);
1157 static BooleanTest *
1158 _copyBooleanTest(BooleanTest *from)
1160 BooleanTest *newnode = makeNode(BooleanTest);
1162 COPY_NODE_FIELD(arg);
1163 COPY_SCALAR_FIELD(booltesttype);
1169 * _copyCoerceToDomain
1171 static CoerceToDomain *
1172 _copyCoerceToDomain(CoerceToDomain *from)
1174 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1176 COPY_NODE_FIELD(arg);
1177 COPY_SCALAR_FIELD(resulttype);
1178 COPY_SCALAR_FIELD(resulttypmod);
1179 COPY_SCALAR_FIELD(coercionformat);
1185 * _copyCoerceToDomainValue
1187 static CoerceToDomainValue *
1188 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1190 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1192 COPY_SCALAR_FIELD(typeId);
1193 COPY_SCALAR_FIELD(typeMod);
1201 static SetToDefault *
1202 _copySetToDefault(SetToDefault *from)
1204 SetToDefault *newnode = makeNode(SetToDefault);
1206 COPY_SCALAR_FIELD(typeId);
1207 COPY_SCALAR_FIELD(typeMod);
1215 static TargetEntry *
1216 _copyTargetEntry(TargetEntry *from)
1218 TargetEntry *newnode = makeNode(TargetEntry);
1220 COPY_NODE_FIELD(expr);
1221 COPY_SCALAR_FIELD(resno);
1222 COPY_STRING_FIELD(resname);
1223 COPY_SCALAR_FIELD(ressortgroupref);
1224 COPY_SCALAR_FIELD(resorigtbl);
1225 COPY_SCALAR_FIELD(resorigcol);
1226 COPY_SCALAR_FIELD(resjunk);
1234 static RangeTblRef *
1235 _copyRangeTblRef(RangeTblRef *from)
1237 RangeTblRef *newnode = makeNode(RangeTblRef);
1239 COPY_SCALAR_FIELD(rtindex);
1248 _copyJoinExpr(JoinExpr *from)
1250 JoinExpr *newnode = makeNode(JoinExpr);
1252 COPY_SCALAR_FIELD(jointype);
1253 COPY_SCALAR_FIELD(isNatural);
1254 COPY_NODE_FIELD(larg);
1255 COPY_NODE_FIELD(rarg);
1256 COPY_NODE_FIELD(using);
1257 COPY_NODE_FIELD(quals);
1258 COPY_NODE_FIELD(alias);
1259 COPY_SCALAR_FIELD(rtindex);
1268 _copyFromExpr(FromExpr *from)
1270 FromExpr *newnode = makeNode(FromExpr);
1272 COPY_NODE_FIELD(fromlist);
1273 COPY_NODE_FIELD(quals);
1278 /* ****************************************************************
1279 * relation.h copy functions
1281 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1282 * There are some subsidiary structs that are useful to copy, though.
1283 * ****************************************************************
1290 _copyPathKey(PathKey *from)
1292 PathKey *newnode = makeNode(PathKey);
1294 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1295 COPY_SCALAR_FIELD(pk_eclass);
1296 COPY_SCALAR_FIELD(pk_opfamily);
1297 COPY_SCALAR_FIELD(pk_strategy);
1298 COPY_SCALAR_FIELD(pk_nulls_first);
1306 static RestrictInfo *
1307 _copyRestrictInfo(RestrictInfo *from)
1309 RestrictInfo *newnode = makeNode(RestrictInfo);
1311 COPY_NODE_FIELD(clause);
1312 COPY_SCALAR_FIELD(is_pushed_down);
1313 COPY_SCALAR_FIELD(outerjoin_delayed);
1314 COPY_SCALAR_FIELD(can_join);
1315 COPY_SCALAR_FIELD(pseudoconstant);
1316 COPY_BITMAPSET_FIELD(clause_relids);
1317 COPY_BITMAPSET_FIELD(required_relids);
1318 COPY_BITMAPSET_FIELD(left_relids);
1319 COPY_BITMAPSET_FIELD(right_relids);
1320 COPY_NODE_FIELD(orclause);
1321 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1322 COPY_SCALAR_FIELD(parent_ec);
1323 COPY_SCALAR_FIELD(eval_cost);
1324 COPY_SCALAR_FIELD(this_selec);
1325 COPY_NODE_FIELD(mergeopfamilies);
1326 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1327 COPY_SCALAR_FIELD(left_ec);
1328 COPY_SCALAR_FIELD(right_ec);
1329 COPY_SCALAR_FIELD(outer_is_left);
1330 COPY_SCALAR_FIELD(hashjoinoperator);
1331 COPY_SCALAR_FIELD(left_bucketsize);
1332 COPY_SCALAR_FIELD(right_bucketsize);
1338 * _copyOuterJoinInfo
1340 static OuterJoinInfo *
1341 _copyOuterJoinInfo(OuterJoinInfo *from)
1343 OuterJoinInfo *newnode = makeNode(OuterJoinInfo);
1345 COPY_BITMAPSET_FIELD(min_lefthand);
1346 COPY_BITMAPSET_FIELD(min_righthand);
1347 COPY_SCALAR_FIELD(is_full_join);
1348 COPY_SCALAR_FIELD(lhs_strict);
1356 static InClauseInfo *
1357 _copyInClauseInfo(InClauseInfo *from)
1359 InClauseInfo *newnode = makeNode(InClauseInfo);
1361 COPY_BITMAPSET_FIELD(lefthand);
1362 COPY_BITMAPSET_FIELD(righthand);
1363 COPY_NODE_FIELD(sub_targetlist);
1364 COPY_NODE_FIELD(in_operators);
1370 * _copyAppendRelInfo
1372 static AppendRelInfo *
1373 _copyAppendRelInfo(AppendRelInfo *from)
1375 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1377 COPY_SCALAR_FIELD(parent_relid);
1378 COPY_SCALAR_FIELD(child_relid);
1379 COPY_SCALAR_FIELD(parent_reltype);
1380 COPY_SCALAR_FIELD(child_reltype);
1381 COPY_NODE_FIELD(col_mappings);
1382 COPY_NODE_FIELD(translated_vars);
1383 COPY_SCALAR_FIELD(parent_reloid);
1388 /* ****************************************************************
1389 * parsenodes.h copy functions
1390 * ****************************************************************
1393 static RangeTblEntry *
1394 _copyRangeTblEntry(RangeTblEntry *from)
1396 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1398 COPY_SCALAR_FIELD(rtekind);
1399 COPY_SCALAR_FIELD(relid);
1400 COPY_NODE_FIELD(subquery);
1401 COPY_NODE_FIELD(funcexpr);
1402 COPY_NODE_FIELD(funccoltypes);
1403 COPY_NODE_FIELD(funccoltypmods);
1404 COPY_NODE_FIELD(values_lists);
1405 COPY_SCALAR_FIELD(jointype);
1406 COPY_NODE_FIELD(joinaliasvars);
1407 COPY_NODE_FIELD(alias);
1408 COPY_NODE_FIELD(eref);
1409 COPY_SCALAR_FIELD(inh);
1410 COPY_SCALAR_FIELD(inFromCl);
1411 COPY_SCALAR_FIELD(requiredPerms);
1412 COPY_SCALAR_FIELD(checkAsUser);
1417 static FkConstraint *
1418 _copyFkConstraint(FkConstraint *from)
1420 FkConstraint *newnode = makeNode(FkConstraint);
1422 COPY_STRING_FIELD(constr_name);
1423 COPY_NODE_FIELD(pktable);
1424 COPY_NODE_FIELD(fk_attrs);
1425 COPY_NODE_FIELD(pk_attrs);
1426 COPY_SCALAR_FIELD(fk_matchtype);
1427 COPY_SCALAR_FIELD(fk_upd_action);
1428 COPY_SCALAR_FIELD(fk_del_action);
1429 COPY_SCALAR_FIELD(deferrable);
1430 COPY_SCALAR_FIELD(initdeferred);
1431 COPY_SCALAR_FIELD(skip_validation);
1437 _copySortClause(SortClause *from)
1439 SortClause *newnode = makeNode(SortClause);
1441 COPY_SCALAR_FIELD(tleSortGroupRef);
1442 COPY_SCALAR_FIELD(sortop);
1443 COPY_SCALAR_FIELD(nulls_first);
1448 static GroupClause *
1449 _copyGroupClause(GroupClause *from)
1451 GroupClause *newnode = makeNode(GroupClause);
1453 COPY_SCALAR_FIELD(tleSortGroupRef);
1454 COPY_SCALAR_FIELD(sortop);
1455 COPY_SCALAR_FIELD(nulls_first);
1460 static RowMarkClause *
1461 _copyRowMarkClause(RowMarkClause *from)
1463 RowMarkClause *newnode = makeNode(RowMarkClause);
1465 COPY_SCALAR_FIELD(rti);
1466 COPY_SCALAR_FIELD(forUpdate);
1467 COPY_SCALAR_FIELD(noWait);
1473 _copyAExpr(A_Expr *from)
1475 A_Expr *newnode = makeNode(A_Expr);
1477 COPY_SCALAR_FIELD(kind);
1478 COPY_NODE_FIELD(name);
1479 COPY_NODE_FIELD(lexpr);
1480 COPY_NODE_FIELD(rexpr);
1481 COPY_SCALAR_FIELD(location);
1487 _copyColumnRef(ColumnRef *from)
1489 ColumnRef *newnode = makeNode(ColumnRef);
1491 COPY_NODE_FIELD(fields);
1492 COPY_SCALAR_FIELD(location);
1498 _copyParamRef(ParamRef *from)
1500 ParamRef *newnode = makeNode(ParamRef);
1502 COPY_SCALAR_FIELD(number);
1508 _copyAConst(A_Const *from)
1510 A_Const *newnode = makeNode(A_Const);
1512 /* This part must duplicate _copyValue */
1513 COPY_SCALAR_FIELD(val.type);
1514 switch (from->val.type)
1517 COPY_SCALAR_FIELD(val.val.ival);
1522 COPY_STRING_FIELD(val.val.str);
1528 elog(ERROR, "unrecognized node type: %d",
1529 (int) from->val.type);
1533 COPY_NODE_FIELD(typename);
1539 _copyFuncCall(FuncCall *from)
1541 FuncCall *newnode = makeNode(FuncCall);
1543 COPY_NODE_FIELD(funcname);
1544 COPY_NODE_FIELD(args);
1545 COPY_SCALAR_FIELD(agg_star);
1546 COPY_SCALAR_FIELD(agg_distinct);
1547 COPY_SCALAR_FIELD(location);
1553 _copyAIndices(A_Indices *from)
1555 A_Indices *newnode = makeNode(A_Indices);
1557 COPY_NODE_FIELD(lidx);
1558 COPY_NODE_FIELD(uidx);
1563 static A_Indirection *
1564 _copyA_Indirection(A_Indirection *from)
1566 A_Indirection *newnode = makeNode(A_Indirection);
1568 COPY_NODE_FIELD(arg);
1569 COPY_NODE_FIELD(indirection);
1575 _copyResTarget(ResTarget *from)
1577 ResTarget *newnode = makeNode(ResTarget);
1579 COPY_STRING_FIELD(name);
1580 COPY_NODE_FIELD(indirection);
1581 COPY_NODE_FIELD(val);
1582 COPY_SCALAR_FIELD(location);
1588 _copyTypeName(TypeName *from)
1590 TypeName *newnode = makeNode(TypeName);
1592 COPY_NODE_FIELD(names);
1593 COPY_SCALAR_FIELD(typeid);
1594 COPY_SCALAR_FIELD(timezone);
1595 COPY_SCALAR_FIELD(setof);
1596 COPY_SCALAR_FIELD(pct_type);
1597 COPY_NODE_FIELD(typmods);
1598 COPY_SCALAR_FIELD(typemod);
1599 COPY_NODE_FIELD(arrayBounds);
1600 COPY_SCALAR_FIELD(location);
1606 _copySortBy(SortBy *from)
1608 SortBy *newnode = makeNode(SortBy);
1610 COPY_SCALAR_FIELD(sortby_dir);
1611 COPY_SCALAR_FIELD(sortby_nulls);
1612 COPY_NODE_FIELD(useOp);
1613 COPY_NODE_FIELD(node);
1618 static RangeSubselect *
1619 _copyRangeSubselect(RangeSubselect *from)
1621 RangeSubselect *newnode = makeNode(RangeSubselect);
1623 COPY_NODE_FIELD(subquery);
1624 COPY_NODE_FIELD(alias);
1629 static RangeFunction *
1630 _copyRangeFunction(RangeFunction *from)
1632 RangeFunction *newnode = makeNode(RangeFunction);
1634 COPY_NODE_FIELD(funccallnode);
1635 COPY_NODE_FIELD(alias);
1636 COPY_NODE_FIELD(coldeflist);
1642 _copyTypeCast(TypeCast *from)
1644 TypeCast *newnode = makeNode(TypeCast);
1646 COPY_NODE_FIELD(arg);
1647 COPY_NODE_FIELD(typename);
1653 _copyIndexElem(IndexElem *from)
1655 IndexElem *newnode = makeNode(IndexElem);
1657 COPY_STRING_FIELD(name);
1658 COPY_NODE_FIELD(expr);
1659 COPY_NODE_FIELD(opclass);
1660 COPY_SCALAR_FIELD(ordering);
1661 COPY_SCALAR_FIELD(nulls_ordering);
1667 _copyColumnDef(ColumnDef *from)
1669 ColumnDef *newnode = makeNode(ColumnDef);
1671 COPY_STRING_FIELD(colname);
1672 COPY_NODE_FIELD(typename);
1673 COPY_SCALAR_FIELD(inhcount);
1674 COPY_SCALAR_FIELD(is_local);
1675 COPY_SCALAR_FIELD(is_not_null);
1676 COPY_NODE_FIELD(raw_default);
1677 COPY_STRING_FIELD(cooked_default);
1678 COPY_NODE_FIELD(constraints);
1684 _copyConstraint(Constraint *from)
1686 Constraint *newnode = makeNode(Constraint);
1688 COPY_SCALAR_FIELD(contype);
1689 COPY_STRING_FIELD(name);
1690 COPY_NODE_FIELD(raw_expr);
1691 COPY_STRING_FIELD(cooked_expr);
1692 COPY_NODE_FIELD(keys);
1693 COPY_NODE_FIELD(options);
1694 COPY_STRING_FIELD(indexspace);
1700 _copyDefElem(DefElem *from)
1702 DefElem *newnode = makeNode(DefElem);
1704 COPY_STRING_FIELD(defname);
1705 COPY_NODE_FIELD(arg);
1710 static LockingClause *
1711 _copyLockingClause(LockingClause *from)
1713 LockingClause *newnode = makeNode(LockingClause);
1715 COPY_NODE_FIELD(lockedRels);
1716 COPY_SCALAR_FIELD(forUpdate);
1717 COPY_SCALAR_FIELD(noWait);
1723 _copyQuery(Query *from)
1725 Query *newnode = makeNode(Query);
1727 COPY_SCALAR_FIELD(commandType);
1728 COPY_SCALAR_FIELD(querySource);
1729 COPY_SCALAR_FIELD(canSetTag);
1730 COPY_NODE_FIELD(utilityStmt);
1731 COPY_SCALAR_FIELD(resultRelation);
1732 COPY_NODE_FIELD(into);
1733 COPY_NODE_FIELD(intoOptions);
1734 COPY_SCALAR_FIELD(intoOnCommit);
1735 COPY_STRING_FIELD(intoTableSpaceName);
1736 COPY_SCALAR_FIELD(hasAggs);
1737 COPY_SCALAR_FIELD(hasSubLinks);
1738 COPY_NODE_FIELD(rtable);
1739 COPY_NODE_FIELD(jointree);
1740 COPY_NODE_FIELD(targetList);
1741 COPY_NODE_FIELD(returningList);
1742 COPY_NODE_FIELD(groupClause);
1743 COPY_NODE_FIELD(havingQual);
1744 COPY_NODE_FIELD(distinctClause);
1745 COPY_NODE_FIELD(sortClause);
1746 COPY_NODE_FIELD(limitOffset);
1747 COPY_NODE_FIELD(limitCount);
1748 COPY_NODE_FIELD(rowMarks);
1749 COPY_NODE_FIELD(setOperations);
1750 COPY_NODE_FIELD(resultRelations);
1751 COPY_NODE_FIELD(returningLists);
1757 _copyInsertStmt(InsertStmt *from)
1759 InsertStmt *newnode = makeNode(InsertStmt);
1761 COPY_NODE_FIELD(relation);
1762 COPY_NODE_FIELD(cols);
1763 COPY_NODE_FIELD(selectStmt);
1764 COPY_NODE_FIELD(returningList);
1770 _copyDeleteStmt(DeleteStmt *from)
1772 DeleteStmt *newnode = makeNode(DeleteStmt);
1774 COPY_NODE_FIELD(relation);
1775 COPY_NODE_FIELD(usingClause);
1776 COPY_NODE_FIELD(whereClause);
1777 COPY_NODE_FIELD(returningList);
1783 _copyUpdateStmt(UpdateStmt *from)
1785 UpdateStmt *newnode = makeNode(UpdateStmt);
1787 COPY_NODE_FIELD(relation);
1788 COPY_NODE_FIELD(targetList);
1789 COPY_NODE_FIELD(whereClause);
1790 COPY_NODE_FIELD(fromClause);
1791 COPY_NODE_FIELD(returningList);
1797 _copySelectStmt(SelectStmt *from)
1799 SelectStmt *newnode = makeNode(SelectStmt);
1801 COPY_NODE_FIELD(distinctClause);
1802 COPY_NODE_FIELD(into);
1803 COPY_NODE_FIELD(intoColNames);
1804 COPY_NODE_FIELD(intoOptions);
1805 COPY_SCALAR_FIELD(intoOnCommit);
1806 COPY_STRING_FIELD(intoTableSpaceName);
1807 COPY_NODE_FIELD(targetList);
1808 COPY_NODE_FIELD(fromClause);
1809 COPY_NODE_FIELD(whereClause);
1810 COPY_NODE_FIELD(groupClause);
1811 COPY_NODE_FIELD(havingClause);
1812 COPY_NODE_FIELD(valuesLists);
1813 COPY_NODE_FIELD(sortClause);
1814 COPY_NODE_FIELD(limitOffset);
1815 COPY_NODE_FIELD(limitCount);
1816 COPY_NODE_FIELD(lockingClause);
1817 COPY_SCALAR_FIELD(op);
1818 COPY_SCALAR_FIELD(all);
1819 COPY_NODE_FIELD(larg);
1820 COPY_NODE_FIELD(rarg);
1825 static SetOperationStmt *
1826 _copySetOperationStmt(SetOperationStmt *from)
1828 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1830 COPY_SCALAR_FIELD(op);
1831 COPY_SCALAR_FIELD(all);
1832 COPY_NODE_FIELD(larg);
1833 COPY_NODE_FIELD(rarg);
1834 COPY_NODE_FIELD(colTypes);
1835 COPY_NODE_FIELD(colTypmods);
1840 static AlterTableStmt *
1841 _copyAlterTableStmt(AlterTableStmt *from)
1843 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1845 COPY_NODE_FIELD(relation);
1846 COPY_NODE_FIELD(cmds);
1847 COPY_SCALAR_FIELD(relkind);
1852 static AlterTableCmd *
1853 _copyAlterTableCmd(AlterTableCmd *from)
1855 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1857 COPY_SCALAR_FIELD(subtype);
1858 COPY_STRING_FIELD(name);
1859 COPY_NODE_FIELD(def);
1860 COPY_NODE_FIELD(transform);
1861 COPY_SCALAR_FIELD(behavior);
1866 static AlterDomainStmt *
1867 _copyAlterDomainStmt(AlterDomainStmt *from)
1869 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1871 COPY_SCALAR_FIELD(subtype);
1872 COPY_NODE_FIELD(typename);
1873 COPY_STRING_FIELD(name);
1874 COPY_NODE_FIELD(def);
1875 COPY_SCALAR_FIELD(behavior);
1881 _copyGrantStmt(GrantStmt *from)
1883 GrantStmt *newnode = makeNode(GrantStmt);
1885 COPY_SCALAR_FIELD(is_grant);
1886 COPY_SCALAR_FIELD(objtype);
1887 COPY_NODE_FIELD(objects);
1888 COPY_NODE_FIELD(privileges);
1889 COPY_NODE_FIELD(grantees);
1890 COPY_SCALAR_FIELD(grant_option);
1891 COPY_SCALAR_FIELD(behavior);
1896 static PrivGrantee *
1897 _copyPrivGrantee(PrivGrantee *from)
1899 PrivGrantee *newnode = makeNode(PrivGrantee);
1901 COPY_STRING_FIELD(rolname);
1906 static FuncWithArgs *
1907 _copyFuncWithArgs(FuncWithArgs *from)
1909 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1911 COPY_NODE_FIELD(funcname);
1912 COPY_NODE_FIELD(funcargs);
1917 static GrantRoleStmt *
1918 _copyGrantRoleStmt(GrantRoleStmt *from)
1920 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
1922 COPY_NODE_FIELD(granted_roles);
1923 COPY_NODE_FIELD(grantee_roles);
1924 COPY_SCALAR_FIELD(is_grant);
1925 COPY_SCALAR_FIELD(admin_opt);
1926 COPY_STRING_FIELD(grantor);
1927 COPY_SCALAR_FIELD(behavior);
1932 static DeclareCursorStmt *
1933 _copyDeclareCursorStmt(DeclareCursorStmt *from)
1935 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
1937 COPY_STRING_FIELD(portalname);
1938 COPY_SCALAR_FIELD(options);
1939 COPY_NODE_FIELD(query);
1944 static ClosePortalStmt *
1945 _copyClosePortalStmt(ClosePortalStmt *from)
1947 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
1949 COPY_STRING_FIELD(portalname);
1954 static ClusterStmt *
1955 _copyClusterStmt(ClusterStmt *from)
1957 ClusterStmt *newnode = makeNode(ClusterStmt);
1959 COPY_NODE_FIELD(relation);
1960 COPY_STRING_FIELD(indexname);
1966 _copyCopyStmt(CopyStmt *from)
1968 CopyStmt *newnode = makeNode(CopyStmt);
1970 COPY_NODE_FIELD(relation);
1971 COPY_NODE_FIELD(query);
1972 COPY_NODE_FIELD(attlist);
1973 COPY_SCALAR_FIELD(is_from);
1974 COPY_STRING_FIELD(filename);
1975 COPY_NODE_FIELD(options);
1981 _copyCreateStmt(CreateStmt *from)
1983 CreateStmt *newnode = makeNode(CreateStmt);
1985 COPY_NODE_FIELD(relation);
1986 COPY_NODE_FIELD(tableElts);
1987 COPY_NODE_FIELD(inhRelations);
1988 COPY_NODE_FIELD(constraints);
1989 COPY_NODE_FIELD(options);
1990 COPY_SCALAR_FIELD(oncommit);
1991 COPY_STRING_FIELD(tablespacename);
1996 static InhRelation *
1997 _copyInhRelation(InhRelation *from)
1999 InhRelation *newnode = makeNode(InhRelation);
2001 COPY_NODE_FIELD(relation);
2002 COPY_NODE_FIELD(options);
2008 _copyDefineStmt(DefineStmt *from)
2010 DefineStmt *newnode = makeNode(DefineStmt);
2012 COPY_SCALAR_FIELD(kind);
2013 COPY_SCALAR_FIELD(oldstyle);
2014 COPY_NODE_FIELD(defnames);
2015 COPY_NODE_FIELD(args);
2016 COPY_NODE_FIELD(definition);
2022 _copyDropStmt(DropStmt *from)
2024 DropStmt *newnode = makeNode(DropStmt);
2026 COPY_NODE_FIELD(objects);
2027 COPY_SCALAR_FIELD(removeType);
2028 COPY_SCALAR_FIELD(behavior);
2029 COPY_SCALAR_FIELD(missing_ok);
2034 static TruncateStmt *
2035 _copyTruncateStmt(TruncateStmt *from)
2037 TruncateStmt *newnode = makeNode(TruncateStmt);
2039 COPY_NODE_FIELD(relations);
2040 COPY_SCALAR_FIELD(behavior);
2045 static CommentStmt *
2046 _copyCommentStmt(CommentStmt *from)
2048 CommentStmt *newnode = makeNode(CommentStmt);
2050 COPY_SCALAR_FIELD(objtype);
2051 COPY_NODE_FIELD(objname);
2052 COPY_NODE_FIELD(objargs);
2053 COPY_STRING_FIELD(comment);
2059 _copyFetchStmt(FetchStmt *from)
2061 FetchStmt *newnode = makeNode(FetchStmt);
2063 COPY_SCALAR_FIELD(direction);
2064 COPY_SCALAR_FIELD(howMany);
2065 COPY_STRING_FIELD(portalname);
2066 COPY_SCALAR_FIELD(ismove);
2072 _copyIndexStmt(IndexStmt *from)
2074 IndexStmt *newnode = makeNode(IndexStmt);
2076 COPY_STRING_FIELD(idxname);
2077 COPY_NODE_FIELD(relation);
2078 COPY_STRING_FIELD(accessMethod);
2079 COPY_STRING_FIELD(tableSpace);
2080 COPY_NODE_FIELD(indexParams);
2081 COPY_NODE_FIELD(options);
2082 COPY_NODE_FIELD(whereClause);
2083 COPY_NODE_FIELD(rangetable);
2084 COPY_SCALAR_FIELD(unique);
2085 COPY_SCALAR_FIELD(primary);
2086 COPY_SCALAR_FIELD(isconstraint);
2087 COPY_SCALAR_FIELD(concurrent);
2092 static CreateFunctionStmt *
2093 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2095 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2097 COPY_SCALAR_FIELD(replace);
2098 COPY_NODE_FIELD(funcname);
2099 COPY_NODE_FIELD(parameters);
2100 COPY_NODE_FIELD(returnType);
2101 COPY_NODE_FIELD(options);
2102 COPY_NODE_FIELD(withClause);
2107 static FunctionParameter *
2108 _copyFunctionParameter(FunctionParameter *from)
2110 FunctionParameter *newnode = makeNode(FunctionParameter);
2112 COPY_STRING_FIELD(name);
2113 COPY_NODE_FIELD(argType);
2114 COPY_SCALAR_FIELD(mode);
2119 static AlterFunctionStmt *
2120 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2122 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2124 COPY_NODE_FIELD(func);
2125 COPY_NODE_FIELD(actions);
2130 static RemoveFuncStmt *
2131 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2133 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2135 COPY_SCALAR_FIELD(kind);
2136 COPY_NODE_FIELD(name);
2137 COPY_NODE_FIELD(args);
2138 COPY_SCALAR_FIELD(behavior);
2139 COPY_SCALAR_FIELD(missing_ok);
2144 static RemoveOpClassStmt *
2145 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2147 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2149 COPY_NODE_FIELD(opclassname);
2150 COPY_STRING_FIELD(amname);
2151 COPY_SCALAR_FIELD(behavior);
2152 COPY_SCALAR_FIELD(missing_ok);
2158 _copyRenameStmt(RenameStmt *from)
2160 RenameStmt *newnode = makeNode(RenameStmt);
2162 COPY_SCALAR_FIELD(renameType);
2163 COPY_NODE_FIELD(relation);
2164 COPY_NODE_FIELD(object);
2165 COPY_NODE_FIELD(objarg);
2166 COPY_STRING_FIELD(subname);
2167 COPY_STRING_FIELD(newname);
2172 static AlterObjectSchemaStmt *
2173 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2175 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2177 COPY_SCALAR_FIELD(objectType);
2178 COPY_NODE_FIELD(relation);
2179 COPY_NODE_FIELD(object);
2180 COPY_NODE_FIELD(objarg);
2181 COPY_STRING_FIELD(addname);
2182 COPY_STRING_FIELD(newschema);
2187 static AlterOwnerStmt *
2188 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2190 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2192 COPY_SCALAR_FIELD(objectType);
2193 COPY_NODE_FIELD(relation);
2194 COPY_NODE_FIELD(object);
2195 COPY_NODE_FIELD(objarg);
2196 COPY_STRING_FIELD(addname);
2197 COPY_STRING_FIELD(newowner);
2203 _copyRuleStmt(RuleStmt *from)
2205 RuleStmt *newnode = makeNode(RuleStmt);
2207 COPY_NODE_FIELD(relation);
2208 COPY_STRING_FIELD(rulename);
2209 COPY_NODE_FIELD(whereClause);
2210 COPY_SCALAR_FIELD(event);
2211 COPY_SCALAR_FIELD(instead);
2212 COPY_NODE_FIELD(actions);
2213 COPY_SCALAR_FIELD(replace);
2219 _copyNotifyStmt(NotifyStmt *from)
2221 NotifyStmt *newnode = makeNode(NotifyStmt);
2223 COPY_NODE_FIELD(relation);
2229 _copyListenStmt(ListenStmt *from)
2231 ListenStmt *newnode = makeNode(ListenStmt);
2233 COPY_NODE_FIELD(relation);
2238 static UnlistenStmt *
2239 _copyUnlistenStmt(UnlistenStmt *from)
2241 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2243 COPY_NODE_FIELD(relation);
2248 static TransactionStmt *
2249 _copyTransactionStmt(TransactionStmt *from)
2251 TransactionStmt *newnode = makeNode(TransactionStmt);
2253 COPY_SCALAR_FIELD(kind);
2254 COPY_NODE_FIELD(options);
2255 COPY_STRING_FIELD(gid);
2260 static CompositeTypeStmt *
2261 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2263 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2265 COPY_NODE_FIELD(typevar);
2266 COPY_NODE_FIELD(coldeflist);
2272 _copyViewStmt(ViewStmt *from)
2274 ViewStmt *newnode = makeNode(ViewStmt);
2276 COPY_NODE_FIELD(view);
2277 COPY_NODE_FIELD(aliases);
2278 COPY_NODE_FIELD(query);
2279 COPY_SCALAR_FIELD(replace);
2285 _copyLoadStmt(LoadStmt *from)
2287 LoadStmt *newnode = makeNode(LoadStmt);
2289 COPY_STRING_FIELD(filename);
2294 static CreateDomainStmt *
2295 _copyCreateDomainStmt(CreateDomainStmt *from)
2297 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2299 COPY_NODE_FIELD(domainname);
2300 COPY_NODE_FIELD(typename);
2301 COPY_NODE_FIELD(constraints);
2306 static CreateOpClassStmt *
2307 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2309 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2311 COPY_NODE_FIELD(opclassname);
2312 COPY_NODE_FIELD(opfamilyname);
2313 COPY_STRING_FIELD(amname);
2314 COPY_NODE_FIELD(datatype);
2315 COPY_NODE_FIELD(items);
2316 COPY_SCALAR_FIELD(isDefault);
2321 static CreateOpClassItem *
2322 _copyCreateOpClassItem(CreateOpClassItem *from)
2324 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2326 COPY_SCALAR_FIELD(itemtype);
2327 COPY_NODE_FIELD(name);
2328 COPY_NODE_FIELD(args);
2329 COPY_SCALAR_FIELD(number);
2330 COPY_SCALAR_FIELD(recheck);
2331 COPY_NODE_FIELD(storedtype);
2336 static CreatedbStmt *
2337 _copyCreatedbStmt(CreatedbStmt *from)
2339 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2341 COPY_STRING_FIELD(dbname);
2342 COPY_NODE_FIELD(options);
2347 static AlterDatabaseStmt *
2348 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2350 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2352 COPY_STRING_FIELD(dbname);
2353 COPY_NODE_FIELD(options);
2358 static AlterDatabaseSetStmt *
2359 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2361 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2363 COPY_STRING_FIELD(dbname);
2364 COPY_STRING_FIELD(variable);
2365 COPY_NODE_FIELD(value);
2371 _copyDropdbStmt(DropdbStmt *from)
2373 DropdbStmt *newnode = makeNode(DropdbStmt);
2375 COPY_STRING_FIELD(dbname);
2376 COPY_SCALAR_FIELD(missing_ok);
2382 _copyVacuumStmt(VacuumStmt *from)
2384 VacuumStmt *newnode = makeNode(VacuumStmt);
2386 COPY_SCALAR_FIELD(vacuum);
2387 COPY_SCALAR_FIELD(full);
2388 COPY_SCALAR_FIELD(analyze);
2389 COPY_SCALAR_FIELD(verbose);
2390 COPY_SCALAR_FIELD(freeze_min_age);
2391 COPY_NODE_FIELD(relation);
2392 COPY_NODE_FIELD(va_cols);
2397 static ExplainStmt *
2398 _copyExplainStmt(ExplainStmt *from)
2400 ExplainStmt *newnode = makeNode(ExplainStmt);
2402 COPY_NODE_FIELD(query);
2403 COPY_SCALAR_FIELD(verbose);
2404 COPY_SCALAR_FIELD(analyze);
2409 static CreateSeqStmt *
2410 _copyCreateSeqStmt(CreateSeqStmt *from)
2412 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2414 COPY_NODE_FIELD(sequence);
2415 COPY_NODE_FIELD(options);
2420 static AlterSeqStmt *
2421 _copyAlterSeqStmt(AlterSeqStmt *from)
2423 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2425 COPY_NODE_FIELD(sequence);
2426 COPY_NODE_FIELD(options);
2431 static VariableSetStmt *
2432 _copyVariableSetStmt(VariableSetStmt *from)
2434 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2436 COPY_STRING_FIELD(name);
2437 COPY_NODE_FIELD(args);
2438 COPY_SCALAR_FIELD(is_local);
2443 static VariableShowStmt *
2444 _copyVariableShowStmt(VariableShowStmt *from)
2446 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2448 COPY_STRING_FIELD(name);
2453 static VariableResetStmt *
2454 _copyVariableResetStmt(VariableResetStmt *from)
2456 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2458 COPY_STRING_FIELD(name);
2463 static CreateTableSpaceStmt *
2464 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2466 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2468 COPY_STRING_FIELD(tablespacename);
2469 COPY_STRING_FIELD(owner);
2470 COPY_STRING_FIELD(location);
2475 static DropTableSpaceStmt *
2476 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2478 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2480 COPY_STRING_FIELD(tablespacename);
2481 COPY_SCALAR_FIELD(missing_ok);
2486 static CreateTrigStmt *
2487 _copyCreateTrigStmt(CreateTrigStmt *from)
2489 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2491 COPY_STRING_FIELD(trigname);
2492 COPY_NODE_FIELD(relation);
2493 COPY_NODE_FIELD(funcname);
2494 COPY_NODE_FIELD(args);
2495 COPY_SCALAR_FIELD(before);
2496 COPY_SCALAR_FIELD(row);
2497 strcpy(newnode->actions, from->actions); /* in-line string field */
2498 COPY_SCALAR_FIELD(isconstraint);
2499 COPY_SCALAR_FIELD(deferrable);
2500 COPY_SCALAR_FIELD(initdeferred);
2501 COPY_NODE_FIELD(constrrel);
2506 static DropPropertyStmt *
2507 _copyDropPropertyStmt(DropPropertyStmt *from)
2509 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2511 COPY_NODE_FIELD(relation);
2512 COPY_STRING_FIELD(property);
2513 COPY_SCALAR_FIELD(removeType);
2514 COPY_SCALAR_FIELD(behavior);
2515 COPY_SCALAR_FIELD(missing_ok);
2520 static CreatePLangStmt *
2521 _copyCreatePLangStmt(CreatePLangStmt *from)
2523 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2525 COPY_STRING_FIELD(plname);
2526 COPY_NODE_FIELD(plhandler);
2527 COPY_NODE_FIELD(plvalidator);
2528 COPY_SCALAR_FIELD(pltrusted);
2533 static DropPLangStmt *
2534 _copyDropPLangStmt(DropPLangStmt *from)
2536 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2538 COPY_STRING_FIELD(plname);
2539 COPY_SCALAR_FIELD(behavior);
2540 COPY_SCALAR_FIELD(missing_ok);
2545 static CreateRoleStmt *
2546 _copyCreateRoleStmt(CreateRoleStmt *from)
2548 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2550 COPY_SCALAR_FIELD(stmt_type);
2551 COPY_STRING_FIELD(role);
2552 COPY_NODE_FIELD(options);
2557 static AlterRoleStmt *
2558 _copyAlterRoleStmt(AlterRoleStmt *from)
2560 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2562 COPY_STRING_FIELD(role);
2563 COPY_NODE_FIELD(options);
2564 COPY_SCALAR_FIELD(action);
2569 static AlterRoleSetStmt *
2570 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2572 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2574 COPY_STRING_FIELD(role);
2575 COPY_STRING_FIELD(variable);
2576 COPY_NODE_FIELD(value);
2581 static DropRoleStmt *
2582 _copyDropRoleStmt(DropRoleStmt *from)
2584 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2586 COPY_NODE_FIELD(roles);
2587 COPY_SCALAR_FIELD(missing_ok);
2593 _copyLockStmt(LockStmt *from)
2595 LockStmt *newnode = makeNode(LockStmt);
2597 COPY_NODE_FIELD(relations);
2598 COPY_SCALAR_FIELD(mode);
2599 COPY_SCALAR_FIELD(nowait);
2604 static ConstraintsSetStmt *
2605 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2607 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2609 COPY_NODE_FIELD(constraints);
2610 COPY_SCALAR_FIELD(deferred);
2615 static ReindexStmt *
2616 _copyReindexStmt(ReindexStmt *from)
2618 ReindexStmt *newnode = makeNode(ReindexStmt);
2620 COPY_SCALAR_FIELD(kind);
2621 COPY_NODE_FIELD(relation);
2622 COPY_STRING_FIELD(name);
2623 COPY_SCALAR_FIELD(do_system);
2624 COPY_SCALAR_FIELD(do_user);
2629 static CreateSchemaStmt *
2630 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2632 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2634 COPY_STRING_FIELD(schemaname);
2635 COPY_STRING_FIELD(authid);
2636 COPY_NODE_FIELD(schemaElts);
2641 static CreateConversionStmt *
2642 _copyCreateConversionStmt(CreateConversionStmt *from)
2644 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2646 COPY_NODE_FIELD(conversion_name);
2647 COPY_STRING_FIELD(for_encoding_name);
2648 COPY_STRING_FIELD(to_encoding_name);
2649 COPY_NODE_FIELD(func_name);
2650 COPY_SCALAR_FIELD(def);
2655 static CreateCastStmt *
2656 _copyCreateCastStmt(CreateCastStmt *from)
2658 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2660 COPY_NODE_FIELD(sourcetype);
2661 COPY_NODE_FIELD(targettype);
2662 COPY_NODE_FIELD(func);
2663 COPY_SCALAR_FIELD(context);
2668 static DropCastStmt *
2669 _copyDropCastStmt(DropCastStmt *from)
2671 DropCastStmt *newnode = makeNode(DropCastStmt);
2673 COPY_NODE_FIELD(sourcetype);
2674 COPY_NODE_FIELD(targettype);
2675 COPY_SCALAR_FIELD(behavior);
2676 COPY_SCALAR_FIELD(missing_ok);
2681 static PrepareStmt *
2682 _copyPrepareStmt(PrepareStmt *from)
2684 PrepareStmt *newnode = makeNode(PrepareStmt);
2686 COPY_STRING_FIELD(name);
2687 COPY_NODE_FIELD(argtypes);
2688 COPY_NODE_FIELD(argtype_oids);
2689 COPY_NODE_FIELD(query);
2694 static ExecuteStmt *
2695 _copyExecuteStmt(ExecuteStmt *from)
2697 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2699 COPY_STRING_FIELD(name);
2700 COPY_NODE_FIELD(into);
2701 COPY_NODE_FIELD(intoOptions);
2702 COPY_SCALAR_FIELD(into_on_commit);
2703 COPY_STRING_FIELD(into_tbl_space);
2704 COPY_NODE_FIELD(params);
2709 static DeallocateStmt *
2710 _copyDeallocateStmt(DeallocateStmt *from)
2712 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2714 COPY_STRING_FIELD(name);
2719 static DropOwnedStmt *
2720 _copyDropOwnedStmt(DropOwnedStmt *from)
2722 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2724 COPY_NODE_FIELD(roles);
2725 COPY_SCALAR_FIELD(behavior);
2730 static ReassignOwnedStmt *
2731 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
2733 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2735 COPY_NODE_FIELD(roles);
2736 COPY_SCALAR_FIELD(newrole);
2741 /* ****************************************************************
2742 * pg_list.h copy functions
2743 * ****************************************************************
2747 * Perform a deep copy of the specified list, using copyObject(). The
2748 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2749 * need deep copies, so they should be copied via list_copy()
2751 #define COPY_NODE_CELL(new, old) \
2752 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2753 lfirst(new) = copyObject(lfirst(old));
2756 _copyList(List *from)
2762 Assert(list_length(from) >= 1);
2764 new = makeNode(List);
2765 new->length = from->length;
2767 COPY_NODE_CELL(new->head, from->head);
2768 prev_new = new->head;
2769 curr_old = lnext(from->head);
2773 COPY_NODE_CELL(prev_new->next, curr_old);
2774 prev_new = prev_new->next;
2775 curr_old = curr_old->next;
2777 prev_new->next = NULL;
2778 new->tail = prev_new;
2783 /* ****************************************************************
2784 * value.h copy functions
2785 * ****************************************************************
2788 _copyValue(Value *from)
2790 Value *newnode = makeNode(Value);
2792 /* See also _copyAConst when changing this code! */
2794 COPY_SCALAR_FIELD(type);
2798 COPY_SCALAR_FIELD(val.ival);
2803 COPY_STRING_FIELD(val.str);
2809 elog(ERROR, "unrecognized node type: %d",
2819 * Create a copy of a Node tree or list. This is a "deep" copy: all
2820 * substructure is copied too, recursively.
2823 copyObject(void *from)
2830 switch (nodeTag(from))
2836 retval = _copyPlan(from);
2839 retval = _copyResult(from);
2842 retval = _copyAppend(from);
2845 retval = _copyBitmapAnd(from);
2848 retval = _copyBitmapOr(from);
2851 retval = _copyScan(from);
2854 retval = _copySeqScan(from);
2857 retval = _copyIndexScan(from);
2859 case T_BitmapIndexScan:
2860 retval = _copyBitmapIndexScan(from);
2862 case T_BitmapHeapScan:
2863 retval = _copyBitmapHeapScan(from);
2866 retval = _copyTidScan(from);
2868 case T_SubqueryScan:
2869 retval = _copySubqueryScan(from);
2871 case T_FunctionScan:
2872 retval = _copyFunctionScan(from);
2875 retval = _copyValuesScan(from);
2878 retval = _copyJoin(from);
2881 retval = _copyNestLoop(from);
2884 retval = _copyMergeJoin(from);
2887 retval = _copyHashJoin(from);
2890 retval = _copyMaterial(from);
2893 retval = _copySort(from);
2896 retval = _copyGroup(from);
2899 retval = _copyAgg(from);
2902 retval = _copyUnique(from);
2905 retval = _copyHash(from);
2908 retval = _copySetOp(from);
2911 retval = _copyLimit(from);
2918 retval = _copyAlias(from);
2921 retval = _copyRangeVar(from);
2924 retval = _copyVar(from);
2927 retval = _copyConst(from);
2930 retval = _copyParam(from);
2933 retval = _copyAggref(from);
2936 retval = _copyArrayRef(from);
2939 retval = _copyFuncExpr(from);
2942 retval = _copyOpExpr(from);
2944 case T_DistinctExpr:
2945 retval = _copyDistinctExpr(from);
2947 case T_ScalarArrayOpExpr:
2948 retval = _copyScalarArrayOpExpr(from);
2951 retval = _copyBoolExpr(from);
2954 retval = _copySubLink(from);
2957 retval = _copySubPlan(from);
2960 retval = _copyFieldSelect(from);
2963 retval = _copyFieldStore(from);
2966 retval = _copyRelabelType(from);
2968 case T_ConvertRowtypeExpr:
2969 retval = _copyConvertRowtypeExpr(from);
2972 retval = _copyCaseExpr(from);
2975 retval = _copyCaseWhen(from);
2977 case T_CaseTestExpr:
2978 retval = _copyCaseTestExpr(from);
2981 retval = _copyArrayExpr(from);
2984 retval = _copyRowExpr(from);
2986 case T_RowCompareExpr:
2987 retval = _copyRowCompareExpr(from);
2989 case T_CoalesceExpr:
2990 retval = _copyCoalesceExpr(from);
2993 retval = _copyMinMaxExpr(from);
2996 retval = _copyXmlExpr(from);
2999 retval = _copyNullIfExpr(from);
3002 retval = _copyNullTest(from);
3005 retval = _copyBooleanTest(from);
3007 case T_CoerceToDomain:
3008 retval = _copyCoerceToDomain(from);
3010 case T_CoerceToDomainValue:
3011 retval = _copyCoerceToDomainValue(from);
3013 case T_SetToDefault:
3014 retval = _copySetToDefault(from);
3017 retval = _copyTargetEntry(from);
3020 retval = _copyRangeTblRef(from);
3023 retval = _copyJoinExpr(from);
3026 retval = _copyFromExpr(from);
3033 retval = _copyPathKey(from);
3035 case T_RestrictInfo:
3036 retval = _copyRestrictInfo(from);
3038 case T_OuterJoinInfo:
3039 retval = _copyOuterJoinInfo(from);
3041 case T_InClauseInfo:
3042 retval = _copyInClauseInfo(from);
3044 case T_AppendRelInfo:
3045 retval = _copyAppendRelInfo(from);
3056 retval = _copyValue(from);
3063 retval = _copyList(from);
3067 * Lists of integers and OIDs don't need to be deep-copied, so we
3068 * perform a shallow copy via list_copy()
3072 retval = list_copy(from);
3079 retval = _copyQuery(from);
3082 retval = _copyInsertStmt(from);
3085 retval = _copyDeleteStmt(from);
3088 retval = _copyUpdateStmt(from);
3091 retval = _copySelectStmt(from);
3093 case T_SetOperationStmt:
3094 retval = _copySetOperationStmt(from);
3096 case T_AlterTableStmt:
3097 retval = _copyAlterTableStmt(from);
3099 case T_AlterTableCmd:
3100 retval = _copyAlterTableCmd(from);
3102 case T_AlterDomainStmt:
3103 retval = _copyAlterDomainStmt(from);
3106 retval = _copyGrantStmt(from);
3108 case T_GrantRoleStmt:
3109 retval = _copyGrantRoleStmt(from);
3111 case T_DeclareCursorStmt:
3112 retval = _copyDeclareCursorStmt(from);
3114 case T_ClosePortalStmt:
3115 retval = _copyClosePortalStmt(from);
3118 retval = _copyClusterStmt(from);
3121 retval = _copyCopyStmt(from);
3124 retval = _copyCreateStmt(from);
3127 retval = _copyInhRelation(from);
3130 retval = _copyDefineStmt(from);
3133 retval = _copyDropStmt(from);
3135 case T_TruncateStmt:
3136 retval = _copyTruncateStmt(from);
3139 retval = _copyCommentStmt(from);
3142 retval = _copyFetchStmt(from);
3145 retval = _copyIndexStmt(from);
3147 case T_CreateFunctionStmt:
3148 retval = _copyCreateFunctionStmt(from);
3150 case T_FunctionParameter:
3151 retval = _copyFunctionParameter(from);
3153 case T_AlterFunctionStmt:
3154 retval = _copyAlterFunctionStmt(from);
3156 case T_RemoveFuncStmt:
3157 retval = _copyRemoveFuncStmt(from);
3159 case T_RemoveOpClassStmt:
3160 retval = _copyRemoveOpClassStmt(from);
3163 retval = _copyRenameStmt(from);
3165 case T_AlterObjectSchemaStmt:
3166 retval = _copyAlterObjectSchemaStmt(from);
3168 case T_AlterOwnerStmt:
3169 retval = _copyAlterOwnerStmt(from);
3172 retval = _copyRuleStmt(from);
3175 retval = _copyNotifyStmt(from);
3178 retval = _copyListenStmt(from);
3180 case T_UnlistenStmt:
3181 retval = _copyUnlistenStmt(from);
3183 case T_TransactionStmt:
3184 retval = _copyTransactionStmt(from);
3186 case T_CompositeTypeStmt:
3187 retval = _copyCompositeTypeStmt(from);
3190 retval = _copyViewStmt(from);
3193 retval = _copyLoadStmt(from);
3195 case T_CreateDomainStmt:
3196 retval = _copyCreateDomainStmt(from);
3198 case T_CreateOpClassStmt:
3199 retval = _copyCreateOpClassStmt(from);
3201 case T_CreateOpClassItem:
3202 retval = _copyCreateOpClassItem(from);
3204 case T_CreatedbStmt:
3205 retval = _copyCreatedbStmt(from);
3207 case T_AlterDatabaseStmt:
3208 retval = _copyAlterDatabaseStmt(from);
3210 case T_AlterDatabaseSetStmt:
3211 retval = _copyAlterDatabaseSetStmt(from);
3214 retval = _copyDropdbStmt(from);
3217 retval = _copyVacuumStmt(from);
3220 retval = _copyExplainStmt(from);
3222 case T_CreateSeqStmt:
3223 retval = _copyCreateSeqStmt(from);
3225 case T_AlterSeqStmt:
3226 retval = _copyAlterSeqStmt(from);
3228 case T_VariableSetStmt:
3229 retval = _copyVariableSetStmt(from);
3231 case T_VariableShowStmt:
3232 retval = _copyVariableShowStmt(from);
3234 case T_VariableResetStmt:
3235 retval = _copyVariableResetStmt(from);
3237 case T_CreateTableSpaceStmt:
3238 retval = _copyCreateTableSpaceStmt(from);
3240 case T_DropTableSpaceStmt:
3241 retval = _copyDropTableSpaceStmt(from);
3243 case T_CreateTrigStmt:
3244 retval = _copyCreateTrigStmt(from);
3246 case T_DropPropertyStmt:
3247 retval = _copyDropPropertyStmt(from);
3249 case T_CreatePLangStmt:
3250 retval = _copyCreatePLangStmt(from);
3252 case T_DropPLangStmt:
3253 retval = _copyDropPLangStmt(from);
3255 case T_CreateRoleStmt:
3256 retval = _copyCreateRoleStmt(from);
3258 case T_AlterRoleStmt:
3259 retval = _copyAlterRoleStmt(from);
3261 case T_AlterRoleSetStmt:
3262 retval = _copyAlterRoleSetStmt(from);
3264 case T_DropRoleStmt:
3265 retval = _copyDropRoleStmt(from);
3268 retval = _copyLockStmt(from);
3270 case T_ConstraintsSetStmt:
3271 retval = _copyConstraintsSetStmt(from);
3274 retval = _copyReindexStmt(from);
3276 case T_CheckPointStmt:
3277 retval = (void *) makeNode(CheckPointStmt);
3279 case T_CreateSchemaStmt:
3280 retval = _copyCreateSchemaStmt(from);
3282 case T_CreateConversionStmt:
3283 retval = _copyCreateConversionStmt(from);
3285 case T_CreateCastStmt:
3286 retval = _copyCreateCastStmt(from);
3288 case T_DropCastStmt:
3289 retval = _copyDropCastStmt(from);
3292 retval = _copyPrepareStmt(from);
3295 retval = _copyExecuteStmt(from);
3297 case T_DeallocateStmt:
3298 retval = _copyDeallocateStmt(from);
3300 case T_DropOwnedStmt:
3301 retval = _copyDropOwnedStmt(from);
3303 case T_ReassignOwnedStmt:
3304 retval = _copyReassignOwnedStmt(from);
3308 retval = _copyAExpr(from);
3311 retval = _copyColumnRef(from);
3314 retval = _copyParamRef(from);
3317 retval = _copyAConst(from);
3320 retval = _copyFuncCall(from);
3323 retval = _copyAIndices(from);
3325 case T_A_Indirection:
3326 retval = _copyA_Indirection(from);
3329 retval = _copyResTarget(from);
3332 retval = _copyTypeCast(from);
3335 retval = _copySortBy(from);
3337 case T_RangeSubselect:
3338 retval = _copyRangeSubselect(from);
3340 case T_RangeFunction:
3341 retval = _copyRangeFunction(from);
3344 retval = _copyTypeName(from);
3347 retval = _copyIndexElem(from);
3350 retval = _copyColumnDef(from);
3353 retval = _copyConstraint(from);
3356 retval = _copyDefElem(from);
3358 case T_LockingClause:
3359 retval = _copyLockingClause(from);
3361 case T_RangeTblEntry:
3362 retval = _copyRangeTblEntry(from);
3365 retval = _copySortClause(from);
3368 retval = _copyGroupClause(from);
3370 case T_RowMarkClause:
3371 retval = _copyRowMarkClause(from);
3373 case T_FkConstraint:
3374 retval = _copyFkConstraint(from);
3377 retval = _copyPrivGrantee(from);
3379 case T_FuncWithArgs:
3380 retval = _copyFuncWithArgs(from);
3384 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3385 retval = from; /* keep compiler quiet */