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.366 2007/02/19 02:23:11 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);
367 * copy remainder of node
369 COPY_NODE_FIELD(funcexpr);
370 COPY_NODE_FIELD(funccolnames);
371 COPY_NODE_FIELD(funccoltypes);
372 COPY_NODE_FIELD(funccoltypmods);
381 _copyValuesScan(ValuesScan *from)
383 ValuesScan *newnode = makeNode(ValuesScan);
386 * copy node superclass fields
388 CopyScanFields((Scan *) from, (Scan *) newnode);
391 * copy remainder of node
393 COPY_NODE_FIELD(values_lists);
401 * This function copies the fields of the Join node. It is used by
402 * all the copy functions for classes which inherit from Join.
405 CopyJoinFields(Join *from, Join *newnode)
407 CopyPlanFields((Plan *) from, (Plan *) newnode);
409 COPY_SCALAR_FIELD(jointype);
410 COPY_NODE_FIELD(joinqual);
418 _copyJoin(Join *from)
420 Join *newnode = makeNode(Join);
423 * copy node superclass fields
425 CopyJoinFields(from, newnode);
435 _copyNestLoop(NestLoop *from)
437 NestLoop *newnode = makeNode(NestLoop);
440 * copy node superclass fields
442 CopyJoinFields((Join *) from, (Join *) newnode);
452 _copyMergeJoin(MergeJoin *from)
454 MergeJoin *newnode = makeNode(MergeJoin);
458 * copy node superclass fields
460 CopyJoinFields((Join *) from, (Join *) newnode);
463 * copy remainder of node
465 COPY_NODE_FIELD(mergeclauses);
466 numCols = list_length(from->mergeclauses);
467 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
468 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
469 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
478 _copyHashJoin(HashJoin *from)
480 HashJoin *newnode = makeNode(HashJoin);
483 * copy node superclass fields
485 CopyJoinFields((Join *) from, (Join *) newnode);
488 * copy remainder of node
490 COPY_NODE_FIELD(hashclauses);
500 _copyMaterial(Material *from)
502 Material *newnode = makeNode(Material);
505 * copy node superclass fields
507 CopyPlanFields((Plan *) from, (Plan *) newnode);
517 _copySort(Sort *from)
519 Sort *newnode = makeNode(Sort);
522 * copy node superclass fields
524 CopyPlanFields((Plan *) from, (Plan *) newnode);
526 COPY_SCALAR_FIELD(numCols);
527 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
528 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
529 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
539 _copyGroup(Group *from)
541 Group *newnode = makeNode(Group);
543 CopyPlanFields((Plan *) from, (Plan *) newnode);
545 COPY_SCALAR_FIELD(numCols);
546 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
547 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
558 Agg *newnode = makeNode(Agg);
560 CopyPlanFields((Plan *) from, (Plan *) newnode);
562 COPY_SCALAR_FIELD(aggstrategy);
563 COPY_SCALAR_FIELD(numCols);
564 if (from->numCols > 0)
566 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
567 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
569 COPY_SCALAR_FIELD(numGroups);
578 _copyUnique(Unique *from)
580 Unique *newnode = makeNode(Unique);
583 * copy node superclass fields
585 CopyPlanFields((Plan *) from, (Plan *) newnode);
588 * copy remainder of node
590 COPY_SCALAR_FIELD(numCols);
591 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
592 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
601 _copyHash(Hash *from)
603 Hash *newnode = makeNode(Hash);
606 * copy node superclass fields
608 CopyPlanFields((Plan *) from, (Plan *) newnode);
611 * copy remainder of node
621 _copySetOp(SetOp *from)
623 SetOp *newnode = makeNode(SetOp);
626 * copy node superclass fields
628 CopyPlanFields((Plan *) from, (Plan *) newnode);
631 * copy remainder of node
633 COPY_SCALAR_FIELD(cmd);
634 COPY_SCALAR_FIELD(numCols);
635 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
636 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
637 COPY_SCALAR_FIELD(flagColIdx);
646 _copyLimit(Limit *from)
648 Limit *newnode = makeNode(Limit);
651 * copy node superclass fields
653 CopyPlanFields((Plan *) from, (Plan *) newnode);
656 * copy remainder of node
658 COPY_NODE_FIELD(limitOffset);
659 COPY_NODE_FIELD(limitCount);
664 /* ****************************************************************
665 * primnodes.h copy functions
666 * ****************************************************************
673 _copyAlias(Alias *from)
675 Alias *newnode = makeNode(Alias);
677 COPY_STRING_FIELD(aliasname);
678 COPY_NODE_FIELD(colnames);
687 _copyRangeVar(RangeVar *from)
689 RangeVar *newnode = makeNode(RangeVar);
691 COPY_STRING_FIELD(catalogname);
692 COPY_STRING_FIELD(schemaname);
693 COPY_STRING_FIELD(relname);
694 COPY_SCALAR_FIELD(inhOpt);
695 COPY_SCALAR_FIELD(istemp);
696 COPY_NODE_FIELD(alias);
702 * We don't need a _copyExpr because Expr is an abstract supertype which
703 * should never actually get instantiated. Also, since it has no common
704 * fields except NodeTag, there's no need for a helper routine to factor
705 * out copying the common fields...
714 Var *newnode = makeNode(Var);
716 COPY_SCALAR_FIELD(varno);
717 COPY_SCALAR_FIELD(varattno);
718 COPY_SCALAR_FIELD(vartype);
719 COPY_SCALAR_FIELD(vartypmod);
720 COPY_SCALAR_FIELD(varlevelsup);
721 COPY_SCALAR_FIELD(varnoold);
722 COPY_SCALAR_FIELD(varoattno);
731 _copyConst(Const *from)
733 Const *newnode = makeNode(Const);
735 COPY_SCALAR_FIELD(consttype);
736 COPY_SCALAR_FIELD(constlen);
738 if (from->constbyval || from->constisnull)
741 * passed by value so just copy the datum. Also, don't try to copy
742 * struct when value is null!
744 newnode->constvalue = from->constvalue;
749 * passed by reference. We need a palloc'd copy.
751 newnode->constvalue = datumCopy(from->constvalue,
756 COPY_SCALAR_FIELD(constisnull);
757 COPY_SCALAR_FIELD(constbyval);
766 _copyParam(Param *from)
768 Param *newnode = makeNode(Param);
770 COPY_SCALAR_FIELD(paramkind);
771 COPY_SCALAR_FIELD(paramid);
772 COPY_SCALAR_FIELD(paramtype);
773 COPY_SCALAR_FIELD(paramtypmod);
782 _copyAggref(Aggref *from)
784 Aggref *newnode = makeNode(Aggref);
786 COPY_SCALAR_FIELD(aggfnoid);
787 COPY_SCALAR_FIELD(aggtype);
788 COPY_NODE_FIELD(args);
789 COPY_SCALAR_FIELD(agglevelsup);
790 COPY_SCALAR_FIELD(aggstar);
791 COPY_SCALAR_FIELD(aggdistinct);
800 _copyArrayRef(ArrayRef *from)
802 ArrayRef *newnode = makeNode(ArrayRef);
804 COPY_SCALAR_FIELD(refrestype);
805 COPY_SCALAR_FIELD(refarraytype);
806 COPY_SCALAR_FIELD(refelemtype);
807 COPY_NODE_FIELD(refupperindexpr);
808 COPY_NODE_FIELD(reflowerindexpr);
809 COPY_NODE_FIELD(refexpr);
810 COPY_NODE_FIELD(refassgnexpr);
819 _copyFuncExpr(FuncExpr *from)
821 FuncExpr *newnode = makeNode(FuncExpr);
823 COPY_SCALAR_FIELD(funcid);
824 COPY_SCALAR_FIELD(funcresulttype);
825 COPY_SCALAR_FIELD(funcretset);
826 COPY_SCALAR_FIELD(funcformat);
827 COPY_NODE_FIELD(args);
836 _copyOpExpr(OpExpr *from)
838 OpExpr *newnode = makeNode(OpExpr);
840 COPY_SCALAR_FIELD(opno);
841 COPY_SCALAR_FIELD(opfuncid);
842 COPY_SCALAR_FIELD(opresulttype);
843 COPY_SCALAR_FIELD(opretset);
844 COPY_NODE_FIELD(args);
850 * _copyDistinctExpr (same as OpExpr)
852 static DistinctExpr *
853 _copyDistinctExpr(DistinctExpr *from)
855 DistinctExpr *newnode = makeNode(DistinctExpr);
857 COPY_SCALAR_FIELD(opno);
858 COPY_SCALAR_FIELD(opfuncid);
859 COPY_SCALAR_FIELD(opresulttype);
860 COPY_SCALAR_FIELD(opretset);
861 COPY_NODE_FIELD(args);
867 * _copyScalarArrayOpExpr
869 static ScalarArrayOpExpr *
870 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
872 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
874 COPY_SCALAR_FIELD(opno);
875 COPY_SCALAR_FIELD(opfuncid);
876 COPY_SCALAR_FIELD(useOr);
877 COPY_NODE_FIELD(args);
886 _copyBoolExpr(BoolExpr *from)
888 BoolExpr *newnode = makeNode(BoolExpr);
890 COPY_SCALAR_FIELD(boolop);
891 COPY_NODE_FIELD(args);
900 _copySubLink(SubLink *from)
902 SubLink *newnode = makeNode(SubLink);
904 COPY_SCALAR_FIELD(subLinkType);
905 COPY_NODE_FIELD(testexpr);
906 COPY_NODE_FIELD(operName);
907 COPY_NODE_FIELD(subselect);
916 _copySubPlan(SubPlan *from)
918 SubPlan *newnode = makeNode(SubPlan);
920 COPY_SCALAR_FIELD(subLinkType);
921 COPY_NODE_FIELD(testexpr);
922 COPY_NODE_FIELD(paramIds);
923 COPY_NODE_FIELD(plan);
924 COPY_SCALAR_FIELD(plan_id);
925 COPY_NODE_FIELD(rtable);
926 COPY_SCALAR_FIELD(useHashTable);
927 COPY_SCALAR_FIELD(unknownEqFalse);
928 COPY_NODE_FIELD(setParam);
929 COPY_NODE_FIELD(parParam);
930 COPY_NODE_FIELD(args);
939 _copyFieldSelect(FieldSelect *from)
941 FieldSelect *newnode = makeNode(FieldSelect);
943 COPY_NODE_FIELD(arg);
944 COPY_SCALAR_FIELD(fieldnum);
945 COPY_SCALAR_FIELD(resulttype);
946 COPY_SCALAR_FIELD(resulttypmod);
955 _copyFieldStore(FieldStore *from)
957 FieldStore *newnode = makeNode(FieldStore);
959 COPY_NODE_FIELD(arg);
960 COPY_NODE_FIELD(newvals);
961 COPY_NODE_FIELD(fieldnums);
962 COPY_SCALAR_FIELD(resulttype);
971 _copyRelabelType(RelabelType *from)
973 RelabelType *newnode = makeNode(RelabelType);
975 COPY_NODE_FIELD(arg);
976 COPY_SCALAR_FIELD(resulttype);
977 COPY_SCALAR_FIELD(resulttypmod);
978 COPY_SCALAR_FIELD(relabelformat);
984 * _copyConvertRowtypeExpr
986 static ConvertRowtypeExpr *
987 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
989 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
991 COPY_NODE_FIELD(arg);
992 COPY_SCALAR_FIELD(resulttype);
993 COPY_SCALAR_FIELD(convertformat);
1002 _copyCaseExpr(CaseExpr *from)
1004 CaseExpr *newnode = makeNode(CaseExpr);
1006 COPY_SCALAR_FIELD(casetype);
1007 COPY_NODE_FIELD(arg);
1008 COPY_NODE_FIELD(args);
1009 COPY_NODE_FIELD(defresult);
1018 _copyCaseWhen(CaseWhen *from)
1020 CaseWhen *newnode = makeNode(CaseWhen);
1022 COPY_NODE_FIELD(expr);
1023 COPY_NODE_FIELD(result);
1031 static CaseTestExpr *
1032 _copyCaseTestExpr(CaseTestExpr *from)
1034 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1036 COPY_SCALAR_FIELD(typeId);
1037 COPY_SCALAR_FIELD(typeMod);
1046 _copyArrayExpr(ArrayExpr *from)
1048 ArrayExpr *newnode = makeNode(ArrayExpr);
1050 COPY_SCALAR_FIELD(array_typeid);
1051 COPY_SCALAR_FIELD(element_typeid);
1052 COPY_NODE_FIELD(elements);
1053 COPY_SCALAR_FIELD(multidims);
1062 _copyRowExpr(RowExpr *from)
1064 RowExpr *newnode = makeNode(RowExpr);
1066 COPY_NODE_FIELD(args);
1067 COPY_SCALAR_FIELD(row_typeid);
1068 COPY_SCALAR_FIELD(row_format);
1074 * _copyRowCompareExpr
1076 static RowCompareExpr *
1077 _copyRowCompareExpr(RowCompareExpr *from)
1079 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1081 COPY_SCALAR_FIELD(rctype);
1082 COPY_NODE_FIELD(opnos);
1083 COPY_NODE_FIELD(opfamilies);
1084 COPY_NODE_FIELD(largs);
1085 COPY_NODE_FIELD(rargs);
1093 static CoalesceExpr *
1094 _copyCoalesceExpr(CoalesceExpr *from)
1096 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1098 COPY_SCALAR_FIELD(coalescetype);
1099 COPY_NODE_FIELD(args);
1108 _copyMinMaxExpr(MinMaxExpr *from)
1110 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1112 COPY_SCALAR_FIELD(minmaxtype);
1113 COPY_SCALAR_FIELD(op);
1114 COPY_NODE_FIELD(args);
1123 _copyXmlExpr(XmlExpr *from)
1125 XmlExpr *newnode = makeNode(XmlExpr);
1127 COPY_SCALAR_FIELD(op);
1128 COPY_STRING_FIELD(name);
1129 COPY_NODE_FIELD(named_args);
1130 COPY_NODE_FIELD(arg_names);
1131 COPY_NODE_FIELD(args);
1132 COPY_SCALAR_FIELD(xmloption);
1133 COPY_SCALAR_FIELD(type);
1134 COPY_SCALAR_FIELD(typmod);
1140 * _copyNullIfExpr (same as OpExpr)
1143 _copyNullIfExpr(NullIfExpr *from)
1145 NullIfExpr *newnode = makeNode(NullIfExpr);
1147 COPY_SCALAR_FIELD(opno);
1148 COPY_SCALAR_FIELD(opfuncid);
1149 COPY_SCALAR_FIELD(opresulttype);
1150 COPY_SCALAR_FIELD(opretset);
1151 COPY_NODE_FIELD(args);
1160 _copyNullTest(NullTest *from)
1162 NullTest *newnode = makeNode(NullTest);
1164 COPY_NODE_FIELD(arg);
1165 COPY_SCALAR_FIELD(nulltesttype);
1173 static BooleanTest *
1174 _copyBooleanTest(BooleanTest *from)
1176 BooleanTest *newnode = makeNode(BooleanTest);
1178 COPY_NODE_FIELD(arg);
1179 COPY_SCALAR_FIELD(booltesttype);
1185 * _copyCoerceToDomain
1187 static CoerceToDomain *
1188 _copyCoerceToDomain(CoerceToDomain *from)
1190 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1192 COPY_NODE_FIELD(arg);
1193 COPY_SCALAR_FIELD(resulttype);
1194 COPY_SCALAR_FIELD(resulttypmod);
1195 COPY_SCALAR_FIELD(coercionformat);
1201 * _copyCoerceToDomainValue
1203 static CoerceToDomainValue *
1204 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1206 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1208 COPY_SCALAR_FIELD(typeId);
1209 COPY_SCALAR_FIELD(typeMod);
1217 static SetToDefault *
1218 _copySetToDefault(SetToDefault *from)
1220 SetToDefault *newnode = makeNode(SetToDefault);
1222 COPY_SCALAR_FIELD(typeId);
1223 COPY_SCALAR_FIELD(typeMod);
1231 static TargetEntry *
1232 _copyTargetEntry(TargetEntry *from)
1234 TargetEntry *newnode = makeNode(TargetEntry);
1236 COPY_NODE_FIELD(expr);
1237 COPY_SCALAR_FIELD(resno);
1238 COPY_STRING_FIELD(resname);
1239 COPY_SCALAR_FIELD(ressortgroupref);
1240 COPY_SCALAR_FIELD(resorigtbl);
1241 COPY_SCALAR_FIELD(resorigcol);
1242 COPY_SCALAR_FIELD(resjunk);
1250 static RangeTblRef *
1251 _copyRangeTblRef(RangeTblRef *from)
1253 RangeTblRef *newnode = makeNode(RangeTblRef);
1255 COPY_SCALAR_FIELD(rtindex);
1264 _copyJoinExpr(JoinExpr *from)
1266 JoinExpr *newnode = makeNode(JoinExpr);
1268 COPY_SCALAR_FIELD(jointype);
1269 COPY_SCALAR_FIELD(isNatural);
1270 COPY_NODE_FIELD(larg);
1271 COPY_NODE_FIELD(rarg);
1272 COPY_NODE_FIELD(using);
1273 COPY_NODE_FIELD(quals);
1274 COPY_NODE_FIELD(alias);
1275 COPY_SCALAR_FIELD(rtindex);
1284 _copyFromExpr(FromExpr *from)
1286 FromExpr *newnode = makeNode(FromExpr);
1288 COPY_NODE_FIELD(fromlist);
1289 COPY_NODE_FIELD(quals);
1294 /* ****************************************************************
1295 * relation.h copy functions
1297 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1298 * There are some subsidiary structs that are useful to copy, though.
1299 * ****************************************************************
1306 _copyPathKey(PathKey *from)
1308 PathKey *newnode = makeNode(PathKey);
1310 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1311 COPY_SCALAR_FIELD(pk_eclass);
1312 COPY_SCALAR_FIELD(pk_opfamily);
1313 COPY_SCALAR_FIELD(pk_strategy);
1314 COPY_SCALAR_FIELD(pk_nulls_first);
1322 static RestrictInfo *
1323 _copyRestrictInfo(RestrictInfo *from)
1325 RestrictInfo *newnode = makeNode(RestrictInfo);
1327 COPY_NODE_FIELD(clause);
1328 COPY_SCALAR_FIELD(is_pushed_down);
1329 COPY_SCALAR_FIELD(outerjoin_delayed);
1330 COPY_SCALAR_FIELD(can_join);
1331 COPY_SCALAR_FIELD(pseudoconstant);
1332 COPY_BITMAPSET_FIELD(clause_relids);
1333 COPY_BITMAPSET_FIELD(required_relids);
1334 COPY_BITMAPSET_FIELD(left_relids);
1335 COPY_BITMAPSET_FIELD(right_relids);
1336 COPY_NODE_FIELD(orclause);
1337 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1338 COPY_SCALAR_FIELD(parent_ec);
1339 COPY_SCALAR_FIELD(eval_cost);
1340 COPY_SCALAR_FIELD(this_selec);
1341 COPY_NODE_FIELD(mergeopfamilies);
1342 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1343 COPY_SCALAR_FIELD(left_ec);
1344 COPY_SCALAR_FIELD(right_ec);
1345 COPY_SCALAR_FIELD(left_em);
1346 COPY_SCALAR_FIELD(right_em);
1347 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1348 newnode->scansel_cache = NIL;
1349 COPY_SCALAR_FIELD(outer_is_left);
1350 COPY_SCALAR_FIELD(hashjoinoperator);
1351 COPY_SCALAR_FIELD(left_bucketsize);
1352 COPY_SCALAR_FIELD(right_bucketsize);
1358 * _copyOuterJoinInfo
1360 static OuterJoinInfo *
1361 _copyOuterJoinInfo(OuterJoinInfo *from)
1363 OuterJoinInfo *newnode = makeNode(OuterJoinInfo);
1365 COPY_BITMAPSET_FIELD(min_lefthand);
1366 COPY_BITMAPSET_FIELD(min_righthand);
1367 COPY_SCALAR_FIELD(is_full_join);
1368 COPY_SCALAR_FIELD(lhs_strict);
1376 static InClauseInfo *
1377 _copyInClauseInfo(InClauseInfo *from)
1379 InClauseInfo *newnode = makeNode(InClauseInfo);
1381 COPY_BITMAPSET_FIELD(lefthand);
1382 COPY_BITMAPSET_FIELD(righthand);
1383 COPY_NODE_FIELD(sub_targetlist);
1384 COPY_NODE_FIELD(in_operators);
1390 * _copyAppendRelInfo
1392 static AppendRelInfo *
1393 _copyAppendRelInfo(AppendRelInfo *from)
1395 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1397 COPY_SCALAR_FIELD(parent_relid);
1398 COPY_SCALAR_FIELD(child_relid);
1399 COPY_SCALAR_FIELD(parent_reltype);
1400 COPY_SCALAR_FIELD(child_reltype);
1401 COPY_NODE_FIELD(col_mappings);
1402 COPY_NODE_FIELD(translated_vars);
1403 COPY_SCALAR_FIELD(parent_reloid);
1408 /* ****************************************************************
1409 * parsenodes.h copy functions
1410 * ****************************************************************
1413 static RangeTblEntry *
1414 _copyRangeTblEntry(RangeTblEntry *from)
1416 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1418 COPY_SCALAR_FIELD(rtekind);
1419 COPY_SCALAR_FIELD(relid);
1420 COPY_NODE_FIELD(subquery);
1421 COPY_NODE_FIELD(funcexpr);
1422 COPY_NODE_FIELD(funccoltypes);
1423 COPY_NODE_FIELD(funccoltypmods);
1424 COPY_NODE_FIELD(values_lists);
1425 COPY_SCALAR_FIELD(jointype);
1426 COPY_NODE_FIELD(joinaliasvars);
1427 COPY_NODE_FIELD(alias);
1428 COPY_NODE_FIELD(eref);
1429 COPY_SCALAR_FIELD(inh);
1430 COPY_SCALAR_FIELD(inFromCl);
1431 COPY_SCALAR_FIELD(requiredPerms);
1432 COPY_SCALAR_FIELD(checkAsUser);
1437 static FkConstraint *
1438 _copyFkConstraint(FkConstraint *from)
1440 FkConstraint *newnode = makeNode(FkConstraint);
1442 COPY_STRING_FIELD(constr_name);
1443 COPY_NODE_FIELD(pktable);
1444 COPY_NODE_FIELD(fk_attrs);
1445 COPY_NODE_FIELD(pk_attrs);
1446 COPY_SCALAR_FIELD(fk_matchtype);
1447 COPY_SCALAR_FIELD(fk_upd_action);
1448 COPY_SCALAR_FIELD(fk_del_action);
1449 COPY_SCALAR_FIELD(deferrable);
1450 COPY_SCALAR_FIELD(initdeferred);
1451 COPY_SCALAR_FIELD(skip_validation);
1457 _copySortClause(SortClause *from)
1459 SortClause *newnode = makeNode(SortClause);
1461 COPY_SCALAR_FIELD(tleSortGroupRef);
1462 COPY_SCALAR_FIELD(sortop);
1463 COPY_SCALAR_FIELD(nulls_first);
1468 static GroupClause *
1469 _copyGroupClause(GroupClause *from)
1471 GroupClause *newnode = makeNode(GroupClause);
1473 COPY_SCALAR_FIELD(tleSortGroupRef);
1474 COPY_SCALAR_FIELD(sortop);
1475 COPY_SCALAR_FIELD(nulls_first);
1480 static RowMarkClause *
1481 _copyRowMarkClause(RowMarkClause *from)
1483 RowMarkClause *newnode = makeNode(RowMarkClause);
1485 COPY_SCALAR_FIELD(rti);
1486 COPY_SCALAR_FIELD(forUpdate);
1487 COPY_SCALAR_FIELD(noWait);
1493 _copyAExpr(A_Expr *from)
1495 A_Expr *newnode = makeNode(A_Expr);
1497 COPY_SCALAR_FIELD(kind);
1498 COPY_NODE_FIELD(name);
1499 COPY_NODE_FIELD(lexpr);
1500 COPY_NODE_FIELD(rexpr);
1501 COPY_SCALAR_FIELD(location);
1507 _copyColumnRef(ColumnRef *from)
1509 ColumnRef *newnode = makeNode(ColumnRef);
1511 COPY_NODE_FIELD(fields);
1512 COPY_SCALAR_FIELD(location);
1518 _copyParamRef(ParamRef *from)
1520 ParamRef *newnode = makeNode(ParamRef);
1522 COPY_SCALAR_FIELD(number);
1528 _copyAConst(A_Const *from)
1530 A_Const *newnode = makeNode(A_Const);
1532 /* This part must duplicate _copyValue */
1533 COPY_SCALAR_FIELD(val.type);
1534 switch (from->val.type)
1537 COPY_SCALAR_FIELD(val.val.ival);
1542 COPY_STRING_FIELD(val.val.str);
1548 elog(ERROR, "unrecognized node type: %d",
1549 (int) from->val.type);
1553 COPY_NODE_FIELD(typename);
1559 _copyFuncCall(FuncCall *from)
1561 FuncCall *newnode = makeNode(FuncCall);
1563 COPY_NODE_FIELD(funcname);
1564 COPY_NODE_FIELD(args);
1565 COPY_SCALAR_FIELD(agg_star);
1566 COPY_SCALAR_FIELD(agg_distinct);
1567 COPY_SCALAR_FIELD(location);
1573 _copyAIndices(A_Indices *from)
1575 A_Indices *newnode = makeNode(A_Indices);
1577 COPY_NODE_FIELD(lidx);
1578 COPY_NODE_FIELD(uidx);
1583 static A_Indirection *
1584 _copyA_Indirection(A_Indirection *from)
1586 A_Indirection *newnode = makeNode(A_Indirection);
1588 COPY_NODE_FIELD(arg);
1589 COPY_NODE_FIELD(indirection);
1595 _copyResTarget(ResTarget *from)
1597 ResTarget *newnode = makeNode(ResTarget);
1599 COPY_STRING_FIELD(name);
1600 COPY_NODE_FIELD(indirection);
1601 COPY_NODE_FIELD(val);
1602 COPY_SCALAR_FIELD(location);
1608 _copyTypeName(TypeName *from)
1610 TypeName *newnode = makeNode(TypeName);
1612 COPY_NODE_FIELD(names);
1613 COPY_SCALAR_FIELD(typeid);
1614 COPY_SCALAR_FIELD(timezone);
1615 COPY_SCALAR_FIELD(setof);
1616 COPY_SCALAR_FIELD(pct_type);
1617 COPY_NODE_FIELD(typmods);
1618 COPY_SCALAR_FIELD(typemod);
1619 COPY_NODE_FIELD(arrayBounds);
1620 COPY_SCALAR_FIELD(location);
1626 _copySortBy(SortBy *from)
1628 SortBy *newnode = makeNode(SortBy);
1630 COPY_SCALAR_FIELD(sortby_dir);
1631 COPY_SCALAR_FIELD(sortby_nulls);
1632 COPY_NODE_FIELD(useOp);
1633 COPY_NODE_FIELD(node);
1638 static RangeSubselect *
1639 _copyRangeSubselect(RangeSubselect *from)
1641 RangeSubselect *newnode = makeNode(RangeSubselect);
1643 COPY_NODE_FIELD(subquery);
1644 COPY_NODE_FIELD(alias);
1649 static RangeFunction *
1650 _copyRangeFunction(RangeFunction *from)
1652 RangeFunction *newnode = makeNode(RangeFunction);
1654 COPY_NODE_FIELD(funccallnode);
1655 COPY_NODE_FIELD(alias);
1656 COPY_NODE_FIELD(coldeflist);
1662 _copyTypeCast(TypeCast *from)
1664 TypeCast *newnode = makeNode(TypeCast);
1666 COPY_NODE_FIELD(arg);
1667 COPY_NODE_FIELD(typename);
1673 _copyIndexElem(IndexElem *from)
1675 IndexElem *newnode = makeNode(IndexElem);
1677 COPY_STRING_FIELD(name);
1678 COPY_NODE_FIELD(expr);
1679 COPY_NODE_FIELD(opclass);
1680 COPY_SCALAR_FIELD(ordering);
1681 COPY_SCALAR_FIELD(nulls_ordering);
1687 _copyColumnDef(ColumnDef *from)
1689 ColumnDef *newnode = makeNode(ColumnDef);
1691 COPY_STRING_FIELD(colname);
1692 COPY_NODE_FIELD(typename);
1693 COPY_SCALAR_FIELD(inhcount);
1694 COPY_SCALAR_FIELD(is_local);
1695 COPY_SCALAR_FIELD(is_not_null);
1696 COPY_NODE_FIELD(raw_default);
1697 COPY_STRING_FIELD(cooked_default);
1698 COPY_NODE_FIELD(constraints);
1704 _copyConstraint(Constraint *from)
1706 Constraint *newnode = makeNode(Constraint);
1708 COPY_SCALAR_FIELD(contype);
1709 COPY_STRING_FIELD(name);
1710 COPY_NODE_FIELD(raw_expr);
1711 COPY_STRING_FIELD(cooked_expr);
1712 COPY_NODE_FIELD(keys);
1713 COPY_NODE_FIELD(options);
1714 COPY_STRING_FIELD(indexspace);
1720 _copyDefElem(DefElem *from)
1722 DefElem *newnode = makeNode(DefElem);
1724 COPY_STRING_FIELD(defname);
1725 COPY_NODE_FIELD(arg);
1730 static LockingClause *
1731 _copyLockingClause(LockingClause *from)
1733 LockingClause *newnode = makeNode(LockingClause);
1735 COPY_NODE_FIELD(lockedRels);
1736 COPY_SCALAR_FIELD(forUpdate);
1737 COPY_SCALAR_FIELD(noWait);
1742 static XmlSerialize *
1743 _copyXmlSerialize(XmlSerialize *from)
1745 XmlSerialize *newnode = makeNode(XmlSerialize);
1747 COPY_SCALAR_FIELD(xmloption);
1748 COPY_NODE_FIELD(expr);
1749 COPY_NODE_FIELD(typename);
1755 _copyQuery(Query *from)
1757 Query *newnode = makeNode(Query);
1759 COPY_SCALAR_FIELD(commandType);
1760 COPY_SCALAR_FIELD(querySource);
1761 COPY_SCALAR_FIELD(canSetTag);
1762 COPY_NODE_FIELD(utilityStmt);
1763 COPY_SCALAR_FIELD(resultRelation);
1764 COPY_NODE_FIELD(into);
1765 COPY_NODE_FIELD(intoOptions);
1766 COPY_SCALAR_FIELD(intoOnCommit);
1767 COPY_STRING_FIELD(intoTableSpaceName);
1768 COPY_SCALAR_FIELD(hasAggs);
1769 COPY_SCALAR_FIELD(hasSubLinks);
1770 COPY_NODE_FIELD(rtable);
1771 COPY_NODE_FIELD(jointree);
1772 COPY_NODE_FIELD(targetList);
1773 COPY_NODE_FIELD(returningList);
1774 COPY_NODE_FIELD(groupClause);
1775 COPY_NODE_FIELD(havingQual);
1776 COPY_NODE_FIELD(distinctClause);
1777 COPY_NODE_FIELD(sortClause);
1778 COPY_NODE_FIELD(limitOffset);
1779 COPY_NODE_FIELD(limitCount);
1780 COPY_NODE_FIELD(rowMarks);
1781 COPY_NODE_FIELD(setOperations);
1782 COPY_NODE_FIELD(resultRelations);
1783 COPY_NODE_FIELD(returningLists);
1789 _copyInsertStmt(InsertStmt *from)
1791 InsertStmt *newnode = makeNode(InsertStmt);
1793 COPY_NODE_FIELD(relation);
1794 COPY_NODE_FIELD(cols);
1795 COPY_NODE_FIELD(selectStmt);
1796 COPY_NODE_FIELD(returningList);
1802 _copyDeleteStmt(DeleteStmt *from)
1804 DeleteStmt *newnode = makeNode(DeleteStmt);
1806 COPY_NODE_FIELD(relation);
1807 COPY_NODE_FIELD(usingClause);
1808 COPY_NODE_FIELD(whereClause);
1809 COPY_NODE_FIELD(returningList);
1815 _copyUpdateStmt(UpdateStmt *from)
1817 UpdateStmt *newnode = makeNode(UpdateStmt);
1819 COPY_NODE_FIELD(relation);
1820 COPY_NODE_FIELD(targetList);
1821 COPY_NODE_FIELD(whereClause);
1822 COPY_NODE_FIELD(fromClause);
1823 COPY_NODE_FIELD(returningList);
1829 _copySelectStmt(SelectStmt *from)
1831 SelectStmt *newnode = makeNode(SelectStmt);
1833 COPY_NODE_FIELD(distinctClause);
1834 COPY_NODE_FIELD(into);
1835 COPY_NODE_FIELD(intoColNames);
1836 COPY_NODE_FIELD(intoOptions);
1837 COPY_SCALAR_FIELD(intoOnCommit);
1838 COPY_STRING_FIELD(intoTableSpaceName);
1839 COPY_NODE_FIELD(targetList);
1840 COPY_NODE_FIELD(fromClause);
1841 COPY_NODE_FIELD(whereClause);
1842 COPY_NODE_FIELD(groupClause);
1843 COPY_NODE_FIELD(havingClause);
1844 COPY_NODE_FIELD(valuesLists);
1845 COPY_NODE_FIELD(sortClause);
1846 COPY_NODE_FIELD(limitOffset);
1847 COPY_NODE_FIELD(limitCount);
1848 COPY_NODE_FIELD(lockingClause);
1849 COPY_SCALAR_FIELD(op);
1850 COPY_SCALAR_FIELD(all);
1851 COPY_NODE_FIELD(larg);
1852 COPY_NODE_FIELD(rarg);
1857 static SetOperationStmt *
1858 _copySetOperationStmt(SetOperationStmt *from)
1860 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1862 COPY_SCALAR_FIELD(op);
1863 COPY_SCALAR_FIELD(all);
1864 COPY_NODE_FIELD(larg);
1865 COPY_NODE_FIELD(rarg);
1866 COPY_NODE_FIELD(colTypes);
1867 COPY_NODE_FIELD(colTypmods);
1872 static AlterTableStmt *
1873 _copyAlterTableStmt(AlterTableStmt *from)
1875 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1877 COPY_NODE_FIELD(relation);
1878 COPY_NODE_FIELD(cmds);
1879 COPY_SCALAR_FIELD(relkind);
1884 static AlterTableCmd *
1885 _copyAlterTableCmd(AlterTableCmd *from)
1887 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1889 COPY_SCALAR_FIELD(subtype);
1890 COPY_STRING_FIELD(name);
1891 COPY_NODE_FIELD(def);
1892 COPY_NODE_FIELD(transform);
1893 COPY_SCALAR_FIELD(behavior);
1898 static AlterDomainStmt *
1899 _copyAlterDomainStmt(AlterDomainStmt *from)
1901 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1903 COPY_SCALAR_FIELD(subtype);
1904 COPY_NODE_FIELD(typename);
1905 COPY_STRING_FIELD(name);
1906 COPY_NODE_FIELD(def);
1907 COPY_SCALAR_FIELD(behavior);
1913 _copyGrantStmt(GrantStmt *from)
1915 GrantStmt *newnode = makeNode(GrantStmt);
1917 COPY_SCALAR_FIELD(is_grant);
1918 COPY_SCALAR_FIELD(objtype);
1919 COPY_NODE_FIELD(objects);
1920 COPY_NODE_FIELD(privileges);
1921 COPY_NODE_FIELD(grantees);
1922 COPY_SCALAR_FIELD(grant_option);
1923 COPY_SCALAR_FIELD(behavior);
1928 static PrivGrantee *
1929 _copyPrivGrantee(PrivGrantee *from)
1931 PrivGrantee *newnode = makeNode(PrivGrantee);
1933 COPY_STRING_FIELD(rolname);
1938 static FuncWithArgs *
1939 _copyFuncWithArgs(FuncWithArgs *from)
1941 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1943 COPY_NODE_FIELD(funcname);
1944 COPY_NODE_FIELD(funcargs);
1949 static GrantRoleStmt *
1950 _copyGrantRoleStmt(GrantRoleStmt *from)
1952 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
1954 COPY_NODE_FIELD(granted_roles);
1955 COPY_NODE_FIELD(grantee_roles);
1956 COPY_SCALAR_FIELD(is_grant);
1957 COPY_SCALAR_FIELD(admin_opt);
1958 COPY_STRING_FIELD(grantor);
1959 COPY_SCALAR_FIELD(behavior);
1964 static DeclareCursorStmt *
1965 _copyDeclareCursorStmt(DeclareCursorStmt *from)
1967 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
1969 COPY_STRING_FIELD(portalname);
1970 COPY_SCALAR_FIELD(options);
1971 COPY_NODE_FIELD(query);
1976 static ClosePortalStmt *
1977 _copyClosePortalStmt(ClosePortalStmt *from)
1979 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
1981 COPY_STRING_FIELD(portalname);
1986 static ClusterStmt *
1987 _copyClusterStmt(ClusterStmt *from)
1989 ClusterStmt *newnode = makeNode(ClusterStmt);
1991 COPY_NODE_FIELD(relation);
1992 COPY_STRING_FIELD(indexname);
1998 _copyCopyStmt(CopyStmt *from)
2000 CopyStmt *newnode = makeNode(CopyStmt);
2002 COPY_NODE_FIELD(relation);
2003 COPY_NODE_FIELD(query);
2004 COPY_NODE_FIELD(attlist);
2005 COPY_SCALAR_FIELD(is_from);
2006 COPY_STRING_FIELD(filename);
2007 COPY_NODE_FIELD(options);
2013 _copyCreateStmt(CreateStmt *from)
2015 CreateStmt *newnode = makeNode(CreateStmt);
2017 COPY_NODE_FIELD(relation);
2018 COPY_NODE_FIELD(tableElts);
2019 COPY_NODE_FIELD(inhRelations);
2020 COPY_NODE_FIELD(constraints);
2021 COPY_NODE_FIELD(options);
2022 COPY_SCALAR_FIELD(oncommit);
2023 COPY_STRING_FIELD(tablespacename);
2028 static InhRelation *
2029 _copyInhRelation(InhRelation *from)
2031 InhRelation *newnode = makeNode(InhRelation);
2033 COPY_NODE_FIELD(relation);
2034 COPY_NODE_FIELD(options);
2040 _copyDefineStmt(DefineStmt *from)
2042 DefineStmt *newnode = makeNode(DefineStmt);
2044 COPY_SCALAR_FIELD(kind);
2045 COPY_SCALAR_FIELD(oldstyle);
2046 COPY_NODE_FIELD(defnames);
2047 COPY_NODE_FIELD(args);
2048 COPY_NODE_FIELD(definition);
2054 _copyDropStmt(DropStmt *from)
2056 DropStmt *newnode = makeNode(DropStmt);
2058 COPY_NODE_FIELD(objects);
2059 COPY_SCALAR_FIELD(removeType);
2060 COPY_SCALAR_FIELD(behavior);
2061 COPY_SCALAR_FIELD(missing_ok);
2066 static TruncateStmt *
2067 _copyTruncateStmt(TruncateStmt *from)
2069 TruncateStmt *newnode = makeNode(TruncateStmt);
2071 COPY_NODE_FIELD(relations);
2072 COPY_SCALAR_FIELD(behavior);
2077 static CommentStmt *
2078 _copyCommentStmt(CommentStmt *from)
2080 CommentStmt *newnode = makeNode(CommentStmt);
2082 COPY_SCALAR_FIELD(objtype);
2083 COPY_NODE_FIELD(objname);
2084 COPY_NODE_FIELD(objargs);
2085 COPY_STRING_FIELD(comment);
2091 _copyFetchStmt(FetchStmt *from)
2093 FetchStmt *newnode = makeNode(FetchStmt);
2095 COPY_SCALAR_FIELD(direction);
2096 COPY_SCALAR_FIELD(howMany);
2097 COPY_STRING_FIELD(portalname);
2098 COPY_SCALAR_FIELD(ismove);
2104 _copyIndexStmt(IndexStmt *from)
2106 IndexStmt *newnode = makeNode(IndexStmt);
2108 COPY_STRING_FIELD(idxname);
2109 COPY_NODE_FIELD(relation);
2110 COPY_STRING_FIELD(accessMethod);
2111 COPY_STRING_FIELD(tableSpace);
2112 COPY_NODE_FIELD(indexParams);
2113 COPY_NODE_FIELD(options);
2114 COPY_NODE_FIELD(whereClause);
2115 COPY_NODE_FIELD(rangetable);
2116 COPY_SCALAR_FIELD(unique);
2117 COPY_SCALAR_FIELD(primary);
2118 COPY_SCALAR_FIELD(isconstraint);
2119 COPY_SCALAR_FIELD(concurrent);
2124 static CreateFunctionStmt *
2125 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2127 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2129 COPY_SCALAR_FIELD(replace);
2130 COPY_NODE_FIELD(funcname);
2131 COPY_NODE_FIELD(parameters);
2132 COPY_NODE_FIELD(returnType);
2133 COPY_NODE_FIELD(options);
2134 COPY_NODE_FIELD(withClause);
2139 static FunctionParameter *
2140 _copyFunctionParameter(FunctionParameter *from)
2142 FunctionParameter *newnode = makeNode(FunctionParameter);
2144 COPY_STRING_FIELD(name);
2145 COPY_NODE_FIELD(argType);
2146 COPY_SCALAR_FIELD(mode);
2151 static AlterFunctionStmt *
2152 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2154 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2156 COPY_NODE_FIELD(func);
2157 COPY_NODE_FIELD(actions);
2162 static RemoveFuncStmt *
2163 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2165 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2167 COPY_SCALAR_FIELD(kind);
2168 COPY_NODE_FIELD(name);
2169 COPY_NODE_FIELD(args);
2170 COPY_SCALAR_FIELD(behavior);
2171 COPY_SCALAR_FIELD(missing_ok);
2176 static RemoveOpClassStmt *
2177 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2179 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2181 COPY_NODE_FIELD(opclassname);
2182 COPY_STRING_FIELD(amname);
2183 COPY_SCALAR_FIELD(behavior);
2184 COPY_SCALAR_FIELD(missing_ok);
2189 static RemoveOpFamilyStmt *
2190 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2192 RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2194 COPY_NODE_FIELD(opfamilyname);
2195 COPY_STRING_FIELD(amname);
2196 COPY_SCALAR_FIELD(behavior);
2197 COPY_SCALAR_FIELD(missing_ok);
2203 _copyRenameStmt(RenameStmt *from)
2205 RenameStmt *newnode = makeNode(RenameStmt);
2207 COPY_SCALAR_FIELD(renameType);
2208 COPY_NODE_FIELD(relation);
2209 COPY_NODE_FIELD(object);
2210 COPY_NODE_FIELD(objarg);
2211 COPY_STRING_FIELD(subname);
2212 COPY_STRING_FIELD(newname);
2217 static AlterObjectSchemaStmt *
2218 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2220 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2222 COPY_SCALAR_FIELD(objectType);
2223 COPY_NODE_FIELD(relation);
2224 COPY_NODE_FIELD(object);
2225 COPY_NODE_FIELD(objarg);
2226 COPY_STRING_FIELD(addname);
2227 COPY_STRING_FIELD(newschema);
2232 static AlterOwnerStmt *
2233 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2235 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2237 COPY_SCALAR_FIELD(objectType);
2238 COPY_NODE_FIELD(relation);
2239 COPY_NODE_FIELD(object);
2240 COPY_NODE_FIELD(objarg);
2241 COPY_STRING_FIELD(addname);
2242 COPY_STRING_FIELD(newowner);
2248 _copyRuleStmt(RuleStmt *from)
2250 RuleStmt *newnode = makeNode(RuleStmt);
2252 COPY_NODE_FIELD(relation);
2253 COPY_STRING_FIELD(rulename);
2254 COPY_NODE_FIELD(whereClause);
2255 COPY_SCALAR_FIELD(event);
2256 COPY_SCALAR_FIELD(instead);
2257 COPY_NODE_FIELD(actions);
2258 COPY_SCALAR_FIELD(replace);
2264 _copyNotifyStmt(NotifyStmt *from)
2266 NotifyStmt *newnode = makeNode(NotifyStmt);
2268 COPY_NODE_FIELD(relation);
2274 _copyListenStmt(ListenStmt *from)
2276 ListenStmt *newnode = makeNode(ListenStmt);
2278 COPY_NODE_FIELD(relation);
2283 static UnlistenStmt *
2284 _copyUnlistenStmt(UnlistenStmt *from)
2286 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2288 COPY_NODE_FIELD(relation);
2293 static TransactionStmt *
2294 _copyTransactionStmt(TransactionStmt *from)
2296 TransactionStmt *newnode = makeNode(TransactionStmt);
2298 COPY_SCALAR_FIELD(kind);
2299 COPY_NODE_FIELD(options);
2300 COPY_STRING_FIELD(gid);
2305 static CompositeTypeStmt *
2306 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2308 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2310 COPY_NODE_FIELD(typevar);
2311 COPY_NODE_FIELD(coldeflist);
2317 _copyViewStmt(ViewStmt *from)
2319 ViewStmt *newnode = makeNode(ViewStmt);
2321 COPY_NODE_FIELD(view);
2322 COPY_NODE_FIELD(aliases);
2323 COPY_NODE_FIELD(query);
2324 COPY_SCALAR_FIELD(replace);
2330 _copyLoadStmt(LoadStmt *from)
2332 LoadStmt *newnode = makeNode(LoadStmt);
2334 COPY_STRING_FIELD(filename);
2339 static CreateDomainStmt *
2340 _copyCreateDomainStmt(CreateDomainStmt *from)
2342 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2344 COPY_NODE_FIELD(domainname);
2345 COPY_NODE_FIELD(typename);
2346 COPY_NODE_FIELD(constraints);
2351 static CreateOpClassStmt *
2352 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2354 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2356 COPY_NODE_FIELD(opclassname);
2357 COPY_NODE_FIELD(opfamilyname);
2358 COPY_STRING_FIELD(amname);
2359 COPY_NODE_FIELD(datatype);
2360 COPY_NODE_FIELD(items);
2361 COPY_SCALAR_FIELD(isDefault);
2366 static CreateOpClassItem *
2367 _copyCreateOpClassItem(CreateOpClassItem *from)
2369 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2371 COPY_SCALAR_FIELD(itemtype);
2372 COPY_NODE_FIELD(name);
2373 COPY_NODE_FIELD(args);
2374 COPY_SCALAR_FIELD(number);
2375 COPY_SCALAR_FIELD(recheck);
2376 COPY_NODE_FIELD(class_args);
2377 COPY_NODE_FIELD(storedtype);
2382 static CreateOpFamilyStmt *
2383 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
2385 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
2387 COPY_NODE_FIELD(opfamilyname);
2388 COPY_STRING_FIELD(amname);
2393 static AlterOpFamilyStmt *
2394 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
2396 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
2398 COPY_NODE_FIELD(opfamilyname);
2399 COPY_STRING_FIELD(amname);
2400 COPY_SCALAR_FIELD(isDrop);
2401 COPY_NODE_FIELD(items);
2406 static CreatedbStmt *
2407 _copyCreatedbStmt(CreatedbStmt *from)
2409 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2411 COPY_STRING_FIELD(dbname);
2412 COPY_NODE_FIELD(options);
2417 static AlterDatabaseStmt *
2418 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2420 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2422 COPY_STRING_FIELD(dbname);
2423 COPY_NODE_FIELD(options);
2428 static AlterDatabaseSetStmt *
2429 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2431 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2433 COPY_STRING_FIELD(dbname);
2434 COPY_STRING_FIELD(variable);
2435 COPY_NODE_FIELD(value);
2441 _copyDropdbStmt(DropdbStmt *from)
2443 DropdbStmt *newnode = makeNode(DropdbStmt);
2445 COPY_STRING_FIELD(dbname);
2446 COPY_SCALAR_FIELD(missing_ok);
2452 _copyVacuumStmt(VacuumStmt *from)
2454 VacuumStmt *newnode = makeNode(VacuumStmt);
2456 COPY_SCALAR_FIELD(vacuum);
2457 COPY_SCALAR_FIELD(full);
2458 COPY_SCALAR_FIELD(analyze);
2459 COPY_SCALAR_FIELD(verbose);
2460 COPY_SCALAR_FIELD(freeze_min_age);
2461 COPY_NODE_FIELD(relation);
2462 COPY_NODE_FIELD(va_cols);
2467 static ExplainStmt *
2468 _copyExplainStmt(ExplainStmt *from)
2470 ExplainStmt *newnode = makeNode(ExplainStmt);
2472 COPY_NODE_FIELD(query);
2473 COPY_SCALAR_FIELD(verbose);
2474 COPY_SCALAR_FIELD(analyze);
2479 static CreateSeqStmt *
2480 _copyCreateSeqStmt(CreateSeqStmt *from)
2482 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2484 COPY_NODE_FIELD(sequence);
2485 COPY_NODE_FIELD(options);
2490 static AlterSeqStmt *
2491 _copyAlterSeqStmt(AlterSeqStmt *from)
2493 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2495 COPY_NODE_FIELD(sequence);
2496 COPY_NODE_FIELD(options);
2501 static VariableSetStmt *
2502 _copyVariableSetStmt(VariableSetStmt *from)
2504 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2506 COPY_STRING_FIELD(name);
2507 COPY_NODE_FIELD(args);
2508 COPY_SCALAR_FIELD(is_local);
2513 static VariableShowStmt *
2514 _copyVariableShowStmt(VariableShowStmt *from)
2516 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2518 COPY_STRING_FIELD(name);
2523 static VariableResetStmt *
2524 _copyVariableResetStmt(VariableResetStmt *from)
2526 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2528 COPY_STRING_FIELD(name);
2533 static CreateTableSpaceStmt *
2534 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2536 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2538 COPY_STRING_FIELD(tablespacename);
2539 COPY_STRING_FIELD(owner);
2540 COPY_STRING_FIELD(location);
2545 static DropTableSpaceStmt *
2546 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2548 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2550 COPY_STRING_FIELD(tablespacename);
2551 COPY_SCALAR_FIELD(missing_ok);
2556 static CreateTrigStmt *
2557 _copyCreateTrigStmt(CreateTrigStmt *from)
2559 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2561 COPY_STRING_FIELD(trigname);
2562 COPY_NODE_FIELD(relation);
2563 COPY_NODE_FIELD(funcname);
2564 COPY_NODE_FIELD(args);
2565 COPY_SCALAR_FIELD(before);
2566 COPY_SCALAR_FIELD(row);
2567 strcpy(newnode->actions, from->actions); /* in-line string field */
2568 COPY_SCALAR_FIELD(isconstraint);
2569 COPY_SCALAR_FIELD(deferrable);
2570 COPY_SCALAR_FIELD(initdeferred);
2571 COPY_NODE_FIELD(constrrel);
2576 static DropPropertyStmt *
2577 _copyDropPropertyStmt(DropPropertyStmt *from)
2579 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2581 COPY_NODE_FIELD(relation);
2582 COPY_STRING_FIELD(property);
2583 COPY_SCALAR_FIELD(removeType);
2584 COPY_SCALAR_FIELD(behavior);
2585 COPY_SCALAR_FIELD(missing_ok);
2590 static CreatePLangStmt *
2591 _copyCreatePLangStmt(CreatePLangStmt *from)
2593 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2595 COPY_STRING_FIELD(plname);
2596 COPY_NODE_FIELD(plhandler);
2597 COPY_NODE_FIELD(plvalidator);
2598 COPY_SCALAR_FIELD(pltrusted);
2603 static DropPLangStmt *
2604 _copyDropPLangStmt(DropPLangStmt *from)
2606 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2608 COPY_STRING_FIELD(plname);
2609 COPY_SCALAR_FIELD(behavior);
2610 COPY_SCALAR_FIELD(missing_ok);
2615 static CreateRoleStmt *
2616 _copyCreateRoleStmt(CreateRoleStmt *from)
2618 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2620 COPY_SCALAR_FIELD(stmt_type);
2621 COPY_STRING_FIELD(role);
2622 COPY_NODE_FIELD(options);
2627 static AlterRoleStmt *
2628 _copyAlterRoleStmt(AlterRoleStmt *from)
2630 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2632 COPY_STRING_FIELD(role);
2633 COPY_NODE_FIELD(options);
2634 COPY_SCALAR_FIELD(action);
2639 static AlterRoleSetStmt *
2640 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2642 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2644 COPY_STRING_FIELD(role);
2645 COPY_STRING_FIELD(variable);
2646 COPY_NODE_FIELD(value);
2651 static DropRoleStmt *
2652 _copyDropRoleStmt(DropRoleStmt *from)
2654 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2656 COPY_NODE_FIELD(roles);
2657 COPY_SCALAR_FIELD(missing_ok);
2663 _copyLockStmt(LockStmt *from)
2665 LockStmt *newnode = makeNode(LockStmt);
2667 COPY_NODE_FIELD(relations);
2668 COPY_SCALAR_FIELD(mode);
2669 COPY_SCALAR_FIELD(nowait);
2674 static ConstraintsSetStmt *
2675 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2677 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2679 COPY_NODE_FIELD(constraints);
2680 COPY_SCALAR_FIELD(deferred);
2685 static ReindexStmt *
2686 _copyReindexStmt(ReindexStmt *from)
2688 ReindexStmt *newnode = makeNode(ReindexStmt);
2690 COPY_SCALAR_FIELD(kind);
2691 COPY_NODE_FIELD(relation);
2692 COPY_STRING_FIELD(name);
2693 COPY_SCALAR_FIELD(do_system);
2694 COPY_SCALAR_FIELD(do_user);
2699 static CreateSchemaStmt *
2700 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2702 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2704 COPY_STRING_FIELD(schemaname);
2705 COPY_STRING_FIELD(authid);
2706 COPY_NODE_FIELD(schemaElts);
2711 static CreateConversionStmt *
2712 _copyCreateConversionStmt(CreateConversionStmt *from)
2714 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2716 COPY_NODE_FIELD(conversion_name);
2717 COPY_STRING_FIELD(for_encoding_name);
2718 COPY_STRING_FIELD(to_encoding_name);
2719 COPY_NODE_FIELD(func_name);
2720 COPY_SCALAR_FIELD(def);
2725 static CreateCastStmt *
2726 _copyCreateCastStmt(CreateCastStmt *from)
2728 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2730 COPY_NODE_FIELD(sourcetype);
2731 COPY_NODE_FIELD(targettype);
2732 COPY_NODE_FIELD(func);
2733 COPY_SCALAR_FIELD(context);
2738 static DropCastStmt *
2739 _copyDropCastStmt(DropCastStmt *from)
2741 DropCastStmt *newnode = makeNode(DropCastStmt);
2743 COPY_NODE_FIELD(sourcetype);
2744 COPY_NODE_FIELD(targettype);
2745 COPY_SCALAR_FIELD(behavior);
2746 COPY_SCALAR_FIELD(missing_ok);
2751 static PrepareStmt *
2752 _copyPrepareStmt(PrepareStmt *from)
2754 PrepareStmt *newnode = makeNode(PrepareStmt);
2756 COPY_STRING_FIELD(name);
2757 COPY_NODE_FIELD(argtypes);
2758 COPY_NODE_FIELD(argtype_oids);
2759 COPY_NODE_FIELD(query);
2764 static ExecuteStmt *
2765 _copyExecuteStmt(ExecuteStmt *from)
2767 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2769 COPY_STRING_FIELD(name);
2770 COPY_NODE_FIELD(into);
2771 COPY_NODE_FIELD(intoOptions);
2772 COPY_SCALAR_FIELD(into_on_commit);
2773 COPY_STRING_FIELD(into_tbl_space);
2774 COPY_NODE_FIELD(params);
2779 static DeallocateStmt *
2780 _copyDeallocateStmt(DeallocateStmt *from)
2782 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2784 COPY_STRING_FIELD(name);
2789 static DropOwnedStmt *
2790 _copyDropOwnedStmt(DropOwnedStmt *from)
2792 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2794 COPY_NODE_FIELD(roles);
2795 COPY_SCALAR_FIELD(behavior);
2800 static ReassignOwnedStmt *
2801 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
2803 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2805 COPY_NODE_FIELD(roles);
2806 COPY_SCALAR_FIELD(newrole);
2811 /* ****************************************************************
2812 * pg_list.h copy functions
2813 * ****************************************************************
2817 * Perform a deep copy of the specified list, using copyObject(). The
2818 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2819 * need deep copies, so they should be copied via list_copy()
2821 #define COPY_NODE_CELL(new, old) \
2822 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2823 lfirst(new) = copyObject(lfirst(old));
2826 _copyList(List *from)
2832 Assert(list_length(from) >= 1);
2834 new = makeNode(List);
2835 new->length = from->length;
2837 COPY_NODE_CELL(new->head, from->head);
2838 prev_new = new->head;
2839 curr_old = lnext(from->head);
2843 COPY_NODE_CELL(prev_new->next, curr_old);
2844 prev_new = prev_new->next;
2845 curr_old = curr_old->next;
2847 prev_new->next = NULL;
2848 new->tail = prev_new;
2853 /* ****************************************************************
2854 * value.h copy functions
2855 * ****************************************************************
2858 _copyValue(Value *from)
2860 Value *newnode = makeNode(Value);
2862 /* See also _copyAConst when changing this code! */
2864 COPY_SCALAR_FIELD(type);
2868 COPY_SCALAR_FIELD(val.ival);
2873 COPY_STRING_FIELD(val.str);
2879 elog(ERROR, "unrecognized node type: %d",
2889 * Create a copy of a Node tree or list. This is a "deep" copy: all
2890 * substructure is copied too, recursively.
2893 copyObject(void *from)
2900 switch (nodeTag(from))
2906 retval = _copyPlan(from);
2909 retval = _copyResult(from);
2912 retval = _copyAppend(from);
2915 retval = _copyBitmapAnd(from);
2918 retval = _copyBitmapOr(from);
2921 retval = _copyScan(from);
2924 retval = _copySeqScan(from);
2927 retval = _copyIndexScan(from);
2929 case T_BitmapIndexScan:
2930 retval = _copyBitmapIndexScan(from);
2932 case T_BitmapHeapScan:
2933 retval = _copyBitmapHeapScan(from);
2936 retval = _copyTidScan(from);
2938 case T_SubqueryScan:
2939 retval = _copySubqueryScan(from);
2941 case T_FunctionScan:
2942 retval = _copyFunctionScan(from);
2945 retval = _copyValuesScan(from);
2948 retval = _copyJoin(from);
2951 retval = _copyNestLoop(from);
2954 retval = _copyMergeJoin(from);
2957 retval = _copyHashJoin(from);
2960 retval = _copyMaterial(from);
2963 retval = _copySort(from);
2966 retval = _copyGroup(from);
2969 retval = _copyAgg(from);
2972 retval = _copyUnique(from);
2975 retval = _copyHash(from);
2978 retval = _copySetOp(from);
2981 retval = _copyLimit(from);
2988 retval = _copyAlias(from);
2991 retval = _copyRangeVar(from);
2994 retval = _copyVar(from);
2997 retval = _copyConst(from);
3000 retval = _copyParam(from);
3003 retval = _copyAggref(from);
3006 retval = _copyArrayRef(from);
3009 retval = _copyFuncExpr(from);
3012 retval = _copyOpExpr(from);
3014 case T_DistinctExpr:
3015 retval = _copyDistinctExpr(from);
3017 case T_ScalarArrayOpExpr:
3018 retval = _copyScalarArrayOpExpr(from);
3021 retval = _copyBoolExpr(from);
3024 retval = _copySubLink(from);
3027 retval = _copySubPlan(from);
3030 retval = _copyFieldSelect(from);
3033 retval = _copyFieldStore(from);
3036 retval = _copyRelabelType(from);
3038 case T_ConvertRowtypeExpr:
3039 retval = _copyConvertRowtypeExpr(from);
3042 retval = _copyCaseExpr(from);
3045 retval = _copyCaseWhen(from);
3047 case T_CaseTestExpr:
3048 retval = _copyCaseTestExpr(from);
3051 retval = _copyArrayExpr(from);
3054 retval = _copyRowExpr(from);
3056 case T_RowCompareExpr:
3057 retval = _copyRowCompareExpr(from);
3059 case T_CoalesceExpr:
3060 retval = _copyCoalesceExpr(from);
3063 retval = _copyMinMaxExpr(from);
3066 retval = _copyXmlExpr(from);
3069 retval = _copyNullIfExpr(from);
3072 retval = _copyNullTest(from);
3075 retval = _copyBooleanTest(from);
3077 case T_CoerceToDomain:
3078 retval = _copyCoerceToDomain(from);
3080 case T_CoerceToDomainValue:
3081 retval = _copyCoerceToDomainValue(from);
3083 case T_SetToDefault:
3084 retval = _copySetToDefault(from);
3087 retval = _copyTargetEntry(from);
3090 retval = _copyRangeTblRef(from);
3093 retval = _copyJoinExpr(from);
3096 retval = _copyFromExpr(from);
3103 retval = _copyPathKey(from);
3105 case T_RestrictInfo:
3106 retval = _copyRestrictInfo(from);
3108 case T_OuterJoinInfo:
3109 retval = _copyOuterJoinInfo(from);
3111 case T_InClauseInfo:
3112 retval = _copyInClauseInfo(from);
3114 case T_AppendRelInfo:
3115 retval = _copyAppendRelInfo(from);
3126 retval = _copyValue(from);
3133 retval = _copyList(from);
3137 * Lists of integers and OIDs don't need to be deep-copied, so we
3138 * perform a shallow copy via list_copy()
3142 retval = list_copy(from);
3149 retval = _copyQuery(from);
3152 retval = _copyInsertStmt(from);
3155 retval = _copyDeleteStmt(from);
3158 retval = _copyUpdateStmt(from);
3161 retval = _copySelectStmt(from);
3163 case T_SetOperationStmt:
3164 retval = _copySetOperationStmt(from);
3166 case T_AlterTableStmt:
3167 retval = _copyAlterTableStmt(from);
3169 case T_AlterTableCmd:
3170 retval = _copyAlterTableCmd(from);
3172 case T_AlterDomainStmt:
3173 retval = _copyAlterDomainStmt(from);
3176 retval = _copyGrantStmt(from);
3178 case T_GrantRoleStmt:
3179 retval = _copyGrantRoleStmt(from);
3181 case T_DeclareCursorStmt:
3182 retval = _copyDeclareCursorStmt(from);
3184 case T_ClosePortalStmt:
3185 retval = _copyClosePortalStmt(from);
3188 retval = _copyClusterStmt(from);
3191 retval = _copyCopyStmt(from);
3194 retval = _copyCreateStmt(from);
3197 retval = _copyInhRelation(from);
3200 retval = _copyDefineStmt(from);
3203 retval = _copyDropStmt(from);
3205 case T_TruncateStmt:
3206 retval = _copyTruncateStmt(from);
3209 retval = _copyCommentStmt(from);
3212 retval = _copyFetchStmt(from);
3215 retval = _copyIndexStmt(from);
3217 case T_CreateFunctionStmt:
3218 retval = _copyCreateFunctionStmt(from);
3220 case T_FunctionParameter:
3221 retval = _copyFunctionParameter(from);
3223 case T_AlterFunctionStmt:
3224 retval = _copyAlterFunctionStmt(from);
3226 case T_RemoveFuncStmt:
3227 retval = _copyRemoveFuncStmt(from);
3229 case T_RemoveOpClassStmt:
3230 retval = _copyRemoveOpClassStmt(from);
3232 case T_RemoveOpFamilyStmt:
3233 retval = _copyRemoveOpFamilyStmt(from);
3236 retval = _copyRenameStmt(from);
3238 case T_AlterObjectSchemaStmt:
3239 retval = _copyAlterObjectSchemaStmt(from);
3241 case T_AlterOwnerStmt:
3242 retval = _copyAlterOwnerStmt(from);
3245 retval = _copyRuleStmt(from);
3248 retval = _copyNotifyStmt(from);
3251 retval = _copyListenStmt(from);
3253 case T_UnlistenStmt:
3254 retval = _copyUnlistenStmt(from);
3256 case T_TransactionStmt:
3257 retval = _copyTransactionStmt(from);
3259 case T_CompositeTypeStmt:
3260 retval = _copyCompositeTypeStmt(from);
3263 retval = _copyViewStmt(from);
3266 retval = _copyLoadStmt(from);
3268 case T_CreateDomainStmt:
3269 retval = _copyCreateDomainStmt(from);
3271 case T_CreateOpClassStmt:
3272 retval = _copyCreateOpClassStmt(from);
3274 case T_CreateOpClassItem:
3275 retval = _copyCreateOpClassItem(from);
3277 case T_CreateOpFamilyStmt:
3278 retval = _copyCreateOpFamilyStmt(from);
3280 case T_AlterOpFamilyStmt:
3281 retval = _copyAlterOpFamilyStmt(from);
3283 case T_CreatedbStmt:
3284 retval = _copyCreatedbStmt(from);
3286 case T_AlterDatabaseStmt:
3287 retval = _copyAlterDatabaseStmt(from);
3289 case T_AlterDatabaseSetStmt:
3290 retval = _copyAlterDatabaseSetStmt(from);
3293 retval = _copyDropdbStmt(from);
3296 retval = _copyVacuumStmt(from);
3299 retval = _copyExplainStmt(from);
3301 case T_CreateSeqStmt:
3302 retval = _copyCreateSeqStmt(from);
3304 case T_AlterSeqStmt:
3305 retval = _copyAlterSeqStmt(from);
3307 case T_VariableSetStmt:
3308 retval = _copyVariableSetStmt(from);
3310 case T_VariableShowStmt:
3311 retval = _copyVariableShowStmt(from);
3313 case T_VariableResetStmt:
3314 retval = _copyVariableResetStmt(from);
3316 case T_CreateTableSpaceStmt:
3317 retval = _copyCreateTableSpaceStmt(from);
3319 case T_DropTableSpaceStmt:
3320 retval = _copyDropTableSpaceStmt(from);
3322 case T_CreateTrigStmt:
3323 retval = _copyCreateTrigStmt(from);
3325 case T_DropPropertyStmt:
3326 retval = _copyDropPropertyStmt(from);
3328 case T_CreatePLangStmt:
3329 retval = _copyCreatePLangStmt(from);
3331 case T_DropPLangStmt:
3332 retval = _copyDropPLangStmt(from);
3334 case T_CreateRoleStmt:
3335 retval = _copyCreateRoleStmt(from);
3337 case T_AlterRoleStmt:
3338 retval = _copyAlterRoleStmt(from);
3340 case T_AlterRoleSetStmt:
3341 retval = _copyAlterRoleSetStmt(from);
3343 case T_DropRoleStmt:
3344 retval = _copyDropRoleStmt(from);
3347 retval = _copyLockStmt(from);
3349 case T_ConstraintsSetStmt:
3350 retval = _copyConstraintsSetStmt(from);
3353 retval = _copyReindexStmt(from);
3355 case T_CheckPointStmt:
3356 retval = (void *) makeNode(CheckPointStmt);
3358 case T_CreateSchemaStmt:
3359 retval = _copyCreateSchemaStmt(from);
3361 case T_CreateConversionStmt:
3362 retval = _copyCreateConversionStmt(from);
3364 case T_CreateCastStmt:
3365 retval = _copyCreateCastStmt(from);
3367 case T_DropCastStmt:
3368 retval = _copyDropCastStmt(from);
3371 retval = _copyPrepareStmt(from);
3374 retval = _copyExecuteStmt(from);
3376 case T_DeallocateStmt:
3377 retval = _copyDeallocateStmt(from);
3379 case T_DropOwnedStmt:
3380 retval = _copyDropOwnedStmt(from);
3382 case T_ReassignOwnedStmt:
3383 retval = _copyReassignOwnedStmt(from);
3387 retval = _copyAExpr(from);
3390 retval = _copyColumnRef(from);
3393 retval = _copyParamRef(from);
3396 retval = _copyAConst(from);
3399 retval = _copyFuncCall(from);
3402 retval = _copyAIndices(from);
3404 case T_A_Indirection:
3405 retval = _copyA_Indirection(from);
3408 retval = _copyResTarget(from);
3411 retval = _copyTypeCast(from);
3414 retval = _copySortBy(from);
3416 case T_RangeSubselect:
3417 retval = _copyRangeSubselect(from);
3419 case T_RangeFunction:
3420 retval = _copyRangeFunction(from);
3423 retval = _copyTypeName(from);
3426 retval = _copyIndexElem(from);
3429 retval = _copyColumnDef(from);
3432 retval = _copyConstraint(from);
3435 retval = _copyDefElem(from);
3437 case T_LockingClause:
3438 retval = _copyLockingClause(from);
3440 case T_RangeTblEntry:
3441 retval = _copyRangeTblEntry(from);
3444 retval = _copySortClause(from);
3447 retval = _copyGroupClause(from);
3449 case T_RowMarkClause:
3450 retval = _copyRowMarkClause(from);
3452 case T_FkConstraint:
3453 retval = _copyFkConstraint(from);
3456 retval = _copyPrivGrantee(from);
3458 case T_FuncWithArgs:
3459 retval = _copyFuncWithArgs(from);
3461 case T_XmlSerialize:
3462 retval = _copyXmlSerialize(from);
3466 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3467 retval = from; /* keep compiler quiet */