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.348 2006/08/21 00:57:24 tgl Exp $
20 *-------------------------------------------------------------------------
25 #include "nodes/plannodes.h"
26 #include "nodes/relation.h"
27 #include "utils/datum.h"
31 * Macros to simplify copying of different kinds of fields. Use these
32 * wherever possible to reduce the chance for silly typos. Note that these
33 * hard-wire the convention that the local variables in a Copy routine are
34 * named 'newnode' and 'from'.
37 /* Copy a simple scalar field (int, float, bool, enum, etc) */
38 #define COPY_SCALAR_FIELD(fldname) \
39 (newnode->fldname = from->fldname)
41 /* Copy a field that is a pointer to some kind of Node or Node tree */
42 #define COPY_NODE_FIELD(fldname) \
43 (newnode->fldname = copyObject(from->fldname))
45 /* Copy a field that is a pointer to a Bitmapset */
46 #define COPY_BITMAPSET_FIELD(fldname) \
47 (newnode->fldname = bms_copy(from->fldname))
49 /* Copy a field that is a pointer to a C string, or perhaps NULL */
50 #define COPY_STRING_FIELD(fldname) \
51 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
53 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
54 #define COPY_POINTER_FIELD(fldname, sz) \
57 newnode->fldname = palloc(_size); \
58 memcpy(newnode->fldname, from->fldname, _size); \
62 /* ****************************************************************
63 * plannodes.h copy functions
64 * ****************************************************************
70 * This function copies the fields of the Plan node. It is used by
71 * all the copy functions for classes which inherit from Plan.
74 CopyPlanFields(Plan *from, Plan *newnode)
76 COPY_SCALAR_FIELD(startup_cost);
77 COPY_SCALAR_FIELD(total_cost);
78 COPY_SCALAR_FIELD(plan_rows);
79 COPY_SCALAR_FIELD(plan_width);
80 COPY_NODE_FIELD(targetlist);
81 COPY_NODE_FIELD(qual);
82 COPY_NODE_FIELD(lefttree);
83 COPY_NODE_FIELD(righttree);
84 COPY_NODE_FIELD(initPlan);
85 COPY_BITMAPSET_FIELD(extParam);
86 COPY_BITMAPSET_FIELD(allParam);
87 COPY_SCALAR_FIELD(nParamExec);
96 Plan *newnode = makeNode(Plan);
99 * copy node superclass fields
101 CopyPlanFields(from, newnode);
111 _copyResult(Result *from)
113 Result *newnode = makeNode(Result);
116 * copy node superclass fields
118 CopyPlanFields((Plan *) from, (Plan *) newnode);
121 * copy remainder of node
123 COPY_NODE_FIELD(resconstantqual);
132 _copyAppend(Append *from)
134 Append *newnode = makeNode(Append);
137 * copy node superclass fields
139 CopyPlanFields((Plan *) from, (Plan *) newnode);
142 * copy remainder of node
144 COPY_NODE_FIELD(appendplans);
145 COPY_SCALAR_FIELD(isTarget);
154 _copyBitmapAnd(BitmapAnd *from)
156 BitmapAnd *newnode = makeNode(BitmapAnd);
159 * copy node superclass fields
161 CopyPlanFields((Plan *) from, (Plan *) newnode);
164 * copy remainder of node
166 COPY_NODE_FIELD(bitmapplans);
175 _copyBitmapOr(BitmapOr *from)
177 BitmapOr *newnode = makeNode(BitmapOr);
180 * copy node superclass fields
182 CopyPlanFields((Plan *) from, (Plan *) newnode);
185 * copy remainder of node
187 COPY_NODE_FIELD(bitmapplans);
196 * This function copies the fields of the Scan node. It is used by
197 * all the copy functions for classes which inherit from Scan.
200 CopyScanFields(Scan *from, Scan *newnode)
202 CopyPlanFields((Plan *) from, (Plan *) newnode);
204 COPY_SCALAR_FIELD(scanrelid);
211 _copyScan(Scan *from)
213 Scan *newnode = makeNode(Scan);
216 * copy node superclass fields
218 CopyScanFields((Scan *) from, (Scan *) newnode);
227 _copySeqScan(SeqScan *from)
229 SeqScan *newnode = makeNode(SeqScan);
232 * copy node superclass fields
234 CopyScanFields((Scan *) from, (Scan *) newnode);
243 _copyIndexScan(IndexScan *from)
245 IndexScan *newnode = makeNode(IndexScan);
248 * copy node superclass fields
250 CopyScanFields((Scan *) from, (Scan *) newnode);
253 * copy remainder of node
255 COPY_SCALAR_FIELD(indexid);
256 COPY_NODE_FIELD(indexqual);
257 COPY_NODE_FIELD(indexqualorig);
258 COPY_NODE_FIELD(indexstrategy);
259 COPY_NODE_FIELD(indexsubtype);
260 COPY_SCALAR_FIELD(indexorderdir);
266 * _copyBitmapIndexScan
268 static BitmapIndexScan *
269 _copyBitmapIndexScan(BitmapIndexScan *from)
271 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
274 * copy node superclass fields
276 CopyScanFields((Scan *) from, (Scan *) newnode);
279 * copy remainder of node
281 COPY_SCALAR_FIELD(indexid);
282 COPY_NODE_FIELD(indexqual);
283 COPY_NODE_FIELD(indexqualorig);
284 COPY_NODE_FIELD(indexstrategy);
285 COPY_NODE_FIELD(indexsubtype);
291 * _copyBitmapHeapScan
293 static BitmapHeapScan *
294 _copyBitmapHeapScan(BitmapHeapScan *from)
296 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
299 * copy node superclass fields
301 CopyScanFields((Scan *) from, (Scan *) newnode);
304 * copy remainder of node
306 COPY_NODE_FIELD(bitmapqualorig);
315 _copyTidScan(TidScan *from)
317 TidScan *newnode = makeNode(TidScan);
320 * copy node superclass fields
322 CopyScanFields((Scan *) from, (Scan *) newnode);
325 * copy remainder of node
327 COPY_NODE_FIELD(tidquals);
335 static SubqueryScan *
336 _copySubqueryScan(SubqueryScan *from)
338 SubqueryScan *newnode = makeNode(SubqueryScan);
341 * copy node superclass fields
343 CopyScanFields((Scan *) from, (Scan *) newnode);
346 * copy remainder of node
348 COPY_NODE_FIELD(subplan);
356 static FunctionScan *
357 _copyFunctionScan(FunctionScan *from)
359 FunctionScan *newnode = makeNode(FunctionScan);
362 * copy node superclass fields
364 CopyScanFields((Scan *) from, (Scan *) newnode);
373 _copyValuesScan(ValuesScan *from)
375 ValuesScan *newnode = makeNode(ValuesScan);
378 * copy node superclass fields
380 CopyScanFields((Scan *) from, (Scan *) newnode);
388 * This function copies the fields of the Join node. It is used by
389 * all the copy functions for classes which inherit from Join.
392 CopyJoinFields(Join *from, Join *newnode)
394 CopyPlanFields((Plan *) from, (Plan *) newnode);
396 COPY_SCALAR_FIELD(jointype);
397 COPY_NODE_FIELD(joinqual);
405 _copyJoin(Join *from)
407 Join *newnode = makeNode(Join);
410 * copy node superclass fields
412 CopyJoinFields(from, newnode);
422 _copyNestLoop(NestLoop *from)
424 NestLoop *newnode = makeNode(NestLoop);
427 * copy node superclass fields
429 CopyJoinFields((Join *) from, (Join *) newnode);
439 _copyMergeJoin(MergeJoin *from)
441 MergeJoin *newnode = makeNode(MergeJoin);
444 * copy node superclass fields
446 CopyJoinFields((Join *) from, (Join *) newnode);
449 * copy remainder of node
451 COPY_NODE_FIELD(mergeclauses);
460 _copyHashJoin(HashJoin *from)
462 HashJoin *newnode = makeNode(HashJoin);
465 * copy node superclass fields
467 CopyJoinFields((Join *) from, (Join *) newnode);
470 * copy remainder of node
472 COPY_NODE_FIELD(hashclauses);
482 _copyMaterial(Material *from)
484 Material *newnode = makeNode(Material);
487 * copy node superclass fields
489 CopyPlanFields((Plan *) from, (Plan *) newnode);
499 _copySort(Sort *from)
501 Sort *newnode = makeNode(Sort);
504 * copy node superclass fields
506 CopyPlanFields((Plan *) from, (Plan *) newnode);
508 COPY_SCALAR_FIELD(numCols);
509 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
510 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
520 _copyGroup(Group *from)
522 Group *newnode = makeNode(Group);
524 CopyPlanFields((Plan *) from, (Plan *) newnode);
526 COPY_SCALAR_FIELD(numCols);
527 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
538 Agg *newnode = makeNode(Agg);
540 CopyPlanFields((Plan *) from, (Plan *) newnode);
542 COPY_SCALAR_FIELD(aggstrategy);
543 COPY_SCALAR_FIELD(numCols);
544 if (from->numCols > 0)
545 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
546 COPY_SCALAR_FIELD(numGroups);
555 _copyUnique(Unique *from)
557 Unique *newnode = makeNode(Unique);
560 * copy node superclass fields
562 CopyPlanFields((Plan *) from, (Plan *) newnode);
565 * copy remainder of node
567 COPY_SCALAR_FIELD(numCols);
568 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
577 _copyHash(Hash *from)
579 Hash *newnode = makeNode(Hash);
582 * copy node superclass fields
584 CopyPlanFields((Plan *) from, (Plan *) newnode);
587 * copy remainder of node
597 _copySetOp(SetOp *from)
599 SetOp *newnode = makeNode(SetOp);
602 * copy node superclass fields
604 CopyPlanFields((Plan *) from, (Plan *) newnode);
607 * copy remainder of node
609 COPY_SCALAR_FIELD(cmd);
610 COPY_SCALAR_FIELD(numCols);
611 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
612 COPY_SCALAR_FIELD(flagColIdx);
621 _copyLimit(Limit *from)
623 Limit *newnode = makeNode(Limit);
626 * copy node superclass fields
628 CopyPlanFields((Plan *) from, (Plan *) newnode);
631 * copy remainder of node
633 COPY_NODE_FIELD(limitOffset);
634 COPY_NODE_FIELD(limitCount);
639 /* ****************************************************************
640 * primnodes.h copy functions
641 * ****************************************************************
648 _copyAlias(Alias *from)
650 Alias *newnode = makeNode(Alias);
652 COPY_STRING_FIELD(aliasname);
653 COPY_NODE_FIELD(colnames);
662 _copyRangeVar(RangeVar *from)
664 RangeVar *newnode = makeNode(RangeVar);
666 COPY_STRING_FIELD(catalogname);
667 COPY_STRING_FIELD(schemaname);
668 COPY_STRING_FIELD(relname);
669 COPY_SCALAR_FIELD(inhOpt);
670 COPY_SCALAR_FIELD(istemp);
671 COPY_NODE_FIELD(alias);
677 * We don't need a _copyExpr because Expr is an abstract supertype which
678 * should never actually get instantiated. Also, since it has no common
679 * fields except NodeTag, there's no need for a helper routine to factor
680 * out copying the common fields...
689 Var *newnode = makeNode(Var);
691 COPY_SCALAR_FIELD(varno);
692 COPY_SCALAR_FIELD(varattno);
693 COPY_SCALAR_FIELD(vartype);
694 COPY_SCALAR_FIELD(vartypmod);
695 COPY_SCALAR_FIELD(varlevelsup);
696 COPY_SCALAR_FIELD(varnoold);
697 COPY_SCALAR_FIELD(varoattno);
706 _copyConst(Const *from)
708 Const *newnode = makeNode(Const);
710 COPY_SCALAR_FIELD(consttype);
711 COPY_SCALAR_FIELD(constlen);
713 if (from->constbyval || from->constisnull)
716 * passed by value so just copy the datum. Also, don't try to copy
717 * struct when value is null!
719 newnode->constvalue = from->constvalue;
724 * passed by reference. We need a palloc'd copy.
726 newnode->constvalue = datumCopy(from->constvalue,
731 COPY_SCALAR_FIELD(constisnull);
732 COPY_SCALAR_FIELD(constbyval);
741 _copyParam(Param *from)
743 Param *newnode = makeNode(Param);
745 COPY_SCALAR_FIELD(paramkind);
746 COPY_SCALAR_FIELD(paramid);
747 COPY_SCALAR_FIELD(paramtype);
756 _copyAggref(Aggref *from)
758 Aggref *newnode = makeNode(Aggref);
760 COPY_SCALAR_FIELD(aggfnoid);
761 COPY_SCALAR_FIELD(aggtype);
762 COPY_NODE_FIELD(args);
763 COPY_SCALAR_FIELD(agglevelsup);
764 COPY_SCALAR_FIELD(aggstar);
765 COPY_SCALAR_FIELD(aggdistinct);
774 _copyArrayRef(ArrayRef *from)
776 ArrayRef *newnode = makeNode(ArrayRef);
778 COPY_SCALAR_FIELD(refrestype);
779 COPY_SCALAR_FIELD(refarraytype);
780 COPY_SCALAR_FIELD(refelemtype);
781 COPY_NODE_FIELD(refupperindexpr);
782 COPY_NODE_FIELD(reflowerindexpr);
783 COPY_NODE_FIELD(refexpr);
784 COPY_NODE_FIELD(refassgnexpr);
793 _copyFuncExpr(FuncExpr *from)
795 FuncExpr *newnode = makeNode(FuncExpr);
797 COPY_SCALAR_FIELD(funcid);
798 COPY_SCALAR_FIELD(funcresulttype);
799 COPY_SCALAR_FIELD(funcretset);
800 COPY_SCALAR_FIELD(funcformat);
801 COPY_NODE_FIELD(args);
810 _copyOpExpr(OpExpr *from)
812 OpExpr *newnode = makeNode(OpExpr);
814 COPY_SCALAR_FIELD(opno);
815 COPY_SCALAR_FIELD(opfuncid);
816 COPY_SCALAR_FIELD(opresulttype);
817 COPY_SCALAR_FIELD(opretset);
818 COPY_NODE_FIELD(args);
824 * _copyDistinctExpr (same as OpExpr)
826 static DistinctExpr *
827 _copyDistinctExpr(DistinctExpr *from)
829 DistinctExpr *newnode = makeNode(DistinctExpr);
831 COPY_SCALAR_FIELD(opno);
832 COPY_SCALAR_FIELD(opfuncid);
833 COPY_SCALAR_FIELD(opresulttype);
834 COPY_SCALAR_FIELD(opretset);
835 COPY_NODE_FIELD(args);
841 * _copyScalarArrayOpExpr
843 static ScalarArrayOpExpr *
844 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
846 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
848 COPY_SCALAR_FIELD(opno);
849 COPY_SCALAR_FIELD(opfuncid);
850 COPY_SCALAR_FIELD(useOr);
851 COPY_NODE_FIELD(args);
860 _copyBoolExpr(BoolExpr *from)
862 BoolExpr *newnode = makeNode(BoolExpr);
864 COPY_SCALAR_FIELD(boolop);
865 COPY_NODE_FIELD(args);
874 _copySubLink(SubLink *from)
876 SubLink *newnode = makeNode(SubLink);
878 COPY_SCALAR_FIELD(subLinkType);
879 COPY_NODE_FIELD(testexpr);
880 COPY_NODE_FIELD(operName);
881 COPY_NODE_FIELD(subselect);
890 _copySubPlan(SubPlan *from)
892 SubPlan *newnode = makeNode(SubPlan);
894 COPY_SCALAR_FIELD(subLinkType);
895 COPY_NODE_FIELD(testexpr);
896 COPY_NODE_FIELD(paramIds);
897 COPY_NODE_FIELD(plan);
898 COPY_SCALAR_FIELD(plan_id);
899 COPY_NODE_FIELD(rtable);
900 COPY_SCALAR_FIELD(useHashTable);
901 COPY_SCALAR_FIELD(unknownEqFalse);
902 COPY_NODE_FIELD(setParam);
903 COPY_NODE_FIELD(parParam);
904 COPY_NODE_FIELD(args);
913 _copyFieldSelect(FieldSelect *from)
915 FieldSelect *newnode = makeNode(FieldSelect);
917 COPY_NODE_FIELD(arg);
918 COPY_SCALAR_FIELD(fieldnum);
919 COPY_SCALAR_FIELD(resulttype);
920 COPY_SCALAR_FIELD(resulttypmod);
929 _copyFieldStore(FieldStore *from)
931 FieldStore *newnode = makeNode(FieldStore);
933 COPY_NODE_FIELD(arg);
934 COPY_NODE_FIELD(newvals);
935 COPY_NODE_FIELD(fieldnums);
936 COPY_SCALAR_FIELD(resulttype);
945 _copyRelabelType(RelabelType *from)
947 RelabelType *newnode = makeNode(RelabelType);
949 COPY_NODE_FIELD(arg);
950 COPY_SCALAR_FIELD(resulttype);
951 COPY_SCALAR_FIELD(resulttypmod);
952 COPY_SCALAR_FIELD(relabelformat);
958 * _copyConvertRowtypeExpr
960 static ConvertRowtypeExpr *
961 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
963 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
965 COPY_NODE_FIELD(arg);
966 COPY_SCALAR_FIELD(resulttype);
967 COPY_SCALAR_FIELD(convertformat);
976 _copyCaseExpr(CaseExpr *from)
978 CaseExpr *newnode = makeNode(CaseExpr);
980 COPY_SCALAR_FIELD(casetype);
981 COPY_NODE_FIELD(arg);
982 COPY_NODE_FIELD(args);
983 COPY_NODE_FIELD(defresult);
992 _copyCaseWhen(CaseWhen *from)
994 CaseWhen *newnode = makeNode(CaseWhen);
996 COPY_NODE_FIELD(expr);
997 COPY_NODE_FIELD(result);
1005 static CaseTestExpr *
1006 _copyCaseTestExpr(CaseTestExpr *from)
1008 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1010 COPY_SCALAR_FIELD(typeId);
1011 COPY_SCALAR_FIELD(typeMod);
1020 _copyArrayExpr(ArrayExpr *from)
1022 ArrayExpr *newnode = makeNode(ArrayExpr);
1024 COPY_SCALAR_FIELD(array_typeid);
1025 COPY_SCALAR_FIELD(element_typeid);
1026 COPY_NODE_FIELD(elements);
1027 COPY_SCALAR_FIELD(multidims);
1036 _copyRowExpr(RowExpr *from)
1038 RowExpr *newnode = makeNode(RowExpr);
1040 COPY_NODE_FIELD(args);
1041 COPY_SCALAR_FIELD(row_typeid);
1042 COPY_SCALAR_FIELD(row_format);
1048 * _copyRowCompareExpr
1050 static RowCompareExpr *
1051 _copyRowCompareExpr(RowCompareExpr *from)
1053 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1055 COPY_SCALAR_FIELD(rctype);
1056 COPY_NODE_FIELD(opnos);
1057 COPY_NODE_FIELD(opclasses);
1058 COPY_NODE_FIELD(largs);
1059 COPY_NODE_FIELD(rargs);
1067 static CoalesceExpr *
1068 _copyCoalesceExpr(CoalesceExpr *from)
1070 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1072 COPY_SCALAR_FIELD(coalescetype);
1073 COPY_NODE_FIELD(args);
1082 _copyMinMaxExpr(MinMaxExpr *from)
1084 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1086 COPY_SCALAR_FIELD(minmaxtype);
1087 COPY_SCALAR_FIELD(op);
1088 COPY_NODE_FIELD(args);
1094 * _copyNullIfExpr (same as OpExpr)
1097 _copyNullIfExpr(NullIfExpr *from)
1099 NullIfExpr *newnode = makeNode(NullIfExpr);
1101 COPY_SCALAR_FIELD(opno);
1102 COPY_SCALAR_FIELD(opfuncid);
1103 COPY_SCALAR_FIELD(opresulttype);
1104 COPY_SCALAR_FIELD(opretset);
1105 COPY_NODE_FIELD(args);
1114 _copyNullTest(NullTest *from)
1116 NullTest *newnode = makeNode(NullTest);
1118 COPY_NODE_FIELD(arg);
1119 COPY_SCALAR_FIELD(nulltesttype);
1127 static BooleanTest *
1128 _copyBooleanTest(BooleanTest *from)
1130 BooleanTest *newnode = makeNode(BooleanTest);
1132 COPY_NODE_FIELD(arg);
1133 COPY_SCALAR_FIELD(booltesttype);
1139 * _copyCoerceToDomain
1141 static CoerceToDomain *
1142 _copyCoerceToDomain(CoerceToDomain *from)
1144 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1146 COPY_NODE_FIELD(arg);
1147 COPY_SCALAR_FIELD(resulttype);
1148 COPY_SCALAR_FIELD(resulttypmod);
1149 COPY_SCALAR_FIELD(coercionformat);
1155 * _copyCoerceToDomainValue
1157 static CoerceToDomainValue *
1158 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1160 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1162 COPY_SCALAR_FIELD(typeId);
1163 COPY_SCALAR_FIELD(typeMod);
1171 static SetToDefault *
1172 _copySetToDefault(SetToDefault *from)
1174 SetToDefault *newnode = makeNode(SetToDefault);
1176 COPY_SCALAR_FIELD(typeId);
1177 COPY_SCALAR_FIELD(typeMod);
1185 static TargetEntry *
1186 _copyTargetEntry(TargetEntry *from)
1188 TargetEntry *newnode = makeNode(TargetEntry);
1190 COPY_NODE_FIELD(expr);
1191 COPY_SCALAR_FIELD(resno);
1192 COPY_STRING_FIELD(resname);
1193 COPY_SCALAR_FIELD(ressortgroupref);
1194 COPY_SCALAR_FIELD(resorigtbl);
1195 COPY_SCALAR_FIELD(resorigcol);
1196 COPY_SCALAR_FIELD(resjunk);
1204 static RangeTblRef *
1205 _copyRangeTblRef(RangeTblRef *from)
1207 RangeTblRef *newnode = makeNode(RangeTblRef);
1209 COPY_SCALAR_FIELD(rtindex);
1218 _copyJoinExpr(JoinExpr *from)
1220 JoinExpr *newnode = makeNode(JoinExpr);
1222 COPY_SCALAR_FIELD(jointype);
1223 COPY_SCALAR_FIELD(isNatural);
1224 COPY_NODE_FIELD(larg);
1225 COPY_NODE_FIELD(rarg);
1226 COPY_NODE_FIELD(using);
1227 COPY_NODE_FIELD(quals);
1228 COPY_NODE_FIELD(alias);
1229 COPY_SCALAR_FIELD(rtindex);
1238 _copyFromExpr(FromExpr *from)
1240 FromExpr *newnode = makeNode(FromExpr);
1242 COPY_NODE_FIELD(fromlist);
1243 COPY_NODE_FIELD(quals);
1248 /* ****************************************************************
1249 * relation.h copy functions
1251 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1252 * There are some subsidiary structs that are useful to copy, though.
1253 * ****************************************************************
1259 static PathKeyItem *
1260 _copyPathKeyItem(PathKeyItem *from)
1262 PathKeyItem *newnode = makeNode(PathKeyItem);
1264 COPY_NODE_FIELD(key);
1265 COPY_SCALAR_FIELD(sortop);
1273 static RestrictInfo *
1274 _copyRestrictInfo(RestrictInfo *from)
1276 RestrictInfo *newnode = makeNode(RestrictInfo);
1278 COPY_NODE_FIELD(clause);
1279 COPY_SCALAR_FIELD(is_pushed_down);
1280 COPY_SCALAR_FIELD(outerjoin_delayed);
1281 COPY_SCALAR_FIELD(can_join);
1282 COPY_SCALAR_FIELD(pseudoconstant);
1283 COPY_BITMAPSET_FIELD(clause_relids);
1284 COPY_BITMAPSET_FIELD(required_relids);
1285 COPY_BITMAPSET_FIELD(left_relids);
1286 COPY_BITMAPSET_FIELD(right_relids);
1287 COPY_NODE_FIELD(orclause);
1288 COPY_SCALAR_FIELD(eval_cost);
1289 COPY_SCALAR_FIELD(this_selec);
1290 COPY_SCALAR_FIELD(mergejoinoperator);
1291 COPY_SCALAR_FIELD(left_sortop);
1292 COPY_SCALAR_FIELD(right_sortop);
1295 * Do not copy pathkeys, since they'd not be canonical in a copied query
1297 newnode->left_pathkey = NIL;
1298 newnode->right_pathkey = NIL;
1300 COPY_SCALAR_FIELD(left_mergescansel);
1301 COPY_SCALAR_FIELD(right_mergescansel);
1302 COPY_SCALAR_FIELD(hashjoinoperator);
1303 COPY_SCALAR_FIELD(left_bucketsize);
1304 COPY_SCALAR_FIELD(right_bucketsize);
1310 * _copyOuterJoinInfo
1312 static OuterJoinInfo *
1313 _copyOuterJoinInfo(OuterJoinInfo *from)
1315 OuterJoinInfo *newnode = makeNode(OuterJoinInfo);
1317 COPY_BITMAPSET_FIELD(min_lefthand);
1318 COPY_BITMAPSET_FIELD(min_righthand);
1319 COPY_SCALAR_FIELD(is_full_join);
1320 COPY_SCALAR_FIELD(lhs_strict);
1328 static InClauseInfo *
1329 _copyInClauseInfo(InClauseInfo *from)
1331 InClauseInfo *newnode = makeNode(InClauseInfo);
1333 COPY_BITMAPSET_FIELD(lefthand);
1334 COPY_BITMAPSET_FIELD(righthand);
1335 COPY_NODE_FIELD(sub_targetlist);
1341 * _copyAppendRelInfo
1343 static AppendRelInfo *
1344 _copyAppendRelInfo(AppendRelInfo *from)
1346 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1348 COPY_SCALAR_FIELD(parent_relid);
1349 COPY_SCALAR_FIELD(child_relid);
1350 COPY_SCALAR_FIELD(parent_reltype);
1351 COPY_SCALAR_FIELD(child_reltype);
1352 COPY_NODE_FIELD(col_mappings);
1353 COPY_NODE_FIELD(translated_vars);
1354 COPY_SCALAR_FIELD(parent_reloid);
1359 /* ****************************************************************
1360 * parsenodes.h copy functions
1361 * ****************************************************************
1364 static RangeTblEntry *
1365 _copyRangeTblEntry(RangeTblEntry *from)
1367 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1369 COPY_SCALAR_FIELD(rtekind);
1370 COPY_SCALAR_FIELD(relid);
1371 COPY_NODE_FIELD(subquery);
1372 COPY_NODE_FIELD(funcexpr);
1373 COPY_NODE_FIELD(funccoltypes);
1374 COPY_NODE_FIELD(funccoltypmods);
1375 COPY_NODE_FIELD(values_lists);
1376 COPY_SCALAR_FIELD(jointype);
1377 COPY_NODE_FIELD(joinaliasvars);
1378 COPY_NODE_FIELD(alias);
1379 COPY_NODE_FIELD(eref);
1380 COPY_SCALAR_FIELD(inh);
1381 COPY_SCALAR_FIELD(inFromCl);
1382 COPY_SCALAR_FIELD(requiredPerms);
1383 COPY_SCALAR_FIELD(checkAsUser);
1388 static FkConstraint *
1389 _copyFkConstraint(FkConstraint *from)
1391 FkConstraint *newnode = makeNode(FkConstraint);
1393 COPY_STRING_FIELD(constr_name);
1394 COPY_NODE_FIELD(pktable);
1395 COPY_NODE_FIELD(fk_attrs);
1396 COPY_NODE_FIELD(pk_attrs);
1397 COPY_SCALAR_FIELD(fk_matchtype);
1398 COPY_SCALAR_FIELD(fk_upd_action);
1399 COPY_SCALAR_FIELD(fk_del_action);
1400 COPY_SCALAR_FIELD(deferrable);
1401 COPY_SCALAR_FIELD(initdeferred);
1402 COPY_SCALAR_FIELD(skip_validation);
1408 _copySortClause(SortClause *from)
1410 SortClause *newnode = makeNode(SortClause);
1412 COPY_SCALAR_FIELD(tleSortGroupRef);
1413 COPY_SCALAR_FIELD(sortop);
1418 static GroupClause *
1419 _copyGroupClause(GroupClause *from)
1421 GroupClause *newnode = makeNode(GroupClause);
1423 COPY_SCALAR_FIELD(tleSortGroupRef);
1424 COPY_SCALAR_FIELD(sortop);
1429 static RowMarkClause *
1430 _copyRowMarkClause(RowMarkClause *from)
1432 RowMarkClause *newnode = makeNode(RowMarkClause);
1434 COPY_SCALAR_FIELD(rti);
1435 COPY_SCALAR_FIELD(forUpdate);
1436 COPY_SCALAR_FIELD(noWait);
1442 _copyAExpr(A_Expr *from)
1444 A_Expr *newnode = makeNode(A_Expr);
1446 COPY_SCALAR_FIELD(kind);
1447 COPY_NODE_FIELD(name);
1448 COPY_NODE_FIELD(lexpr);
1449 COPY_NODE_FIELD(rexpr);
1450 COPY_SCALAR_FIELD(location);
1456 _copyColumnRef(ColumnRef *from)
1458 ColumnRef *newnode = makeNode(ColumnRef);
1460 COPY_NODE_FIELD(fields);
1461 COPY_SCALAR_FIELD(location);
1467 _copyParamRef(ParamRef *from)
1469 ParamRef *newnode = makeNode(ParamRef);
1471 COPY_SCALAR_FIELD(number);
1477 _copyAConst(A_Const *from)
1479 A_Const *newnode = makeNode(A_Const);
1481 /* This part must duplicate _copyValue */
1482 COPY_SCALAR_FIELD(val.type);
1483 switch (from->val.type)
1486 COPY_SCALAR_FIELD(val.val.ival);
1491 COPY_STRING_FIELD(val.val.str);
1497 elog(ERROR, "unrecognized node type: %d",
1498 (int) from->val.type);
1502 COPY_NODE_FIELD(typename);
1508 _copyFuncCall(FuncCall *from)
1510 FuncCall *newnode = makeNode(FuncCall);
1512 COPY_NODE_FIELD(funcname);
1513 COPY_NODE_FIELD(args);
1514 COPY_SCALAR_FIELD(agg_star);
1515 COPY_SCALAR_FIELD(agg_distinct);
1516 COPY_SCALAR_FIELD(location);
1522 _copyAIndices(A_Indices *from)
1524 A_Indices *newnode = makeNode(A_Indices);
1526 COPY_NODE_FIELD(lidx);
1527 COPY_NODE_FIELD(uidx);
1532 static A_Indirection *
1533 _copyA_Indirection(A_Indirection *from)
1535 A_Indirection *newnode = makeNode(A_Indirection);
1537 COPY_NODE_FIELD(arg);
1538 COPY_NODE_FIELD(indirection);
1544 _copyResTarget(ResTarget *from)
1546 ResTarget *newnode = makeNode(ResTarget);
1548 COPY_STRING_FIELD(name);
1549 COPY_NODE_FIELD(indirection);
1550 COPY_NODE_FIELD(val);
1551 COPY_SCALAR_FIELD(location);
1557 _copyTypeName(TypeName *from)
1559 TypeName *newnode = makeNode(TypeName);
1561 COPY_NODE_FIELD(names);
1562 COPY_SCALAR_FIELD(typeid);
1563 COPY_SCALAR_FIELD(timezone);
1564 COPY_SCALAR_FIELD(setof);
1565 COPY_SCALAR_FIELD(pct_type);
1566 COPY_SCALAR_FIELD(typmod);
1567 COPY_NODE_FIELD(arrayBounds);
1568 COPY_SCALAR_FIELD(location);
1574 _copySortBy(SortBy *from)
1576 SortBy *newnode = makeNode(SortBy);
1578 COPY_SCALAR_FIELD(sortby_kind);
1579 COPY_NODE_FIELD(useOp);
1580 COPY_NODE_FIELD(node);
1585 static RangeSubselect *
1586 _copyRangeSubselect(RangeSubselect *from)
1588 RangeSubselect *newnode = makeNode(RangeSubselect);
1590 COPY_NODE_FIELD(subquery);
1591 COPY_NODE_FIELD(alias);
1596 static RangeFunction *
1597 _copyRangeFunction(RangeFunction *from)
1599 RangeFunction *newnode = makeNode(RangeFunction);
1601 COPY_NODE_FIELD(funccallnode);
1602 COPY_NODE_FIELD(alias);
1603 COPY_NODE_FIELD(coldeflist);
1609 _copyTypeCast(TypeCast *from)
1611 TypeCast *newnode = makeNode(TypeCast);
1613 COPY_NODE_FIELD(arg);
1614 COPY_NODE_FIELD(typename);
1620 _copyIndexElem(IndexElem *from)
1622 IndexElem *newnode = makeNode(IndexElem);
1624 COPY_STRING_FIELD(name);
1625 COPY_NODE_FIELD(expr);
1626 COPY_NODE_FIELD(opclass);
1632 _copyColumnDef(ColumnDef *from)
1634 ColumnDef *newnode = makeNode(ColumnDef);
1636 COPY_STRING_FIELD(colname);
1637 COPY_NODE_FIELD(typename);
1638 COPY_SCALAR_FIELD(inhcount);
1639 COPY_SCALAR_FIELD(is_local);
1640 COPY_SCALAR_FIELD(is_not_null);
1641 COPY_NODE_FIELD(raw_default);
1642 COPY_STRING_FIELD(cooked_default);
1643 COPY_NODE_FIELD(constraints);
1649 _copyConstraint(Constraint *from)
1651 Constraint *newnode = makeNode(Constraint);
1653 COPY_SCALAR_FIELD(contype);
1654 COPY_STRING_FIELD(name);
1655 COPY_NODE_FIELD(raw_expr);
1656 COPY_STRING_FIELD(cooked_expr);
1657 COPY_NODE_FIELD(keys);
1658 COPY_NODE_FIELD(options);
1659 COPY_STRING_FIELD(indexspace);
1665 _copyDefElem(DefElem *from)
1667 DefElem *newnode = makeNode(DefElem);
1669 COPY_STRING_FIELD(defname);
1670 COPY_NODE_FIELD(arg);
1675 static LockingClause *
1676 _copyLockingClause(LockingClause *from)
1678 LockingClause *newnode = makeNode(LockingClause);
1680 COPY_NODE_FIELD(lockedRels);
1681 COPY_SCALAR_FIELD(forUpdate);
1682 COPY_SCALAR_FIELD(noWait);
1688 _copyQuery(Query *from)
1690 Query *newnode = makeNode(Query);
1692 COPY_SCALAR_FIELD(commandType);
1693 COPY_SCALAR_FIELD(querySource);
1694 COPY_SCALAR_FIELD(canSetTag);
1695 COPY_NODE_FIELD(utilityStmt);
1696 COPY_SCALAR_FIELD(resultRelation);
1697 COPY_NODE_FIELD(into);
1698 COPY_NODE_FIELD(intoOptions);
1699 COPY_SCALAR_FIELD(intoOnCommit);
1700 COPY_STRING_FIELD(intoTableSpaceName);
1701 COPY_SCALAR_FIELD(hasAggs);
1702 COPY_SCALAR_FIELD(hasSubLinks);
1703 COPY_NODE_FIELD(rtable);
1704 COPY_NODE_FIELD(jointree);
1705 COPY_NODE_FIELD(targetList);
1706 COPY_NODE_FIELD(returningList);
1707 COPY_NODE_FIELD(groupClause);
1708 COPY_NODE_FIELD(havingQual);
1709 COPY_NODE_FIELD(distinctClause);
1710 COPY_NODE_FIELD(sortClause);
1711 COPY_NODE_FIELD(limitOffset);
1712 COPY_NODE_FIELD(limitCount);
1713 COPY_NODE_FIELD(rowMarks);
1714 COPY_NODE_FIELD(setOperations);
1715 COPY_NODE_FIELD(resultRelations);
1716 COPY_NODE_FIELD(returningLists);
1722 _copyInsertStmt(InsertStmt *from)
1724 InsertStmt *newnode = makeNode(InsertStmt);
1726 COPY_NODE_FIELD(relation);
1727 COPY_NODE_FIELD(cols);
1728 COPY_NODE_FIELD(selectStmt);
1729 COPY_NODE_FIELD(returningList);
1735 _copyDeleteStmt(DeleteStmt *from)
1737 DeleteStmt *newnode = makeNode(DeleteStmt);
1739 COPY_NODE_FIELD(relation);
1740 COPY_NODE_FIELD(usingClause);
1741 COPY_NODE_FIELD(whereClause);
1742 COPY_NODE_FIELD(returningList);
1748 _copyUpdateStmt(UpdateStmt *from)
1750 UpdateStmt *newnode = makeNode(UpdateStmt);
1752 COPY_NODE_FIELD(relation);
1753 COPY_NODE_FIELD(targetList);
1754 COPY_NODE_FIELD(whereClause);
1755 COPY_NODE_FIELD(fromClause);
1756 COPY_NODE_FIELD(returningList);
1762 _copySelectStmt(SelectStmt *from)
1764 SelectStmt *newnode = makeNode(SelectStmt);
1766 COPY_NODE_FIELD(distinctClause);
1767 COPY_NODE_FIELD(into);
1768 COPY_NODE_FIELD(intoColNames);
1769 COPY_NODE_FIELD(intoOptions);
1770 COPY_SCALAR_FIELD(intoOnCommit);
1771 COPY_STRING_FIELD(intoTableSpaceName);
1772 COPY_NODE_FIELD(targetList);
1773 COPY_NODE_FIELD(fromClause);
1774 COPY_NODE_FIELD(whereClause);
1775 COPY_NODE_FIELD(groupClause);
1776 COPY_NODE_FIELD(havingClause);
1777 COPY_NODE_FIELD(valuesLists);
1778 COPY_NODE_FIELD(sortClause);
1779 COPY_NODE_FIELD(limitOffset);
1780 COPY_NODE_FIELD(limitCount);
1781 COPY_NODE_FIELD(lockingClause);
1782 COPY_SCALAR_FIELD(op);
1783 COPY_SCALAR_FIELD(all);
1784 COPY_NODE_FIELD(larg);
1785 COPY_NODE_FIELD(rarg);
1790 static SetOperationStmt *
1791 _copySetOperationStmt(SetOperationStmt *from)
1793 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1795 COPY_SCALAR_FIELD(op);
1796 COPY_SCALAR_FIELD(all);
1797 COPY_NODE_FIELD(larg);
1798 COPY_NODE_FIELD(rarg);
1799 COPY_NODE_FIELD(colTypes);
1800 COPY_NODE_FIELD(colTypmods);
1805 static AlterTableStmt *
1806 _copyAlterTableStmt(AlterTableStmt *from)
1808 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1810 COPY_NODE_FIELD(relation);
1811 COPY_NODE_FIELD(cmds);
1812 COPY_SCALAR_FIELD(relkind);
1817 static AlterTableCmd *
1818 _copyAlterTableCmd(AlterTableCmd *from)
1820 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1822 COPY_SCALAR_FIELD(subtype);
1823 COPY_STRING_FIELD(name);
1824 COPY_NODE_FIELD(parent);
1825 COPY_NODE_FIELD(def);
1826 COPY_NODE_FIELD(transform);
1827 COPY_SCALAR_FIELD(behavior);
1832 static AlterDomainStmt *
1833 _copyAlterDomainStmt(AlterDomainStmt *from)
1835 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1837 COPY_SCALAR_FIELD(subtype);
1838 COPY_NODE_FIELD(typename);
1839 COPY_STRING_FIELD(name);
1840 COPY_NODE_FIELD(def);
1841 COPY_SCALAR_FIELD(behavior);
1847 _copyGrantStmt(GrantStmt *from)
1849 GrantStmt *newnode = makeNode(GrantStmt);
1851 COPY_SCALAR_FIELD(is_grant);
1852 COPY_SCALAR_FIELD(objtype);
1853 COPY_NODE_FIELD(objects);
1854 COPY_NODE_FIELD(privileges);
1855 COPY_NODE_FIELD(grantees);
1856 COPY_SCALAR_FIELD(grant_option);
1857 COPY_SCALAR_FIELD(behavior);
1862 static PrivGrantee *
1863 _copyPrivGrantee(PrivGrantee *from)
1865 PrivGrantee *newnode = makeNode(PrivGrantee);
1867 COPY_STRING_FIELD(rolname);
1872 static FuncWithArgs *
1873 _copyFuncWithArgs(FuncWithArgs *from)
1875 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1877 COPY_NODE_FIELD(funcname);
1878 COPY_NODE_FIELD(funcargs);
1883 static GrantRoleStmt *
1884 _copyGrantRoleStmt(GrantRoleStmt *from)
1886 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
1888 COPY_NODE_FIELD(granted_roles);
1889 COPY_NODE_FIELD(grantee_roles);
1890 COPY_SCALAR_FIELD(is_grant);
1891 COPY_SCALAR_FIELD(admin_opt);
1892 COPY_STRING_FIELD(grantor);
1893 COPY_SCALAR_FIELD(behavior);
1898 static DeclareCursorStmt *
1899 _copyDeclareCursorStmt(DeclareCursorStmt *from)
1901 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
1903 COPY_STRING_FIELD(portalname);
1904 COPY_SCALAR_FIELD(options);
1905 COPY_NODE_FIELD(query);
1910 static ClosePortalStmt *
1911 _copyClosePortalStmt(ClosePortalStmt *from)
1913 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
1915 COPY_STRING_FIELD(portalname);
1920 static ClusterStmt *
1921 _copyClusterStmt(ClusterStmt *from)
1923 ClusterStmt *newnode = makeNode(ClusterStmt);
1925 COPY_NODE_FIELD(relation);
1926 COPY_STRING_FIELD(indexname);
1932 _copyCopyStmt(CopyStmt *from)
1934 CopyStmt *newnode = makeNode(CopyStmt);
1936 COPY_NODE_FIELD(relation);
1937 COPY_NODE_FIELD(attlist);
1938 COPY_SCALAR_FIELD(is_from);
1939 COPY_STRING_FIELD(filename);
1940 COPY_NODE_FIELD(options);
1946 _copyCreateStmt(CreateStmt *from)
1948 CreateStmt *newnode = makeNode(CreateStmt);
1950 COPY_NODE_FIELD(relation);
1951 COPY_NODE_FIELD(tableElts);
1952 COPY_NODE_FIELD(inhRelations);
1953 COPY_NODE_FIELD(constraints);
1954 COPY_NODE_FIELD(options);
1955 COPY_SCALAR_FIELD(oncommit);
1956 COPY_STRING_FIELD(tablespacename);
1961 static InhRelation *
1962 _copyInhRelation(InhRelation *from)
1964 InhRelation *newnode = makeNode(InhRelation);
1966 COPY_NODE_FIELD(relation);
1967 COPY_NODE_FIELD(options);
1973 _copyDefineStmt(DefineStmt *from)
1975 DefineStmt *newnode = makeNode(DefineStmt);
1977 COPY_SCALAR_FIELD(kind);
1978 COPY_SCALAR_FIELD(oldstyle);
1979 COPY_NODE_FIELD(defnames);
1980 COPY_NODE_FIELD(args);
1981 COPY_NODE_FIELD(definition);
1987 _copyDropStmt(DropStmt *from)
1989 DropStmt *newnode = makeNode(DropStmt);
1991 COPY_NODE_FIELD(objects);
1992 COPY_SCALAR_FIELD(removeType);
1993 COPY_SCALAR_FIELD(behavior);
1994 COPY_SCALAR_FIELD(missing_ok);
1999 static TruncateStmt *
2000 _copyTruncateStmt(TruncateStmt *from)
2002 TruncateStmt *newnode = makeNode(TruncateStmt);
2004 COPY_NODE_FIELD(relations);
2005 COPY_SCALAR_FIELD(behavior);
2010 static CommentStmt *
2011 _copyCommentStmt(CommentStmt *from)
2013 CommentStmt *newnode = makeNode(CommentStmt);
2015 COPY_SCALAR_FIELD(objtype);
2016 COPY_NODE_FIELD(objname);
2017 COPY_NODE_FIELD(objargs);
2018 COPY_STRING_FIELD(comment);
2024 _copyFetchStmt(FetchStmt *from)
2026 FetchStmt *newnode = makeNode(FetchStmt);
2028 COPY_SCALAR_FIELD(direction);
2029 COPY_SCALAR_FIELD(howMany);
2030 COPY_STRING_FIELD(portalname);
2031 COPY_SCALAR_FIELD(ismove);
2037 _copyIndexStmt(IndexStmt *from)
2039 IndexStmt *newnode = makeNode(IndexStmt);
2041 COPY_STRING_FIELD(idxname);
2042 COPY_NODE_FIELD(relation);
2043 COPY_STRING_FIELD(accessMethod);
2044 COPY_STRING_FIELD(tableSpace);
2045 COPY_NODE_FIELD(indexParams);
2046 COPY_NODE_FIELD(options);
2047 COPY_NODE_FIELD(whereClause);
2048 COPY_NODE_FIELD(rangetable);
2049 COPY_SCALAR_FIELD(unique);
2050 COPY_SCALAR_FIELD(primary);
2051 COPY_SCALAR_FIELD(isconstraint);
2056 static CreateFunctionStmt *
2057 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2059 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2061 COPY_SCALAR_FIELD(replace);
2062 COPY_NODE_FIELD(funcname);
2063 COPY_NODE_FIELD(parameters);
2064 COPY_NODE_FIELD(returnType);
2065 COPY_NODE_FIELD(options);
2066 COPY_NODE_FIELD(withClause);
2071 static FunctionParameter *
2072 _copyFunctionParameter(FunctionParameter *from)
2074 FunctionParameter *newnode = makeNode(FunctionParameter);
2076 COPY_STRING_FIELD(name);
2077 COPY_NODE_FIELD(argType);
2078 COPY_SCALAR_FIELD(mode);
2083 static AlterFunctionStmt *
2084 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2086 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2088 COPY_NODE_FIELD(func);
2089 COPY_NODE_FIELD(actions);
2094 static RemoveFuncStmt *
2095 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2097 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2099 COPY_SCALAR_FIELD(kind);
2100 COPY_NODE_FIELD(name);
2101 COPY_NODE_FIELD(args);
2102 COPY_SCALAR_FIELD(behavior);
2103 COPY_SCALAR_FIELD(missing_ok);
2108 static RemoveOpClassStmt *
2109 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2111 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2113 COPY_NODE_FIELD(opclassname);
2114 COPY_STRING_FIELD(amname);
2115 COPY_SCALAR_FIELD(behavior);
2116 COPY_SCALAR_FIELD(missing_ok);
2122 _copyRenameStmt(RenameStmt *from)
2124 RenameStmt *newnode = makeNode(RenameStmt);
2126 COPY_SCALAR_FIELD(renameType);
2127 COPY_NODE_FIELD(relation);
2128 COPY_NODE_FIELD(object);
2129 COPY_NODE_FIELD(objarg);
2130 COPY_STRING_FIELD(subname);
2131 COPY_STRING_FIELD(newname);
2136 static AlterObjectSchemaStmt *
2137 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2139 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
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(newschema);
2151 static AlterOwnerStmt *
2152 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2154 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2156 COPY_SCALAR_FIELD(objectType);
2157 COPY_NODE_FIELD(relation);
2158 COPY_NODE_FIELD(object);
2159 COPY_NODE_FIELD(objarg);
2160 COPY_STRING_FIELD(addname);
2161 COPY_STRING_FIELD(newowner);
2167 _copyRuleStmt(RuleStmt *from)
2169 RuleStmt *newnode = makeNode(RuleStmt);
2171 COPY_NODE_FIELD(relation);
2172 COPY_STRING_FIELD(rulename);
2173 COPY_NODE_FIELD(whereClause);
2174 COPY_SCALAR_FIELD(event);
2175 COPY_SCALAR_FIELD(instead);
2176 COPY_NODE_FIELD(actions);
2177 COPY_SCALAR_FIELD(replace);
2183 _copyNotifyStmt(NotifyStmt *from)
2185 NotifyStmt *newnode = makeNode(NotifyStmt);
2187 COPY_NODE_FIELD(relation);
2193 _copyListenStmt(ListenStmt *from)
2195 ListenStmt *newnode = makeNode(ListenStmt);
2197 COPY_NODE_FIELD(relation);
2202 static UnlistenStmt *
2203 _copyUnlistenStmt(UnlistenStmt *from)
2205 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2207 COPY_NODE_FIELD(relation);
2212 static TransactionStmt *
2213 _copyTransactionStmt(TransactionStmt *from)
2215 TransactionStmt *newnode = makeNode(TransactionStmt);
2217 COPY_SCALAR_FIELD(kind);
2218 COPY_NODE_FIELD(options);
2219 COPY_STRING_FIELD(gid);
2224 static CompositeTypeStmt *
2225 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2227 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2229 COPY_NODE_FIELD(typevar);
2230 COPY_NODE_FIELD(coldeflist);
2236 _copyViewStmt(ViewStmt *from)
2238 ViewStmt *newnode = makeNode(ViewStmt);
2240 COPY_NODE_FIELD(view);
2241 COPY_NODE_FIELD(aliases);
2242 COPY_NODE_FIELD(query);
2243 COPY_SCALAR_FIELD(replace);
2249 _copyLoadStmt(LoadStmt *from)
2251 LoadStmt *newnode = makeNode(LoadStmt);
2253 COPY_STRING_FIELD(filename);
2258 static CreateDomainStmt *
2259 _copyCreateDomainStmt(CreateDomainStmt *from)
2261 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2263 COPY_NODE_FIELD(domainname);
2264 COPY_NODE_FIELD(typename);
2265 COPY_NODE_FIELD(constraints);
2270 static CreateOpClassStmt *
2271 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2273 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2275 COPY_NODE_FIELD(opclassname);
2276 COPY_STRING_FIELD(amname);
2277 COPY_NODE_FIELD(datatype);
2278 COPY_NODE_FIELD(items);
2279 COPY_SCALAR_FIELD(isDefault);
2284 static CreateOpClassItem *
2285 _copyCreateOpClassItem(CreateOpClassItem *from)
2287 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2289 COPY_SCALAR_FIELD(itemtype);
2290 COPY_NODE_FIELD(name);
2291 COPY_NODE_FIELD(args);
2292 COPY_SCALAR_FIELD(number);
2293 COPY_SCALAR_FIELD(recheck);
2294 COPY_NODE_FIELD(storedtype);
2299 static CreatedbStmt *
2300 _copyCreatedbStmt(CreatedbStmt *from)
2302 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2304 COPY_STRING_FIELD(dbname);
2305 COPY_NODE_FIELD(options);
2310 static AlterDatabaseStmt *
2311 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2313 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2315 COPY_STRING_FIELD(dbname);
2316 COPY_NODE_FIELD(options);
2321 static AlterDatabaseSetStmt *
2322 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2324 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2326 COPY_STRING_FIELD(dbname);
2327 COPY_STRING_FIELD(variable);
2328 COPY_NODE_FIELD(value);
2334 _copyDropdbStmt(DropdbStmt *from)
2336 DropdbStmt *newnode = makeNode(DropdbStmt);
2338 COPY_STRING_FIELD(dbname);
2339 COPY_SCALAR_FIELD(missing_ok);
2345 _copyVacuumStmt(VacuumStmt *from)
2347 VacuumStmt *newnode = makeNode(VacuumStmt);
2349 COPY_SCALAR_FIELD(vacuum);
2350 COPY_SCALAR_FIELD(full);
2351 COPY_SCALAR_FIELD(analyze);
2352 COPY_SCALAR_FIELD(freeze);
2353 COPY_SCALAR_FIELD(verbose);
2354 COPY_NODE_FIELD(relation);
2355 COPY_NODE_FIELD(va_cols);
2360 static ExplainStmt *
2361 _copyExplainStmt(ExplainStmt *from)
2363 ExplainStmt *newnode = makeNode(ExplainStmt);
2365 COPY_NODE_FIELD(query);
2366 COPY_SCALAR_FIELD(verbose);
2367 COPY_SCALAR_FIELD(analyze);
2372 static CreateSeqStmt *
2373 _copyCreateSeqStmt(CreateSeqStmt *from)
2375 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2377 COPY_NODE_FIELD(sequence);
2378 COPY_NODE_FIELD(options);
2383 static AlterSeqStmt *
2384 _copyAlterSeqStmt(AlterSeqStmt *from)
2386 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2388 COPY_NODE_FIELD(sequence);
2389 COPY_NODE_FIELD(options);
2394 static VariableSetStmt *
2395 _copyVariableSetStmt(VariableSetStmt *from)
2397 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2399 COPY_STRING_FIELD(name);
2400 COPY_NODE_FIELD(args);
2401 COPY_SCALAR_FIELD(is_local);
2406 static VariableShowStmt *
2407 _copyVariableShowStmt(VariableShowStmt *from)
2409 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2411 COPY_STRING_FIELD(name);
2416 static VariableResetStmt *
2417 _copyVariableResetStmt(VariableResetStmt *from)
2419 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2421 COPY_STRING_FIELD(name);
2426 static CreateTableSpaceStmt *
2427 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2429 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2431 COPY_STRING_FIELD(tablespacename);
2432 COPY_STRING_FIELD(owner);
2433 COPY_STRING_FIELD(location);
2438 static DropTableSpaceStmt *
2439 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2441 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2443 COPY_STRING_FIELD(tablespacename);
2444 COPY_SCALAR_FIELD(missing_ok);
2449 static CreateTrigStmt *
2450 _copyCreateTrigStmt(CreateTrigStmt *from)
2452 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2454 COPY_STRING_FIELD(trigname);
2455 COPY_NODE_FIELD(relation);
2456 COPY_NODE_FIELD(funcname);
2457 COPY_NODE_FIELD(args);
2458 COPY_SCALAR_FIELD(before);
2459 COPY_SCALAR_FIELD(row);
2460 strcpy(newnode->actions, from->actions); /* in-line string field */
2461 COPY_SCALAR_FIELD(isconstraint);
2462 COPY_SCALAR_FIELD(deferrable);
2463 COPY_SCALAR_FIELD(initdeferred);
2464 COPY_NODE_FIELD(constrrel);
2469 static DropPropertyStmt *
2470 _copyDropPropertyStmt(DropPropertyStmt *from)
2472 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2474 COPY_NODE_FIELD(relation);
2475 COPY_STRING_FIELD(property);
2476 COPY_SCALAR_FIELD(removeType);
2477 COPY_SCALAR_FIELD(behavior);
2478 COPY_SCALAR_FIELD(missing_ok);
2483 static CreatePLangStmt *
2484 _copyCreatePLangStmt(CreatePLangStmt *from)
2486 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2488 COPY_STRING_FIELD(plname);
2489 COPY_NODE_FIELD(plhandler);
2490 COPY_NODE_FIELD(plvalidator);
2491 COPY_SCALAR_FIELD(pltrusted);
2496 static DropPLangStmt *
2497 _copyDropPLangStmt(DropPLangStmt *from)
2499 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2501 COPY_STRING_FIELD(plname);
2502 COPY_SCALAR_FIELD(behavior);
2503 COPY_SCALAR_FIELD(missing_ok);
2508 static CreateRoleStmt *
2509 _copyCreateRoleStmt(CreateRoleStmt *from)
2511 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2513 COPY_SCALAR_FIELD(stmt_type);
2514 COPY_STRING_FIELD(role);
2515 COPY_NODE_FIELD(options);
2520 static AlterRoleStmt *
2521 _copyAlterRoleStmt(AlterRoleStmt *from)
2523 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2525 COPY_STRING_FIELD(role);
2526 COPY_NODE_FIELD(options);
2527 COPY_SCALAR_FIELD(action);
2532 static AlterRoleSetStmt *
2533 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2535 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2537 COPY_STRING_FIELD(role);
2538 COPY_STRING_FIELD(variable);
2539 COPY_NODE_FIELD(value);
2544 static DropRoleStmt *
2545 _copyDropRoleStmt(DropRoleStmt *from)
2547 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2549 COPY_NODE_FIELD(roles);
2550 COPY_SCALAR_FIELD(missing_ok);
2556 _copyLockStmt(LockStmt *from)
2558 LockStmt *newnode = makeNode(LockStmt);
2560 COPY_NODE_FIELD(relations);
2561 COPY_SCALAR_FIELD(mode);
2562 COPY_SCALAR_FIELD(nowait);
2567 static ConstraintsSetStmt *
2568 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2570 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2572 COPY_NODE_FIELD(constraints);
2573 COPY_SCALAR_FIELD(deferred);
2578 static ReindexStmt *
2579 _copyReindexStmt(ReindexStmt *from)
2581 ReindexStmt *newnode = makeNode(ReindexStmt);
2583 COPY_SCALAR_FIELD(kind);
2584 COPY_NODE_FIELD(relation);
2585 COPY_STRING_FIELD(name);
2586 COPY_SCALAR_FIELD(do_system);
2587 COPY_SCALAR_FIELD(do_user);
2592 static CreateSchemaStmt *
2593 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2595 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2597 COPY_STRING_FIELD(schemaname);
2598 COPY_STRING_FIELD(authid);
2599 COPY_NODE_FIELD(schemaElts);
2604 static CreateConversionStmt *
2605 _copyCreateConversionStmt(CreateConversionStmt *from)
2607 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2609 COPY_NODE_FIELD(conversion_name);
2610 COPY_STRING_FIELD(for_encoding_name);
2611 COPY_STRING_FIELD(to_encoding_name);
2612 COPY_NODE_FIELD(func_name);
2613 COPY_SCALAR_FIELD(def);
2618 static CreateCastStmt *
2619 _copyCreateCastStmt(CreateCastStmt *from)
2621 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2623 COPY_NODE_FIELD(sourcetype);
2624 COPY_NODE_FIELD(targettype);
2625 COPY_NODE_FIELD(func);
2626 COPY_SCALAR_FIELD(context);
2631 static DropCastStmt *
2632 _copyDropCastStmt(DropCastStmt *from)
2634 DropCastStmt *newnode = makeNode(DropCastStmt);
2636 COPY_NODE_FIELD(sourcetype);
2637 COPY_NODE_FIELD(targettype);
2638 COPY_SCALAR_FIELD(behavior);
2639 COPY_SCALAR_FIELD(missing_ok);
2644 static PrepareStmt *
2645 _copyPrepareStmt(PrepareStmt *from)
2647 PrepareStmt *newnode = makeNode(PrepareStmt);
2649 COPY_STRING_FIELD(name);
2650 COPY_NODE_FIELD(argtypes);
2651 COPY_NODE_FIELD(argtype_oids);
2652 COPY_NODE_FIELD(query);
2657 static ExecuteStmt *
2658 _copyExecuteStmt(ExecuteStmt *from)
2660 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2662 COPY_STRING_FIELD(name);
2663 COPY_NODE_FIELD(into);
2664 COPY_NODE_FIELD(intoOptions);
2665 COPY_SCALAR_FIELD(into_on_commit);
2666 COPY_STRING_FIELD(into_tbl_space);
2667 COPY_NODE_FIELD(params);
2672 static DeallocateStmt *
2673 _copyDeallocateStmt(DeallocateStmt *from)
2675 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2677 COPY_STRING_FIELD(name);
2682 static DropOwnedStmt *
2683 _copyDropOwnedStmt(DropOwnedStmt * from)
2685 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2687 COPY_NODE_FIELD(roles);
2688 COPY_SCALAR_FIELD(behavior);
2693 static ReassignOwnedStmt *
2694 _copyReassignOwnedStmt(ReassignOwnedStmt * from)
2696 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2698 COPY_NODE_FIELD(roles);
2699 COPY_SCALAR_FIELD(newrole);
2704 /* ****************************************************************
2705 * pg_list.h copy functions
2706 * ****************************************************************
2710 * Perform a deep copy of the specified list, using copyObject(). The
2711 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2712 * need deep copies, so they should be copied via list_copy()
2714 #define COPY_NODE_CELL(new, old) \
2715 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2716 lfirst(new) = copyObject(lfirst(old));
2719 _copyList(List *from)
2725 Assert(list_length(from) >= 1);
2727 new = makeNode(List);
2728 new->length = from->length;
2730 COPY_NODE_CELL(new->head, from->head);
2731 prev_new = new->head;
2732 curr_old = lnext(from->head);
2736 COPY_NODE_CELL(prev_new->next, curr_old);
2737 prev_new = prev_new->next;
2738 curr_old = curr_old->next;
2740 prev_new->next = NULL;
2741 new->tail = prev_new;
2746 /* ****************************************************************
2747 * value.h copy functions
2748 * ****************************************************************
2751 _copyValue(Value *from)
2753 Value *newnode = makeNode(Value);
2755 /* See also _copyAConst when changing this code! */
2757 COPY_SCALAR_FIELD(type);
2761 COPY_SCALAR_FIELD(val.ival);
2766 COPY_STRING_FIELD(val.str);
2772 elog(ERROR, "unrecognized node type: %d",
2782 * Create a copy of a Node tree or list. This is a "deep" copy: all
2783 * substructure is copied too, recursively.
2786 copyObject(void *from)
2793 switch (nodeTag(from))
2799 retval = _copyPlan(from);
2802 retval = _copyResult(from);
2805 retval = _copyAppend(from);
2808 retval = _copyBitmapAnd(from);
2811 retval = _copyBitmapOr(from);
2814 retval = _copyScan(from);
2817 retval = _copySeqScan(from);
2820 retval = _copyIndexScan(from);
2822 case T_BitmapIndexScan:
2823 retval = _copyBitmapIndexScan(from);
2825 case T_BitmapHeapScan:
2826 retval = _copyBitmapHeapScan(from);
2829 retval = _copyTidScan(from);
2831 case T_SubqueryScan:
2832 retval = _copySubqueryScan(from);
2834 case T_FunctionScan:
2835 retval = _copyFunctionScan(from);
2838 retval = _copyValuesScan(from);
2841 retval = _copyJoin(from);
2844 retval = _copyNestLoop(from);
2847 retval = _copyMergeJoin(from);
2850 retval = _copyHashJoin(from);
2853 retval = _copyMaterial(from);
2856 retval = _copySort(from);
2859 retval = _copyGroup(from);
2862 retval = _copyAgg(from);
2865 retval = _copyUnique(from);
2868 retval = _copyHash(from);
2871 retval = _copySetOp(from);
2874 retval = _copyLimit(from);
2881 retval = _copyAlias(from);
2884 retval = _copyRangeVar(from);
2887 retval = _copyVar(from);
2890 retval = _copyConst(from);
2893 retval = _copyParam(from);
2896 retval = _copyAggref(from);
2899 retval = _copyArrayRef(from);
2902 retval = _copyFuncExpr(from);
2905 retval = _copyOpExpr(from);
2907 case T_DistinctExpr:
2908 retval = _copyDistinctExpr(from);
2910 case T_ScalarArrayOpExpr:
2911 retval = _copyScalarArrayOpExpr(from);
2914 retval = _copyBoolExpr(from);
2917 retval = _copySubLink(from);
2920 retval = _copySubPlan(from);
2923 retval = _copyFieldSelect(from);
2926 retval = _copyFieldStore(from);
2929 retval = _copyRelabelType(from);
2931 case T_ConvertRowtypeExpr:
2932 retval = _copyConvertRowtypeExpr(from);
2935 retval = _copyCaseExpr(from);
2938 retval = _copyCaseWhen(from);
2940 case T_CaseTestExpr:
2941 retval = _copyCaseTestExpr(from);
2944 retval = _copyArrayExpr(from);
2947 retval = _copyRowExpr(from);
2949 case T_RowCompareExpr:
2950 retval = _copyRowCompareExpr(from);
2952 case T_CoalesceExpr:
2953 retval = _copyCoalesceExpr(from);
2956 retval = _copyMinMaxExpr(from);
2959 retval = _copyNullIfExpr(from);
2962 retval = _copyNullTest(from);
2965 retval = _copyBooleanTest(from);
2967 case T_CoerceToDomain:
2968 retval = _copyCoerceToDomain(from);
2970 case T_CoerceToDomainValue:
2971 retval = _copyCoerceToDomainValue(from);
2973 case T_SetToDefault:
2974 retval = _copySetToDefault(from);
2977 retval = _copyTargetEntry(from);
2980 retval = _copyRangeTblRef(from);
2983 retval = _copyJoinExpr(from);
2986 retval = _copyFromExpr(from);
2993 retval = _copyPathKeyItem(from);
2995 case T_RestrictInfo:
2996 retval = _copyRestrictInfo(from);
2998 case T_OuterJoinInfo:
2999 retval = _copyOuterJoinInfo(from);
3001 case T_InClauseInfo:
3002 retval = _copyInClauseInfo(from);
3004 case T_AppendRelInfo:
3005 retval = _copyAppendRelInfo(from);
3016 retval = _copyValue(from);
3023 retval = _copyList(from);
3027 * Lists of integers and OIDs don't need to be deep-copied, so we
3028 * perform a shallow copy via list_copy()
3032 retval = list_copy(from);
3039 retval = _copyQuery(from);
3042 retval = _copyInsertStmt(from);
3045 retval = _copyDeleteStmt(from);
3048 retval = _copyUpdateStmt(from);
3051 retval = _copySelectStmt(from);
3053 case T_SetOperationStmt:
3054 retval = _copySetOperationStmt(from);
3056 case T_AlterTableStmt:
3057 retval = _copyAlterTableStmt(from);
3059 case T_AlterTableCmd:
3060 retval = _copyAlterTableCmd(from);
3062 case T_AlterDomainStmt:
3063 retval = _copyAlterDomainStmt(from);
3066 retval = _copyGrantStmt(from);
3068 case T_GrantRoleStmt:
3069 retval = _copyGrantRoleStmt(from);
3071 case T_DeclareCursorStmt:
3072 retval = _copyDeclareCursorStmt(from);
3074 case T_ClosePortalStmt:
3075 retval = _copyClosePortalStmt(from);
3078 retval = _copyClusterStmt(from);
3081 retval = _copyCopyStmt(from);
3084 retval = _copyCreateStmt(from);
3087 retval = _copyInhRelation(from);
3090 retval = _copyDefineStmt(from);
3093 retval = _copyDropStmt(from);
3095 case T_TruncateStmt:
3096 retval = _copyTruncateStmt(from);
3099 retval = _copyCommentStmt(from);
3102 retval = _copyFetchStmt(from);
3105 retval = _copyIndexStmt(from);
3107 case T_CreateFunctionStmt:
3108 retval = _copyCreateFunctionStmt(from);
3110 case T_FunctionParameter:
3111 retval = _copyFunctionParameter(from);
3113 case T_AlterFunctionStmt:
3114 retval = _copyAlterFunctionStmt(from);
3116 case T_RemoveFuncStmt:
3117 retval = _copyRemoveFuncStmt(from);
3119 case T_RemoveOpClassStmt:
3120 retval = _copyRemoveOpClassStmt(from);
3123 retval = _copyRenameStmt(from);
3125 case T_AlterObjectSchemaStmt:
3126 retval = _copyAlterObjectSchemaStmt(from);
3128 case T_AlterOwnerStmt:
3129 retval = _copyAlterOwnerStmt(from);
3132 retval = _copyRuleStmt(from);
3135 retval = _copyNotifyStmt(from);
3138 retval = _copyListenStmt(from);
3140 case T_UnlistenStmt:
3141 retval = _copyUnlistenStmt(from);
3143 case T_TransactionStmt:
3144 retval = _copyTransactionStmt(from);
3146 case T_CompositeTypeStmt:
3147 retval = _copyCompositeTypeStmt(from);
3150 retval = _copyViewStmt(from);
3153 retval = _copyLoadStmt(from);
3155 case T_CreateDomainStmt:
3156 retval = _copyCreateDomainStmt(from);
3158 case T_CreateOpClassStmt:
3159 retval = _copyCreateOpClassStmt(from);
3161 case T_CreateOpClassItem:
3162 retval = _copyCreateOpClassItem(from);
3164 case T_CreatedbStmt:
3165 retval = _copyCreatedbStmt(from);
3167 case T_AlterDatabaseStmt:
3168 retval = _copyAlterDatabaseStmt(from);
3170 case T_AlterDatabaseSetStmt:
3171 retval = _copyAlterDatabaseSetStmt(from);
3174 retval = _copyDropdbStmt(from);
3177 retval = _copyVacuumStmt(from);
3180 retval = _copyExplainStmt(from);
3182 case T_CreateSeqStmt:
3183 retval = _copyCreateSeqStmt(from);
3185 case T_AlterSeqStmt:
3186 retval = _copyAlterSeqStmt(from);
3188 case T_VariableSetStmt:
3189 retval = _copyVariableSetStmt(from);
3191 case T_VariableShowStmt:
3192 retval = _copyVariableShowStmt(from);
3194 case T_VariableResetStmt:
3195 retval = _copyVariableResetStmt(from);
3197 case T_CreateTableSpaceStmt:
3198 retval = _copyCreateTableSpaceStmt(from);
3200 case T_DropTableSpaceStmt:
3201 retval = _copyDropTableSpaceStmt(from);
3203 case T_CreateTrigStmt:
3204 retval = _copyCreateTrigStmt(from);
3206 case T_DropPropertyStmt:
3207 retval = _copyDropPropertyStmt(from);
3209 case T_CreatePLangStmt:
3210 retval = _copyCreatePLangStmt(from);
3212 case T_DropPLangStmt:
3213 retval = _copyDropPLangStmt(from);
3215 case T_CreateRoleStmt:
3216 retval = _copyCreateRoleStmt(from);
3218 case T_AlterRoleStmt:
3219 retval = _copyAlterRoleStmt(from);
3221 case T_AlterRoleSetStmt:
3222 retval = _copyAlterRoleSetStmt(from);
3224 case T_DropRoleStmt:
3225 retval = _copyDropRoleStmt(from);
3228 retval = _copyLockStmt(from);
3230 case T_ConstraintsSetStmt:
3231 retval = _copyConstraintsSetStmt(from);
3234 retval = _copyReindexStmt(from);
3236 case T_CheckPointStmt:
3237 retval = (void *) makeNode(CheckPointStmt);
3239 case T_CreateSchemaStmt:
3240 retval = _copyCreateSchemaStmt(from);
3242 case T_CreateConversionStmt:
3243 retval = _copyCreateConversionStmt(from);
3245 case T_CreateCastStmt:
3246 retval = _copyCreateCastStmt(from);
3248 case T_DropCastStmt:
3249 retval = _copyDropCastStmt(from);
3252 retval = _copyPrepareStmt(from);
3255 retval = _copyExecuteStmt(from);
3257 case T_DeallocateStmt:
3258 retval = _copyDeallocateStmt(from);
3260 case T_DropOwnedStmt:
3261 retval = _copyDropOwnedStmt(from);
3263 case T_ReassignOwnedStmt:
3264 retval = _copyReassignOwnedStmt(from);
3268 retval = _copyAExpr(from);
3271 retval = _copyColumnRef(from);
3274 retval = _copyParamRef(from);
3277 retval = _copyAConst(from);
3280 retval = _copyFuncCall(from);
3283 retval = _copyAIndices(from);
3285 case T_A_Indirection:
3286 retval = _copyA_Indirection(from);
3289 retval = _copyResTarget(from);
3292 retval = _copyTypeCast(from);
3295 retval = _copySortBy(from);
3297 case T_RangeSubselect:
3298 retval = _copyRangeSubselect(from);
3300 case T_RangeFunction:
3301 retval = _copyRangeFunction(from);
3304 retval = _copyTypeName(from);
3307 retval = _copyIndexElem(from);
3310 retval = _copyColumnDef(from);
3313 retval = _copyConstraint(from);
3316 retval = _copyDefElem(from);
3318 case T_LockingClause:
3319 retval = _copyLockingClause(from);
3321 case T_RangeTblEntry:
3322 retval = _copyRangeTblEntry(from);
3325 retval = _copySortClause(from);
3328 retval = _copyGroupClause(from);
3330 case T_RowMarkClause:
3331 retval = _copyRowMarkClause(from);
3333 case T_FkConstraint:
3334 retval = _copyFkConstraint(from);
3337 retval = _copyPrivGrantee(from);
3339 case T_FuncWithArgs:
3340 retval = _copyFuncWithArgs(from);
3344 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3345 retval = from; /* keep compiler quiet */