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.364 2007/01/23 05:07:17 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(left_em);
1330 COPY_SCALAR_FIELD(right_em);
1331 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1332 newnode->scansel_cache = NIL;
1333 COPY_SCALAR_FIELD(outer_is_left);
1334 COPY_SCALAR_FIELD(hashjoinoperator);
1335 COPY_SCALAR_FIELD(left_bucketsize);
1336 COPY_SCALAR_FIELD(right_bucketsize);
1342 * _copyOuterJoinInfo
1344 static OuterJoinInfo *
1345 _copyOuterJoinInfo(OuterJoinInfo *from)
1347 OuterJoinInfo *newnode = makeNode(OuterJoinInfo);
1349 COPY_BITMAPSET_FIELD(min_lefthand);
1350 COPY_BITMAPSET_FIELD(min_righthand);
1351 COPY_SCALAR_FIELD(is_full_join);
1352 COPY_SCALAR_FIELD(lhs_strict);
1360 static InClauseInfo *
1361 _copyInClauseInfo(InClauseInfo *from)
1363 InClauseInfo *newnode = makeNode(InClauseInfo);
1365 COPY_BITMAPSET_FIELD(lefthand);
1366 COPY_BITMAPSET_FIELD(righthand);
1367 COPY_NODE_FIELD(sub_targetlist);
1368 COPY_NODE_FIELD(in_operators);
1374 * _copyAppendRelInfo
1376 static AppendRelInfo *
1377 _copyAppendRelInfo(AppendRelInfo *from)
1379 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1381 COPY_SCALAR_FIELD(parent_relid);
1382 COPY_SCALAR_FIELD(child_relid);
1383 COPY_SCALAR_FIELD(parent_reltype);
1384 COPY_SCALAR_FIELD(child_reltype);
1385 COPY_NODE_FIELD(col_mappings);
1386 COPY_NODE_FIELD(translated_vars);
1387 COPY_SCALAR_FIELD(parent_reloid);
1392 /* ****************************************************************
1393 * parsenodes.h copy functions
1394 * ****************************************************************
1397 static RangeTblEntry *
1398 _copyRangeTblEntry(RangeTblEntry *from)
1400 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1402 COPY_SCALAR_FIELD(rtekind);
1403 COPY_SCALAR_FIELD(relid);
1404 COPY_NODE_FIELD(subquery);
1405 COPY_NODE_FIELD(funcexpr);
1406 COPY_NODE_FIELD(funccoltypes);
1407 COPY_NODE_FIELD(funccoltypmods);
1408 COPY_NODE_FIELD(values_lists);
1409 COPY_SCALAR_FIELD(jointype);
1410 COPY_NODE_FIELD(joinaliasvars);
1411 COPY_NODE_FIELD(alias);
1412 COPY_NODE_FIELD(eref);
1413 COPY_SCALAR_FIELD(inh);
1414 COPY_SCALAR_FIELD(inFromCl);
1415 COPY_SCALAR_FIELD(requiredPerms);
1416 COPY_SCALAR_FIELD(checkAsUser);
1421 static FkConstraint *
1422 _copyFkConstraint(FkConstraint *from)
1424 FkConstraint *newnode = makeNode(FkConstraint);
1426 COPY_STRING_FIELD(constr_name);
1427 COPY_NODE_FIELD(pktable);
1428 COPY_NODE_FIELD(fk_attrs);
1429 COPY_NODE_FIELD(pk_attrs);
1430 COPY_SCALAR_FIELD(fk_matchtype);
1431 COPY_SCALAR_FIELD(fk_upd_action);
1432 COPY_SCALAR_FIELD(fk_del_action);
1433 COPY_SCALAR_FIELD(deferrable);
1434 COPY_SCALAR_FIELD(initdeferred);
1435 COPY_SCALAR_FIELD(skip_validation);
1441 _copySortClause(SortClause *from)
1443 SortClause *newnode = makeNode(SortClause);
1445 COPY_SCALAR_FIELD(tleSortGroupRef);
1446 COPY_SCALAR_FIELD(sortop);
1447 COPY_SCALAR_FIELD(nulls_first);
1452 static GroupClause *
1453 _copyGroupClause(GroupClause *from)
1455 GroupClause *newnode = makeNode(GroupClause);
1457 COPY_SCALAR_FIELD(tleSortGroupRef);
1458 COPY_SCALAR_FIELD(sortop);
1459 COPY_SCALAR_FIELD(nulls_first);
1464 static RowMarkClause *
1465 _copyRowMarkClause(RowMarkClause *from)
1467 RowMarkClause *newnode = makeNode(RowMarkClause);
1469 COPY_SCALAR_FIELD(rti);
1470 COPY_SCALAR_FIELD(forUpdate);
1471 COPY_SCALAR_FIELD(noWait);
1477 _copyAExpr(A_Expr *from)
1479 A_Expr *newnode = makeNode(A_Expr);
1481 COPY_SCALAR_FIELD(kind);
1482 COPY_NODE_FIELD(name);
1483 COPY_NODE_FIELD(lexpr);
1484 COPY_NODE_FIELD(rexpr);
1485 COPY_SCALAR_FIELD(location);
1491 _copyColumnRef(ColumnRef *from)
1493 ColumnRef *newnode = makeNode(ColumnRef);
1495 COPY_NODE_FIELD(fields);
1496 COPY_SCALAR_FIELD(location);
1502 _copyParamRef(ParamRef *from)
1504 ParamRef *newnode = makeNode(ParamRef);
1506 COPY_SCALAR_FIELD(number);
1512 _copyAConst(A_Const *from)
1514 A_Const *newnode = makeNode(A_Const);
1516 /* This part must duplicate _copyValue */
1517 COPY_SCALAR_FIELD(val.type);
1518 switch (from->val.type)
1521 COPY_SCALAR_FIELD(val.val.ival);
1526 COPY_STRING_FIELD(val.val.str);
1532 elog(ERROR, "unrecognized node type: %d",
1533 (int) from->val.type);
1537 COPY_NODE_FIELD(typename);
1543 _copyFuncCall(FuncCall *from)
1545 FuncCall *newnode = makeNode(FuncCall);
1547 COPY_NODE_FIELD(funcname);
1548 COPY_NODE_FIELD(args);
1549 COPY_SCALAR_FIELD(agg_star);
1550 COPY_SCALAR_FIELD(agg_distinct);
1551 COPY_SCALAR_FIELD(location);
1557 _copyAIndices(A_Indices *from)
1559 A_Indices *newnode = makeNode(A_Indices);
1561 COPY_NODE_FIELD(lidx);
1562 COPY_NODE_FIELD(uidx);
1567 static A_Indirection *
1568 _copyA_Indirection(A_Indirection *from)
1570 A_Indirection *newnode = makeNode(A_Indirection);
1572 COPY_NODE_FIELD(arg);
1573 COPY_NODE_FIELD(indirection);
1579 _copyResTarget(ResTarget *from)
1581 ResTarget *newnode = makeNode(ResTarget);
1583 COPY_STRING_FIELD(name);
1584 COPY_NODE_FIELD(indirection);
1585 COPY_NODE_FIELD(val);
1586 COPY_SCALAR_FIELD(location);
1592 _copyTypeName(TypeName *from)
1594 TypeName *newnode = makeNode(TypeName);
1596 COPY_NODE_FIELD(names);
1597 COPY_SCALAR_FIELD(typeid);
1598 COPY_SCALAR_FIELD(timezone);
1599 COPY_SCALAR_FIELD(setof);
1600 COPY_SCALAR_FIELD(pct_type);
1601 COPY_NODE_FIELD(typmods);
1602 COPY_SCALAR_FIELD(typemod);
1603 COPY_NODE_FIELD(arrayBounds);
1604 COPY_SCALAR_FIELD(location);
1610 _copySortBy(SortBy *from)
1612 SortBy *newnode = makeNode(SortBy);
1614 COPY_SCALAR_FIELD(sortby_dir);
1615 COPY_SCALAR_FIELD(sortby_nulls);
1616 COPY_NODE_FIELD(useOp);
1617 COPY_NODE_FIELD(node);
1622 static RangeSubselect *
1623 _copyRangeSubselect(RangeSubselect *from)
1625 RangeSubselect *newnode = makeNode(RangeSubselect);
1627 COPY_NODE_FIELD(subquery);
1628 COPY_NODE_FIELD(alias);
1633 static RangeFunction *
1634 _copyRangeFunction(RangeFunction *from)
1636 RangeFunction *newnode = makeNode(RangeFunction);
1638 COPY_NODE_FIELD(funccallnode);
1639 COPY_NODE_FIELD(alias);
1640 COPY_NODE_FIELD(coldeflist);
1646 _copyTypeCast(TypeCast *from)
1648 TypeCast *newnode = makeNode(TypeCast);
1650 COPY_NODE_FIELD(arg);
1651 COPY_NODE_FIELD(typename);
1657 _copyIndexElem(IndexElem *from)
1659 IndexElem *newnode = makeNode(IndexElem);
1661 COPY_STRING_FIELD(name);
1662 COPY_NODE_FIELD(expr);
1663 COPY_NODE_FIELD(opclass);
1664 COPY_SCALAR_FIELD(ordering);
1665 COPY_SCALAR_FIELD(nulls_ordering);
1671 _copyColumnDef(ColumnDef *from)
1673 ColumnDef *newnode = makeNode(ColumnDef);
1675 COPY_STRING_FIELD(colname);
1676 COPY_NODE_FIELD(typename);
1677 COPY_SCALAR_FIELD(inhcount);
1678 COPY_SCALAR_FIELD(is_local);
1679 COPY_SCALAR_FIELD(is_not_null);
1680 COPY_NODE_FIELD(raw_default);
1681 COPY_STRING_FIELD(cooked_default);
1682 COPY_NODE_FIELD(constraints);
1688 _copyConstraint(Constraint *from)
1690 Constraint *newnode = makeNode(Constraint);
1692 COPY_SCALAR_FIELD(contype);
1693 COPY_STRING_FIELD(name);
1694 COPY_NODE_FIELD(raw_expr);
1695 COPY_STRING_FIELD(cooked_expr);
1696 COPY_NODE_FIELD(keys);
1697 COPY_NODE_FIELD(options);
1698 COPY_STRING_FIELD(indexspace);
1704 _copyDefElem(DefElem *from)
1706 DefElem *newnode = makeNode(DefElem);
1708 COPY_STRING_FIELD(defname);
1709 COPY_NODE_FIELD(arg);
1714 static LockingClause *
1715 _copyLockingClause(LockingClause *from)
1717 LockingClause *newnode = makeNode(LockingClause);
1719 COPY_NODE_FIELD(lockedRels);
1720 COPY_SCALAR_FIELD(forUpdate);
1721 COPY_SCALAR_FIELD(noWait);
1727 _copyQuery(Query *from)
1729 Query *newnode = makeNode(Query);
1731 COPY_SCALAR_FIELD(commandType);
1732 COPY_SCALAR_FIELD(querySource);
1733 COPY_SCALAR_FIELD(canSetTag);
1734 COPY_NODE_FIELD(utilityStmt);
1735 COPY_SCALAR_FIELD(resultRelation);
1736 COPY_NODE_FIELD(into);
1737 COPY_NODE_FIELD(intoOptions);
1738 COPY_SCALAR_FIELD(intoOnCommit);
1739 COPY_STRING_FIELD(intoTableSpaceName);
1740 COPY_SCALAR_FIELD(hasAggs);
1741 COPY_SCALAR_FIELD(hasSubLinks);
1742 COPY_NODE_FIELD(rtable);
1743 COPY_NODE_FIELD(jointree);
1744 COPY_NODE_FIELD(targetList);
1745 COPY_NODE_FIELD(returningList);
1746 COPY_NODE_FIELD(groupClause);
1747 COPY_NODE_FIELD(havingQual);
1748 COPY_NODE_FIELD(distinctClause);
1749 COPY_NODE_FIELD(sortClause);
1750 COPY_NODE_FIELD(limitOffset);
1751 COPY_NODE_FIELD(limitCount);
1752 COPY_NODE_FIELD(rowMarks);
1753 COPY_NODE_FIELD(setOperations);
1754 COPY_NODE_FIELD(resultRelations);
1755 COPY_NODE_FIELD(returningLists);
1761 _copyInsertStmt(InsertStmt *from)
1763 InsertStmt *newnode = makeNode(InsertStmt);
1765 COPY_NODE_FIELD(relation);
1766 COPY_NODE_FIELD(cols);
1767 COPY_NODE_FIELD(selectStmt);
1768 COPY_NODE_FIELD(returningList);
1774 _copyDeleteStmt(DeleteStmt *from)
1776 DeleteStmt *newnode = makeNode(DeleteStmt);
1778 COPY_NODE_FIELD(relation);
1779 COPY_NODE_FIELD(usingClause);
1780 COPY_NODE_FIELD(whereClause);
1781 COPY_NODE_FIELD(returningList);
1787 _copyUpdateStmt(UpdateStmt *from)
1789 UpdateStmt *newnode = makeNode(UpdateStmt);
1791 COPY_NODE_FIELD(relation);
1792 COPY_NODE_FIELD(targetList);
1793 COPY_NODE_FIELD(whereClause);
1794 COPY_NODE_FIELD(fromClause);
1795 COPY_NODE_FIELD(returningList);
1801 _copySelectStmt(SelectStmt *from)
1803 SelectStmt *newnode = makeNode(SelectStmt);
1805 COPY_NODE_FIELD(distinctClause);
1806 COPY_NODE_FIELD(into);
1807 COPY_NODE_FIELD(intoColNames);
1808 COPY_NODE_FIELD(intoOptions);
1809 COPY_SCALAR_FIELD(intoOnCommit);
1810 COPY_STRING_FIELD(intoTableSpaceName);
1811 COPY_NODE_FIELD(targetList);
1812 COPY_NODE_FIELD(fromClause);
1813 COPY_NODE_FIELD(whereClause);
1814 COPY_NODE_FIELD(groupClause);
1815 COPY_NODE_FIELD(havingClause);
1816 COPY_NODE_FIELD(valuesLists);
1817 COPY_NODE_FIELD(sortClause);
1818 COPY_NODE_FIELD(limitOffset);
1819 COPY_NODE_FIELD(limitCount);
1820 COPY_NODE_FIELD(lockingClause);
1821 COPY_SCALAR_FIELD(op);
1822 COPY_SCALAR_FIELD(all);
1823 COPY_NODE_FIELD(larg);
1824 COPY_NODE_FIELD(rarg);
1829 static SetOperationStmt *
1830 _copySetOperationStmt(SetOperationStmt *from)
1832 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1834 COPY_SCALAR_FIELD(op);
1835 COPY_SCALAR_FIELD(all);
1836 COPY_NODE_FIELD(larg);
1837 COPY_NODE_FIELD(rarg);
1838 COPY_NODE_FIELD(colTypes);
1839 COPY_NODE_FIELD(colTypmods);
1844 static AlterTableStmt *
1845 _copyAlterTableStmt(AlterTableStmt *from)
1847 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1849 COPY_NODE_FIELD(relation);
1850 COPY_NODE_FIELD(cmds);
1851 COPY_SCALAR_FIELD(relkind);
1856 static AlterTableCmd *
1857 _copyAlterTableCmd(AlterTableCmd *from)
1859 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1861 COPY_SCALAR_FIELD(subtype);
1862 COPY_STRING_FIELD(name);
1863 COPY_NODE_FIELD(def);
1864 COPY_NODE_FIELD(transform);
1865 COPY_SCALAR_FIELD(behavior);
1870 static AlterDomainStmt *
1871 _copyAlterDomainStmt(AlterDomainStmt *from)
1873 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1875 COPY_SCALAR_FIELD(subtype);
1876 COPY_NODE_FIELD(typename);
1877 COPY_STRING_FIELD(name);
1878 COPY_NODE_FIELD(def);
1879 COPY_SCALAR_FIELD(behavior);
1885 _copyGrantStmt(GrantStmt *from)
1887 GrantStmt *newnode = makeNode(GrantStmt);
1889 COPY_SCALAR_FIELD(is_grant);
1890 COPY_SCALAR_FIELD(objtype);
1891 COPY_NODE_FIELD(objects);
1892 COPY_NODE_FIELD(privileges);
1893 COPY_NODE_FIELD(grantees);
1894 COPY_SCALAR_FIELD(grant_option);
1895 COPY_SCALAR_FIELD(behavior);
1900 static PrivGrantee *
1901 _copyPrivGrantee(PrivGrantee *from)
1903 PrivGrantee *newnode = makeNode(PrivGrantee);
1905 COPY_STRING_FIELD(rolname);
1910 static FuncWithArgs *
1911 _copyFuncWithArgs(FuncWithArgs *from)
1913 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1915 COPY_NODE_FIELD(funcname);
1916 COPY_NODE_FIELD(funcargs);
1921 static GrantRoleStmt *
1922 _copyGrantRoleStmt(GrantRoleStmt *from)
1924 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
1926 COPY_NODE_FIELD(granted_roles);
1927 COPY_NODE_FIELD(grantee_roles);
1928 COPY_SCALAR_FIELD(is_grant);
1929 COPY_SCALAR_FIELD(admin_opt);
1930 COPY_STRING_FIELD(grantor);
1931 COPY_SCALAR_FIELD(behavior);
1936 static DeclareCursorStmt *
1937 _copyDeclareCursorStmt(DeclareCursorStmt *from)
1939 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
1941 COPY_STRING_FIELD(portalname);
1942 COPY_SCALAR_FIELD(options);
1943 COPY_NODE_FIELD(query);
1948 static ClosePortalStmt *
1949 _copyClosePortalStmt(ClosePortalStmt *from)
1951 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
1953 COPY_STRING_FIELD(portalname);
1958 static ClusterStmt *
1959 _copyClusterStmt(ClusterStmt *from)
1961 ClusterStmt *newnode = makeNode(ClusterStmt);
1963 COPY_NODE_FIELD(relation);
1964 COPY_STRING_FIELD(indexname);
1970 _copyCopyStmt(CopyStmt *from)
1972 CopyStmt *newnode = makeNode(CopyStmt);
1974 COPY_NODE_FIELD(relation);
1975 COPY_NODE_FIELD(query);
1976 COPY_NODE_FIELD(attlist);
1977 COPY_SCALAR_FIELD(is_from);
1978 COPY_STRING_FIELD(filename);
1979 COPY_NODE_FIELD(options);
1985 _copyCreateStmt(CreateStmt *from)
1987 CreateStmt *newnode = makeNode(CreateStmt);
1989 COPY_NODE_FIELD(relation);
1990 COPY_NODE_FIELD(tableElts);
1991 COPY_NODE_FIELD(inhRelations);
1992 COPY_NODE_FIELD(constraints);
1993 COPY_NODE_FIELD(options);
1994 COPY_SCALAR_FIELD(oncommit);
1995 COPY_STRING_FIELD(tablespacename);
2000 static InhRelation *
2001 _copyInhRelation(InhRelation *from)
2003 InhRelation *newnode = makeNode(InhRelation);
2005 COPY_NODE_FIELD(relation);
2006 COPY_NODE_FIELD(options);
2012 _copyDefineStmt(DefineStmt *from)
2014 DefineStmt *newnode = makeNode(DefineStmt);
2016 COPY_SCALAR_FIELD(kind);
2017 COPY_SCALAR_FIELD(oldstyle);
2018 COPY_NODE_FIELD(defnames);
2019 COPY_NODE_FIELD(args);
2020 COPY_NODE_FIELD(definition);
2026 _copyDropStmt(DropStmt *from)
2028 DropStmt *newnode = makeNode(DropStmt);
2030 COPY_NODE_FIELD(objects);
2031 COPY_SCALAR_FIELD(removeType);
2032 COPY_SCALAR_FIELD(behavior);
2033 COPY_SCALAR_FIELD(missing_ok);
2038 static TruncateStmt *
2039 _copyTruncateStmt(TruncateStmt *from)
2041 TruncateStmt *newnode = makeNode(TruncateStmt);
2043 COPY_NODE_FIELD(relations);
2044 COPY_SCALAR_FIELD(behavior);
2049 static CommentStmt *
2050 _copyCommentStmt(CommentStmt *from)
2052 CommentStmt *newnode = makeNode(CommentStmt);
2054 COPY_SCALAR_FIELD(objtype);
2055 COPY_NODE_FIELD(objname);
2056 COPY_NODE_FIELD(objargs);
2057 COPY_STRING_FIELD(comment);
2063 _copyFetchStmt(FetchStmt *from)
2065 FetchStmt *newnode = makeNode(FetchStmt);
2067 COPY_SCALAR_FIELD(direction);
2068 COPY_SCALAR_FIELD(howMany);
2069 COPY_STRING_FIELD(portalname);
2070 COPY_SCALAR_FIELD(ismove);
2076 _copyIndexStmt(IndexStmt *from)
2078 IndexStmt *newnode = makeNode(IndexStmt);
2080 COPY_STRING_FIELD(idxname);
2081 COPY_NODE_FIELD(relation);
2082 COPY_STRING_FIELD(accessMethod);
2083 COPY_STRING_FIELD(tableSpace);
2084 COPY_NODE_FIELD(indexParams);
2085 COPY_NODE_FIELD(options);
2086 COPY_NODE_FIELD(whereClause);
2087 COPY_NODE_FIELD(rangetable);
2088 COPY_SCALAR_FIELD(unique);
2089 COPY_SCALAR_FIELD(primary);
2090 COPY_SCALAR_FIELD(isconstraint);
2091 COPY_SCALAR_FIELD(concurrent);
2096 static CreateFunctionStmt *
2097 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2099 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2101 COPY_SCALAR_FIELD(replace);
2102 COPY_NODE_FIELD(funcname);
2103 COPY_NODE_FIELD(parameters);
2104 COPY_NODE_FIELD(returnType);
2105 COPY_NODE_FIELD(options);
2106 COPY_NODE_FIELD(withClause);
2111 static FunctionParameter *
2112 _copyFunctionParameter(FunctionParameter *from)
2114 FunctionParameter *newnode = makeNode(FunctionParameter);
2116 COPY_STRING_FIELD(name);
2117 COPY_NODE_FIELD(argType);
2118 COPY_SCALAR_FIELD(mode);
2123 static AlterFunctionStmt *
2124 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2126 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2128 COPY_NODE_FIELD(func);
2129 COPY_NODE_FIELD(actions);
2134 static RemoveFuncStmt *
2135 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2137 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2139 COPY_SCALAR_FIELD(kind);
2140 COPY_NODE_FIELD(name);
2141 COPY_NODE_FIELD(args);
2142 COPY_SCALAR_FIELD(behavior);
2143 COPY_SCALAR_FIELD(missing_ok);
2148 static RemoveOpClassStmt *
2149 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2151 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2153 COPY_NODE_FIELD(opclassname);
2154 COPY_STRING_FIELD(amname);
2155 COPY_SCALAR_FIELD(behavior);
2156 COPY_SCALAR_FIELD(missing_ok);
2161 static RemoveOpFamilyStmt *
2162 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2164 RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2166 COPY_NODE_FIELD(opfamilyname);
2167 COPY_STRING_FIELD(amname);
2168 COPY_SCALAR_FIELD(behavior);
2169 COPY_SCALAR_FIELD(missing_ok);
2175 _copyRenameStmt(RenameStmt *from)
2177 RenameStmt *newnode = makeNode(RenameStmt);
2179 COPY_SCALAR_FIELD(renameType);
2180 COPY_NODE_FIELD(relation);
2181 COPY_NODE_FIELD(object);
2182 COPY_NODE_FIELD(objarg);
2183 COPY_STRING_FIELD(subname);
2184 COPY_STRING_FIELD(newname);
2189 static AlterObjectSchemaStmt *
2190 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2192 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2194 COPY_SCALAR_FIELD(objectType);
2195 COPY_NODE_FIELD(relation);
2196 COPY_NODE_FIELD(object);
2197 COPY_NODE_FIELD(objarg);
2198 COPY_STRING_FIELD(addname);
2199 COPY_STRING_FIELD(newschema);
2204 static AlterOwnerStmt *
2205 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2207 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2209 COPY_SCALAR_FIELD(objectType);
2210 COPY_NODE_FIELD(relation);
2211 COPY_NODE_FIELD(object);
2212 COPY_NODE_FIELD(objarg);
2213 COPY_STRING_FIELD(addname);
2214 COPY_STRING_FIELD(newowner);
2220 _copyRuleStmt(RuleStmt *from)
2222 RuleStmt *newnode = makeNode(RuleStmt);
2224 COPY_NODE_FIELD(relation);
2225 COPY_STRING_FIELD(rulename);
2226 COPY_NODE_FIELD(whereClause);
2227 COPY_SCALAR_FIELD(event);
2228 COPY_SCALAR_FIELD(instead);
2229 COPY_NODE_FIELD(actions);
2230 COPY_SCALAR_FIELD(replace);
2236 _copyNotifyStmt(NotifyStmt *from)
2238 NotifyStmt *newnode = makeNode(NotifyStmt);
2240 COPY_NODE_FIELD(relation);
2246 _copyListenStmt(ListenStmt *from)
2248 ListenStmt *newnode = makeNode(ListenStmt);
2250 COPY_NODE_FIELD(relation);
2255 static UnlistenStmt *
2256 _copyUnlistenStmt(UnlistenStmt *from)
2258 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2260 COPY_NODE_FIELD(relation);
2265 static TransactionStmt *
2266 _copyTransactionStmt(TransactionStmt *from)
2268 TransactionStmt *newnode = makeNode(TransactionStmt);
2270 COPY_SCALAR_FIELD(kind);
2271 COPY_NODE_FIELD(options);
2272 COPY_STRING_FIELD(gid);
2277 static CompositeTypeStmt *
2278 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2280 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2282 COPY_NODE_FIELD(typevar);
2283 COPY_NODE_FIELD(coldeflist);
2289 _copyViewStmt(ViewStmt *from)
2291 ViewStmt *newnode = makeNode(ViewStmt);
2293 COPY_NODE_FIELD(view);
2294 COPY_NODE_FIELD(aliases);
2295 COPY_NODE_FIELD(query);
2296 COPY_SCALAR_FIELD(replace);
2302 _copyLoadStmt(LoadStmt *from)
2304 LoadStmt *newnode = makeNode(LoadStmt);
2306 COPY_STRING_FIELD(filename);
2311 static CreateDomainStmt *
2312 _copyCreateDomainStmt(CreateDomainStmt *from)
2314 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2316 COPY_NODE_FIELD(domainname);
2317 COPY_NODE_FIELD(typename);
2318 COPY_NODE_FIELD(constraints);
2323 static CreateOpClassStmt *
2324 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2326 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2328 COPY_NODE_FIELD(opclassname);
2329 COPY_NODE_FIELD(opfamilyname);
2330 COPY_STRING_FIELD(amname);
2331 COPY_NODE_FIELD(datatype);
2332 COPY_NODE_FIELD(items);
2333 COPY_SCALAR_FIELD(isDefault);
2338 static CreateOpClassItem *
2339 _copyCreateOpClassItem(CreateOpClassItem *from)
2341 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2343 COPY_SCALAR_FIELD(itemtype);
2344 COPY_NODE_FIELD(name);
2345 COPY_NODE_FIELD(args);
2346 COPY_SCALAR_FIELD(number);
2347 COPY_SCALAR_FIELD(recheck);
2348 COPY_NODE_FIELD(class_args);
2349 COPY_NODE_FIELD(storedtype);
2354 static CreateOpFamilyStmt *
2355 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
2357 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
2359 COPY_NODE_FIELD(opfamilyname);
2360 COPY_STRING_FIELD(amname);
2365 static AlterOpFamilyStmt *
2366 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
2368 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
2370 COPY_NODE_FIELD(opfamilyname);
2371 COPY_STRING_FIELD(amname);
2372 COPY_SCALAR_FIELD(isDrop);
2373 COPY_NODE_FIELD(items);
2378 static CreatedbStmt *
2379 _copyCreatedbStmt(CreatedbStmt *from)
2381 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2383 COPY_STRING_FIELD(dbname);
2384 COPY_NODE_FIELD(options);
2389 static AlterDatabaseStmt *
2390 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2392 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2394 COPY_STRING_FIELD(dbname);
2395 COPY_NODE_FIELD(options);
2400 static AlterDatabaseSetStmt *
2401 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2403 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2405 COPY_STRING_FIELD(dbname);
2406 COPY_STRING_FIELD(variable);
2407 COPY_NODE_FIELD(value);
2413 _copyDropdbStmt(DropdbStmt *from)
2415 DropdbStmt *newnode = makeNode(DropdbStmt);
2417 COPY_STRING_FIELD(dbname);
2418 COPY_SCALAR_FIELD(missing_ok);
2424 _copyVacuumStmt(VacuumStmt *from)
2426 VacuumStmt *newnode = makeNode(VacuumStmt);
2428 COPY_SCALAR_FIELD(vacuum);
2429 COPY_SCALAR_FIELD(full);
2430 COPY_SCALAR_FIELD(analyze);
2431 COPY_SCALAR_FIELD(verbose);
2432 COPY_SCALAR_FIELD(freeze_min_age);
2433 COPY_NODE_FIELD(relation);
2434 COPY_NODE_FIELD(va_cols);
2439 static ExplainStmt *
2440 _copyExplainStmt(ExplainStmt *from)
2442 ExplainStmt *newnode = makeNode(ExplainStmt);
2444 COPY_NODE_FIELD(query);
2445 COPY_SCALAR_FIELD(verbose);
2446 COPY_SCALAR_FIELD(analyze);
2451 static CreateSeqStmt *
2452 _copyCreateSeqStmt(CreateSeqStmt *from)
2454 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2456 COPY_NODE_FIELD(sequence);
2457 COPY_NODE_FIELD(options);
2462 static AlterSeqStmt *
2463 _copyAlterSeqStmt(AlterSeqStmt *from)
2465 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2467 COPY_NODE_FIELD(sequence);
2468 COPY_NODE_FIELD(options);
2473 static VariableSetStmt *
2474 _copyVariableSetStmt(VariableSetStmt *from)
2476 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2478 COPY_STRING_FIELD(name);
2479 COPY_NODE_FIELD(args);
2480 COPY_SCALAR_FIELD(is_local);
2485 static VariableShowStmt *
2486 _copyVariableShowStmt(VariableShowStmt *from)
2488 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2490 COPY_STRING_FIELD(name);
2495 static VariableResetStmt *
2496 _copyVariableResetStmt(VariableResetStmt *from)
2498 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2500 COPY_STRING_FIELD(name);
2505 static CreateTableSpaceStmt *
2506 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2508 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2510 COPY_STRING_FIELD(tablespacename);
2511 COPY_STRING_FIELD(owner);
2512 COPY_STRING_FIELD(location);
2517 static DropTableSpaceStmt *
2518 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2520 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2522 COPY_STRING_FIELD(tablespacename);
2523 COPY_SCALAR_FIELD(missing_ok);
2528 static CreateTrigStmt *
2529 _copyCreateTrigStmt(CreateTrigStmt *from)
2531 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2533 COPY_STRING_FIELD(trigname);
2534 COPY_NODE_FIELD(relation);
2535 COPY_NODE_FIELD(funcname);
2536 COPY_NODE_FIELD(args);
2537 COPY_SCALAR_FIELD(before);
2538 COPY_SCALAR_FIELD(row);
2539 strcpy(newnode->actions, from->actions); /* in-line string field */
2540 COPY_SCALAR_FIELD(isconstraint);
2541 COPY_SCALAR_FIELD(deferrable);
2542 COPY_SCALAR_FIELD(initdeferred);
2543 COPY_NODE_FIELD(constrrel);
2548 static DropPropertyStmt *
2549 _copyDropPropertyStmt(DropPropertyStmt *from)
2551 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2553 COPY_NODE_FIELD(relation);
2554 COPY_STRING_FIELD(property);
2555 COPY_SCALAR_FIELD(removeType);
2556 COPY_SCALAR_FIELD(behavior);
2557 COPY_SCALAR_FIELD(missing_ok);
2562 static CreatePLangStmt *
2563 _copyCreatePLangStmt(CreatePLangStmt *from)
2565 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2567 COPY_STRING_FIELD(plname);
2568 COPY_NODE_FIELD(plhandler);
2569 COPY_NODE_FIELD(plvalidator);
2570 COPY_SCALAR_FIELD(pltrusted);
2575 static DropPLangStmt *
2576 _copyDropPLangStmt(DropPLangStmt *from)
2578 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2580 COPY_STRING_FIELD(plname);
2581 COPY_SCALAR_FIELD(behavior);
2582 COPY_SCALAR_FIELD(missing_ok);
2587 static CreateRoleStmt *
2588 _copyCreateRoleStmt(CreateRoleStmt *from)
2590 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2592 COPY_SCALAR_FIELD(stmt_type);
2593 COPY_STRING_FIELD(role);
2594 COPY_NODE_FIELD(options);
2599 static AlterRoleStmt *
2600 _copyAlterRoleStmt(AlterRoleStmt *from)
2602 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2604 COPY_STRING_FIELD(role);
2605 COPY_NODE_FIELD(options);
2606 COPY_SCALAR_FIELD(action);
2611 static AlterRoleSetStmt *
2612 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2614 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2616 COPY_STRING_FIELD(role);
2617 COPY_STRING_FIELD(variable);
2618 COPY_NODE_FIELD(value);
2623 static DropRoleStmt *
2624 _copyDropRoleStmt(DropRoleStmt *from)
2626 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2628 COPY_NODE_FIELD(roles);
2629 COPY_SCALAR_FIELD(missing_ok);
2635 _copyLockStmt(LockStmt *from)
2637 LockStmt *newnode = makeNode(LockStmt);
2639 COPY_NODE_FIELD(relations);
2640 COPY_SCALAR_FIELD(mode);
2641 COPY_SCALAR_FIELD(nowait);
2646 static ConstraintsSetStmt *
2647 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2649 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2651 COPY_NODE_FIELD(constraints);
2652 COPY_SCALAR_FIELD(deferred);
2657 static ReindexStmt *
2658 _copyReindexStmt(ReindexStmt *from)
2660 ReindexStmt *newnode = makeNode(ReindexStmt);
2662 COPY_SCALAR_FIELD(kind);
2663 COPY_NODE_FIELD(relation);
2664 COPY_STRING_FIELD(name);
2665 COPY_SCALAR_FIELD(do_system);
2666 COPY_SCALAR_FIELD(do_user);
2671 static CreateSchemaStmt *
2672 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2674 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2676 COPY_STRING_FIELD(schemaname);
2677 COPY_STRING_FIELD(authid);
2678 COPY_NODE_FIELD(schemaElts);
2683 static CreateConversionStmt *
2684 _copyCreateConversionStmt(CreateConversionStmt *from)
2686 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2688 COPY_NODE_FIELD(conversion_name);
2689 COPY_STRING_FIELD(for_encoding_name);
2690 COPY_STRING_FIELD(to_encoding_name);
2691 COPY_NODE_FIELD(func_name);
2692 COPY_SCALAR_FIELD(def);
2697 static CreateCastStmt *
2698 _copyCreateCastStmt(CreateCastStmt *from)
2700 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2702 COPY_NODE_FIELD(sourcetype);
2703 COPY_NODE_FIELD(targettype);
2704 COPY_NODE_FIELD(func);
2705 COPY_SCALAR_FIELD(context);
2710 static DropCastStmt *
2711 _copyDropCastStmt(DropCastStmt *from)
2713 DropCastStmt *newnode = makeNode(DropCastStmt);
2715 COPY_NODE_FIELD(sourcetype);
2716 COPY_NODE_FIELD(targettype);
2717 COPY_SCALAR_FIELD(behavior);
2718 COPY_SCALAR_FIELD(missing_ok);
2723 static PrepareStmt *
2724 _copyPrepareStmt(PrepareStmt *from)
2726 PrepareStmt *newnode = makeNode(PrepareStmt);
2728 COPY_STRING_FIELD(name);
2729 COPY_NODE_FIELD(argtypes);
2730 COPY_NODE_FIELD(argtype_oids);
2731 COPY_NODE_FIELD(query);
2736 static ExecuteStmt *
2737 _copyExecuteStmt(ExecuteStmt *from)
2739 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2741 COPY_STRING_FIELD(name);
2742 COPY_NODE_FIELD(into);
2743 COPY_NODE_FIELD(intoOptions);
2744 COPY_SCALAR_FIELD(into_on_commit);
2745 COPY_STRING_FIELD(into_tbl_space);
2746 COPY_NODE_FIELD(params);
2751 static DeallocateStmt *
2752 _copyDeallocateStmt(DeallocateStmt *from)
2754 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2756 COPY_STRING_FIELD(name);
2761 static DropOwnedStmt *
2762 _copyDropOwnedStmt(DropOwnedStmt *from)
2764 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2766 COPY_NODE_FIELD(roles);
2767 COPY_SCALAR_FIELD(behavior);
2772 static ReassignOwnedStmt *
2773 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
2775 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2777 COPY_NODE_FIELD(roles);
2778 COPY_SCALAR_FIELD(newrole);
2783 /* ****************************************************************
2784 * pg_list.h copy functions
2785 * ****************************************************************
2789 * Perform a deep copy of the specified list, using copyObject(). The
2790 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2791 * need deep copies, so they should be copied via list_copy()
2793 #define COPY_NODE_CELL(new, old) \
2794 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2795 lfirst(new) = copyObject(lfirst(old));
2798 _copyList(List *from)
2804 Assert(list_length(from) >= 1);
2806 new = makeNode(List);
2807 new->length = from->length;
2809 COPY_NODE_CELL(new->head, from->head);
2810 prev_new = new->head;
2811 curr_old = lnext(from->head);
2815 COPY_NODE_CELL(prev_new->next, curr_old);
2816 prev_new = prev_new->next;
2817 curr_old = curr_old->next;
2819 prev_new->next = NULL;
2820 new->tail = prev_new;
2825 /* ****************************************************************
2826 * value.h copy functions
2827 * ****************************************************************
2830 _copyValue(Value *from)
2832 Value *newnode = makeNode(Value);
2834 /* See also _copyAConst when changing this code! */
2836 COPY_SCALAR_FIELD(type);
2840 COPY_SCALAR_FIELD(val.ival);
2845 COPY_STRING_FIELD(val.str);
2851 elog(ERROR, "unrecognized node type: %d",
2861 * Create a copy of a Node tree or list. This is a "deep" copy: all
2862 * substructure is copied too, recursively.
2865 copyObject(void *from)
2872 switch (nodeTag(from))
2878 retval = _copyPlan(from);
2881 retval = _copyResult(from);
2884 retval = _copyAppend(from);
2887 retval = _copyBitmapAnd(from);
2890 retval = _copyBitmapOr(from);
2893 retval = _copyScan(from);
2896 retval = _copySeqScan(from);
2899 retval = _copyIndexScan(from);
2901 case T_BitmapIndexScan:
2902 retval = _copyBitmapIndexScan(from);
2904 case T_BitmapHeapScan:
2905 retval = _copyBitmapHeapScan(from);
2908 retval = _copyTidScan(from);
2910 case T_SubqueryScan:
2911 retval = _copySubqueryScan(from);
2913 case T_FunctionScan:
2914 retval = _copyFunctionScan(from);
2917 retval = _copyValuesScan(from);
2920 retval = _copyJoin(from);
2923 retval = _copyNestLoop(from);
2926 retval = _copyMergeJoin(from);
2929 retval = _copyHashJoin(from);
2932 retval = _copyMaterial(from);
2935 retval = _copySort(from);
2938 retval = _copyGroup(from);
2941 retval = _copyAgg(from);
2944 retval = _copyUnique(from);
2947 retval = _copyHash(from);
2950 retval = _copySetOp(from);
2953 retval = _copyLimit(from);
2960 retval = _copyAlias(from);
2963 retval = _copyRangeVar(from);
2966 retval = _copyVar(from);
2969 retval = _copyConst(from);
2972 retval = _copyParam(from);
2975 retval = _copyAggref(from);
2978 retval = _copyArrayRef(from);
2981 retval = _copyFuncExpr(from);
2984 retval = _copyOpExpr(from);
2986 case T_DistinctExpr:
2987 retval = _copyDistinctExpr(from);
2989 case T_ScalarArrayOpExpr:
2990 retval = _copyScalarArrayOpExpr(from);
2993 retval = _copyBoolExpr(from);
2996 retval = _copySubLink(from);
2999 retval = _copySubPlan(from);
3002 retval = _copyFieldSelect(from);
3005 retval = _copyFieldStore(from);
3008 retval = _copyRelabelType(from);
3010 case T_ConvertRowtypeExpr:
3011 retval = _copyConvertRowtypeExpr(from);
3014 retval = _copyCaseExpr(from);
3017 retval = _copyCaseWhen(from);
3019 case T_CaseTestExpr:
3020 retval = _copyCaseTestExpr(from);
3023 retval = _copyArrayExpr(from);
3026 retval = _copyRowExpr(from);
3028 case T_RowCompareExpr:
3029 retval = _copyRowCompareExpr(from);
3031 case T_CoalesceExpr:
3032 retval = _copyCoalesceExpr(from);
3035 retval = _copyMinMaxExpr(from);
3038 retval = _copyXmlExpr(from);
3041 retval = _copyNullIfExpr(from);
3044 retval = _copyNullTest(from);
3047 retval = _copyBooleanTest(from);
3049 case T_CoerceToDomain:
3050 retval = _copyCoerceToDomain(from);
3052 case T_CoerceToDomainValue:
3053 retval = _copyCoerceToDomainValue(from);
3055 case T_SetToDefault:
3056 retval = _copySetToDefault(from);
3059 retval = _copyTargetEntry(from);
3062 retval = _copyRangeTblRef(from);
3065 retval = _copyJoinExpr(from);
3068 retval = _copyFromExpr(from);
3075 retval = _copyPathKey(from);
3077 case T_RestrictInfo:
3078 retval = _copyRestrictInfo(from);
3080 case T_OuterJoinInfo:
3081 retval = _copyOuterJoinInfo(from);
3083 case T_InClauseInfo:
3084 retval = _copyInClauseInfo(from);
3086 case T_AppendRelInfo:
3087 retval = _copyAppendRelInfo(from);
3098 retval = _copyValue(from);
3105 retval = _copyList(from);
3109 * Lists of integers and OIDs don't need to be deep-copied, so we
3110 * perform a shallow copy via list_copy()
3114 retval = list_copy(from);
3121 retval = _copyQuery(from);
3124 retval = _copyInsertStmt(from);
3127 retval = _copyDeleteStmt(from);
3130 retval = _copyUpdateStmt(from);
3133 retval = _copySelectStmt(from);
3135 case T_SetOperationStmt:
3136 retval = _copySetOperationStmt(from);
3138 case T_AlterTableStmt:
3139 retval = _copyAlterTableStmt(from);
3141 case T_AlterTableCmd:
3142 retval = _copyAlterTableCmd(from);
3144 case T_AlterDomainStmt:
3145 retval = _copyAlterDomainStmt(from);
3148 retval = _copyGrantStmt(from);
3150 case T_GrantRoleStmt:
3151 retval = _copyGrantRoleStmt(from);
3153 case T_DeclareCursorStmt:
3154 retval = _copyDeclareCursorStmt(from);
3156 case T_ClosePortalStmt:
3157 retval = _copyClosePortalStmt(from);
3160 retval = _copyClusterStmt(from);
3163 retval = _copyCopyStmt(from);
3166 retval = _copyCreateStmt(from);
3169 retval = _copyInhRelation(from);
3172 retval = _copyDefineStmt(from);
3175 retval = _copyDropStmt(from);
3177 case T_TruncateStmt:
3178 retval = _copyTruncateStmt(from);
3181 retval = _copyCommentStmt(from);
3184 retval = _copyFetchStmt(from);
3187 retval = _copyIndexStmt(from);
3189 case T_CreateFunctionStmt:
3190 retval = _copyCreateFunctionStmt(from);
3192 case T_FunctionParameter:
3193 retval = _copyFunctionParameter(from);
3195 case T_AlterFunctionStmt:
3196 retval = _copyAlterFunctionStmt(from);
3198 case T_RemoveFuncStmt:
3199 retval = _copyRemoveFuncStmt(from);
3201 case T_RemoveOpClassStmt:
3202 retval = _copyRemoveOpClassStmt(from);
3204 case T_RemoveOpFamilyStmt:
3205 retval = _copyRemoveOpFamilyStmt(from);
3208 retval = _copyRenameStmt(from);
3210 case T_AlterObjectSchemaStmt:
3211 retval = _copyAlterObjectSchemaStmt(from);
3213 case T_AlterOwnerStmt:
3214 retval = _copyAlterOwnerStmt(from);
3217 retval = _copyRuleStmt(from);
3220 retval = _copyNotifyStmt(from);
3223 retval = _copyListenStmt(from);
3225 case T_UnlistenStmt:
3226 retval = _copyUnlistenStmt(from);
3228 case T_TransactionStmt:
3229 retval = _copyTransactionStmt(from);
3231 case T_CompositeTypeStmt:
3232 retval = _copyCompositeTypeStmt(from);
3235 retval = _copyViewStmt(from);
3238 retval = _copyLoadStmt(from);
3240 case T_CreateDomainStmt:
3241 retval = _copyCreateDomainStmt(from);
3243 case T_CreateOpClassStmt:
3244 retval = _copyCreateOpClassStmt(from);
3246 case T_CreateOpClassItem:
3247 retval = _copyCreateOpClassItem(from);
3249 case T_CreateOpFamilyStmt:
3250 retval = _copyCreateOpFamilyStmt(from);
3252 case T_AlterOpFamilyStmt:
3253 retval = _copyAlterOpFamilyStmt(from);
3255 case T_CreatedbStmt:
3256 retval = _copyCreatedbStmt(from);
3258 case T_AlterDatabaseStmt:
3259 retval = _copyAlterDatabaseStmt(from);
3261 case T_AlterDatabaseSetStmt:
3262 retval = _copyAlterDatabaseSetStmt(from);
3265 retval = _copyDropdbStmt(from);
3268 retval = _copyVacuumStmt(from);
3271 retval = _copyExplainStmt(from);
3273 case T_CreateSeqStmt:
3274 retval = _copyCreateSeqStmt(from);
3276 case T_AlterSeqStmt:
3277 retval = _copyAlterSeqStmt(from);
3279 case T_VariableSetStmt:
3280 retval = _copyVariableSetStmt(from);
3282 case T_VariableShowStmt:
3283 retval = _copyVariableShowStmt(from);
3285 case T_VariableResetStmt:
3286 retval = _copyVariableResetStmt(from);
3288 case T_CreateTableSpaceStmt:
3289 retval = _copyCreateTableSpaceStmt(from);
3291 case T_DropTableSpaceStmt:
3292 retval = _copyDropTableSpaceStmt(from);
3294 case T_CreateTrigStmt:
3295 retval = _copyCreateTrigStmt(from);
3297 case T_DropPropertyStmt:
3298 retval = _copyDropPropertyStmt(from);
3300 case T_CreatePLangStmt:
3301 retval = _copyCreatePLangStmt(from);
3303 case T_DropPLangStmt:
3304 retval = _copyDropPLangStmt(from);
3306 case T_CreateRoleStmt:
3307 retval = _copyCreateRoleStmt(from);
3309 case T_AlterRoleStmt:
3310 retval = _copyAlterRoleStmt(from);
3312 case T_AlterRoleSetStmt:
3313 retval = _copyAlterRoleSetStmt(from);
3315 case T_DropRoleStmt:
3316 retval = _copyDropRoleStmt(from);
3319 retval = _copyLockStmt(from);
3321 case T_ConstraintsSetStmt:
3322 retval = _copyConstraintsSetStmt(from);
3325 retval = _copyReindexStmt(from);
3327 case T_CheckPointStmt:
3328 retval = (void *) makeNode(CheckPointStmt);
3330 case T_CreateSchemaStmt:
3331 retval = _copyCreateSchemaStmt(from);
3333 case T_CreateConversionStmt:
3334 retval = _copyCreateConversionStmt(from);
3336 case T_CreateCastStmt:
3337 retval = _copyCreateCastStmt(from);
3339 case T_DropCastStmt:
3340 retval = _copyDropCastStmt(from);
3343 retval = _copyPrepareStmt(from);
3346 retval = _copyExecuteStmt(from);
3348 case T_DeallocateStmt:
3349 retval = _copyDeallocateStmt(from);
3351 case T_DropOwnedStmt:
3352 retval = _copyDropOwnedStmt(from);
3354 case T_ReassignOwnedStmt:
3355 retval = _copyReassignOwnedStmt(from);
3359 retval = _copyAExpr(from);
3362 retval = _copyColumnRef(from);
3365 retval = _copyParamRef(from);
3368 retval = _copyAConst(from);
3371 retval = _copyFuncCall(from);
3374 retval = _copyAIndices(from);
3376 case T_A_Indirection:
3377 retval = _copyA_Indirection(from);
3380 retval = _copyResTarget(from);
3383 retval = _copyTypeCast(from);
3386 retval = _copySortBy(from);
3388 case T_RangeSubselect:
3389 retval = _copyRangeSubselect(from);
3391 case T_RangeFunction:
3392 retval = _copyRangeFunction(from);
3395 retval = _copyTypeName(from);
3398 retval = _copyIndexElem(from);
3401 retval = _copyColumnDef(from);
3404 retval = _copyConstraint(from);
3407 retval = _copyDefElem(from);
3409 case T_LockingClause:
3410 retval = _copyLockingClause(from);
3412 case T_RangeTblEntry:
3413 retval = _copyRangeTblEntry(from);
3416 retval = _copySortClause(from);
3419 retval = _copyGroupClause(from);
3421 case T_RowMarkClause:
3422 retval = _copyRowMarkClause(from);
3424 case T_FkConstraint:
3425 retval = _copyFkConstraint(from);
3428 retval = _copyPrivGrantee(from);
3430 case T_FuncWithArgs:
3431 retval = _copyFuncWithArgs(from);
3435 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3436 retval = from; /* keep compiler quiet */