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-2006, 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.332 2006/03/23 00:19:29 tgl Exp $
20 *-------------------------------------------------------------------------
25 #include "nodes/parsenodes.h"
26 #include "nodes/plannodes.h"
27 #include "nodes/relation.h"
28 #include "utils/datum.h"
32 * Macros to simplify copying of different kinds of fields. Use these
33 * wherever possible to reduce the chance for silly typos. Note that these
34 * hard-wire the convention that the local variables in a Copy routine are
35 * named 'newnode' and 'from'.
38 /* Copy a simple scalar field (int, float, bool, enum, etc) */
39 #define COPY_SCALAR_FIELD(fldname) \
40 (newnode->fldname = from->fldname)
42 /* Copy a field that is a pointer to some kind of Node or Node tree */
43 #define COPY_NODE_FIELD(fldname) \
44 (newnode->fldname = copyObject(from->fldname))
46 /* Copy a field that is a pointer to a Bitmapset */
47 #define COPY_BITMAPSET_FIELD(fldname) \
48 (newnode->fldname = bms_copy(from->fldname))
50 /* Copy a field that is a pointer to a C string, or perhaps NULL */
51 #define COPY_STRING_FIELD(fldname) \
52 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
54 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
55 #define COPY_POINTER_FIELD(fldname, sz) \
58 newnode->fldname = palloc(_size); \
59 memcpy(newnode->fldname, from->fldname, _size); \
63 /* ****************************************************************
64 * plannodes.h copy functions
65 * ****************************************************************
71 * This function copies the fields of the Plan node. It is used by
72 * all the copy functions for classes which inherit from Plan.
75 CopyPlanFields(Plan *from, Plan *newnode)
77 COPY_SCALAR_FIELD(startup_cost);
78 COPY_SCALAR_FIELD(total_cost);
79 COPY_SCALAR_FIELD(plan_rows);
80 COPY_SCALAR_FIELD(plan_width);
81 COPY_NODE_FIELD(targetlist);
82 COPY_NODE_FIELD(qual);
83 COPY_NODE_FIELD(lefttree);
84 COPY_NODE_FIELD(righttree);
85 COPY_NODE_FIELD(initPlan);
86 COPY_BITMAPSET_FIELD(extParam);
87 COPY_BITMAPSET_FIELD(allParam);
88 COPY_SCALAR_FIELD(nParamExec);
97 Plan *newnode = makeNode(Plan);
100 * copy node superclass fields
102 CopyPlanFields(from, newnode);
112 _copyResult(Result *from)
114 Result *newnode = makeNode(Result);
117 * copy node superclass fields
119 CopyPlanFields((Plan *) from, (Plan *) newnode);
122 * copy remainder of node
124 COPY_NODE_FIELD(resconstantqual);
133 _copyAppend(Append *from)
135 Append *newnode = makeNode(Append);
138 * copy node superclass fields
140 CopyPlanFields((Plan *) from, (Plan *) newnode);
143 * copy remainder of node
145 COPY_NODE_FIELD(appendplans);
146 COPY_SCALAR_FIELD(isTarget);
155 _copyBitmapAnd(BitmapAnd *from)
157 BitmapAnd *newnode = makeNode(BitmapAnd);
160 * copy node superclass fields
162 CopyPlanFields((Plan *) from, (Plan *) newnode);
165 * copy remainder of node
167 COPY_NODE_FIELD(bitmapplans);
176 _copyBitmapOr(BitmapOr *from)
178 BitmapOr *newnode = makeNode(BitmapOr);
181 * copy node superclass fields
183 CopyPlanFields((Plan *) from, (Plan *) newnode);
186 * copy remainder of node
188 COPY_NODE_FIELD(bitmapplans);
197 * This function copies the fields of the Scan node. It is used by
198 * all the copy functions for classes which inherit from Scan.
201 CopyScanFields(Scan *from, Scan *newnode)
203 CopyPlanFields((Plan *) from, (Plan *) newnode);
205 COPY_SCALAR_FIELD(scanrelid);
212 _copyScan(Scan *from)
214 Scan *newnode = makeNode(Scan);
217 * copy node superclass fields
219 CopyScanFields((Scan *) from, (Scan *) newnode);
228 _copySeqScan(SeqScan *from)
230 SeqScan *newnode = makeNode(SeqScan);
233 * copy node superclass fields
235 CopyScanFields((Scan *) from, (Scan *) newnode);
244 _copyIndexScan(IndexScan *from)
246 IndexScan *newnode = makeNode(IndexScan);
249 * copy node superclass fields
251 CopyScanFields((Scan *) from, (Scan *) newnode);
254 * copy remainder of node
256 COPY_SCALAR_FIELD(indexid);
257 COPY_NODE_FIELD(indexqual);
258 COPY_NODE_FIELD(indexqualorig);
259 COPY_NODE_FIELD(indexstrategy);
260 COPY_NODE_FIELD(indexsubtype);
261 COPY_SCALAR_FIELD(indexorderdir);
267 * _copyBitmapIndexScan
269 static BitmapIndexScan *
270 _copyBitmapIndexScan(BitmapIndexScan *from)
272 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
275 * copy node superclass fields
277 CopyScanFields((Scan *) from, (Scan *) newnode);
280 * copy remainder of node
282 COPY_SCALAR_FIELD(indexid);
283 COPY_NODE_FIELD(indexqual);
284 COPY_NODE_FIELD(indexqualorig);
285 COPY_NODE_FIELD(indexstrategy);
286 COPY_NODE_FIELD(indexsubtype);
292 * _copyBitmapHeapScan
294 static BitmapHeapScan *
295 _copyBitmapHeapScan(BitmapHeapScan *from)
297 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
300 * copy node superclass fields
302 CopyScanFields((Scan *) from, (Scan *) newnode);
305 * copy remainder of node
307 COPY_NODE_FIELD(bitmapqualorig);
316 _copyTidScan(TidScan *from)
318 TidScan *newnode = makeNode(TidScan);
321 * copy node superclass fields
323 CopyScanFields((Scan *) from, (Scan *) newnode);
326 * copy remainder of node
328 COPY_NODE_FIELD(tidquals);
336 static SubqueryScan *
337 _copySubqueryScan(SubqueryScan *from)
339 SubqueryScan *newnode = makeNode(SubqueryScan);
342 * copy node superclass fields
344 CopyScanFields((Scan *) from, (Scan *) newnode);
347 * copy remainder of node
349 COPY_NODE_FIELD(subplan);
357 static FunctionScan *
358 _copyFunctionScan(FunctionScan *from)
360 FunctionScan *newnode = makeNode(FunctionScan);
363 * copy node superclass fields
365 CopyScanFields((Scan *) from, (Scan *) newnode);
373 * This function copies the fields of the Join node. It is used by
374 * all the copy functions for classes which inherit from Join.
377 CopyJoinFields(Join *from, Join *newnode)
379 CopyPlanFields((Plan *) from, (Plan *) newnode);
381 COPY_SCALAR_FIELD(jointype);
382 COPY_NODE_FIELD(joinqual);
390 _copyJoin(Join *from)
392 Join *newnode = makeNode(Join);
395 * copy node superclass fields
397 CopyJoinFields(from, newnode);
407 _copyNestLoop(NestLoop *from)
409 NestLoop *newnode = makeNode(NestLoop);
412 * copy node superclass fields
414 CopyJoinFields((Join *) from, (Join *) newnode);
424 _copyMergeJoin(MergeJoin *from)
426 MergeJoin *newnode = makeNode(MergeJoin);
429 * copy node superclass fields
431 CopyJoinFields((Join *) from, (Join *) newnode);
434 * copy remainder of node
436 COPY_NODE_FIELD(mergeclauses);
445 _copyHashJoin(HashJoin *from)
447 HashJoin *newnode = makeNode(HashJoin);
450 * copy node superclass fields
452 CopyJoinFields((Join *) from, (Join *) newnode);
455 * copy remainder of node
457 COPY_NODE_FIELD(hashclauses);
467 _copyMaterial(Material *from)
469 Material *newnode = makeNode(Material);
472 * copy node superclass fields
474 CopyPlanFields((Plan *) from, (Plan *) newnode);
484 _copySort(Sort *from)
486 Sort *newnode = makeNode(Sort);
489 * copy node superclass fields
491 CopyPlanFields((Plan *) from, (Plan *) newnode);
493 COPY_SCALAR_FIELD(numCols);
494 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
495 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
505 _copyGroup(Group *from)
507 Group *newnode = makeNode(Group);
509 CopyPlanFields((Plan *) from, (Plan *) newnode);
511 COPY_SCALAR_FIELD(numCols);
512 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
523 Agg *newnode = makeNode(Agg);
525 CopyPlanFields((Plan *) from, (Plan *) newnode);
527 COPY_SCALAR_FIELD(aggstrategy);
528 COPY_SCALAR_FIELD(numCols);
529 if (from->numCols > 0)
530 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
531 COPY_SCALAR_FIELD(numGroups);
540 _copyUnique(Unique *from)
542 Unique *newnode = makeNode(Unique);
545 * copy node superclass fields
547 CopyPlanFields((Plan *) from, (Plan *) newnode);
550 * copy remainder of node
552 COPY_SCALAR_FIELD(numCols);
553 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
562 _copyHash(Hash *from)
564 Hash *newnode = makeNode(Hash);
567 * copy node superclass fields
569 CopyPlanFields((Plan *) from, (Plan *) newnode);
572 * copy remainder of node
582 _copySetOp(SetOp *from)
584 SetOp *newnode = makeNode(SetOp);
587 * copy node superclass fields
589 CopyPlanFields((Plan *) from, (Plan *) newnode);
592 * copy remainder of node
594 COPY_SCALAR_FIELD(cmd);
595 COPY_SCALAR_FIELD(numCols);
596 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
597 COPY_SCALAR_FIELD(flagColIdx);
606 _copyLimit(Limit *from)
608 Limit *newnode = makeNode(Limit);
611 * copy node superclass fields
613 CopyPlanFields((Plan *) from, (Plan *) newnode);
616 * copy remainder of node
618 COPY_NODE_FIELD(limitOffset);
619 COPY_NODE_FIELD(limitCount);
624 /* ****************************************************************
625 * primnodes.h copy functions
626 * ****************************************************************
633 _copyAlias(Alias *from)
635 Alias *newnode = makeNode(Alias);
637 COPY_STRING_FIELD(aliasname);
638 COPY_NODE_FIELD(colnames);
647 _copyRangeVar(RangeVar *from)
649 RangeVar *newnode = makeNode(RangeVar);
651 COPY_STRING_FIELD(catalogname);
652 COPY_STRING_FIELD(schemaname);
653 COPY_STRING_FIELD(relname);
654 COPY_SCALAR_FIELD(inhOpt);
655 COPY_SCALAR_FIELD(istemp);
656 COPY_NODE_FIELD(alias);
662 * We don't need a _copyExpr because Expr is an abstract supertype which
663 * should never actually get instantiated. Also, since it has no common
664 * fields except NodeTag, there's no need for a helper routine to factor
665 * out copying the common fields...
674 Var *newnode = makeNode(Var);
676 COPY_SCALAR_FIELD(varno);
677 COPY_SCALAR_FIELD(varattno);
678 COPY_SCALAR_FIELD(vartype);
679 COPY_SCALAR_FIELD(vartypmod);
680 COPY_SCALAR_FIELD(varlevelsup);
681 COPY_SCALAR_FIELD(varnoold);
682 COPY_SCALAR_FIELD(varoattno);
691 _copyConst(Const *from)
693 Const *newnode = makeNode(Const);
695 COPY_SCALAR_FIELD(consttype);
696 COPY_SCALAR_FIELD(constlen);
698 if (from->constbyval || from->constisnull)
701 * passed by value so just copy the datum. Also, don't try to copy
702 * struct when value is null!
704 newnode->constvalue = from->constvalue;
709 * passed by reference. We need a palloc'd copy.
711 newnode->constvalue = datumCopy(from->constvalue,
716 COPY_SCALAR_FIELD(constisnull);
717 COPY_SCALAR_FIELD(constbyval);
726 _copyParam(Param *from)
728 Param *newnode = makeNode(Param);
730 COPY_SCALAR_FIELD(paramkind);
731 COPY_SCALAR_FIELD(paramid);
732 COPY_STRING_FIELD(paramname);
733 COPY_SCALAR_FIELD(paramtype);
742 _copyAggref(Aggref *from)
744 Aggref *newnode = makeNode(Aggref);
746 COPY_SCALAR_FIELD(aggfnoid);
747 COPY_SCALAR_FIELD(aggtype);
748 COPY_NODE_FIELD(target);
749 COPY_SCALAR_FIELD(agglevelsup);
750 COPY_SCALAR_FIELD(aggstar);
751 COPY_SCALAR_FIELD(aggdistinct);
760 _copyArrayRef(ArrayRef *from)
762 ArrayRef *newnode = makeNode(ArrayRef);
764 COPY_SCALAR_FIELD(refrestype);
765 COPY_SCALAR_FIELD(refarraytype);
766 COPY_SCALAR_FIELD(refelemtype);
767 COPY_NODE_FIELD(refupperindexpr);
768 COPY_NODE_FIELD(reflowerindexpr);
769 COPY_NODE_FIELD(refexpr);
770 COPY_NODE_FIELD(refassgnexpr);
779 _copyFuncExpr(FuncExpr *from)
781 FuncExpr *newnode = makeNode(FuncExpr);
783 COPY_SCALAR_FIELD(funcid);
784 COPY_SCALAR_FIELD(funcresulttype);
785 COPY_SCALAR_FIELD(funcretset);
786 COPY_SCALAR_FIELD(funcformat);
787 COPY_NODE_FIELD(args);
796 _copyOpExpr(OpExpr *from)
798 OpExpr *newnode = makeNode(OpExpr);
800 COPY_SCALAR_FIELD(opno);
801 COPY_SCALAR_FIELD(opfuncid);
802 COPY_SCALAR_FIELD(opresulttype);
803 COPY_SCALAR_FIELD(opretset);
804 COPY_NODE_FIELD(args);
810 * _copyDistinctExpr (same as OpExpr)
812 static DistinctExpr *
813 _copyDistinctExpr(DistinctExpr *from)
815 DistinctExpr *newnode = makeNode(DistinctExpr);
817 COPY_SCALAR_FIELD(opno);
818 COPY_SCALAR_FIELD(opfuncid);
819 COPY_SCALAR_FIELD(opresulttype);
820 COPY_SCALAR_FIELD(opretset);
821 COPY_NODE_FIELD(args);
827 * _copyScalarArrayOpExpr
829 static ScalarArrayOpExpr *
830 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
832 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
834 COPY_SCALAR_FIELD(opno);
835 COPY_SCALAR_FIELD(opfuncid);
836 COPY_SCALAR_FIELD(useOr);
837 COPY_NODE_FIELD(args);
846 _copyBoolExpr(BoolExpr *from)
848 BoolExpr *newnode = makeNode(BoolExpr);
850 COPY_SCALAR_FIELD(boolop);
851 COPY_NODE_FIELD(args);
860 _copySubLink(SubLink *from)
862 SubLink *newnode = makeNode(SubLink);
864 COPY_SCALAR_FIELD(subLinkType);
865 COPY_NODE_FIELD(testexpr);
866 COPY_NODE_FIELD(operName);
867 COPY_NODE_FIELD(subselect);
876 _copySubPlan(SubPlan *from)
878 SubPlan *newnode = makeNode(SubPlan);
880 COPY_SCALAR_FIELD(subLinkType);
881 COPY_NODE_FIELD(testexpr);
882 COPY_NODE_FIELD(paramIds);
883 COPY_NODE_FIELD(plan);
884 COPY_SCALAR_FIELD(plan_id);
885 COPY_NODE_FIELD(rtable);
886 COPY_SCALAR_FIELD(useHashTable);
887 COPY_SCALAR_FIELD(unknownEqFalse);
888 COPY_NODE_FIELD(setParam);
889 COPY_NODE_FIELD(parParam);
890 COPY_NODE_FIELD(args);
899 _copyFieldSelect(FieldSelect *from)
901 FieldSelect *newnode = makeNode(FieldSelect);
903 COPY_NODE_FIELD(arg);
904 COPY_SCALAR_FIELD(fieldnum);
905 COPY_SCALAR_FIELD(resulttype);
906 COPY_SCALAR_FIELD(resulttypmod);
915 _copyFieldStore(FieldStore *from)
917 FieldStore *newnode = makeNode(FieldStore);
919 COPY_NODE_FIELD(arg);
920 COPY_NODE_FIELD(newvals);
921 COPY_NODE_FIELD(fieldnums);
922 COPY_SCALAR_FIELD(resulttype);
931 _copyRelabelType(RelabelType *from)
933 RelabelType *newnode = makeNode(RelabelType);
935 COPY_NODE_FIELD(arg);
936 COPY_SCALAR_FIELD(resulttype);
937 COPY_SCALAR_FIELD(resulttypmod);
938 COPY_SCALAR_FIELD(relabelformat);
944 * _copyConvertRowtypeExpr
946 static ConvertRowtypeExpr *
947 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
949 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
951 COPY_NODE_FIELD(arg);
952 COPY_SCALAR_FIELD(resulttype);
953 COPY_SCALAR_FIELD(convertformat);
962 _copyCaseExpr(CaseExpr *from)
964 CaseExpr *newnode = makeNode(CaseExpr);
966 COPY_SCALAR_FIELD(casetype);
967 COPY_NODE_FIELD(arg);
968 COPY_NODE_FIELD(args);
969 COPY_NODE_FIELD(defresult);
978 _copyCaseWhen(CaseWhen *from)
980 CaseWhen *newnode = makeNode(CaseWhen);
982 COPY_NODE_FIELD(expr);
983 COPY_NODE_FIELD(result);
991 static CaseTestExpr *
992 _copyCaseTestExpr(CaseTestExpr *from)
994 CaseTestExpr *newnode = makeNode(CaseTestExpr);
996 COPY_SCALAR_FIELD(typeId);
997 COPY_SCALAR_FIELD(typeMod);
1006 _copyArrayExpr(ArrayExpr *from)
1008 ArrayExpr *newnode = makeNode(ArrayExpr);
1010 COPY_SCALAR_FIELD(array_typeid);
1011 COPY_SCALAR_FIELD(element_typeid);
1012 COPY_NODE_FIELD(elements);
1013 COPY_SCALAR_FIELD(multidims);
1022 _copyRowExpr(RowExpr *from)
1024 RowExpr *newnode = makeNode(RowExpr);
1026 COPY_NODE_FIELD(args);
1027 COPY_SCALAR_FIELD(row_typeid);
1028 COPY_SCALAR_FIELD(row_format);
1034 * _copyRowCompareExpr
1036 static RowCompareExpr *
1037 _copyRowCompareExpr(RowCompareExpr *from)
1039 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1041 COPY_SCALAR_FIELD(rctype);
1042 COPY_NODE_FIELD(opnos);
1043 COPY_NODE_FIELD(opclasses);
1044 COPY_NODE_FIELD(largs);
1045 COPY_NODE_FIELD(rargs);
1053 static CoalesceExpr *
1054 _copyCoalesceExpr(CoalesceExpr *from)
1056 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1058 COPY_SCALAR_FIELD(coalescetype);
1059 COPY_NODE_FIELD(args);
1068 _copyMinMaxExpr(MinMaxExpr *from)
1070 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1072 COPY_SCALAR_FIELD(minmaxtype);
1073 COPY_SCALAR_FIELD(op);
1074 COPY_NODE_FIELD(args);
1080 * _copyNullIfExpr (same as OpExpr)
1083 _copyNullIfExpr(NullIfExpr *from)
1085 NullIfExpr *newnode = makeNode(NullIfExpr);
1087 COPY_SCALAR_FIELD(opno);
1088 COPY_SCALAR_FIELD(opfuncid);
1089 COPY_SCALAR_FIELD(opresulttype);
1090 COPY_SCALAR_FIELD(opretset);
1091 COPY_NODE_FIELD(args);
1100 _copyNullTest(NullTest *from)
1102 NullTest *newnode = makeNode(NullTest);
1104 COPY_NODE_FIELD(arg);
1105 COPY_SCALAR_FIELD(nulltesttype);
1113 static BooleanTest *
1114 _copyBooleanTest(BooleanTest *from)
1116 BooleanTest *newnode = makeNode(BooleanTest);
1118 COPY_NODE_FIELD(arg);
1119 COPY_SCALAR_FIELD(booltesttype);
1125 * _copyCoerceToDomain
1127 static CoerceToDomain *
1128 _copyCoerceToDomain(CoerceToDomain *from)
1130 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1132 COPY_NODE_FIELD(arg);
1133 COPY_SCALAR_FIELD(resulttype);
1134 COPY_SCALAR_FIELD(resulttypmod);
1135 COPY_SCALAR_FIELD(coercionformat);
1141 * _copyCoerceToDomainValue
1143 static CoerceToDomainValue *
1144 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1146 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1148 COPY_SCALAR_FIELD(typeId);
1149 COPY_SCALAR_FIELD(typeMod);
1157 static SetToDefault *
1158 _copySetToDefault(SetToDefault *from)
1160 SetToDefault *newnode = makeNode(SetToDefault);
1162 COPY_SCALAR_FIELD(typeId);
1163 COPY_SCALAR_FIELD(typeMod);
1171 static TargetEntry *
1172 _copyTargetEntry(TargetEntry *from)
1174 TargetEntry *newnode = makeNode(TargetEntry);
1176 COPY_NODE_FIELD(expr);
1177 COPY_SCALAR_FIELD(resno);
1178 COPY_STRING_FIELD(resname);
1179 COPY_SCALAR_FIELD(ressortgroupref);
1180 COPY_SCALAR_FIELD(resorigtbl);
1181 COPY_SCALAR_FIELD(resorigcol);
1182 COPY_SCALAR_FIELD(resjunk);
1190 static RangeTblRef *
1191 _copyRangeTblRef(RangeTblRef *from)
1193 RangeTblRef *newnode = makeNode(RangeTblRef);
1195 COPY_SCALAR_FIELD(rtindex);
1204 _copyJoinExpr(JoinExpr *from)
1206 JoinExpr *newnode = makeNode(JoinExpr);
1208 COPY_SCALAR_FIELD(jointype);
1209 COPY_SCALAR_FIELD(isNatural);
1210 COPY_NODE_FIELD(larg);
1211 COPY_NODE_FIELD(rarg);
1212 COPY_NODE_FIELD(using);
1213 COPY_NODE_FIELD(quals);
1214 COPY_NODE_FIELD(alias);
1215 COPY_SCALAR_FIELD(rtindex);
1224 _copyFromExpr(FromExpr *from)
1226 FromExpr *newnode = makeNode(FromExpr);
1228 COPY_NODE_FIELD(fromlist);
1229 COPY_NODE_FIELD(quals);
1234 /* ****************************************************************
1235 * relation.h copy functions
1237 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1238 * There are some subsidiary structs that are useful to copy, though.
1239 * ****************************************************************
1245 static PathKeyItem *
1246 _copyPathKeyItem(PathKeyItem *from)
1248 PathKeyItem *newnode = makeNode(PathKeyItem);
1250 COPY_NODE_FIELD(key);
1251 COPY_SCALAR_FIELD(sortop);
1259 static RestrictInfo *
1260 _copyRestrictInfo(RestrictInfo *from)
1262 RestrictInfo *newnode = makeNode(RestrictInfo);
1264 COPY_NODE_FIELD(clause);
1265 COPY_SCALAR_FIELD(is_pushed_down);
1266 COPY_SCALAR_FIELD(outerjoin_delayed);
1267 COPY_SCALAR_FIELD(can_join);
1268 COPY_BITMAPSET_FIELD(clause_relids);
1269 COPY_BITMAPSET_FIELD(required_relids);
1270 COPY_BITMAPSET_FIELD(left_relids);
1271 COPY_BITMAPSET_FIELD(right_relids);
1272 COPY_NODE_FIELD(orclause);
1273 COPY_SCALAR_FIELD(eval_cost);
1274 COPY_SCALAR_FIELD(this_selec);
1275 COPY_SCALAR_FIELD(mergejoinoperator);
1276 COPY_SCALAR_FIELD(left_sortop);
1277 COPY_SCALAR_FIELD(right_sortop);
1280 * Do not copy pathkeys, since they'd not be canonical in a copied query
1282 newnode->left_pathkey = NIL;
1283 newnode->right_pathkey = NIL;
1285 COPY_SCALAR_FIELD(left_mergescansel);
1286 COPY_SCALAR_FIELD(right_mergescansel);
1287 COPY_SCALAR_FIELD(hashjoinoperator);
1288 COPY_SCALAR_FIELD(left_bucketsize);
1289 COPY_SCALAR_FIELD(right_bucketsize);
1295 * _copyOuterJoinInfo
1297 static OuterJoinInfo *
1298 _copyOuterJoinInfo(OuterJoinInfo *from)
1300 OuterJoinInfo *newnode = makeNode(OuterJoinInfo);
1302 COPY_BITMAPSET_FIELD(min_lefthand);
1303 COPY_BITMAPSET_FIELD(min_righthand);
1304 COPY_SCALAR_FIELD(is_full_join);
1305 COPY_SCALAR_FIELD(lhs_strict);
1313 static InClauseInfo *
1314 _copyInClauseInfo(InClauseInfo *from)
1316 InClauseInfo *newnode = makeNode(InClauseInfo);
1318 COPY_BITMAPSET_FIELD(lefthand);
1319 COPY_BITMAPSET_FIELD(righthand);
1320 COPY_NODE_FIELD(sub_targetlist);
1326 * _copyAppendRelInfo
1328 static AppendRelInfo *
1329 _copyAppendRelInfo(AppendRelInfo *from)
1331 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1333 COPY_SCALAR_FIELD(parent_relid);
1334 COPY_SCALAR_FIELD(child_relid);
1335 COPY_SCALAR_FIELD(parent_reltype);
1336 COPY_SCALAR_FIELD(child_reltype);
1337 COPY_NODE_FIELD(col_mappings);
1338 COPY_NODE_FIELD(translated_vars);
1339 COPY_SCALAR_FIELD(parent_reloid);
1344 /* ****************************************************************
1345 * parsenodes.h copy functions
1346 * ****************************************************************
1349 static RangeTblEntry *
1350 _copyRangeTblEntry(RangeTblEntry *from)
1352 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1354 COPY_SCALAR_FIELD(rtekind);
1355 COPY_SCALAR_FIELD(relid);
1356 COPY_NODE_FIELD(subquery);
1357 COPY_NODE_FIELD(funcexpr);
1358 COPY_NODE_FIELD(funccoltypes);
1359 COPY_NODE_FIELD(funccoltypmods);
1360 COPY_SCALAR_FIELD(jointype);
1361 COPY_NODE_FIELD(joinaliasvars);
1362 COPY_NODE_FIELD(alias);
1363 COPY_NODE_FIELD(eref);
1364 COPY_SCALAR_FIELD(inh);
1365 COPY_SCALAR_FIELD(inFromCl);
1366 COPY_SCALAR_FIELD(requiredPerms);
1367 COPY_SCALAR_FIELD(checkAsUser);
1372 static FkConstraint *
1373 _copyFkConstraint(FkConstraint *from)
1375 FkConstraint *newnode = makeNode(FkConstraint);
1377 COPY_STRING_FIELD(constr_name);
1378 COPY_NODE_FIELD(pktable);
1379 COPY_NODE_FIELD(fk_attrs);
1380 COPY_NODE_FIELD(pk_attrs);
1381 COPY_SCALAR_FIELD(fk_matchtype);
1382 COPY_SCALAR_FIELD(fk_upd_action);
1383 COPY_SCALAR_FIELD(fk_del_action);
1384 COPY_SCALAR_FIELD(deferrable);
1385 COPY_SCALAR_FIELD(initdeferred);
1386 COPY_SCALAR_FIELD(skip_validation);
1392 _copySortClause(SortClause *from)
1394 SortClause *newnode = makeNode(SortClause);
1396 COPY_SCALAR_FIELD(tleSortGroupRef);
1397 COPY_SCALAR_FIELD(sortop);
1402 static GroupClause *
1403 _copyGroupClause(GroupClause *from)
1405 GroupClause *newnode = makeNode(GroupClause);
1407 COPY_SCALAR_FIELD(tleSortGroupRef);
1408 COPY_SCALAR_FIELD(sortop);
1414 _copyAExpr(A_Expr *from)
1416 A_Expr *newnode = makeNode(A_Expr);
1418 COPY_SCALAR_FIELD(kind);
1419 COPY_NODE_FIELD(name);
1420 COPY_NODE_FIELD(lexpr);
1421 COPY_NODE_FIELD(rexpr);
1422 COPY_SCALAR_FIELD(location);
1428 _copyColumnRef(ColumnRef *from)
1430 ColumnRef *newnode = makeNode(ColumnRef);
1432 COPY_NODE_FIELD(fields);
1433 COPY_SCALAR_FIELD(location);
1439 _copyParamRef(ParamRef *from)
1441 ParamRef *newnode = makeNode(ParamRef);
1443 COPY_SCALAR_FIELD(number);
1449 _copyAConst(A_Const *from)
1451 A_Const *newnode = makeNode(A_Const);
1453 /* This part must duplicate _copyValue */
1454 COPY_SCALAR_FIELD(val.type);
1455 switch (from->val.type)
1458 COPY_SCALAR_FIELD(val.val.ival);
1463 COPY_STRING_FIELD(val.val.str);
1469 elog(ERROR, "unrecognized node type: %d",
1470 (int) from->val.type);
1474 COPY_NODE_FIELD(typename);
1480 _copyFuncCall(FuncCall *from)
1482 FuncCall *newnode = makeNode(FuncCall);
1484 COPY_NODE_FIELD(funcname);
1485 COPY_NODE_FIELD(args);
1486 COPY_SCALAR_FIELD(agg_star);
1487 COPY_SCALAR_FIELD(agg_distinct);
1488 COPY_SCALAR_FIELD(location);
1494 _copyAIndices(A_Indices *from)
1496 A_Indices *newnode = makeNode(A_Indices);
1498 COPY_NODE_FIELD(lidx);
1499 COPY_NODE_FIELD(uidx);
1504 static A_Indirection *
1505 _copyA_Indirection(A_Indirection *from)
1507 A_Indirection *newnode = makeNode(A_Indirection);
1509 COPY_NODE_FIELD(arg);
1510 COPY_NODE_FIELD(indirection);
1516 _copyResTarget(ResTarget *from)
1518 ResTarget *newnode = makeNode(ResTarget);
1520 COPY_STRING_FIELD(name);
1521 COPY_NODE_FIELD(indirection);
1522 COPY_NODE_FIELD(val);
1523 COPY_SCALAR_FIELD(location);
1529 _copyTypeName(TypeName *from)
1531 TypeName *newnode = makeNode(TypeName);
1533 COPY_NODE_FIELD(names);
1534 COPY_SCALAR_FIELD(typeid);
1535 COPY_SCALAR_FIELD(timezone);
1536 COPY_SCALAR_FIELD(setof);
1537 COPY_SCALAR_FIELD(pct_type);
1538 COPY_SCALAR_FIELD(typmod);
1539 COPY_NODE_FIELD(arrayBounds);
1540 COPY_SCALAR_FIELD(location);
1546 _copySortBy(SortBy *from)
1548 SortBy *newnode = makeNode(SortBy);
1550 COPY_SCALAR_FIELD(sortby_kind);
1551 COPY_NODE_FIELD(useOp);
1552 COPY_NODE_FIELD(node);
1557 static RangeSubselect *
1558 _copyRangeSubselect(RangeSubselect *from)
1560 RangeSubselect *newnode = makeNode(RangeSubselect);
1562 COPY_NODE_FIELD(subquery);
1563 COPY_NODE_FIELD(alias);
1568 static RangeFunction *
1569 _copyRangeFunction(RangeFunction *from)
1571 RangeFunction *newnode = makeNode(RangeFunction);
1573 COPY_NODE_FIELD(funccallnode);
1574 COPY_NODE_FIELD(alias);
1575 COPY_NODE_FIELD(coldeflist);
1581 _copyTypeCast(TypeCast *from)
1583 TypeCast *newnode = makeNode(TypeCast);
1585 COPY_NODE_FIELD(arg);
1586 COPY_NODE_FIELD(typename);
1592 _copyIndexElem(IndexElem *from)
1594 IndexElem *newnode = makeNode(IndexElem);
1596 COPY_STRING_FIELD(name);
1597 COPY_NODE_FIELD(expr);
1598 COPY_NODE_FIELD(opclass);
1604 _copyColumnDef(ColumnDef *from)
1606 ColumnDef *newnode = makeNode(ColumnDef);
1608 COPY_STRING_FIELD(colname);
1609 COPY_NODE_FIELD(typename);
1610 COPY_SCALAR_FIELD(inhcount);
1611 COPY_SCALAR_FIELD(is_local);
1612 COPY_SCALAR_FIELD(is_not_null);
1613 COPY_NODE_FIELD(raw_default);
1614 COPY_STRING_FIELD(cooked_default);
1615 COPY_NODE_FIELD(constraints);
1616 COPY_NODE_FIELD(support);
1622 _copyConstraint(Constraint *from)
1624 Constraint *newnode = makeNode(Constraint);
1626 COPY_SCALAR_FIELD(contype);
1627 COPY_STRING_FIELD(name);
1628 COPY_NODE_FIELD(raw_expr);
1629 COPY_STRING_FIELD(cooked_expr);
1630 COPY_NODE_FIELD(keys);
1631 COPY_STRING_FIELD(indexspace);
1637 _copyDefElem(DefElem *from)
1639 DefElem *newnode = makeNode(DefElem);
1641 COPY_STRING_FIELD(defname);
1642 COPY_NODE_FIELD(arg);
1647 static LockingClause *
1648 _copyLockingClause(LockingClause *from)
1650 LockingClause *newnode = makeNode(LockingClause);
1652 COPY_NODE_FIELD(lockedRels);
1653 COPY_SCALAR_FIELD(forUpdate);
1654 COPY_SCALAR_FIELD(nowait);
1660 _copyQuery(Query *from)
1662 Query *newnode = makeNode(Query);
1664 COPY_SCALAR_FIELD(commandType);
1665 COPY_SCALAR_FIELD(querySource);
1666 COPY_SCALAR_FIELD(canSetTag);
1667 COPY_NODE_FIELD(utilityStmt);
1668 COPY_SCALAR_FIELD(resultRelation);
1669 COPY_NODE_FIELD(into);
1670 COPY_SCALAR_FIELD(intoHasOids);
1671 COPY_SCALAR_FIELD(intoOnCommit);
1672 COPY_STRING_FIELD(intoTableSpaceName);
1673 COPY_SCALAR_FIELD(hasAggs);
1674 COPY_SCALAR_FIELD(hasSubLinks);
1675 COPY_NODE_FIELD(rtable);
1676 COPY_NODE_FIELD(jointree);
1677 COPY_NODE_FIELD(rowMarks);
1678 COPY_SCALAR_FIELD(forUpdate);
1679 COPY_SCALAR_FIELD(rowNoWait);
1680 COPY_NODE_FIELD(targetList);
1681 COPY_NODE_FIELD(groupClause);
1682 COPY_NODE_FIELD(havingQual);
1683 COPY_NODE_FIELD(distinctClause);
1684 COPY_NODE_FIELD(sortClause);
1685 COPY_NODE_FIELD(limitOffset);
1686 COPY_NODE_FIELD(limitCount);
1687 COPY_NODE_FIELD(setOperations);
1688 COPY_NODE_FIELD(resultRelations);
1694 _copyInsertStmt(InsertStmt *from)
1696 InsertStmt *newnode = makeNode(InsertStmt);
1698 COPY_NODE_FIELD(relation);
1699 COPY_NODE_FIELD(cols);
1700 COPY_NODE_FIELD(targetList);
1701 COPY_NODE_FIELD(selectStmt);
1707 _copyDeleteStmt(DeleteStmt *from)
1709 DeleteStmt *newnode = makeNode(DeleteStmt);
1711 COPY_NODE_FIELD(relation);
1712 COPY_NODE_FIELD(whereClause);
1713 COPY_NODE_FIELD(usingClause);
1719 _copyUpdateStmt(UpdateStmt *from)
1721 UpdateStmt *newnode = makeNode(UpdateStmt);
1723 COPY_NODE_FIELD(relation);
1724 COPY_NODE_FIELD(targetList);
1725 COPY_NODE_FIELD(whereClause);
1726 COPY_NODE_FIELD(fromClause);
1732 _copySelectStmt(SelectStmt *from)
1734 SelectStmt *newnode = makeNode(SelectStmt);
1736 COPY_NODE_FIELD(distinctClause);
1737 COPY_NODE_FIELD(into);
1738 COPY_NODE_FIELD(intoColNames);
1739 COPY_SCALAR_FIELD(intoHasOids);
1740 COPY_SCALAR_FIELD(intoOnCommit);
1741 COPY_STRING_FIELD(intoTableSpaceName);
1742 COPY_NODE_FIELD(targetList);
1743 COPY_NODE_FIELD(fromClause);
1744 COPY_NODE_FIELD(whereClause);
1745 COPY_NODE_FIELD(groupClause);
1746 COPY_NODE_FIELD(havingClause);
1747 COPY_NODE_FIELD(sortClause);
1748 COPY_NODE_FIELD(limitOffset);
1749 COPY_NODE_FIELD(limitCount);
1750 COPY_NODE_FIELD(lockingClause);
1751 COPY_SCALAR_FIELD(op);
1752 COPY_SCALAR_FIELD(all);
1753 COPY_NODE_FIELD(larg);
1754 COPY_NODE_FIELD(rarg);
1759 static SetOperationStmt *
1760 _copySetOperationStmt(SetOperationStmt *from)
1762 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1764 COPY_SCALAR_FIELD(op);
1765 COPY_SCALAR_FIELD(all);
1766 COPY_NODE_FIELD(larg);
1767 COPY_NODE_FIELD(rarg);
1768 COPY_NODE_FIELD(colTypes);
1773 static AlterTableStmt *
1774 _copyAlterTableStmt(AlterTableStmt *from)
1776 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1778 COPY_NODE_FIELD(relation);
1779 COPY_NODE_FIELD(cmds);
1780 COPY_SCALAR_FIELD(relkind);
1785 static AlterTableCmd *
1786 _copyAlterTableCmd(AlterTableCmd *from)
1788 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1790 COPY_SCALAR_FIELD(subtype);
1791 COPY_STRING_FIELD(name);
1792 COPY_NODE_FIELD(def);
1793 COPY_NODE_FIELD(transform);
1794 COPY_SCALAR_FIELD(behavior);
1799 static AlterDomainStmt *
1800 _copyAlterDomainStmt(AlterDomainStmt *from)
1802 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1804 COPY_SCALAR_FIELD(subtype);
1805 COPY_NODE_FIELD(typename);
1806 COPY_STRING_FIELD(name);
1807 COPY_NODE_FIELD(def);
1808 COPY_SCALAR_FIELD(behavior);
1814 _copyGrantStmt(GrantStmt *from)
1816 GrantStmt *newnode = makeNode(GrantStmt);
1818 COPY_SCALAR_FIELD(is_grant);
1819 COPY_SCALAR_FIELD(objtype);
1820 COPY_NODE_FIELD(objects);
1821 COPY_NODE_FIELD(privileges);
1822 COPY_NODE_FIELD(grantees);
1823 COPY_SCALAR_FIELD(grant_option);
1824 COPY_SCALAR_FIELD(behavior);
1829 static PrivGrantee *
1830 _copyPrivGrantee(PrivGrantee *from)
1832 PrivGrantee *newnode = makeNode(PrivGrantee);
1834 COPY_STRING_FIELD(rolname);
1839 static FuncWithArgs *
1840 _copyFuncWithArgs(FuncWithArgs *from)
1842 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1844 COPY_NODE_FIELD(funcname);
1845 COPY_NODE_FIELD(funcargs);
1850 static GrantRoleStmt *
1851 _copyGrantRoleStmt(GrantRoleStmt *from)
1853 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
1855 COPY_NODE_FIELD(granted_roles);
1856 COPY_NODE_FIELD(grantee_roles);
1857 COPY_SCALAR_FIELD(is_grant);
1858 COPY_SCALAR_FIELD(admin_opt);
1859 COPY_STRING_FIELD(grantor);
1860 COPY_SCALAR_FIELD(behavior);
1865 static DeclareCursorStmt *
1866 _copyDeclareCursorStmt(DeclareCursorStmt *from)
1868 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
1870 COPY_STRING_FIELD(portalname);
1871 COPY_SCALAR_FIELD(options);
1872 COPY_NODE_FIELD(query);
1877 static ClosePortalStmt *
1878 _copyClosePortalStmt(ClosePortalStmt *from)
1880 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
1882 COPY_STRING_FIELD(portalname);
1887 static ClusterStmt *
1888 _copyClusterStmt(ClusterStmt *from)
1890 ClusterStmt *newnode = makeNode(ClusterStmt);
1892 COPY_NODE_FIELD(relation);
1893 COPY_STRING_FIELD(indexname);
1899 _copyCopyStmt(CopyStmt *from)
1901 CopyStmt *newnode = makeNode(CopyStmt);
1903 COPY_NODE_FIELD(relation);
1904 COPY_NODE_FIELD(attlist);
1905 COPY_SCALAR_FIELD(is_from);
1906 COPY_STRING_FIELD(filename);
1907 COPY_NODE_FIELD(options);
1913 _copyCreateStmt(CreateStmt *from)
1915 CreateStmt *newnode = makeNode(CreateStmt);
1917 COPY_NODE_FIELD(relation);
1918 COPY_NODE_FIELD(tableElts);
1919 COPY_NODE_FIELD(inhRelations);
1920 COPY_NODE_FIELD(constraints);
1921 COPY_SCALAR_FIELD(hasoids);
1922 COPY_SCALAR_FIELD(oncommit);
1923 COPY_STRING_FIELD(tablespacename);
1928 static InhRelation *
1929 _copyInhRelation(InhRelation *from)
1931 InhRelation *newnode = makeNode(InhRelation);
1933 COPY_NODE_FIELD(relation);
1934 COPY_SCALAR_FIELD(including_defaults);
1940 _copyDefineStmt(DefineStmt *from)
1942 DefineStmt *newnode = makeNode(DefineStmt);
1944 COPY_SCALAR_FIELD(kind);
1945 COPY_NODE_FIELD(defnames);
1946 COPY_NODE_FIELD(definition);
1952 _copyDropStmt(DropStmt *from)
1954 DropStmt *newnode = makeNode(DropStmt);
1956 COPY_NODE_FIELD(objects);
1957 COPY_SCALAR_FIELD(removeType);
1958 COPY_SCALAR_FIELD(behavior);
1959 COPY_SCALAR_FIELD(missing_ok);
1964 static TruncateStmt *
1965 _copyTruncateStmt(TruncateStmt *from)
1967 TruncateStmt *newnode = makeNode(TruncateStmt);
1969 COPY_NODE_FIELD(relations);
1970 COPY_SCALAR_FIELD(behavior);
1975 static CommentStmt *
1976 _copyCommentStmt(CommentStmt *from)
1978 CommentStmt *newnode = makeNode(CommentStmt);
1980 COPY_SCALAR_FIELD(objtype);
1981 COPY_NODE_FIELD(objname);
1982 COPY_NODE_FIELD(objargs);
1983 COPY_STRING_FIELD(comment);
1989 _copyFetchStmt(FetchStmt *from)
1991 FetchStmt *newnode = makeNode(FetchStmt);
1993 COPY_SCALAR_FIELD(direction);
1994 COPY_SCALAR_FIELD(howMany);
1995 COPY_STRING_FIELD(portalname);
1996 COPY_SCALAR_FIELD(ismove);
2002 _copyIndexStmt(IndexStmt *from)
2004 IndexStmt *newnode = makeNode(IndexStmt);
2006 COPY_STRING_FIELD(idxname);
2007 COPY_NODE_FIELD(relation);
2008 COPY_STRING_FIELD(accessMethod);
2009 COPY_STRING_FIELD(tableSpace);
2010 COPY_NODE_FIELD(indexParams);
2011 COPY_NODE_FIELD(whereClause);
2012 COPY_NODE_FIELD(rangetable);
2013 COPY_SCALAR_FIELD(unique);
2014 COPY_SCALAR_FIELD(primary);
2015 COPY_SCALAR_FIELD(isconstraint);
2020 static CreateFunctionStmt *
2021 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2023 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2025 COPY_SCALAR_FIELD(replace);
2026 COPY_NODE_FIELD(funcname);
2027 COPY_NODE_FIELD(parameters);
2028 COPY_NODE_FIELD(returnType);
2029 COPY_NODE_FIELD(options);
2030 COPY_NODE_FIELD(withClause);
2035 static FunctionParameter *
2036 _copyFunctionParameter(FunctionParameter *from)
2038 FunctionParameter *newnode = makeNode(FunctionParameter);
2040 COPY_STRING_FIELD(name);
2041 COPY_NODE_FIELD(argType);
2042 COPY_SCALAR_FIELD(mode);
2047 static AlterFunctionStmt *
2048 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2050 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2052 COPY_NODE_FIELD(func);
2053 COPY_NODE_FIELD(actions);
2058 static RemoveAggrStmt *
2059 _copyRemoveAggrStmt(RemoveAggrStmt *from)
2061 RemoveAggrStmt *newnode = makeNode(RemoveAggrStmt);
2063 COPY_NODE_FIELD(aggname);
2064 COPY_NODE_FIELD(aggtype);
2065 COPY_SCALAR_FIELD(behavior);
2070 static RemoveFuncStmt *
2071 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2073 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2075 COPY_NODE_FIELD(funcname);
2076 COPY_NODE_FIELD(args);
2077 COPY_SCALAR_FIELD(behavior);
2082 static RemoveOperStmt *
2083 _copyRemoveOperStmt(RemoveOperStmt *from)
2085 RemoveOperStmt *newnode = makeNode(RemoveOperStmt);
2087 COPY_NODE_FIELD(opname);
2088 COPY_NODE_FIELD(args);
2089 COPY_SCALAR_FIELD(behavior);
2094 static RemoveOpClassStmt *
2095 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2097 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2099 COPY_NODE_FIELD(opclassname);
2100 COPY_STRING_FIELD(amname);
2101 COPY_SCALAR_FIELD(behavior);
2107 _copyRenameStmt(RenameStmt *from)
2109 RenameStmt *newnode = makeNode(RenameStmt);
2111 COPY_SCALAR_FIELD(renameType);
2112 COPY_NODE_FIELD(relation);
2113 COPY_NODE_FIELD(object);
2114 COPY_NODE_FIELD(objarg);
2115 COPY_STRING_FIELD(subname);
2116 COPY_STRING_FIELD(newname);
2121 static AlterObjectSchemaStmt *
2122 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2124 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2126 COPY_SCALAR_FIELD(objectType);
2127 COPY_NODE_FIELD(relation);
2128 COPY_NODE_FIELD(object);
2129 COPY_NODE_FIELD(objarg);
2130 COPY_STRING_FIELD(addname);
2131 COPY_STRING_FIELD(newschema);
2136 static AlterOwnerStmt *
2137 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2139 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2141 COPY_SCALAR_FIELD(objectType);
2142 COPY_NODE_FIELD(relation);
2143 COPY_NODE_FIELD(object);
2144 COPY_NODE_FIELD(objarg);
2145 COPY_STRING_FIELD(addname);
2146 COPY_STRING_FIELD(newowner);
2152 _copyRuleStmt(RuleStmt *from)
2154 RuleStmt *newnode = makeNode(RuleStmt);
2156 COPY_NODE_FIELD(relation);
2157 COPY_STRING_FIELD(rulename);
2158 COPY_NODE_FIELD(whereClause);
2159 COPY_SCALAR_FIELD(event);
2160 COPY_SCALAR_FIELD(instead);
2161 COPY_NODE_FIELD(actions);
2162 COPY_SCALAR_FIELD(replace);
2168 _copyNotifyStmt(NotifyStmt *from)
2170 NotifyStmt *newnode = makeNode(NotifyStmt);
2172 COPY_NODE_FIELD(relation);
2178 _copyListenStmt(ListenStmt *from)
2180 ListenStmt *newnode = makeNode(ListenStmt);
2182 COPY_NODE_FIELD(relation);
2187 static UnlistenStmt *
2188 _copyUnlistenStmt(UnlistenStmt *from)
2190 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2192 COPY_NODE_FIELD(relation);
2197 static TransactionStmt *
2198 _copyTransactionStmt(TransactionStmt *from)
2200 TransactionStmt *newnode = makeNode(TransactionStmt);
2202 COPY_SCALAR_FIELD(kind);
2203 COPY_NODE_FIELD(options);
2204 COPY_STRING_FIELD(gid);
2209 static CompositeTypeStmt *
2210 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2212 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2214 COPY_NODE_FIELD(typevar);
2215 COPY_NODE_FIELD(coldeflist);
2221 _copyViewStmt(ViewStmt *from)
2223 ViewStmt *newnode = makeNode(ViewStmt);
2225 COPY_NODE_FIELD(view);
2226 COPY_NODE_FIELD(aliases);
2227 COPY_NODE_FIELD(query);
2228 COPY_SCALAR_FIELD(replace);
2234 _copyLoadStmt(LoadStmt *from)
2236 LoadStmt *newnode = makeNode(LoadStmt);
2238 COPY_STRING_FIELD(filename);
2243 static CreateDomainStmt *
2244 _copyCreateDomainStmt(CreateDomainStmt *from)
2246 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2248 COPY_NODE_FIELD(domainname);
2249 COPY_NODE_FIELD(typename);
2250 COPY_NODE_FIELD(constraints);
2255 static CreateOpClassStmt *
2256 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2258 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2260 COPY_NODE_FIELD(opclassname);
2261 COPY_STRING_FIELD(amname);
2262 COPY_NODE_FIELD(datatype);
2263 COPY_NODE_FIELD(items);
2264 COPY_SCALAR_FIELD(isDefault);
2269 static CreateOpClassItem *
2270 _copyCreateOpClassItem(CreateOpClassItem *from)
2272 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2274 COPY_SCALAR_FIELD(itemtype);
2275 COPY_NODE_FIELD(name);
2276 COPY_NODE_FIELD(args);
2277 COPY_SCALAR_FIELD(number);
2278 COPY_SCALAR_FIELD(recheck);
2279 COPY_NODE_FIELD(storedtype);
2284 static CreatedbStmt *
2285 _copyCreatedbStmt(CreatedbStmt *from)
2287 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2289 COPY_STRING_FIELD(dbname);
2290 COPY_NODE_FIELD(options);
2295 static AlterDatabaseStmt *
2296 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2298 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2300 COPY_STRING_FIELD(dbname);
2301 COPY_NODE_FIELD(options);
2306 static AlterDatabaseSetStmt *
2307 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2309 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2311 COPY_STRING_FIELD(dbname);
2312 COPY_STRING_FIELD(variable);
2313 COPY_NODE_FIELD(value);
2319 _copyDropdbStmt(DropdbStmt *from)
2321 DropdbStmt *newnode = makeNode(DropdbStmt);
2323 COPY_STRING_FIELD(dbname);
2324 COPY_SCALAR_FIELD(missing_ok);
2330 _copyVacuumStmt(VacuumStmt *from)
2332 VacuumStmt *newnode = makeNode(VacuumStmt);
2334 COPY_SCALAR_FIELD(vacuum);
2335 COPY_SCALAR_FIELD(full);
2336 COPY_SCALAR_FIELD(analyze);
2337 COPY_SCALAR_FIELD(freeze);
2338 COPY_SCALAR_FIELD(verbose);
2339 COPY_NODE_FIELD(relation);
2340 COPY_NODE_FIELD(va_cols);
2345 static ExplainStmt *
2346 _copyExplainStmt(ExplainStmt *from)
2348 ExplainStmt *newnode = makeNode(ExplainStmt);
2350 COPY_NODE_FIELD(query);
2351 COPY_SCALAR_FIELD(verbose);
2352 COPY_SCALAR_FIELD(analyze);
2357 static CreateSeqStmt *
2358 _copyCreateSeqStmt(CreateSeqStmt *from)
2360 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2362 COPY_NODE_FIELD(sequence);
2363 COPY_NODE_FIELD(options);
2368 static AlterSeqStmt *
2369 _copyAlterSeqStmt(AlterSeqStmt *from)
2371 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2373 COPY_NODE_FIELD(sequence);
2374 COPY_NODE_FIELD(options);
2379 static VariableSetStmt *
2380 _copyVariableSetStmt(VariableSetStmt *from)
2382 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2384 COPY_STRING_FIELD(name);
2385 COPY_NODE_FIELD(args);
2386 COPY_SCALAR_FIELD(is_local);
2391 static VariableShowStmt *
2392 _copyVariableShowStmt(VariableShowStmt *from)
2394 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2396 COPY_STRING_FIELD(name);
2401 static VariableResetStmt *
2402 _copyVariableResetStmt(VariableResetStmt *from)
2404 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2406 COPY_STRING_FIELD(name);
2411 static CreateTableSpaceStmt *
2412 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2414 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2416 COPY_STRING_FIELD(tablespacename);
2417 COPY_STRING_FIELD(owner);
2418 COPY_STRING_FIELD(location);
2423 static DropTableSpaceStmt *
2424 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2426 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2428 COPY_STRING_FIELD(tablespacename);
2433 static CreateTrigStmt *
2434 _copyCreateTrigStmt(CreateTrigStmt *from)
2436 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2438 COPY_STRING_FIELD(trigname);
2439 COPY_NODE_FIELD(relation);
2440 COPY_NODE_FIELD(funcname);
2441 COPY_NODE_FIELD(args);
2442 COPY_SCALAR_FIELD(before);
2443 COPY_SCALAR_FIELD(row);
2444 strcpy(newnode->actions, from->actions); /* in-line string field */
2445 COPY_SCALAR_FIELD(isconstraint);
2446 COPY_SCALAR_FIELD(deferrable);
2447 COPY_SCALAR_FIELD(initdeferred);
2448 COPY_NODE_FIELD(constrrel);
2453 static DropPropertyStmt *
2454 _copyDropPropertyStmt(DropPropertyStmt *from)
2456 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2458 COPY_NODE_FIELD(relation);
2459 COPY_STRING_FIELD(property);
2460 COPY_SCALAR_FIELD(removeType);
2461 COPY_SCALAR_FIELD(behavior);
2466 static CreatePLangStmt *
2467 _copyCreatePLangStmt(CreatePLangStmt *from)
2469 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2471 COPY_STRING_FIELD(plname);
2472 COPY_NODE_FIELD(plhandler);
2473 COPY_NODE_FIELD(plvalidator);
2474 COPY_SCALAR_FIELD(pltrusted);
2479 static DropPLangStmt *
2480 _copyDropPLangStmt(DropPLangStmt *from)
2482 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2484 COPY_STRING_FIELD(plname);
2485 COPY_SCALAR_FIELD(behavior);
2490 static CreateRoleStmt *
2491 _copyCreateRoleStmt(CreateRoleStmt *from)
2493 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2495 COPY_SCALAR_FIELD(stmt_type);
2496 COPY_STRING_FIELD(role);
2497 COPY_NODE_FIELD(options);
2502 static AlterRoleStmt *
2503 _copyAlterRoleStmt(AlterRoleStmt *from)
2505 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2507 COPY_STRING_FIELD(role);
2508 COPY_NODE_FIELD(options);
2509 COPY_SCALAR_FIELD(action);
2514 static AlterRoleSetStmt *
2515 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2517 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2519 COPY_STRING_FIELD(role);
2520 COPY_STRING_FIELD(variable);
2521 COPY_NODE_FIELD(value);
2526 static DropRoleStmt *
2527 _copyDropRoleStmt(DropRoleStmt *from)
2529 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2531 COPY_NODE_FIELD(roles);
2532 COPY_SCALAR_FIELD(missing_ok);
2538 _copyLockStmt(LockStmt *from)
2540 LockStmt *newnode = makeNode(LockStmt);
2542 COPY_NODE_FIELD(relations);
2543 COPY_SCALAR_FIELD(mode);
2544 COPY_SCALAR_FIELD(nowait);
2549 static ConstraintsSetStmt *
2550 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2552 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2554 COPY_NODE_FIELD(constraints);
2555 COPY_SCALAR_FIELD(deferred);
2560 static ReindexStmt *
2561 _copyReindexStmt(ReindexStmt *from)
2563 ReindexStmt *newnode = makeNode(ReindexStmt);
2565 COPY_SCALAR_FIELD(kind);
2566 COPY_NODE_FIELD(relation);
2567 COPY_STRING_FIELD(name);
2568 COPY_SCALAR_FIELD(do_system);
2569 COPY_SCALAR_FIELD(do_user);
2574 static CreateSchemaStmt *
2575 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2577 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2579 COPY_STRING_FIELD(schemaname);
2580 COPY_STRING_FIELD(authid);
2581 COPY_NODE_FIELD(schemaElts);
2586 static CreateConversionStmt *
2587 _copyCreateConversionStmt(CreateConversionStmt *from)
2589 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2591 COPY_NODE_FIELD(conversion_name);
2592 COPY_STRING_FIELD(for_encoding_name);
2593 COPY_STRING_FIELD(to_encoding_name);
2594 COPY_NODE_FIELD(func_name);
2595 COPY_SCALAR_FIELD(def);
2600 static CreateCastStmt *
2601 _copyCreateCastStmt(CreateCastStmt *from)
2603 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2605 COPY_NODE_FIELD(sourcetype);
2606 COPY_NODE_FIELD(targettype);
2607 COPY_NODE_FIELD(func);
2608 COPY_SCALAR_FIELD(context);
2613 static DropCastStmt *
2614 _copyDropCastStmt(DropCastStmt *from)
2616 DropCastStmt *newnode = makeNode(DropCastStmt);
2618 COPY_NODE_FIELD(sourcetype);
2619 COPY_NODE_FIELD(targettype);
2620 COPY_SCALAR_FIELD(behavior);
2625 static PrepareStmt *
2626 _copyPrepareStmt(PrepareStmt *from)
2628 PrepareStmt *newnode = makeNode(PrepareStmt);
2630 COPY_STRING_FIELD(name);
2631 COPY_NODE_FIELD(argtypes);
2632 COPY_NODE_FIELD(argtype_oids);
2633 COPY_NODE_FIELD(query);
2638 static ExecuteStmt *
2639 _copyExecuteStmt(ExecuteStmt *from)
2641 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2643 COPY_STRING_FIELD(name);
2644 COPY_NODE_FIELD(into);
2645 COPY_SCALAR_FIELD(into_contains_oids);
2646 COPY_SCALAR_FIELD(into_has_oids);
2647 COPY_SCALAR_FIELD(into_on_commit);
2648 COPY_STRING_FIELD(into_tbl_space);
2649 COPY_NODE_FIELD(params);
2654 static DeallocateStmt *
2655 _copyDeallocateStmt(DeallocateStmt *from)
2657 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2659 COPY_STRING_FIELD(name);
2664 static DropOwnedStmt *
2665 _copyDropOwnedStmt(DropOwnedStmt * from)
2667 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2669 COPY_NODE_FIELD(roles);
2670 COPY_SCALAR_FIELD(behavior);
2675 static ReassignOwnedStmt *
2676 _copyReassignOwnedStmt(ReassignOwnedStmt * from)
2678 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2680 COPY_NODE_FIELD(roles);
2681 COPY_SCALAR_FIELD(newrole);
2686 /* ****************************************************************
2687 * pg_list.h copy functions
2688 * ****************************************************************
2692 * Perform a deep copy of the specified list, using copyObject(). The
2693 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2694 * need deep copies, so they should be copied via list_copy()
2696 #define COPY_NODE_CELL(new, old) \
2697 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2698 lfirst(new) = copyObject(lfirst(old));
2701 _copyList(List *from)
2707 Assert(list_length(from) >= 1);
2709 new = makeNode(List);
2710 new->length = from->length;
2712 COPY_NODE_CELL(new->head, from->head);
2713 prev_new = new->head;
2714 curr_old = lnext(from->head);
2718 COPY_NODE_CELL(prev_new->next, curr_old);
2719 prev_new = prev_new->next;
2720 curr_old = curr_old->next;
2722 prev_new->next = NULL;
2723 new->tail = prev_new;
2728 /* ****************************************************************
2729 * value.h copy functions
2730 * ****************************************************************
2733 _copyValue(Value *from)
2735 Value *newnode = makeNode(Value);
2737 /* See also _copyAConst when changing this code! */
2739 COPY_SCALAR_FIELD(type);
2743 COPY_SCALAR_FIELD(val.ival);
2748 COPY_STRING_FIELD(val.str);
2754 elog(ERROR, "unrecognized node type: %d",
2764 * Create a copy of a Node tree or list. This is a "deep" copy: all
2765 * substructure is copied too, recursively.
2768 copyObject(void *from)
2775 switch (nodeTag(from))
2781 retval = _copyPlan(from);
2784 retval = _copyResult(from);
2787 retval = _copyAppend(from);
2790 retval = _copyBitmapAnd(from);
2793 retval = _copyBitmapOr(from);
2796 retval = _copyScan(from);
2799 retval = _copySeqScan(from);
2802 retval = _copyIndexScan(from);
2804 case T_BitmapIndexScan:
2805 retval = _copyBitmapIndexScan(from);
2807 case T_BitmapHeapScan:
2808 retval = _copyBitmapHeapScan(from);
2811 retval = _copyTidScan(from);
2813 case T_SubqueryScan:
2814 retval = _copySubqueryScan(from);
2816 case T_FunctionScan:
2817 retval = _copyFunctionScan(from);
2820 retval = _copyJoin(from);
2823 retval = _copyNestLoop(from);
2826 retval = _copyMergeJoin(from);
2829 retval = _copyHashJoin(from);
2832 retval = _copyMaterial(from);
2835 retval = _copySort(from);
2838 retval = _copyGroup(from);
2841 retval = _copyAgg(from);
2844 retval = _copyUnique(from);
2847 retval = _copyHash(from);
2850 retval = _copySetOp(from);
2853 retval = _copyLimit(from);
2860 retval = _copyAlias(from);
2863 retval = _copyRangeVar(from);
2866 retval = _copyVar(from);
2869 retval = _copyConst(from);
2872 retval = _copyParam(from);
2875 retval = _copyAggref(from);
2878 retval = _copyArrayRef(from);
2881 retval = _copyFuncExpr(from);
2884 retval = _copyOpExpr(from);
2886 case T_DistinctExpr:
2887 retval = _copyDistinctExpr(from);
2889 case T_ScalarArrayOpExpr:
2890 retval = _copyScalarArrayOpExpr(from);
2893 retval = _copyBoolExpr(from);
2896 retval = _copySubLink(from);
2899 retval = _copySubPlan(from);
2902 retval = _copyFieldSelect(from);
2905 retval = _copyFieldStore(from);
2908 retval = _copyRelabelType(from);
2910 case T_ConvertRowtypeExpr:
2911 retval = _copyConvertRowtypeExpr(from);
2914 retval = _copyCaseExpr(from);
2917 retval = _copyCaseWhen(from);
2919 case T_CaseTestExpr:
2920 retval = _copyCaseTestExpr(from);
2923 retval = _copyArrayExpr(from);
2926 retval = _copyRowExpr(from);
2928 case T_RowCompareExpr:
2929 retval = _copyRowCompareExpr(from);
2931 case T_CoalesceExpr:
2932 retval = _copyCoalesceExpr(from);
2935 retval = _copyMinMaxExpr(from);
2938 retval = _copyNullIfExpr(from);
2941 retval = _copyNullTest(from);
2944 retval = _copyBooleanTest(from);
2946 case T_CoerceToDomain:
2947 retval = _copyCoerceToDomain(from);
2949 case T_CoerceToDomainValue:
2950 retval = _copyCoerceToDomainValue(from);
2952 case T_SetToDefault:
2953 retval = _copySetToDefault(from);
2956 retval = _copyTargetEntry(from);
2959 retval = _copyRangeTblRef(from);
2962 retval = _copyJoinExpr(from);
2965 retval = _copyFromExpr(from);
2972 retval = _copyPathKeyItem(from);
2974 case T_RestrictInfo:
2975 retval = _copyRestrictInfo(from);
2977 case T_OuterJoinInfo:
2978 retval = _copyOuterJoinInfo(from);
2980 case T_InClauseInfo:
2981 retval = _copyInClauseInfo(from);
2983 case T_AppendRelInfo:
2984 retval = _copyAppendRelInfo(from);
2995 retval = _copyValue(from);
3002 retval = _copyList(from);
3006 * Lists of integers and OIDs don't need to be deep-copied, so we
3007 * perform a shallow copy via list_copy()
3011 retval = list_copy(from);
3018 retval = _copyQuery(from);
3021 retval = _copyInsertStmt(from);
3024 retval = _copyDeleteStmt(from);
3027 retval = _copyUpdateStmt(from);
3030 retval = _copySelectStmt(from);
3032 case T_SetOperationStmt:
3033 retval = _copySetOperationStmt(from);
3035 case T_AlterTableStmt:
3036 retval = _copyAlterTableStmt(from);
3038 case T_AlterTableCmd:
3039 retval = _copyAlterTableCmd(from);
3041 case T_AlterDomainStmt:
3042 retval = _copyAlterDomainStmt(from);
3045 retval = _copyGrantStmt(from);
3047 case T_GrantRoleStmt:
3048 retval = _copyGrantRoleStmt(from);
3050 case T_DeclareCursorStmt:
3051 retval = _copyDeclareCursorStmt(from);
3053 case T_ClosePortalStmt:
3054 retval = _copyClosePortalStmt(from);
3057 retval = _copyClusterStmt(from);
3060 retval = _copyCopyStmt(from);
3063 retval = _copyCreateStmt(from);
3066 retval = _copyInhRelation(from);
3069 retval = _copyDefineStmt(from);
3072 retval = _copyDropStmt(from);
3074 case T_TruncateStmt:
3075 retval = _copyTruncateStmt(from);
3078 retval = _copyCommentStmt(from);
3081 retval = _copyFetchStmt(from);
3084 retval = _copyIndexStmt(from);
3086 case T_CreateFunctionStmt:
3087 retval = _copyCreateFunctionStmt(from);
3089 case T_FunctionParameter:
3090 retval = _copyFunctionParameter(from);
3092 case T_AlterFunctionStmt:
3093 retval = _copyAlterFunctionStmt(from);
3095 case T_RemoveAggrStmt:
3096 retval = _copyRemoveAggrStmt(from);
3098 case T_RemoveFuncStmt:
3099 retval = _copyRemoveFuncStmt(from);
3101 case T_RemoveOperStmt:
3102 retval = _copyRemoveOperStmt(from);
3104 case T_RemoveOpClassStmt:
3105 retval = _copyRemoveOpClassStmt(from);
3108 retval = _copyRenameStmt(from);
3110 case T_AlterObjectSchemaStmt:
3111 retval = _copyAlterObjectSchemaStmt(from);
3113 case T_AlterOwnerStmt:
3114 retval = _copyAlterOwnerStmt(from);
3117 retval = _copyRuleStmt(from);
3120 retval = _copyNotifyStmt(from);
3123 retval = _copyListenStmt(from);
3125 case T_UnlistenStmt:
3126 retval = _copyUnlistenStmt(from);
3128 case T_TransactionStmt:
3129 retval = _copyTransactionStmt(from);
3131 case T_CompositeTypeStmt:
3132 retval = _copyCompositeTypeStmt(from);
3135 retval = _copyViewStmt(from);
3138 retval = _copyLoadStmt(from);
3140 case T_CreateDomainStmt:
3141 retval = _copyCreateDomainStmt(from);
3143 case T_CreateOpClassStmt:
3144 retval = _copyCreateOpClassStmt(from);
3146 case T_CreateOpClassItem:
3147 retval = _copyCreateOpClassItem(from);
3149 case T_CreatedbStmt:
3150 retval = _copyCreatedbStmt(from);
3152 case T_AlterDatabaseStmt:
3153 retval = _copyAlterDatabaseStmt(from);
3155 case T_AlterDatabaseSetStmt:
3156 retval = _copyAlterDatabaseSetStmt(from);
3159 retval = _copyDropdbStmt(from);
3162 retval = _copyVacuumStmt(from);
3165 retval = _copyExplainStmt(from);
3167 case T_CreateSeqStmt:
3168 retval = _copyCreateSeqStmt(from);
3170 case T_AlterSeqStmt:
3171 retval = _copyAlterSeqStmt(from);
3173 case T_VariableSetStmt:
3174 retval = _copyVariableSetStmt(from);
3176 case T_VariableShowStmt:
3177 retval = _copyVariableShowStmt(from);
3179 case T_VariableResetStmt:
3180 retval = _copyVariableResetStmt(from);
3182 case T_CreateTableSpaceStmt:
3183 retval = _copyCreateTableSpaceStmt(from);
3185 case T_DropTableSpaceStmt:
3186 retval = _copyDropTableSpaceStmt(from);
3188 case T_CreateTrigStmt:
3189 retval = _copyCreateTrigStmt(from);
3191 case T_DropPropertyStmt:
3192 retval = _copyDropPropertyStmt(from);
3194 case T_CreatePLangStmt:
3195 retval = _copyCreatePLangStmt(from);
3197 case T_DropPLangStmt:
3198 retval = _copyDropPLangStmt(from);
3200 case T_CreateRoleStmt:
3201 retval = _copyCreateRoleStmt(from);
3203 case T_AlterRoleStmt:
3204 retval = _copyAlterRoleStmt(from);
3206 case T_AlterRoleSetStmt:
3207 retval = _copyAlterRoleSetStmt(from);
3209 case T_DropRoleStmt:
3210 retval = _copyDropRoleStmt(from);
3213 retval = _copyLockStmt(from);
3215 case T_ConstraintsSetStmt:
3216 retval = _copyConstraintsSetStmt(from);
3219 retval = _copyReindexStmt(from);
3221 case T_CheckPointStmt:
3222 retval = (void *) makeNode(CheckPointStmt);
3224 case T_CreateSchemaStmt:
3225 retval = _copyCreateSchemaStmt(from);
3227 case T_CreateConversionStmt:
3228 retval = _copyCreateConversionStmt(from);
3230 case T_CreateCastStmt:
3231 retval = _copyCreateCastStmt(from);
3233 case T_DropCastStmt:
3234 retval = _copyDropCastStmt(from);
3237 retval = _copyPrepareStmt(from);
3240 retval = _copyExecuteStmt(from);
3242 case T_DeallocateStmt:
3243 retval = _copyDeallocateStmt(from);
3245 case T_DropOwnedStmt:
3246 retval = _copyDropOwnedStmt(from);
3248 case T_ReassignOwnedStmt:
3249 retval = _copyReassignOwnedStmt(from);
3253 retval = _copyAExpr(from);
3256 retval = _copyColumnRef(from);
3259 retval = _copyParamRef(from);
3262 retval = _copyAConst(from);
3265 retval = _copyFuncCall(from);
3268 retval = _copyAIndices(from);
3270 case T_A_Indirection:
3271 retval = _copyA_Indirection(from);
3274 retval = _copyResTarget(from);
3277 retval = _copyTypeCast(from);
3280 retval = _copySortBy(from);
3282 case T_RangeSubselect:
3283 retval = _copyRangeSubselect(from);
3285 case T_RangeFunction:
3286 retval = _copyRangeFunction(from);
3289 retval = _copyTypeName(from);
3292 retval = _copyIndexElem(from);
3295 retval = _copyColumnDef(from);
3298 retval = _copyConstraint(from);
3301 retval = _copyDefElem(from);
3303 case T_LockingClause:
3304 retval = _copyLockingClause(from);
3306 case T_RangeTblEntry:
3307 retval = _copyRangeTblEntry(from);
3310 retval = _copySortClause(from);
3313 retval = _copyGroupClause(from);
3315 case T_FkConstraint:
3316 retval = _copyFkConstraint(from);
3319 retval = _copyPrivGrantee(from);
3321 case T_FuncWithArgs:
3322 retval = _copyFuncWithArgs(from);
3326 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3327 retval = from; /* keep compiler quiet */