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.347 2006/08/12 02:52:04 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);
1644 COPY_NODE_FIELD(support);
1650 _copyConstraint(Constraint *from)
1652 Constraint *newnode = makeNode(Constraint);
1654 COPY_SCALAR_FIELD(contype);
1655 COPY_STRING_FIELD(name);
1656 COPY_NODE_FIELD(raw_expr);
1657 COPY_STRING_FIELD(cooked_expr);
1658 COPY_NODE_FIELD(keys);
1659 COPY_NODE_FIELD(options);
1660 COPY_STRING_FIELD(indexspace);
1666 _copyDefElem(DefElem *from)
1668 DefElem *newnode = makeNode(DefElem);
1670 COPY_STRING_FIELD(defname);
1671 COPY_NODE_FIELD(arg);
1676 static LockingClause *
1677 _copyLockingClause(LockingClause *from)
1679 LockingClause *newnode = makeNode(LockingClause);
1681 COPY_NODE_FIELD(lockedRels);
1682 COPY_SCALAR_FIELD(forUpdate);
1683 COPY_SCALAR_FIELD(noWait);
1689 _copyQuery(Query *from)
1691 Query *newnode = makeNode(Query);
1693 COPY_SCALAR_FIELD(commandType);
1694 COPY_SCALAR_FIELD(querySource);
1695 COPY_SCALAR_FIELD(canSetTag);
1696 COPY_NODE_FIELD(utilityStmt);
1697 COPY_SCALAR_FIELD(resultRelation);
1698 COPY_NODE_FIELD(into);
1699 COPY_NODE_FIELD(intoOptions);
1700 COPY_SCALAR_FIELD(intoOnCommit);
1701 COPY_STRING_FIELD(intoTableSpaceName);
1702 COPY_SCALAR_FIELD(hasAggs);
1703 COPY_SCALAR_FIELD(hasSubLinks);
1704 COPY_NODE_FIELD(rtable);
1705 COPY_NODE_FIELD(jointree);
1706 COPY_NODE_FIELD(targetList);
1707 COPY_NODE_FIELD(returningList);
1708 COPY_NODE_FIELD(groupClause);
1709 COPY_NODE_FIELD(havingQual);
1710 COPY_NODE_FIELD(distinctClause);
1711 COPY_NODE_FIELD(sortClause);
1712 COPY_NODE_FIELD(limitOffset);
1713 COPY_NODE_FIELD(limitCount);
1714 COPY_NODE_FIELD(rowMarks);
1715 COPY_NODE_FIELD(setOperations);
1716 COPY_NODE_FIELD(resultRelations);
1717 COPY_NODE_FIELD(returningLists);
1723 _copyInsertStmt(InsertStmt *from)
1725 InsertStmt *newnode = makeNode(InsertStmt);
1727 COPY_NODE_FIELD(relation);
1728 COPY_NODE_FIELD(cols);
1729 COPY_NODE_FIELD(selectStmt);
1730 COPY_NODE_FIELD(returningList);
1736 _copyDeleteStmt(DeleteStmt *from)
1738 DeleteStmt *newnode = makeNode(DeleteStmt);
1740 COPY_NODE_FIELD(relation);
1741 COPY_NODE_FIELD(usingClause);
1742 COPY_NODE_FIELD(whereClause);
1743 COPY_NODE_FIELD(returningList);
1749 _copyUpdateStmt(UpdateStmt *from)
1751 UpdateStmt *newnode = makeNode(UpdateStmt);
1753 COPY_NODE_FIELD(relation);
1754 COPY_NODE_FIELD(targetList);
1755 COPY_NODE_FIELD(whereClause);
1756 COPY_NODE_FIELD(fromClause);
1757 COPY_NODE_FIELD(returningList);
1763 _copySelectStmt(SelectStmt *from)
1765 SelectStmt *newnode = makeNode(SelectStmt);
1767 COPY_NODE_FIELD(distinctClause);
1768 COPY_NODE_FIELD(into);
1769 COPY_NODE_FIELD(intoColNames);
1770 COPY_NODE_FIELD(intoOptions);
1771 COPY_SCALAR_FIELD(intoOnCommit);
1772 COPY_STRING_FIELD(intoTableSpaceName);
1773 COPY_NODE_FIELD(targetList);
1774 COPY_NODE_FIELD(fromClause);
1775 COPY_NODE_FIELD(whereClause);
1776 COPY_NODE_FIELD(groupClause);
1777 COPY_NODE_FIELD(havingClause);
1778 COPY_NODE_FIELD(valuesLists);
1779 COPY_NODE_FIELD(sortClause);
1780 COPY_NODE_FIELD(limitOffset);
1781 COPY_NODE_FIELD(limitCount);
1782 COPY_NODE_FIELD(lockingClause);
1783 COPY_SCALAR_FIELD(op);
1784 COPY_SCALAR_FIELD(all);
1785 COPY_NODE_FIELD(larg);
1786 COPY_NODE_FIELD(rarg);
1791 static SetOperationStmt *
1792 _copySetOperationStmt(SetOperationStmt *from)
1794 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1796 COPY_SCALAR_FIELD(op);
1797 COPY_SCALAR_FIELD(all);
1798 COPY_NODE_FIELD(larg);
1799 COPY_NODE_FIELD(rarg);
1800 COPY_NODE_FIELD(colTypes);
1801 COPY_NODE_FIELD(colTypmods);
1806 static AlterTableStmt *
1807 _copyAlterTableStmt(AlterTableStmt *from)
1809 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1811 COPY_NODE_FIELD(relation);
1812 COPY_NODE_FIELD(cmds);
1813 COPY_SCALAR_FIELD(relkind);
1818 static AlterTableCmd *
1819 _copyAlterTableCmd(AlterTableCmd *from)
1821 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1823 COPY_SCALAR_FIELD(subtype);
1824 COPY_STRING_FIELD(name);
1825 COPY_NODE_FIELD(parent);
1826 COPY_NODE_FIELD(def);
1827 COPY_NODE_FIELD(transform);
1828 COPY_SCALAR_FIELD(behavior);
1833 static AlterDomainStmt *
1834 _copyAlterDomainStmt(AlterDomainStmt *from)
1836 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1838 COPY_SCALAR_FIELD(subtype);
1839 COPY_NODE_FIELD(typename);
1840 COPY_STRING_FIELD(name);
1841 COPY_NODE_FIELD(def);
1842 COPY_SCALAR_FIELD(behavior);
1848 _copyGrantStmt(GrantStmt *from)
1850 GrantStmt *newnode = makeNode(GrantStmt);
1852 COPY_SCALAR_FIELD(is_grant);
1853 COPY_SCALAR_FIELD(objtype);
1854 COPY_NODE_FIELD(objects);
1855 COPY_NODE_FIELD(privileges);
1856 COPY_NODE_FIELD(grantees);
1857 COPY_SCALAR_FIELD(grant_option);
1858 COPY_SCALAR_FIELD(behavior);
1863 static PrivGrantee *
1864 _copyPrivGrantee(PrivGrantee *from)
1866 PrivGrantee *newnode = makeNode(PrivGrantee);
1868 COPY_STRING_FIELD(rolname);
1873 static FuncWithArgs *
1874 _copyFuncWithArgs(FuncWithArgs *from)
1876 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1878 COPY_NODE_FIELD(funcname);
1879 COPY_NODE_FIELD(funcargs);
1884 static GrantRoleStmt *
1885 _copyGrantRoleStmt(GrantRoleStmt *from)
1887 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
1889 COPY_NODE_FIELD(granted_roles);
1890 COPY_NODE_FIELD(grantee_roles);
1891 COPY_SCALAR_FIELD(is_grant);
1892 COPY_SCALAR_FIELD(admin_opt);
1893 COPY_STRING_FIELD(grantor);
1894 COPY_SCALAR_FIELD(behavior);
1899 static DeclareCursorStmt *
1900 _copyDeclareCursorStmt(DeclareCursorStmt *from)
1902 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
1904 COPY_STRING_FIELD(portalname);
1905 COPY_SCALAR_FIELD(options);
1906 COPY_NODE_FIELD(query);
1911 static ClosePortalStmt *
1912 _copyClosePortalStmt(ClosePortalStmt *from)
1914 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
1916 COPY_STRING_FIELD(portalname);
1921 static ClusterStmt *
1922 _copyClusterStmt(ClusterStmt *from)
1924 ClusterStmt *newnode = makeNode(ClusterStmt);
1926 COPY_NODE_FIELD(relation);
1927 COPY_STRING_FIELD(indexname);
1933 _copyCopyStmt(CopyStmt *from)
1935 CopyStmt *newnode = makeNode(CopyStmt);
1937 COPY_NODE_FIELD(relation);
1938 COPY_NODE_FIELD(attlist);
1939 COPY_SCALAR_FIELD(is_from);
1940 COPY_STRING_FIELD(filename);
1941 COPY_NODE_FIELD(options);
1947 _copyCreateStmt(CreateStmt *from)
1949 CreateStmt *newnode = makeNode(CreateStmt);
1951 COPY_NODE_FIELD(relation);
1952 COPY_NODE_FIELD(tableElts);
1953 COPY_NODE_FIELD(inhRelations);
1954 COPY_NODE_FIELD(constraints);
1955 COPY_NODE_FIELD(options);
1956 COPY_SCALAR_FIELD(oncommit);
1957 COPY_STRING_FIELD(tablespacename);
1962 static InhRelation *
1963 _copyInhRelation(InhRelation *from)
1965 InhRelation *newnode = makeNode(InhRelation);
1967 COPY_NODE_FIELD(relation);
1968 COPY_NODE_FIELD(options);
1974 _copyDefineStmt(DefineStmt *from)
1976 DefineStmt *newnode = makeNode(DefineStmt);
1978 COPY_SCALAR_FIELD(kind);
1979 COPY_SCALAR_FIELD(oldstyle);
1980 COPY_NODE_FIELD(defnames);
1981 COPY_NODE_FIELD(args);
1982 COPY_NODE_FIELD(definition);
1988 _copyDropStmt(DropStmt *from)
1990 DropStmt *newnode = makeNode(DropStmt);
1992 COPY_NODE_FIELD(objects);
1993 COPY_SCALAR_FIELD(removeType);
1994 COPY_SCALAR_FIELD(behavior);
1995 COPY_SCALAR_FIELD(missing_ok);
2000 static TruncateStmt *
2001 _copyTruncateStmt(TruncateStmt *from)
2003 TruncateStmt *newnode = makeNode(TruncateStmt);
2005 COPY_NODE_FIELD(relations);
2006 COPY_SCALAR_FIELD(behavior);
2011 static CommentStmt *
2012 _copyCommentStmt(CommentStmt *from)
2014 CommentStmt *newnode = makeNode(CommentStmt);
2016 COPY_SCALAR_FIELD(objtype);
2017 COPY_NODE_FIELD(objname);
2018 COPY_NODE_FIELD(objargs);
2019 COPY_STRING_FIELD(comment);
2025 _copyFetchStmt(FetchStmt *from)
2027 FetchStmt *newnode = makeNode(FetchStmt);
2029 COPY_SCALAR_FIELD(direction);
2030 COPY_SCALAR_FIELD(howMany);
2031 COPY_STRING_FIELD(portalname);
2032 COPY_SCALAR_FIELD(ismove);
2038 _copyIndexStmt(IndexStmt *from)
2040 IndexStmt *newnode = makeNode(IndexStmt);
2042 COPY_STRING_FIELD(idxname);
2043 COPY_NODE_FIELD(relation);
2044 COPY_STRING_FIELD(accessMethod);
2045 COPY_STRING_FIELD(tableSpace);
2046 COPY_NODE_FIELD(indexParams);
2047 COPY_NODE_FIELD(options);
2048 COPY_NODE_FIELD(whereClause);
2049 COPY_NODE_FIELD(rangetable);
2050 COPY_SCALAR_FIELD(unique);
2051 COPY_SCALAR_FIELD(primary);
2052 COPY_SCALAR_FIELD(isconstraint);
2057 static CreateFunctionStmt *
2058 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2060 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2062 COPY_SCALAR_FIELD(replace);
2063 COPY_NODE_FIELD(funcname);
2064 COPY_NODE_FIELD(parameters);
2065 COPY_NODE_FIELD(returnType);
2066 COPY_NODE_FIELD(options);
2067 COPY_NODE_FIELD(withClause);
2072 static FunctionParameter *
2073 _copyFunctionParameter(FunctionParameter *from)
2075 FunctionParameter *newnode = makeNode(FunctionParameter);
2077 COPY_STRING_FIELD(name);
2078 COPY_NODE_FIELD(argType);
2079 COPY_SCALAR_FIELD(mode);
2084 static AlterFunctionStmt *
2085 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2087 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2089 COPY_NODE_FIELD(func);
2090 COPY_NODE_FIELD(actions);
2095 static RemoveFuncStmt *
2096 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2098 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2100 COPY_SCALAR_FIELD(kind);
2101 COPY_NODE_FIELD(name);
2102 COPY_NODE_FIELD(args);
2103 COPY_SCALAR_FIELD(behavior);
2104 COPY_SCALAR_FIELD(missing_ok);
2109 static RemoveOpClassStmt *
2110 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2112 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2114 COPY_NODE_FIELD(opclassname);
2115 COPY_STRING_FIELD(amname);
2116 COPY_SCALAR_FIELD(behavior);
2117 COPY_SCALAR_FIELD(missing_ok);
2123 _copyRenameStmt(RenameStmt *from)
2125 RenameStmt *newnode = makeNode(RenameStmt);
2127 COPY_SCALAR_FIELD(renameType);
2128 COPY_NODE_FIELD(relation);
2129 COPY_NODE_FIELD(object);
2130 COPY_NODE_FIELD(objarg);
2131 COPY_STRING_FIELD(subname);
2132 COPY_STRING_FIELD(newname);
2137 static AlterObjectSchemaStmt *
2138 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2140 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2142 COPY_SCALAR_FIELD(objectType);
2143 COPY_NODE_FIELD(relation);
2144 COPY_NODE_FIELD(object);
2145 COPY_NODE_FIELD(objarg);
2146 COPY_STRING_FIELD(addname);
2147 COPY_STRING_FIELD(newschema);
2152 static AlterOwnerStmt *
2153 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2155 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2157 COPY_SCALAR_FIELD(objectType);
2158 COPY_NODE_FIELD(relation);
2159 COPY_NODE_FIELD(object);
2160 COPY_NODE_FIELD(objarg);
2161 COPY_STRING_FIELD(addname);
2162 COPY_STRING_FIELD(newowner);
2168 _copyRuleStmt(RuleStmt *from)
2170 RuleStmt *newnode = makeNode(RuleStmt);
2172 COPY_NODE_FIELD(relation);
2173 COPY_STRING_FIELD(rulename);
2174 COPY_NODE_FIELD(whereClause);
2175 COPY_SCALAR_FIELD(event);
2176 COPY_SCALAR_FIELD(instead);
2177 COPY_NODE_FIELD(actions);
2178 COPY_SCALAR_FIELD(replace);
2184 _copyNotifyStmt(NotifyStmt *from)
2186 NotifyStmt *newnode = makeNode(NotifyStmt);
2188 COPY_NODE_FIELD(relation);
2194 _copyListenStmt(ListenStmt *from)
2196 ListenStmt *newnode = makeNode(ListenStmt);
2198 COPY_NODE_FIELD(relation);
2203 static UnlistenStmt *
2204 _copyUnlistenStmt(UnlistenStmt *from)
2206 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2208 COPY_NODE_FIELD(relation);
2213 static TransactionStmt *
2214 _copyTransactionStmt(TransactionStmt *from)
2216 TransactionStmt *newnode = makeNode(TransactionStmt);
2218 COPY_SCALAR_FIELD(kind);
2219 COPY_NODE_FIELD(options);
2220 COPY_STRING_FIELD(gid);
2225 static CompositeTypeStmt *
2226 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2228 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2230 COPY_NODE_FIELD(typevar);
2231 COPY_NODE_FIELD(coldeflist);
2237 _copyViewStmt(ViewStmt *from)
2239 ViewStmt *newnode = makeNode(ViewStmt);
2241 COPY_NODE_FIELD(view);
2242 COPY_NODE_FIELD(aliases);
2243 COPY_NODE_FIELD(query);
2244 COPY_SCALAR_FIELD(replace);
2250 _copyLoadStmt(LoadStmt *from)
2252 LoadStmt *newnode = makeNode(LoadStmt);
2254 COPY_STRING_FIELD(filename);
2259 static CreateDomainStmt *
2260 _copyCreateDomainStmt(CreateDomainStmt *from)
2262 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2264 COPY_NODE_FIELD(domainname);
2265 COPY_NODE_FIELD(typename);
2266 COPY_NODE_FIELD(constraints);
2271 static CreateOpClassStmt *
2272 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2274 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2276 COPY_NODE_FIELD(opclassname);
2277 COPY_STRING_FIELD(amname);
2278 COPY_NODE_FIELD(datatype);
2279 COPY_NODE_FIELD(items);
2280 COPY_SCALAR_FIELD(isDefault);
2285 static CreateOpClassItem *
2286 _copyCreateOpClassItem(CreateOpClassItem *from)
2288 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2290 COPY_SCALAR_FIELD(itemtype);
2291 COPY_NODE_FIELD(name);
2292 COPY_NODE_FIELD(args);
2293 COPY_SCALAR_FIELD(number);
2294 COPY_SCALAR_FIELD(recheck);
2295 COPY_NODE_FIELD(storedtype);
2300 static CreatedbStmt *
2301 _copyCreatedbStmt(CreatedbStmt *from)
2303 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2305 COPY_STRING_FIELD(dbname);
2306 COPY_NODE_FIELD(options);
2311 static AlterDatabaseStmt *
2312 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2314 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2316 COPY_STRING_FIELD(dbname);
2317 COPY_NODE_FIELD(options);
2322 static AlterDatabaseSetStmt *
2323 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2325 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2327 COPY_STRING_FIELD(dbname);
2328 COPY_STRING_FIELD(variable);
2329 COPY_NODE_FIELD(value);
2335 _copyDropdbStmt(DropdbStmt *from)
2337 DropdbStmt *newnode = makeNode(DropdbStmt);
2339 COPY_STRING_FIELD(dbname);
2340 COPY_SCALAR_FIELD(missing_ok);
2346 _copyVacuumStmt(VacuumStmt *from)
2348 VacuumStmt *newnode = makeNode(VacuumStmt);
2350 COPY_SCALAR_FIELD(vacuum);
2351 COPY_SCALAR_FIELD(full);
2352 COPY_SCALAR_FIELD(analyze);
2353 COPY_SCALAR_FIELD(freeze);
2354 COPY_SCALAR_FIELD(verbose);
2355 COPY_NODE_FIELD(relation);
2356 COPY_NODE_FIELD(va_cols);
2361 static ExplainStmt *
2362 _copyExplainStmt(ExplainStmt *from)
2364 ExplainStmt *newnode = makeNode(ExplainStmt);
2366 COPY_NODE_FIELD(query);
2367 COPY_SCALAR_FIELD(verbose);
2368 COPY_SCALAR_FIELD(analyze);
2373 static CreateSeqStmt *
2374 _copyCreateSeqStmt(CreateSeqStmt *from)
2376 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2378 COPY_NODE_FIELD(sequence);
2379 COPY_NODE_FIELD(options);
2384 static AlterSeqStmt *
2385 _copyAlterSeqStmt(AlterSeqStmt *from)
2387 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2389 COPY_NODE_FIELD(sequence);
2390 COPY_NODE_FIELD(options);
2395 static VariableSetStmt *
2396 _copyVariableSetStmt(VariableSetStmt *from)
2398 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2400 COPY_STRING_FIELD(name);
2401 COPY_NODE_FIELD(args);
2402 COPY_SCALAR_FIELD(is_local);
2407 static VariableShowStmt *
2408 _copyVariableShowStmt(VariableShowStmt *from)
2410 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2412 COPY_STRING_FIELD(name);
2417 static VariableResetStmt *
2418 _copyVariableResetStmt(VariableResetStmt *from)
2420 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2422 COPY_STRING_FIELD(name);
2427 static CreateTableSpaceStmt *
2428 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2430 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2432 COPY_STRING_FIELD(tablespacename);
2433 COPY_STRING_FIELD(owner);
2434 COPY_STRING_FIELD(location);
2439 static DropTableSpaceStmt *
2440 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2442 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2444 COPY_STRING_FIELD(tablespacename);
2445 COPY_SCALAR_FIELD(missing_ok);
2450 static CreateTrigStmt *
2451 _copyCreateTrigStmt(CreateTrigStmt *from)
2453 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2455 COPY_STRING_FIELD(trigname);
2456 COPY_NODE_FIELD(relation);
2457 COPY_NODE_FIELD(funcname);
2458 COPY_NODE_FIELD(args);
2459 COPY_SCALAR_FIELD(before);
2460 COPY_SCALAR_FIELD(row);
2461 strcpy(newnode->actions, from->actions); /* in-line string field */
2462 COPY_SCALAR_FIELD(isconstraint);
2463 COPY_SCALAR_FIELD(deferrable);
2464 COPY_SCALAR_FIELD(initdeferred);
2465 COPY_NODE_FIELD(constrrel);
2470 static DropPropertyStmt *
2471 _copyDropPropertyStmt(DropPropertyStmt *from)
2473 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2475 COPY_NODE_FIELD(relation);
2476 COPY_STRING_FIELD(property);
2477 COPY_SCALAR_FIELD(removeType);
2478 COPY_SCALAR_FIELD(behavior);
2479 COPY_SCALAR_FIELD(missing_ok);
2484 static CreatePLangStmt *
2485 _copyCreatePLangStmt(CreatePLangStmt *from)
2487 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2489 COPY_STRING_FIELD(plname);
2490 COPY_NODE_FIELD(plhandler);
2491 COPY_NODE_FIELD(plvalidator);
2492 COPY_SCALAR_FIELD(pltrusted);
2497 static DropPLangStmt *
2498 _copyDropPLangStmt(DropPLangStmt *from)
2500 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2502 COPY_STRING_FIELD(plname);
2503 COPY_SCALAR_FIELD(behavior);
2504 COPY_SCALAR_FIELD(missing_ok);
2509 static CreateRoleStmt *
2510 _copyCreateRoleStmt(CreateRoleStmt *from)
2512 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2514 COPY_SCALAR_FIELD(stmt_type);
2515 COPY_STRING_FIELD(role);
2516 COPY_NODE_FIELD(options);
2521 static AlterRoleStmt *
2522 _copyAlterRoleStmt(AlterRoleStmt *from)
2524 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2526 COPY_STRING_FIELD(role);
2527 COPY_NODE_FIELD(options);
2528 COPY_SCALAR_FIELD(action);
2533 static AlterRoleSetStmt *
2534 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2536 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2538 COPY_STRING_FIELD(role);
2539 COPY_STRING_FIELD(variable);
2540 COPY_NODE_FIELD(value);
2545 static DropRoleStmt *
2546 _copyDropRoleStmt(DropRoleStmt *from)
2548 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2550 COPY_NODE_FIELD(roles);
2551 COPY_SCALAR_FIELD(missing_ok);
2557 _copyLockStmt(LockStmt *from)
2559 LockStmt *newnode = makeNode(LockStmt);
2561 COPY_NODE_FIELD(relations);
2562 COPY_SCALAR_FIELD(mode);
2563 COPY_SCALAR_FIELD(nowait);
2568 static ConstraintsSetStmt *
2569 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2571 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2573 COPY_NODE_FIELD(constraints);
2574 COPY_SCALAR_FIELD(deferred);
2579 static ReindexStmt *
2580 _copyReindexStmt(ReindexStmt *from)
2582 ReindexStmt *newnode = makeNode(ReindexStmt);
2584 COPY_SCALAR_FIELD(kind);
2585 COPY_NODE_FIELD(relation);
2586 COPY_STRING_FIELD(name);
2587 COPY_SCALAR_FIELD(do_system);
2588 COPY_SCALAR_FIELD(do_user);
2593 static CreateSchemaStmt *
2594 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2596 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2598 COPY_STRING_FIELD(schemaname);
2599 COPY_STRING_FIELD(authid);
2600 COPY_NODE_FIELD(schemaElts);
2605 static CreateConversionStmt *
2606 _copyCreateConversionStmt(CreateConversionStmt *from)
2608 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2610 COPY_NODE_FIELD(conversion_name);
2611 COPY_STRING_FIELD(for_encoding_name);
2612 COPY_STRING_FIELD(to_encoding_name);
2613 COPY_NODE_FIELD(func_name);
2614 COPY_SCALAR_FIELD(def);
2619 static CreateCastStmt *
2620 _copyCreateCastStmt(CreateCastStmt *from)
2622 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2624 COPY_NODE_FIELD(sourcetype);
2625 COPY_NODE_FIELD(targettype);
2626 COPY_NODE_FIELD(func);
2627 COPY_SCALAR_FIELD(context);
2632 static DropCastStmt *
2633 _copyDropCastStmt(DropCastStmt *from)
2635 DropCastStmt *newnode = makeNode(DropCastStmt);
2637 COPY_NODE_FIELD(sourcetype);
2638 COPY_NODE_FIELD(targettype);
2639 COPY_SCALAR_FIELD(behavior);
2640 COPY_SCALAR_FIELD(missing_ok);
2645 static PrepareStmt *
2646 _copyPrepareStmt(PrepareStmt *from)
2648 PrepareStmt *newnode = makeNode(PrepareStmt);
2650 COPY_STRING_FIELD(name);
2651 COPY_NODE_FIELD(argtypes);
2652 COPY_NODE_FIELD(argtype_oids);
2653 COPY_NODE_FIELD(query);
2658 static ExecuteStmt *
2659 _copyExecuteStmt(ExecuteStmt *from)
2661 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2663 COPY_STRING_FIELD(name);
2664 COPY_NODE_FIELD(into);
2665 COPY_NODE_FIELD(intoOptions);
2666 COPY_SCALAR_FIELD(into_on_commit);
2667 COPY_STRING_FIELD(into_tbl_space);
2668 COPY_NODE_FIELD(params);
2673 static DeallocateStmt *
2674 _copyDeallocateStmt(DeallocateStmt *from)
2676 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2678 COPY_STRING_FIELD(name);
2683 static DropOwnedStmt *
2684 _copyDropOwnedStmt(DropOwnedStmt * from)
2686 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2688 COPY_NODE_FIELD(roles);
2689 COPY_SCALAR_FIELD(behavior);
2694 static ReassignOwnedStmt *
2695 _copyReassignOwnedStmt(ReassignOwnedStmt * from)
2697 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2699 COPY_NODE_FIELD(roles);
2700 COPY_SCALAR_FIELD(newrole);
2705 /* ****************************************************************
2706 * pg_list.h copy functions
2707 * ****************************************************************
2711 * Perform a deep copy of the specified list, using copyObject(). The
2712 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2713 * need deep copies, so they should be copied via list_copy()
2715 #define COPY_NODE_CELL(new, old) \
2716 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2717 lfirst(new) = copyObject(lfirst(old));
2720 _copyList(List *from)
2726 Assert(list_length(from) >= 1);
2728 new = makeNode(List);
2729 new->length = from->length;
2731 COPY_NODE_CELL(new->head, from->head);
2732 prev_new = new->head;
2733 curr_old = lnext(from->head);
2737 COPY_NODE_CELL(prev_new->next, curr_old);
2738 prev_new = prev_new->next;
2739 curr_old = curr_old->next;
2741 prev_new->next = NULL;
2742 new->tail = prev_new;
2747 /* ****************************************************************
2748 * value.h copy functions
2749 * ****************************************************************
2752 _copyValue(Value *from)
2754 Value *newnode = makeNode(Value);
2756 /* See also _copyAConst when changing this code! */
2758 COPY_SCALAR_FIELD(type);
2762 COPY_SCALAR_FIELD(val.ival);
2767 COPY_STRING_FIELD(val.str);
2773 elog(ERROR, "unrecognized node type: %d",
2783 * Create a copy of a Node tree or list. This is a "deep" copy: all
2784 * substructure is copied too, recursively.
2787 copyObject(void *from)
2794 switch (nodeTag(from))
2800 retval = _copyPlan(from);
2803 retval = _copyResult(from);
2806 retval = _copyAppend(from);
2809 retval = _copyBitmapAnd(from);
2812 retval = _copyBitmapOr(from);
2815 retval = _copyScan(from);
2818 retval = _copySeqScan(from);
2821 retval = _copyIndexScan(from);
2823 case T_BitmapIndexScan:
2824 retval = _copyBitmapIndexScan(from);
2826 case T_BitmapHeapScan:
2827 retval = _copyBitmapHeapScan(from);
2830 retval = _copyTidScan(from);
2832 case T_SubqueryScan:
2833 retval = _copySubqueryScan(from);
2835 case T_FunctionScan:
2836 retval = _copyFunctionScan(from);
2839 retval = _copyValuesScan(from);
2842 retval = _copyJoin(from);
2845 retval = _copyNestLoop(from);
2848 retval = _copyMergeJoin(from);
2851 retval = _copyHashJoin(from);
2854 retval = _copyMaterial(from);
2857 retval = _copySort(from);
2860 retval = _copyGroup(from);
2863 retval = _copyAgg(from);
2866 retval = _copyUnique(from);
2869 retval = _copyHash(from);
2872 retval = _copySetOp(from);
2875 retval = _copyLimit(from);
2882 retval = _copyAlias(from);
2885 retval = _copyRangeVar(from);
2888 retval = _copyVar(from);
2891 retval = _copyConst(from);
2894 retval = _copyParam(from);
2897 retval = _copyAggref(from);
2900 retval = _copyArrayRef(from);
2903 retval = _copyFuncExpr(from);
2906 retval = _copyOpExpr(from);
2908 case T_DistinctExpr:
2909 retval = _copyDistinctExpr(from);
2911 case T_ScalarArrayOpExpr:
2912 retval = _copyScalarArrayOpExpr(from);
2915 retval = _copyBoolExpr(from);
2918 retval = _copySubLink(from);
2921 retval = _copySubPlan(from);
2924 retval = _copyFieldSelect(from);
2927 retval = _copyFieldStore(from);
2930 retval = _copyRelabelType(from);
2932 case T_ConvertRowtypeExpr:
2933 retval = _copyConvertRowtypeExpr(from);
2936 retval = _copyCaseExpr(from);
2939 retval = _copyCaseWhen(from);
2941 case T_CaseTestExpr:
2942 retval = _copyCaseTestExpr(from);
2945 retval = _copyArrayExpr(from);
2948 retval = _copyRowExpr(from);
2950 case T_RowCompareExpr:
2951 retval = _copyRowCompareExpr(from);
2953 case T_CoalesceExpr:
2954 retval = _copyCoalesceExpr(from);
2957 retval = _copyMinMaxExpr(from);
2960 retval = _copyNullIfExpr(from);
2963 retval = _copyNullTest(from);
2966 retval = _copyBooleanTest(from);
2968 case T_CoerceToDomain:
2969 retval = _copyCoerceToDomain(from);
2971 case T_CoerceToDomainValue:
2972 retval = _copyCoerceToDomainValue(from);
2974 case T_SetToDefault:
2975 retval = _copySetToDefault(from);
2978 retval = _copyTargetEntry(from);
2981 retval = _copyRangeTblRef(from);
2984 retval = _copyJoinExpr(from);
2987 retval = _copyFromExpr(from);
2994 retval = _copyPathKeyItem(from);
2996 case T_RestrictInfo:
2997 retval = _copyRestrictInfo(from);
2999 case T_OuterJoinInfo:
3000 retval = _copyOuterJoinInfo(from);
3002 case T_InClauseInfo:
3003 retval = _copyInClauseInfo(from);
3005 case T_AppendRelInfo:
3006 retval = _copyAppendRelInfo(from);
3017 retval = _copyValue(from);
3024 retval = _copyList(from);
3028 * Lists of integers and OIDs don't need to be deep-copied, so we
3029 * perform a shallow copy via list_copy()
3033 retval = list_copy(from);
3040 retval = _copyQuery(from);
3043 retval = _copyInsertStmt(from);
3046 retval = _copyDeleteStmt(from);
3049 retval = _copyUpdateStmt(from);
3052 retval = _copySelectStmt(from);
3054 case T_SetOperationStmt:
3055 retval = _copySetOperationStmt(from);
3057 case T_AlterTableStmt:
3058 retval = _copyAlterTableStmt(from);
3060 case T_AlterTableCmd:
3061 retval = _copyAlterTableCmd(from);
3063 case T_AlterDomainStmt:
3064 retval = _copyAlterDomainStmt(from);
3067 retval = _copyGrantStmt(from);
3069 case T_GrantRoleStmt:
3070 retval = _copyGrantRoleStmt(from);
3072 case T_DeclareCursorStmt:
3073 retval = _copyDeclareCursorStmt(from);
3075 case T_ClosePortalStmt:
3076 retval = _copyClosePortalStmt(from);
3079 retval = _copyClusterStmt(from);
3082 retval = _copyCopyStmt(from);
3085 retval = _copyCreateStmt(from);
3088 retval = _copyInhRelation(from);
3091 retval = _copyDefineStmt(from);
3094 retval = _copyDropStmt(from);
3096 case T_TruncateStmt:
3097 retval = _copyTruncateStmt(from);
3100 retval = _copyCommentStmt(from);
3103 retval = _copyFetchStmt(from);
3106 retval = _copyIndexStmt(from);
3108 case T_CreateFunctionStmt:
3109 retval = _copyCreateFunctionStmt(from);
3111 case T_FunctionParameter:
3112 retval = _copyFunctionParameter(from);
3114 case T_AlterFunctionStmt:
3115 retval = _copyAlterFunctionStmt(from);
3117 case T_RemoveFuncStmt:
3118 retval = _copyRemoveFuncStmt(from);
3120 case T_RemoveOpClassStmt:
3121 retval = _copyRemoveOpClassStmt(from);
3124 retval = _copyRenameStmt(from);
3126 case T_AlterObjectSchemaStmt:
3127 retval = _copyAlterObjectSchemaStmt(from);
3129 case T_AlterOwnerStmt:
3130 retval = _copyAlterOwnerStmt(from);
3133 retval = _copyRuleStmt(from);
3136 retval = _copyNotifyStmt(from);
3139 retval = _copyListenStmt(from);
3141 case T_UnlistenStmt:
3142 retval = _copyUnlistenStmt(from);
3144 case T_TransactionStmt:
3145 retval = _copyTransactionStmt(from);
3147 case T_CompositeTypeStmt:
3148 retval = _copyCompositeTypeStmt(from);
3151 retval = _copyViewStmt(from);
3154 retval = _copyLoadStmt(from);
3156 case T_CreateDomainStmt:
3157 retval = _copyCreateDomainStmt(from);
3159 case T_CreateOpClassStmt:
3160 retval = _copyCreateOpClassStmt(from);
3162 case T_CreateOpClassItem:
3163 retval = _copyCreateOpClassItem(from);
3165 case T_CreatedbStmt:
3166 retval = _copyCreatedbStmt(from);
3168 case T_AlterDatabaseStmt:
3169 retval = _copyAlterDatabaseStmt(from);
3171 case T_AlterDatabaseSetStmt:
3172 retval = _copyAlterDatabaseSetStmt(from);
3175 retval = _copyDropdbStmt(from);
3178 retval = _copyVacuumStmt(from);
3181 retval = _copyExplainStmt(from);
3183 case T_CreateSeqStmt:
3184 retval = _copyCreateSeqStmt(from);
3186 case T_AlterSeqStmt:
3187 retval = _copyAlterSeqStmt(from);
3189 case T_VariableSetStmt:
3190 retval = _copyVariableSetStmt(from);
3192 case T_VariableShowStmt:
3193 retval = _copyVariableShowStmt(from);
3195 case T_VariableResetStmt:
3196 retval = _copyVariableResetStmt(from);
3198 case T_CreateTableSpaceStmt:
3199 retval = _copyCreateTableSpaceStmt(from);
3201 case T_DropTableSpaceStmt:
3202 retval = _copyDropTableSpaceStmt(from);
3204 case T_CreateTrigStmt:
3205 retval = _copyCreateTrigStmt(from);
3207 case T_DropPropertyStmt:
3208 retval = _copyDropPropertyStmt(from);
3210 case T_CreatePLangStmt:
3211 retval = _copyCreatePLangStmt(from);
3213 case T_DropPLangStmt:
3214 retval = _copyDropPLangStmt(from);
3216 case T_CreateRoleStmt:
3217 retval = _copyCreateRoleStmt(from);
3219 case T_AlterRoleStmt:
3220 retval = _copyAlterRoleStmt(from);
3222 case T_AlterRoleSetStmt:
3223 retval = _copyAlterRoleSetStmt(from);
3225 case T_DropRoleStmt:
3226 retval = _copyDropRoleStmt(from);
3229 retval = _copyLockStmt(from);
3231 case T_ConstraintsSetStmt:
3232 retval = _copyConstraintsSetStmt(from);
3235 retval = _copyReindexStmt(from);
3237 case T_CheckPointStmt:
3238 retval = (void *) makeNode(CheckPointStmt);
3240 case T_CreateSchemaStmt:
3241 retval = _copyCreateSchemaStmt(from);
3243 case T_CreateConversionStmt:
3244 retval = _copyCreateConversionStmt(from);
3246 case T_CreateCastStmt:
3247 retval = _copyCreateCastStmt(from);
3249 case T_DropCastStmt:
3250 retval = _copyDropCastStmt(from);
3253 retval = _copyPrepareStmt(from);
3256 retval = _copyExecuteStmt(from);
3258 case T_DeallocateStmt:
3259 retval = _copyDeallocateStmt(from);
3261 case T_DropOwnedStmt:
3262 retval = _copyDropOwnedStmt(from);
3264 case T_ReassignOwnedStmt:
3265 retval = _copyReassignOwnedStmt(from);
3269 retval = _copyAExpr(from);
3272 retval = _copyColumnRef(from);
3275 retval = _copyParamRef(from);
3278 retval = _copyAConst(from);
3281 retval = _copyFuncCall(from);
3284 retval = _copyAIndices(from);
3286 case T_A_Indirection:
3287 retval = _copyA_Indirection(from);
3290 retval = _copyResTarget(from);
3293 retval = _copyTypeCast(from);
3296 retval = _copySortBy(from);
3298 case T_RangeSubselect:
3299 retval = _copyRangeSubselect(from);
3301 case T_RangeFunction:
3302 retval = _copyRangeFunction(from);
3305 retval = _copyTypeName(from);
3308 retval = _copyIndexElem(from);
3311 retval = _copyColumnDef(from);
3314 retval = _copyConstraint(from);
3317 retval = _copyDefElem(from);
3319 case T_LockingClause:
3320 retval = _copyLockingClause(from);
3322 case T_RangeTblEntry:
3323 retval = _copyRangeTblEntry(from);
3326 retval = _copySortClause(from);
3329 retval = _copyGroupClause(from);
3331 case T_RowMarkClause:
3332 retval = _copyRowMarkClause(from);
3334 case T_FkConstraint:
3335 retval = _copyFkConstraint(from);
3338 retval = _copyPrivGrantee(from);
3340 case T_FuncWithArgs:
3341 retval = _copyFuncWithArgs(from);
3345 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3346 retval = from; /* keep compiler quiet */