1 /*-------------------------------------------------------------------------
4 * Copy functions for Postgres tree nodes.
6 * NOTE: we currently support copying all node types found in parse and
7 * plan trees. We do not support copying executor state trees; there
8 * is no need for that, and no point in maintaining all the code that
9 * would be needed. We also do not support copying Path trees, mainly
10 * because the circular linkages between RelOptInfo and Path nodes can't
11 * be handled easily in a simple depth-first traversal.
14 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
18 * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.376 2007/05/22 23:23:55 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 * ****************************************************************
71 _copyPlannedStmt(PlannedStmt *from)
73 PlannedStmt *newnode = makeNode(PlannedStmt);
75 COPY_SCALAR_FIELD(commandType);
76 COPY_SCALAR_FIELD(canSetTag);
77 COPY_NODE_FIELD(planTree);
78 COPY_NODE_FIELD(rtable);
79 COPY_NODE_FIELD(resultRelations);
80 COPY_NODE_FIELD(utilityStmt);
81 COPY_NODE_FIELD(intoClause);
82 COPY_NODE_FIELD(subplans);
83 COPY_BITMAPSET_FIELD(rewindPlanIDs);
84 COPY_NODE_FIELD(returningLists);
85 COPY_NODE_FIELD(rowMarks);
86 COPY_SCALAR_FIELD(nParamExec);
94 * This function copies the fields of the Plan node. It is used by
95 * all the copy functions for classes which inherit from Plan.
98 CopyPlanFields(Plan *from, Plan *newnode)
100 COPY_SCALAR_FIELD(startup_cost);
101 COPY_SCALAR_FIELD(total_cost);
102 COPY_SCALAR_FIELD(plan_rows);
103 COPY_SCALAR_FIELD(plan_width);
104 COPY_NODE_FIELD(targetlist);
105 COPY_NODE_FIELD(qual);
106 COPY_NODE_FIELD(lefttree);
107 COPY_NODE_FIELD(righttree);
108 COPY_NODE_FIELD(initPlan);
109 COPY_BITMAPSET_FIELD(extParam);
110 COPY_BITMAPSET_FIELD(allParam);
117 _copyPlan(Plan *from)
119 Plan *newnode = makeNode(Plan);
122 * copy node superclass fields
124 CopyPlanFields(from, newnode);
134 _copyResult(Result *from)
136 Result *newnode = makeNode(Result);
139 * copy node superclass fields
141 CopyPlanFields((Plan *) from, (Plan *) newnode);
144 * copy remainder of node
146 COPY_NODE_FIELD(resconstantqual);
155 _copyAppend(Append *from)
157 Append *newnode = makeNode(Append);
160 * copy node superclass fields
162 CopyPlanFields((Plan *) from, (Plan *) newnode);
165 * copy remainder of node
167 COPY_NODE_FIELD(appendplans);
168 COPY_SCALAR_FIELD(isTarget);
177 _copyBitmapAnd(BitmapAnd *from)
179 BitmapAnd *newnode = makeNode(BitmapAnd);
182 * copy node superclass fields
184 CopyPlanFields((Plan *) from, (Plan *) newnode);
187 * copy remainder of node
189 COPY_NODE_FIELD(bitmapplans);
198 _copyBitmapOr(BitmapOr *from)
200 BitmapOr *newnode = makeNode(BitmapOr);
203 * copy node superclass fields
205 CopyPlanFields((Plan *) from, (Plan *) newnode);
208 * copy remainder of node
210 COPY_NODE_FIELD(bitmapplans);
219 * This function copies the fields of the Scan node. It is used by
220 * all the copy functions for classes which inherit from Scan.
223 CopyScanFields(Scan *from, Scan *newnode)
225 CopyPlanFields((Plan *) from, (Plan *) newnode);
227 COPY_SCALAR_FIELD(scanrelid);
234 _copyScan(Scan *from)
236 Scan *newnode = makeNode(Scan);
239 * copy node superclass fields
241 CopyScanFields((Scan *) from, (Scan *) newnode);
250 _copySeqScan(SeqScan *from)
252 SeqScan *newnode = makeNode(SeqScan);
255 * copy node superclass fields
257 CopyScanFields((Scan *) from, (Scan *) newnode);
266 _copyIndexScan(IndexScan *from)
268 IndexScan *newnode = makeNode(IndexScan);
271 * copy node superclass fields
273 CopyScanFields((Scan *) from, (Scan *) newnode);
276 * copy remainder of node
278 COPY_SCALAR_FIELD(indexid);
279 COPY_NODE_FIELD(indexqual);
280 COPY_NODE_FIELD(indexqualorig);
281 COPY_NODE_FIELD(indexstrategy);
282 COPY_NODE_FIELD(indexsubtype);
283 COPY_SCALAR_FIELD(indexorderdir);
289 * _copyBitmapIndexScan
291 static BitmapIndexScan *
292 _copyBitmapIndexScan(BitmapIndexScan *from)
294 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
297 * copy node superclass fields
299 CopyScanFields((Scan *) from, (Scan *) newnode);
302 * copy remainder of node
304 COPY_SCALAR_FIELD(indexid);
305 COPY_NODE_FIELD(indexqual);
306 COPY_NODE_FIELD(indexqualorig);
307 COPY_NODE_FIELD(indexstrategy);
308 COPY_NODE_FIELD(indexsubtype);
314 * _copyBitmapHeapScan
316 static BitmapHeapScan *
317 _copyBitmapHeapScan(BitmapHeapScan *from)
319 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
322 * copy node superclass fields
324 CopyScanFields((Scan *) from, (Scan *) newnode);
327 * copy remainder of node
329 COPY_NODE_FIELD(bitmapqualorig);
338 _copyTidScan(TidScan *from)
340 TidScan *newnode = makeNode(TidScan);
343 * copy node superclass fields
345 CopyScanFields((Scan *) from, (Scan *) newnode);
348 * copy remainder of node
350 COPY_NODE_FIELD(tidquals);
358 static SubqueryScan *
359 _copySubqueryScan(SubqueryScan *from)
361 SubqueryScan *newnode = makeNode(SubqueryScan);
364 * copy node superclass fields
366 CopyScanFields((Scan *) from, (Scan *) newnode);
369 * copy remainder of node
371 COPY_NODE_FIELD(subplan);
372 COPY_NODE_FIELD(subrtable);
380 static FunctionScan *
381 _copyFunctionScan(FunctionScan *from)
383 FunctionScan *newnode = makeNode(FunctionScan);
386 * copy node superclass fields
388 CopyScanFields((Scan *) from, (Scan *) newnode);
391 * copy remainder of node
393 COPY_NODE_FIELD(funcexpr);
394 COPY_NODE_FIELD(funccolnames);
395 COPY_NODE_FIELD(funccoltypes);
396 COPY_NODE_FIELD(funccoltypmods);
405 _copyValuesScan(ValuesScan *from)
407 ValuesScan *newnode = makeNode(ValuesScan);
410 * copy node superclass fields
412 CopyScanFields((Scan *) from, (Scan *) newnode);
415 * copy remainder of node
417 COPY_NODE_FIELD(values_lists);
425 * This function copies the fields of the Join node. It is used by
426 * all the copy functions for classes which inherit from Join.
429 CopyJoinFields(Join *from, Join *newnode)
431 CopyPlanFields((Plan *) from, (Plan *) newnode);
433 COPY_SCALAR_FIELD(jointype);
434 COPY_NODE_FIELD(joinqual);
442 _copyJoin(Join *from)
444 Join *newnode = makeNode(Join);
447 * copy node superclass fields
449 CopyJoinFields(from, newnode);
459 _copyNestLoop(NestLoop *from)
461 NestLoop *newnode = makeNode(NestLoop);
464 * copy node superclass fields
466 CopyJoinFields((Join *) from, (Join *) newnode);
476 _copyMergeJoin(MergeJoin *from)
478 MergeJoin *newnode = makeNode(MergeJoin);
482 * copy node superclass fields
484 CopyJoinFields((Join *) from, (Join *) newnode);
487 * copy remainder of node
489 COPY_NODE_FIELD(mergeclauses);
490 numCols = list_length(from->mergeclauses);
491 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
492 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
493 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
502 _copyHashJoin(HashJoin *from)
504 HashJoin *newnode = makeNode(HashJoin);
507 * copy node superclass fields
509 CopyJoinFields((Join *) from, (Join *) newnode);
512 * copy remainder of node
514 COPY_NODE_FIELD(hashclauses);
524 _copyMaterial(Material *from)
526 Material *newnode = makeNode(Material);
529 * copy node superclass fields
531 CopyPlanFields((Plan *) from, (Plan *) newnode);
541 _copySort(Sort *from)
543 Sort *newnode = makeNode(Sort);
546 * copy node superclass fields
548 CopyPlanFields((Plan *) from, (Plan *) newnode);
550 COPY_SCALAR_FIELD(numCols);
551 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
552 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
553 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
563 _copyGroup(Group *from)
565 Group *newnode = makeNode(Group);
567 CopyPlanFields((Plan *) from, (Plan *) newnode);
569 COPY_SCALAR_FIELD(numCols);
570 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
571 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
582 Agg *newnode = makeNode(Agg);
584 CopyPlanFields((Plan *) from, (Plan *) newnode);
586 COPY_SCALAR_FIELD(aggstrategy);
587 COPY_SCALAR_FIELD(numCols);
588 if (from->numCols > 0)
590 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
591 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
593 COPY_SCALAR_FIELD(numGroups);
602 _copyUnique(Unique *from)
604 Unique *newnode = makeNode(Unique);
607 * copy node superclass fields
609 CopyPlanFields((Plan *) from, (Plan *) newnode);
612 * copy remainder of node
614 COPY_SCALAR_FIELD(numCols);
615 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
616 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
625 _copyHash(Hash *from)
627 Hash *newnode = makeNode(Hash);
630 * copy node superclass fields
632 CopyPlanFields((Plan *) from, (Plan *) newnode);
635 * copy remainder of node
645 _copySetOp(SetOp *from)
647 SetOp *newnode = makeNode(SetOp);
650 * copy node superclass fields
652 CopyPlanFields((Plan *) from, (Plan *) newnode);
655 * copy remainder of node
657 COPY_SCALAR_FIELD(cmd);
658 COPY_SCALAR_FIELD(numCols);
659 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
660 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
661 COPY_SCALAR_FIELD(flagColIdx);
670 _copyLimit(Limit *from)
672 Limit *newnode = makeNode(Limit);
675 * copy node superclass fields
677 CopyPlanFields((Plan *) from, (Plan *) newnode);
680 * copy remainder of node
682 COPY_NODE_FIELD(limitOffset);
683 COPY_NODE_FIELD(limitCount);
688 /* ****************************************************************
689 * primnodes.h copy functions
690 * ****************************************************************
697 _copyAlias(Alias *from)
699 Alias *newnode = makeNode(Alias);
701 COPY_STRING_FIELD(aliasname);
702 COPY_NODE_FIELD(colnames);
711 _copyRangeVar(RangeVar *from)
713 RangeVar *newnode = makeNode(RangeVar);
715 COPY_STRING_FIELD(catalogname);
716 COPY_STRING_FIELD(schemaname);
717 COPY_STRING_FIELD(relname);
718 COPY_SCALAR_FIELD(inhOpt);
719 COPY_SCALAR_FIELD(istemp);
720 COPY_NODE_FIELD(alias);
729 _copyIntoClause(IntoClause *from)
731 IntoClause *newnode = makeNode(IntoClause);
733 COPY_NODE_FIELD(rel);
734 COPY_NODE_FIELD(colNames);
735 COPY_NODE_FIELD(options);
736 COPY_SCALAR_FIELD(onCommit);
737 COPY_STRING_FIELD(tableSpaceName);
743 * We don't need a _copyExpr because Expr is an abstract supertype which
744 * should never actually get instantiated. Also, since it has no common
745 * fields except NodeTag, there's no need for a helper routine to factor
746 * out copying the common fields...
755 Var *newnode = makeNode(Var);
757 COPY_SCALAR_FIELD(varno);
758 COPY_SCALAR_FIELD(varattno);
759 COPY_SCALAR_FIELD(vartype);
760 COPY_SCALAR_FIELD(vartypmod);
761 COPY_SCALAR_FIELD(varlevelsup);
762 COPY_SCALAR_FIELD(varnoold);
763 COPY_SCALAR_FIELD(varoattno);
772 _copyConst(Const *from)
774 Const *newnode = makeNode(Const);
776 COPY_SCALAR_FIELD(consttype);
777 COPY_SCALAR_FIELD(consttypmod);
778 COPY_SCALAR_FIELD(constlen);
780 if (from->constbyval || from->constisnull)
783 * passed by value so just copy the datum. Also, don't try to copy
784 * struct when value is null!
786 newnode->constvalue = from->constvalue;
791 * passed by reference. We need a palloc'd copy.
793 newnode->constvalue = datumCopy(from->constvalue,
798 COPY_SCALAR_FIELD(constisnull);
799 COPY_SCALAR_FIELD(constbyval);
808 _copyParam(Param *from)
810 Param *newnode = makeNode(Param);
812 COPY_SCALAR_FIELD(paramkind);
813 COPY_SCALAR_FIELD(paramid);
814 COPY_SCALAR_FIELD(paramtype);
815 COPY_SCALAR_FIELD(paramtypmod);
824 _copyAggref(Aggref *from)
826 Aggref *newnode = makeNode(Aggref);
828 COPY_SCALAR_FIELD(aggfnoid);
829 COPY_SCALAR_FIELD(aggtype);
830 COPY_NODE_FIELD(args);
831 COPY_SCALAR_FIELD(agglevelsup);
832 COPY_SCALAR_FIELD(aggstar);
833 COPY_SCALAR_FIELD(aggdistinct);
842 _copyArrayRef(ArrayRef *from)
844 ArrayRef *newnode = makeNode(ArrayRef);
846 COPY_SCALAR_FIELD(refarraytype);
847 COPY_SCALAR_FIELD(refelemtype);
848 COPY_SCALAR_FIELD(reftypmod);
849 COPY_NODE_FIELD(refupperindexpr);
850 COPY_NODE_FIELD(reflowerindexpr);
851 COPY_NODE_FIELD(refexpr);
852 COPY_NODE_FIELD(refassgnexpr);
861 _copyFuncExpr(FuncExpr *from)
863 FuncExpr *newnode = makeNode(FuncExpr);
865 COPY_SCALAR_FIELD(funcid);
866 COPY_SCALAR_FIELD(funcresulttype);
867 COPY_SCALAR_FIELD(funcretset);
868 COPY_SCALAR_FIELD(funcformat);
869 COPY_NODE_FIELD(args);
878 _copyOpExpr(OpExpr *from)
880 OpExpr *newnode = makeNode(OpExpr);
882 COPY_SCALAR_FIELD(opno);
883 COPY_SCALAR_FIELD(opfuncid);
884 COPY_SCALAR_FIELD(opresulttype);
885 COPY_SCALAR_FIELD(opretset);
886 COPY_NODE_FIELD(args);
892 * _copyDistinctExpr (same as OpExpr)
894 static DistinctExpr *
895 _copyDistinctExpr(DistinctExpr *from)
897 DistinctExpr *newnode = makeNode(DistinctExpr);
899 COPY_SCALAR_FIELD(opno);
900 COPY_SCALAR_FIELD(opfuncid);
901 COPY_SCALAR_FIELD(opresulttype);
902 COPY_SCALAR_FIELD(opretset);
903 COPY_NODE_FIELD(args);
909 * _copyScalarArrayOpExpr
911 static ScalarArrayOpExpr *
912 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
914 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
916 COPY_SCALAR_FIELD(opno);
917 COPY_SCALAR_FIELD(opfuncid);
918 COPY_SCALAR_FIELD(useOr);
919 COPY_NODE_FIELD(args);
928 _copyBoolExpr(BoolExpr *from)
930 BoolExpr *newnode = makeNode(BoolExpr);
932 COPY_SCALAR_FIELD(boolop);
933 COPY_NODE_FIELD(args);
942 _copySubLink(SubLink *from)
944 SubLink *newnode = makeNode(SubLink);
946 COPY_SCALAR_FIELD(subLinkType);
947 COPY_NODE_FIELD(testexpr);
948 COPY_NODE_FIELD(operName);
949 COPY_NODE_FIELD(subselect);
958 _copySubPlan(SubPlan *from)
960 SubPlan *newnode = makeNode(SubPlan);
962 COPY_SCALAR_FIELD(subLinkType);
963 COPY_NODE_FIELD(testexpr);
964 COPY_NODE_FIELD(paramIds);
965 COPY_SCALAR_FIELD(plan_id);
966 COPY_SCALAR_FIELD(firstColType);
967 COPY_SCALAR_FIELD(useHashTable);
968 COPY_SCALAR_FIELD(unknownEqFalse);
969 COPY_NODE_FIELD(setParam);
970 COPY_NODE_FIELD(parParam);
971 COPY_NODE_FIELD(args);
980 _copyFieldSelect(FieldSelect *from)
982 FieldSelect *newnode = makeNode(FieldSelect);
984 COPY_NODE_FIELD(arg);
985 COPY_SCALAR_FIELD(fieldnum);
986 COPY_SCALAR_FIELD(resulttype);
987 COPY_SCALAR_FIELD(resulttypmod);
996 _copyFieldStore(FieldStore *from)
998 FieldStore *newnode = makeNode(FieldStore);
1000 COPY_NODE_FIELD(arg);
1001 COPY_NODE_FIELD(newvals);
1002 COPY_NODE_FIELD(fieldnums);
1003 COPY_SCALAR_FIELD(resulttype);
1011 static RelabelType *
1012 _copyRelabelType(RelabelType *from)
1014 RelabelType *newnode = makeNode(RelabelType);
1016 COPY_NODE_FIELD(arg);
1017 COPY_SCALAR_FIELD(resulttype);
1018 COPY_SCALAR_FIELD(resulttypmod);
1019 COPY_SCALAR_FIELD(relabelformat);
1025 * _copyArrayCoerceExpr
1027 static ArrayCoerceExpr *
1028 _copyArrayCoerceExpr(ArrayCoerceExpr *from)
1030 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1032 COPY_NODE_FIELD(arg);
1033 COPY_SCALAR_FIELD(elemfuncid);
1034 COPY_SCALAR_FIELD(resulttype);
1035 COPY_SCALAR_FIELD(resulttypmod);
1036 COPY_SCALAR_FIELD(isExplicit);
1037 COPY_SCALAR_FIELD(coerceformat);
1043 * _copyConvertRowtypeExpr
1045 static ConvertRowtypeExpr *
1046 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
1048 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1050 COPY_NODE_FIELD(arg);
1051 COPY_SCALAR_FIELD(resulttype);
1052 COPY_SCALAR_FIELD(convertformat);
1061 _copyCaseExpr(CaseExpr *from)
1063 CaseExpr *newnode = makeNode(CaseExpr);
1065 COPY_SCALAR_FIELD(casetype);
1066 COPY_NODE_FIELD(arg);
1067 COPY_NODE_FIELD(args);
1068 COPY_NODE_FIELD(defresult);
1077 _copyCaseWhen(CaseWhen *from)
1079 CaseWhen *newnode = makeNode(CaseWhen);
1081 COPY_NODE_FIELD(expr);
1082 COPY_NODE_FIELD(result);
1090 static CaseTestExpr *
1091 _copyCaseTestExpr(CaseTestExpr *from)
1093 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1095 COPY_SCALAR_FIELD(typeId);
1096 COPY_SCALAR_FIELD(typeMod);
1105 _copyArrayExpr(ArrayExpr *from)
1107 ArrayExpr *newnode = makeNode(ArrayExpr);
1109 COPY_SCALAR_FIELD(array_typeid);
1110 COPY_SCALAR_FIELD(element_typeid);
1111 COPY_NODE_FIELD(elements);
1112 COPY_SCALAR_FIELD(multidims);
1121 _copyRowExpr(RowExpr *from)
1123 RowExpr *newnode = makeNode(RowExpr);
1125 COPY_NODE_FIELD(args);
1126 COPY_SCALAR_FIELD(row_typeid);
1127 COPY_SCALAR_FIELD(row_format);
1133 * _copyRowCompareExpr
1135 static RowCompareExpr *
1136 _copyRowCompareExpr(RowCompareExpr *from)
1138 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1140 COPY_SCALAR_FIELD(rctype);
1141 COPY_NODE_FIELD(opnos);
1142 COPY_NODE_FIELD(opfamilies);
1143 COPY_NODE_FIELD(largs);
1144 COPY_NODE_FIELD(rargs);
1152 static CoalesceExpr *
1153 _copyCoalesceExpr(CoalesceExpr *from)
1155 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1157 COPY_SCALAR_FIELD(coalescetype);
1158 COPY_NODE_FIELD(args);
1167 _copyMinMaxExpr(MinMaxExpr *from)
1169 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1171 COPY_SCALAR_FIELD(minmaxtype);
1172 COPY_SCALAR_FIELD(op);
1173 COPY_NODE_FIELD(args);
1182 _copyXmlExpr(XmlExpr *from)
1184 XmlExpr *newnode = makeNode(XmlExpr);
1186 COPY_SCALAR_FIELD(op);
1187 COPY_STRING_FIELD(name);
1188 COPY_NODE_FIELD(named_args);
1189 COPY_NODE_FIELD(arg_names);
1190 COPY_NODE_FIELD(args);
1191 COPY_SCALAR_FIELD(xmloption);
1192 COPY_SCALAR_FIELD(type);
1193 COPY_SCALAR_FIELD(typmod);
1199 * _copyNullIfExpr (same as OpExpr)
1202 _copyNullIfExpr(NullIfExpr *from)
1204 NullIfExpr *newnode = makeNode(NullIfExpr);
1206 COPY_SCALAR_FIELD(opno);
1207 COPY_SCALAR_FIELD(opfuncid);
1208 COPY_SCALAR_FIELD(opresulttype);
1209 COPY_SCALAR_FIELD(opretset);
1210 COPY_NODE_FIELD(args);
1219 _copyNullTest(NullTest *from)
1221 NullTest *newnode = makeNode(NullTest);
1223 COPY_NODE_FIELD(arg);
1224 COPY_SCALAR_FIELD(nulltesttype);
1232 static BooleanTest *
1233 _copyBooleanTest(BooleanTest *from)
1235 BooleanTest *newnode = makeNode(BooleanTest);
1237 COPY_NODE_FIELD(arg);
1238 COPY_SCALAR_FIELD(booltesttype);
1244 * _copyCoerceToDomain
1246 static CoerceToDomain *
1247 _copyCoerceToDomain(CoerceToDomain *from)
1249 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1251 COPY_NODE_FIELD(arg);
1252 COPY_SCALAR_FIELD(resulttype);
1253 COPY_SCALAR_FIELD(resulttypmod);
1254 COPY_SCALAR_FIELD(coercionformat);
1260 * _copyCoerceToDomainValue
1262 static CoerceToDomainValue *
1263 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1265 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1267 COPY_SCALAR_FIELD(typeId);
1268 COPY_SCALAR_FIELD(typeMod);
1276 static SetToDefault *
1277 _copySetToDefault(SetToDefault *from)
1279 SetToDefault *newnode = makeNode(SetToDefault);
1281 COPY_SCALAR_FIELD(typeId);
1282 COPY_SCALAR_FIELD(typeMod);
1290 static TargetEntry *
1291 _copyTargetEntry(TargetEntry *from)
1293 TargetEntry *newnode = makeNode(TargetEntry);
1295 COPY_NODE_FIELD(expr);
1296 COPY_SCALAR_FIELD(resno);
1297 COPY_STRING_FIELD(resname);
1298 COPY_SCALAR_FIELD(ressortgroupref);
1299 COPY_SCALAR_FIELD(resorigtbl);
1300 COPY_SCALAR_FIELD(resorigcol);
1301 COPY_SCALAR_FIELD(resjunk);
1309 static RangeTblRef *
1310 _copyRangeTblRef(RangeTblRef *from)
1312 RangeTblRef *newnode = makeNode(RangeTblRef);
1314 COPY_SCALAR_FIELD(rtindex);
1323 _copyJoinExpr(JoinExpr *from)
1325 JoinExpr *newnode = makeNode(JoinExpr);
1327 COPY_SCALAR_FIELD(jointype);
1328 COPY_SCALAR_FIELD(isNatural);
1329 COPY_NODE_FIELD(larg);
1330 COPY_NODE_FIELD(rarg);
1331 COPY_NODE_FIELD(using);
1332 COPY_NODE_FIELD(quals);
1333 COPY_NODE_FIELD(alias);
1334 COPY_SCALAR_FIELD(rtindex);
1343 _copyFromExpr(FromExpr *from)
1345 FromExpr *newnode = makeNode(FromExpr);
1347 COPY_NODE_FIELD(fromlist);
1348 COPY_NODE_FIELD(quals);
1353 /* ****************************************************************
1354 * relation.h copy functions
1356 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1357 * There are some subsidiary structs that are useful to copy, though.
1358 * ****************************************************************
1365 _copyPathKey(PathKey *from)
1367 PathKey *newnode = makeNode(PathKey);
1369 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1370 COPY_SCALAR_FIELD(pk_eclass);
1371 COPY_SCALAR_FIELD(pk_opfamily);
1372 COPY_SCALAR_FIELD(pk_strategy);
1373 COPY_SCALAR_FIELD(pk_nulls_first);
1381 static RestrictInfo *
1382 _copyRestrictInfo(RestrictInfo *from)
1384 RestrictInfo *newnode = makeNode(RestrictInfo);
1386 COPY_NODE_FIELD(clause);
1387 COPY_SCALAR_FIELD(is_pushed_down);
1388 COPY_SCALAR_FIELD(outerjoin_delayed);
1389 COPY_SCALAR_FIELD(can_join);
1390 COPY_SCALAR_FIELD(pseudoconstant);
1391 COPY_BITMAPSET_FIELD(clause_relids);
1392 COPY_BITMAPSET_FIELD(required_relids);
1393 COPY_BITMAPSET_FIELD(left_relids);
1394 COPY_BITMAPSET_FIELD(right_relids);
1395 COPY_NODE_FIELD(orclause);
1396 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1397 COPY_SCALAR_FIELD(parent_ec);
1398 COPY_SCALAR_FIELD(eval_cost);
1399 COPY_SCALAR_FIELD(this_selec);
1400 COPY_NODE_FIELD(mergeopfamilies);
1401 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1402 COPY_SCALAR_FIELD(left_ec);
1403 COPY_SCALAR_FIELD(right_ec);
1404 COPY_SCALAR_FIELD(left_em);
1405 COPY_SCALAR_FIELD(right_em);
1406 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1407 newnode->scansel_cache = NIL;
1408 COPY_SCALAR_FIELD(outer_is_left);
1409 COPY_SCALAR_FIELD(hashjoinoperator);
1410 COPY_SCALAR_FIELD(left_bucketsize);
1411 COPY_SCALAR_FIELD(right_bucketsize);
1417 * _copyOuterJoinInfo
1419 static OuterJoinInfo *
1420 _copyOuterJoinInfo(OuterJoinInfo *from)
1422 OuterJoinInfo *newnode = makeNode(OuterJoinInfo);
1424 COPY_BITMAPSET_FIELD(min_lefthand);
1425 COPY_BITMAPSET_FIELD(min_righthand);
1426 COPY_SCALAR_FIELD(is_full_join);
1427 COPY_SCALAR_FIELD(lhs_strict);
1428 COPY_SCALAR_FIELD(delay_upper_joins);
1436 static InClauseInfo *
1437 _copyInClauseInfo(InClauseInfo *from)
1439 InClauseInfo *newnode = makeNode(InClauseInfo);
1441 COPY_BITMAPSET_FIELD(lefthand);
1442 COPY_BITMAPSET_FIELD(righthand);
1443 COPY_NODE_FIELD(sub_targetlist);
1444 COPY_NODE_FIELD(in_operators);
1450 * _copyAppendRelInfo
1452 static AppendRelInfo *
1453 _copyAppendRelInfo(AppendRelInfo *from)
1455 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1457 COPY_SCALAR_FIELD(parent_relid);
1458 COPY_SCALAR_FIELD(child_relid);
1459 COPY_SCALAR_FIELD(parent_reltype);
1460 COPY_SCALAR_FIELD(child_reltype);
1461 COPY_NODE_FIELD(col_mappings);
1462 COPY_NODE_FIELD(translated_vars);
1463 COPY_SCALAR_FIELD(parent_reloid);
1468 /* ****************************************************************
1469 * parsenodes.h copy functions
1470 * ****************************************************************
1473 static RangeTblEntry *
1474 _copyRangeTblEntry(RangeTblEntry *from)
1476 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1478 COPY_SCALAR_FIELD(rtekind);
1479 COPY_SCALAR_FIELD(relid);
1480 COPY_NODE_FIELD(subquery);
1481 COPY_NODE_FIELD(funcexpr);
1482 COPY_NODE_FIELD(funccoltypes);
1483 COPY_NODE_FIELD(funccoltypmods);
1484 COPY_NODE_FIELD(values_lists);
1485 COPY_SCALAR_FIELD(jointype);
1486 COPY_NODE_FIELD(joinaliasvars);
1487 COPY_NODE_FIELD(alias);
1488 COPY_NODE_FIELD(eref);
1489 COPY_SCALAR_FIELD(inh);
1490 COPY_SCALAR_FIELD(inFromCl);
1491 COPY_SCALAR_FIELD(requiredPerms);
1492 COPY_SCALAR_FIELD(checkAsUser);
1497 static FkConstraint *
1498 _copyFkConstraint(FkConstraint *from)
1500 FkConstraint *newnode = makeNode(FkConstraint);
1502 COPY_STRING_FIELD(constr_name);
1503 COPY_NODE_FIELD(pktable);
1504 COPY_NODE_FIELD(fk_attrs);
1505 COPY_NODE_FIELD(pk_attrs);
1506 COPY_SCALAR_FIELD(fk_matchtype);
1507 COPY_SCALAR_FIELD(fk_upd_action);
1508 COPY_SCALAR_FIELD(fk_del_action);
1509 COPY_SCALAR_FIELD(deferrable);
1510 COPY_SCALAR_FIELD(initdeferred);
1511 COPY_SCALAR_FIELD(skip_validation);
1517 _copySortClause(SortClause *from)
1519 SortClause *newnode = makeNode(SortClause);
1521 COPY_SCALAR_FIELD(tleSortGroupRef);
1522 COPY_SCALAR_FIELD(sortop);
1523 COPY_SCALAR_FIELD(nulls_first);
1528 static GroupClause *
1529 _copyGroupClause(GroupClause *from)
1531 GroupClause *newnode = makeNode(GroupClause);
1533 COPY_SCALAR_FIELD(tleSortGroupRef);
1534 COPY_SCALAR_FIELD(sortop);
1535 COPY_SCALAR_FIELD(nulls_first);
1540 static RowMarkClause *
1541 _copyRowMarkClause(RowMarkClause *from)
1543 RowMarkClause *newnode = makeNode(RowMarkClause);
1545 COPY_SCALAR_FIELD(rti);
1546 COPY_SCALAR_FIELD(forUpdate);
1547 COPY_SCALAR_FIELD(noWait);
1553 _copyAExpr(A_Expr *from)
1555 A_Expr *newnode = makeNode(A_Expr);
1557 COPY_SCALAR_FIELD(kind);
1558 COPY_NODE_FIELD(name);
1559 COPY_NODE_FIELD(lexpr);
1560 COPY_NODE_FIELD(rexpr);
1561 COPY_SCALAR_FIELD(location);
1567 _copyColumnRef(ColumnRef *from)
1569 ColumnRef *newnode = makeNode(ColumnRef);
1571 COPY_NODE_FIELD(fields);
1572 COPY_SCALAR_FIELD(location);
1578 _copyParamRef(ParamRef *from)
1580 ParamRef *newnode = makeNode(ParamRef);
1582 COPY_SCALAR_FIELD(number);
1588 _copyAConst(A_Const *from)
1590 A_Const *newnode = makeNode(A_Const);
1592 /* This part must duplicate _copyValue */
1593 COPY_SCALAR_FIELD(val.type);
1594 switch (from->val.type)
1597 COPY_SCALAR_FIELD(val.val.ival);
1602 COPY_STRING_FIELD(val.val.str);
1608 elog(ERROR, "unrecognized node type: %d",
1609 (int) from->val.type);
1613 COPY_NODE_FIELD(typename);
1619 _copyFuncCall(FuncCall *from)
1621 FuncCall *newnode = makeNode(FuncCall);
1623 COPY_NODE_FIELD(funcname);
1624 COPY_NODE_FIELD(args);
1625 COPY_SCALAR_FIELD(agg_star);
1626 COPY_SCALAR_FIELD(agg_distinct);
1627 COPY_SCALAR_FIELD(location);
1633 _copyAIndices(A_Indices *from)
1635 A_Indices *newnode = makeNode(A_Indices);
1637 COPY_NODE_FIELD(lidx);
1638 COPY_NODE_FIELD(uidx);
1643 static A_Indirection *
1644 _copyA_Indirection(A_Indirection *from)
1646 A_Indirection *newnode = makeNode(A_Indirection);
1648 COPY_NODE_FIELD(arg);
1649 COPY_NODE_FIELD(indirection);
1655 _copyResTarget(ResTarget *from)
1657 ResTarget *newnode = makeNode(ResTarget);
1659 COPY_STRING_FIELD(name);
1660 COPY_NODE_FIELD(indirection);
1661 COPY_NODE_FIELD(val);
1662 COPY_SCALAR_FIELD(location);
1668 _copyTypeName(TypeName *from)
1670 TypeName *newnode = makeNode(TypeName);
1672 COPY_NODE_FIELD(names);
1673 COPY_SCALAR_FIELD(typeid);
1674 COPY_SCALAR_FIELD(timezone);
1675 COPY_SCALAR_FIELD(setof);
1676 COPY_SCALAR_FIELD(pct_type);
1677 COPY_NODE_FIELD(typmods);
1678 COPY_SCALAR_FIELD(typemod);
1679 COPY_NODE_FIELD(arrayBounds);
1680 COPY_SCALAR_FIELD(location);
1686 _copySortBy(SortBy *from)
1688 SortBy *newnode = makeNode(SortBy);
1690 COPY_SCALAR_FIELD(sortby_dir);
1691 COPY_SCALAR_FIELD(sortby_nulls);
1692 COPY_NODE_FIELD(useOp);
1693 COPY_NODE_FIELD(node);
1698 static RangeSubselect *
1699 _copyRangeSubselect(RangeSubselect *from)
1701 RangeSubselect *newnode = makeNode(RangeSubselect);
1703 COPY_NODE_FIELD(subquery);
1704 COPY_NODE_FIELD(alias);
1709 static RangeFunction *
1710 _copyRangeFunction(RangeFunction *from)
1712 RangeFunction *newnode = makeNode(RangeFunction);
1714 COPY_NODE_FIELD(funccallnode);
1715 COPY_NODE_FIELD(alias);
1716 COPY_NODE_FIELD(coldeflist);
1722 _copyTypeCast(TypeCast *from)
1724 TypeCast *newnode = makeNode(TypeCast);
1726 COPY_NODE_FIELD(arg);
1727 COPY_NODE_FIELD(typename);
1733 _copyIndexElem(IndexElem *from)
1735 IndexElem *newnode = makeNode(IndexElem);
1737 COPY_STRING_FIELD(name);
1738 COPY_NODE_FIELD(expr);
1739 COPY_NODE_FIELD(opclass);
1740 COPY_SCALAR_FIELD(ordering);
1741 COPY_SCALAR_FIELD(nulls_ordering);
1747 _copyColumnDef(ColumnDef *from)
1749 ColumnDef *newnode = makeNode(ColumnDef);
1751 COPY_STRING_FIELD(colname);
1752 COPY_NODE_FIELD(typename);
1753 COPY_SCALAR_FIELD(inhcount);
1754 COPY_SCALAR_FIELD(is_local);
1755 COPY_SCALAR_FIELD(is_not_null);
1756 COPY_NODE_FIELD(raw_default);
1757 COPY_STRING_FIELD(cooked_default);
1758 COPY_NODE_FIELD(constraints);
1764 _copyConstraint(Constraint *from)
1766 Constraint *newnode = makeNode(Constraint);
1768 COPY_SCALAR_FIELD(contype);
1769 COPY_STRING_FIELD(name);
1770 COPY_NODE_FIELD(raw_expr);
1771 COPY_STRING_FIELD(cooked_expr);
1772 COPY_NODE_FIELD(keys);
1773 COPY_NODE_FIELD(options);
1774 COPY_STRING_FIELD(indexspace);
1780 _copyDefElem(DefElem *from)
1782 DefElem *newnode = makeNode(DefElem);
1784 COPY_STRING_FIELD(defname);
1785 COPY_NODE_FIELD(arg);
1790 static LockingClause *
1791 _copyLockingClause(LockingClause *from)
1793 LockingClause *newnode = makeNode(LockingClause);
1795 COPY_NODE_FIELD(lockedRels);
1796 COPY_SCALAR_FIELD(forUpdate);
1797 COPY_SCALAR_FIELD(noWait);
1802 static XmlSerialize *
1803 _copyXmlSerialize(XmlSerialize *from)
1805 XmlSerialize *newnode = makeNode(XmlSerialize);
1807 COPY_SCALAR_FIELD(xmloption);
1808 COPY_NODE_FIELD(expr);
1809 COPY_NODE_FIELD(typename);
1815 _copyQuery(Query *from)
1817 Query *newnode = makeNode(Query);
1819 COPY_SCALAR_FIELD(commandType);
1820 COPY_SCALAR_FIELD(querySource);
1821 COPY_SCALAR_FIELD(canSetTag);
1822 COPY_NODE_FIELD(utilityStmt);
1823 COPY_SCALAR_FIELD(resultRelation);
1824 COPY_NODE_FIELD(intoClause);
1825 COPY_SCALAR_FIELD(hasAggs);
1826 COPY_SCALAR_FIELD(hasSubLinks);
1827 COPY_NODE_FIELD(rtable);
1828 COPY_NODE_FIELD(jointree);
1829 COPY_NODE_FIELD(targetList);
1830 COPY_NODE_FIELD(returningList);
1831 COPY_NODE_FIELD(groupClause);
1832 COPY_NODE_FIELD(havingQual);
1833 COPY_NODE_FIELD(distinctClause);
1834 COPY_NODE_FIELD(sortClause);
1835 COPY_NODE_FIELD(limitOffset);
1836 COPY_NODE_FIELD(limitCount);
1837 COPY_NODE_FIELD(rowMarks);
1838 COPY_NODE_FIELD(setOperations);
1844 _copyInsertStmt(InsertStmt *from)
1846 InsertStmt *newnode = makeNode(InsertStmt);
1848 COPY_NODE_FIELD(relation);
1849 COPY_NODE_FIELD(cols);
1850 COPY_NODE_FIELD(selectStmt);
1851 COPY_NODE_FIELD(returningList);
1857 _copyDeleteStmt(DeleteStmt *from)
1859 DeleteStmt *newnode = makeNode(DeleteStmt);
1861 COPY_NODE_FIELD(relation);
1862 COPY_NODE_FIELD(usingClause);
1863 COPY_NODE_FIELD(whereClause);
1864 COPY_NODE_FIELD(returningList);
1870 _copyUpdateStmt(UpdateStmt *from)
1872 UpdateStmt *newnode = makeNode(UpdateStmt);
1874 COPY_NODE_FIELD(relation);
1875 COPY_NODE_FIELD(targetList);
1876 COPY_NODE_FIELD(whereClause);
1877 COPY_NODE_FIELD(fromClause);
1878 COPY_NODE_FIELD(returningList);
1884 _copySelectStmt(SelectStmt *from)
1886 SelectStmt *newnode = makeNode(SelectStmt);
1888 COPY_NODE_FIELD(distinctClause);
1889 COPY_NODE_FIELD(intoClause);
1890 COPY_NODE_FIELD(targetList);
1891 COPY_NODE_FIELD(fromClause);
1892 COPY_NODE_FIELD(whereClause);
1893 COPY_NODE_FIELD(groupClause);
1894 COPY_NODE_FIELD(havingClause);
1895 COPY_NODE_FIELD(valuesLists);
1896 COPY_NODE_FIELD(sortClause);
1897 COPY_NODE_FIELD(limitOffset);
1898 COPY_NODE_FIELD(limitCount);
1899 COPY_NODE_FIELD(lockingClause);
1900 COPY_SCALAR_FIELD(op);
1901 COPY_SCALAR_FIELD(all);
1902 COPY_NODE_FIELD(larg);
1903 COPY_NODE_FIELD(rarg);
1908 static SetOperationStmt *
1909 _copySetOperationStmt(SetOperationStmt *from)
1911 SetOperationStmt *newnode = makeNode(SetOperationStmt);
1913 COPY_SCALAR_FIELD(op);
1914 COPY_SCALAR_FIELD(all);
1915 COPY_NODE_FIELD(larg);
1916 COPY_NODE_FIELD(rarg);
1917 COPY_NODE_FIELD(colTypes);
1918 COPY_NODE_FIELD(colTypmods);
1923 static AlterTableStmt *
1924 _copyAlterTableStmt(AlterTableStmt *from)
1926 AlterTableStmt *newnode = makeNode(AlterTableStmt);
1928 COPY_NODE_FIELD(relation);
1929 COPY_NODE_FIELD(cmds);
1930 COPY_SCALAR_FIELD(relkind);
1935 static AlterTableCmd *
1936 _copyAlterTableCmd(AlterTableCmd *from)
1938 AlterTableCmd *newnode = makeNode(AlterTableCmd);
1940 COPY_SCALAR_FIELD(subtype);
1941 COPY_STRING_FIELD(name);
1942 COPY_NODE_FIELD(def);
1943 COPY_NODE_FIELD(transform);
1944 COPY_SCALAR_FIELD(behavior);
1949 static AlterDomainStmt *
1950 _copyAlterDomainStmt(AlterDomainStmt *from)
1952 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
1954 COPY_SCALAR_FIELD(subtype);
1955 COPY_NODE_FIELD(typename);
1956 COPY_STRING_FIELD(name);
1957 COPY_NODE_FIELD(def);
1958 COPY_SCALAR_FIELD(behavior);
1964 _copyGrantStmt(GrantStmt *from)
1966 GrantStmt *newnode = makeNode(GrantStmt);
1968 COPY_SCALAR_FIELD(is_grant);
1969 COPY_SCALAR_FIELD(objtype);
1970 COPY_NODE_FIELD(objects);
1971 COPY_NODE_FIELD(privileges);
1972 COPY_NODE_FIELD(grantees);
1973 COPY_SCALAR_FIELD(grant_option);
1974 COPY_SCALAR_FIELD(behavior);
1979 static PrivGrantee *
1980 _copyPrivGrantee(PrivGrantee *from)
1982 PrivGrantee *newnode = makeNode(PrivGrantee);
1984 COPY_STRING_FIELD(rolname);
1989 static FuncWithArgs *
1990 _copyFuncWithArgs(FuncWithArgs *from)
1992 FuncWithArgs *newnode = makeNode(FuncWithArgs);
1994 COPY_NODE_FIELD(funcname);
1995 COPY_NODE_FIELD(funcargs);
2000 static GrantRoleStmt *
2001 _copyGrantRoleStmt(GrantRoleStmt *from)
2003 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2005 COPY_NODE_FIELD(granted_roles);
2006 COPY_NODE_FIELD(grantee_roles);
2007 COPY_SCALAR_FIELD(is_grant);
2008 COPY_SCALAR_FIELD(admin_opt);
2009 COPY_STRING_FIELD(grantor);
2010 COPY_SCALAR_FIELD(behavior);
2015 static DeclareCursorStmt *
2016 _copyDeclareCursorStmt(DeclareCursorStmt *from)
2018 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2020 COPY_STRING_FIELD(portalname);
2021 COPY_SCALAR_FIELD(options);
2022 COPY_NODE_FIELD(query);
2027 static ClosePortalStmt *
2028 _copyClosePortalStmt(ClosePortalStmt *from)
2030 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2032 COPY_STRING_FIELD(portalname);
2037 static ClusterStmt *
2038 _copyClusterStmt(ClusterStmt *from)
2040 ClusterStmt *newnode = makeNode(ClusterStmt);
2042 COPY_NODE_FIELD(relation);
2043 COPY_STRING_FIELD(indexname);
2049 _copyCopyStmt(CopyStmt *from)
2051 CopyStmt *newnode = makeNode(CopyStmt);
2053 COPY_NODE_FIELD(relation);
2054 COPY_NODE_FIELD(query);
2055 COPY_NODE_FIELD(attlist);
2056 COPY_SCALAR_FIELD(is_from);
2057 COPY_STRING_FIELD(filename);
2058 COPY_NODE_FIELD(options);
2064 _copyCreateStmt(CreateStmt *from)
2066 CreateStmt *newnode = makeNode(CreateStmt);
2068 COPY_NODE_FIELD(relation);
2069 COPY_NODE_FIELD(tableElts);
2070 COPY_NODE_FIELD(inhRelations);
2071 COPY_NODE_FIELD(constraints);
2072 COPY_NODE_FIELD(options);
2073 COPY_SCALAR_FIELD(oncommit);
2074 COPY_STRING_FIELD(tablespacename);
2079 static InhRelation *
2080 _copyInhRelation(InhRelation *from)
2082 InhRelation *newnode = makeNode(InhRelation);
2084 COPY_NODE_FIELD(relation);
2085 COPY_NODE_FIELD(options);
2091 _copyDefineStmt(DefineStmt *from)
2093 DefineStmt *newnode = makeNode(DefineStmt);
2095 COPY_SCALAR_FIELD(kind);
2096 COPY_SCALAR_FIELD(oldstyle);
2097 COPY_NODE_FIELD(defnames);
2098 COPY_NODE_FIELD(args);
2099 COPY_NODE_FIELD(definition);
2105 _copyDropStmt(DropStmt *from)
2107 DropStmt *newnode = makeNode(DropStmt);
2109 COPY_NODE_FIELD(objects);
2110 COPY_SCALAR_FIELD(removeType);
2111 COPY_SCALAR_FIELD(behavior);
2112 COPY_SCALAR_FIELD(missing_ok);
2117 static TruncateStmt *
2118 _copyTruncateStmt(TruncateStmt *from)
2120 TruncateStmt *newnode = makeNode(TruncateStmt);
2122 COPY_NODE_FIELD(relations);
2123 COPY_SCALAR_FIELD(behavior);
2128 static CommentStmt *
2129 _copyCommentStmt(CommentStmt *from)
2131 CommentStmt *newnode = makeNode(CommentStmt);
2133 COPY_SCALAR_FIELD(objtype);
2134 COPY_NODE_FIELD(objname);
2135 COPY_NODE_FIELD(objargs);
2136 COPY_STRING_FIELD(comment);
2142 _copyFetchStmt(FetchStmt *from)
2144 FetchStmt *newnode = makeNode(FetchStmt);
2146 COPY_SCALAR_FIELD(direction);
2147 COPY_SCALAR_FIELD(howMany);
2148 COPY_STRING_FIELD(portalname);
2149 COPY_SCALAR_FIELD(ismove);
2155 _copyIndexStmt(IndexStmt *from)
2157 IndexStmt *newnode = makeNode(IndexStmt);
2159 COPY_STRING_FIELD(idxname);
2160 COPY_NODE_FIELD(relation);
2161 COPY_STRING_FIELD(accessMethod);
2162 COPY_STRING_FIELD(tableSpace);
2163 COPY_NODE_FIELD(indexParams);
2164 COPY_NODE_FIELD(options);
2165 COPY_NODE_FIELD(whereClause);
2166 COPY_SCALAR_FIELD(unique);
2167 COPY_SCALAR_FIELD(primary);
2168 COPY_SCALAR_FIELD(isconstraint);
2169 COPY_SCALAR_FIELD(concurrent);
2174 static CreateFunctionStmt *
2175 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2177 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2179 COPY_SCALAR_FIELD(replace);
2180 COPY_NODE_FIELD(funcname);
2181 COPY_NODE_FIELD(parameters);
2182 COPY_NODE_FIELD(returnType);
2183 COPY_NODE_FIELD(options);
2184 COPY_NODE_FIELD(withClause);
2189 static FunctionParameter *
2190 _copyFunctionParameter(FunctionParameter *from)
2192 FunctionParameter *newnode = makeNode(FunctionParameter);
2194 COPY_STRING_FIELD(name);
2195 COPY_NODE_FIELD(argType);
2196 COPY_SCALAR_FIELD(mode);
2201 static AlterFunctionStmt *
2202 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2204 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2206 COPY_NODE_FIELD(func);
2207 COPY_NODE_FIELD(actions);
2212 static RemoveFuncStmt *
2213 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2215 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2217 COPY_SCALAR_FIELD(kind);
2218 COPY_NODE_FIELD(name);
2219 COPY_NODE_FIELD(args);
2220 COPY_SCALAR_FIELD(behavior);
2221 COPY_SCALAR_FIELD(missing_ok);
2226 static RemoveOpClassStmt *
2227 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2229 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2231 COPY_NODE_FIELD(opclassname);
2232 COPY_STRING_FIELD(amname);
2233 COPY_SCALAR_FIELD(behavior);
2234 COPY_SCALAR_FIELD(missing_ok);
2239 static RemoveOpFamilyStmt *
2240 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2242 RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2244 COPY_NODE_FIELD(opfamilyname);
2245 COPY_STRING_FIELD(amname);
2246 COPY_SCALAR_FIELD(behavior);
2247 COPY_SCALAR_FIELD(missing_ok);
2253 _copyRenameStmt(RenameStmt *from)
2255 RenameStmt *newnode = makeNode(RenameStmt);
2257 COPY_SCALAR_FIELD(renameType);
2258 COPY_NODE_FIELD(relation);
2259 COPY_NODE_FIELD(object);
2260 COPY_NODE_FIELD(objarg);
2261 COPY_STRING_FIELD(subname);
2262 COPY_STRING_FIELD(newname);
2267 static AlterObjectSchemaStmt *
2268 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2270 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2272 COPY_SCALAR_FIELD(objectType);
2273 COPY_NODE_FIELD(relation);
2274 COPY_NODE_FIELD(object);
2275 COPY_NODE_FIELD(objarg);
2276 COPY_STRING_FIELD(addname);
2277 COPY_STRING_FIELD(newschema);
2282 static AlterOwnerStmt *
2283 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2285 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2287 COPY_SCALAR_FIELD(objectType);
2288 COPY_NODE_FIELD(relation);
2289 COPY_NODE_FIELD(object);
2290 COPY_NODE_FIELD(objarg);
2291 COPY_STRING_FIELD(addname);
2292 COPY_STRING_FIELD(newowner);
2298 _copyRuleStmt(RuleStmt *from)
2300 RuleStmt *newnode = makeNode(RuleStmt);
2302 COPY_NODE_FIELD(relation);
2303 COPY_STRING_FIELD(rulename);
2304 COPY_NODE_FIELD(whereClause);
2305 COPY_SCALAR_FIELD(event);
2306 COPY_SCALAR_FIELD(instead);
2307 COPY_NODE_FIELD(actions);
2308 COPY_SCALAR_FIELD(replace);
2314 _copyNotifyStmt(NotifyStmt *from)
2316 NotifyStmt *newnode = makeNode(NotifyStmt);
2318 COPY_NODE_FIELD(relation);
2324 _copyListenStmt(ListenStmt *from)
2326 ListenStmt *newnode = makeNode(ListenStmt);
2328 COPY_NODE_FIELD(relation);
2333 static UnlistenStmt *
2334 _copyUnlistenStmt(UnlistenStmt *from)
2336 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2338 COPY_NODE_FIELD(relation);
2343 static TransactionStmt *
2344 _copyTransactionStmt(TransactionStmt *from)
2346 TransactionStmt *newnode = makeNode(TransactionStmt);
2348 COPY_SCALAR_FIELD(kind);
2349 COPY_NODE_FIELD(options);
2350 COPY_STRING_FIELD(gid);
2355 static CompositeTypeStmt *
2356 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2358 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2360 COPY_NODE_FIELD(typevar);
2361 COPY_NODE_FIELD(coldeflist);
2366 static CreateEnumStmt *
2367 _copyCreateEnumStmt(CreateEnumStmt *from)
2369 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
2371 COPY_NODE_FIELD(typename);
2372 COPY_NODE_FIELD(vals);
2378 _copyViewStmt(ViewStmt *from)
2380 ViewStmt *newnode = makeNode(ViewStmt);
2382 COPY_NODE_FIELD(view);
2383 COPY_NODE_FIELD(aliases);
2384 COPY_NODE_FIELD(query);
2385 COPY_SCALAR_FIELD(replace);
2391 _copyLoadStmt(LoadStmt *from)
2393 LoadStmt *newnode = makeNode(LoadStmt);
2395 COPY_STRING_FIELD(filename);
2400 static CreateDomainStmt *
2401 _copyCreateDomainStmt(CreateDomainStmt *from)
2403 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2405 COPY_NODE_FIELD(domainname);
2406 COPY_NODE_FIELD(typename);
2407 COPY_NODE_FIELD(constraints);
2412 static CreateOpClassStmt *
2413 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2415 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2417 COPY_NODE_FIELD(opclassname);
2418 COPY_NODE_FIELD(opfamilyname);
2419 COPY_STRING_FIELD(amname);
2420 COPY_NODE_FIELD(datatype);
2421 COPY_NODE_FIELD(items);
2422 COPY_SCALAR_FIELD(isDefault);
2427 static CreateOpClassItem *
2428 _copyCreateOpClassItem(CreateOpClassItem *from)
2430 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2432 COPY_SCALAR_FIELD(itemtype);
2433 COPY_NODE_FIELD(name);
2434 COPY_NODE_FIELD(args);
2435 COPY_SCALAR_FIELD(number);
2436 COPY_SCALAR_FIELD(recheck);
2437 COPY_NODE_FIELD(class_args);
2438 COPY_NODE_FIELD(storedtype);
2443 static CreateOpFamilyStmt *
2444 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
2446 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
2448 COPY_NODE_FIELD(opfamilyname);
2449 COPY_STRING_FIELD(amname);
2454 static AlterOpFamilyStmt *
2455 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
2457 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
2459 COPY_NODE_FIELD(opfamilyname);
2460 COPY_STRING_FIELD(amname);
2461 COPY_SCALAR_FIELD(isDrop);
2462 COPY_NODE_FIELD(items);
2467 static CreatedbStmt *
2468 _copyCreatedbStmt(CreatedbStmt *from)
2470 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2472 COPY_STRING_FIELD(dbname);
2473 COPY_NODE_FIELD(options);
2478 static AlterDatabaseStmt *
2479 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2481 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2483 COPY_STRING_FIELD(dbname);
2484 COPY_NODE_FIELD(options);
2489 static AlterDatabaseSetStmt *
2490 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2492 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2494 COPY_STRING_FIELD(dbname);
2495 COPY_STRING_FIELD(variable);
2496 COPY_NODE_FIELD(value);
2502 _copyDropdbStmt(DropdbStmt *from)
2504 DropdbStmt *newnode = makeNode(DropdbStmt);
2506 COPY_STRING_FIELD(dbname);
2507 COPY_SCALAR_FIELD(missing_ok);
2513 _copyVacuumStmt(VacuumStmt *from)
2515 VacuumStmt *newnode = makeNode(VacuumStmt);
2517 COPY_SCALAR_FIELD(vacuum);
2518 COPY_SCALAR_FIELD(full);
2519 COPY_SCALAR_FIELD(analyze);
2520 COPY_SCALAR_FIELD(verbose);
2521 COPY_SCALAR_FIELD(freeze_min_age);
2522 COPY_NODE_FIELD(relation);
2523 COPY_NODE_FIELD(va_cols);
2528 static ExplainStmt *
2529 _copyExplainStmt(ExplainStmt *from)
2531 ExplainStmt *newnode = makeNode(ExplainStmt);
2533 COPY_NODE_FIELD(query);
2534 COPY_SCALAR_FIELD(verbose);
2535 COPY_SCALAR_FIELD(analyze);
2540 static CreateSeqStmt *
2541 _copyCreateSeqStmt(CreateSeqStmt *from)
2543 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2545 COPY_NODE_FIELD(sequence);
2546 COPY_NODE_FIELD(options);
2551 static AlterSeqStmt *
2552 _copyAlterSeqStmt(AlterSeqStmt *from)
2554 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2556 COPY_NODE_FIELD(sequence);
2557 COPY_NODE_FIELD(options);
2562 static VariableSetStmt *
2563 _copyVariableSetStmt(VariableSetStmt *from)
2565 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2567 COPY_STRING_FIELD(name);
2568 COPY_NODE_FIELD(args);
2569 COPY_SCALAR_FIELD(is_local);
2574 static VariableShowStmt *
2575 _copyVariableShowStmt(VariableShowStmt *from)
2577 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2579 COPY_STRING_FIELD(name);
2584 static VariableResetStmt *
2585 _copyVariableResetStmt(VariableResetStmt *from)
2587 VariableResetStmt *newnode = makeNode(VariableResetStmt);
2589 COPY_STRING_FIELD(name);
2594 static DiscardStmt *
2595 _copyDiscardStmt(DiscardStmt *from)
2597 DiscardStmt *newnode = makeNode(DiscardStmt);
2599 COPY_SCALAR_FIELD(target);
2604 static CreateTableSpaceStmt *
2605 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2607 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2609 COPY_STRING_FIELD(tablespacename);
2610 COPY_STRING_FIELD(owner);
2611 COPY_STRING_FIELD(location);
2616 static DropTableSpaceStmt *
2617 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2619 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2621 COPY_STRING_FIELD(tablespacename);
2622 COPY_SCALAR_FIELD(missing_ok);
2627 static CreateTrigStmt *
2628 _copyCreateTrigStmt(CreateTrigStmt *from)
2630 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2632 COPY_STRING_FIELD(trigname);
2633 COPY_NODE_FIELD(relation);
2634 COPY_NODE_FIELD(funcname);
2635 COPY_NODE_FIELD(args);
2636 COPY_SCALAR_FIELD(before);
2637 COPY_SCALAR_FIELD(row);
2638 strcpy(newnode->actions, from->actions); /* in-line string field */
2639 COPY_SCALAR_FIELD(isconstraint);
2640 COPY_SCALAR_FIELD(deferrable);
2641 COPY_SCALAR_FIELD(initdeferred);
2642 COPY_NODE_FIELD(constrrel);
2647 static DropPropertyStmt *
2648 _copyDropPropertyStmt(DropPropertyStmt *from)
2650 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2652 COPY_NODE_FIELD(relation);
2653 COPY_STRING_FIELD(property);
2654 COPY_SCALAR_FIELD(removeType);
2655 COPY_SCALAR_FIELD(behavior);
2656 COPY_SCALAR_FIELD(missing_ok);
2661 static CreatePLangStmt *
2662 _copyCreatePLangStmt(CreatePLangStmt *from)
2664 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2666 COPY_STRING_FIELD(plname);
2667 COPY_NODE_FIELD(plhandler);
2668 COPY_NODE_FIELD(plvalidator);
2669 COPY_SCALAR_FIELD(pltrusted);
2674 static DropPLangStmt *
2675 _copyDropPLangStmt(DropPLangStmt *from)
2677 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2679 COPY_STRING_FIELD(plname);
2680 COPY_SCALAR_FIELD(behavior);
2681 COPY_SCALAR_FIELD(missing_ok);
2686 static CreateRoleStmt *
2687 _copyCreateRoleStmt(CreateRoleStmt *from)
2689 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2691 COPY_SCALAR_FIELD(stmt_type);
2692 COPY_STRING_FIELD(role);
2693 COPY_NODE_FIELD(options);
2698 static AlterRoleStmt *
2699 _copyAlterRoleStmt(AlterRoleStmt *from)
2701 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2703 COPY_STRING_FIELD(role);
2704 COPY_NODE_FIELD(options);
2705 COPY_SCALAR_FIELD(action);
2710 static AlterRoleSetStmt *
2711 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2713 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2715 COPY_STRING_FIELD(role);
2716 COPY_STRING_FIELD(variable);
2717 COPY_NODE_FIELD(value);
2722 static DropRoleStmt *
2723 _copyDropRoleStmt(DropRoleStmt *from)
2725 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2727 COPY_NODE_FIELD(roles);
2728 COPY_SCALAR_FIELD(missing_ok);
2734 _copyLockStmt(LockStmt *from)
2736 LockStmt *newnode = makeNode(LockStmt);
2738 COPY_NODE_FIELD(relations);
2739 COPY_SCALAR_FIELD(mode);
2740 COPY_SCALAR_FIELD(nowait);
2745 static ConstraintsSetStmt *
2746 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2748 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2750 COPY_NODE_FIELD(constraints);
2751 COPY_SCALAR_FIELD(deferred);
2756 static ReindexStmt *
2757 _copyReindexStmt(ReindexStmt *from)
2759 ReindexStmt *newnode = makeNode(ReindexStmt);
2761 COPY_SCALAR_FIELD(kind);
2762 COPY_NODE_FIELD(relation);
2763 COPY_STRING_FIELD(name);
2764 COPY_SCALAR_FIELD(do_system);
2765 COPY_SCALAR_FIELD(do_user);
2770 static CreateSchemaStmt *
2771 _copyCreateSchemaStmt(CreateSchemaStmt *from)
2773 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
2775 COPY_STRING_FIELD(schemaname);
2776 COPY_STRING_FIELD(authid);
2777 COPY_NODE_FIELD(schemaElts);
2782 static CreateConversionStmt *
2783 _copyCreateConversionStmt(CreateConversionStmt *from)
2785 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
2787 COPY_NODE_FIELD(conversion_name);
2788 COPY_STRING_FIELD(for_encoding_name);
2789 COPY_STRING_FIELD(to_encoding_name);
2790 COPY_NODE_FIELD(func_name);
2791 COPY_SCALAR_FIELD(def);
2796 static CreateCastStmt *
2797 _copyCreateCastStmt(CreateCastStmt *from)
2799 CreateCastStmt *newnode = makeNode(CreateCastStmt);
2801 COPY_NODE_FIELD(sourcetype);
2802 COPY_NODE_FIELD(targettype);
2803 COPY_NODE_FIELD(func);
2804 COPY_SCALAR_FIELD(context);
2809 static DropCastStmt *
2810 _copyDropCastStmt(DropCastStmt *from)
2812 DropCastStmt *newnode = makeNode(DropCastStmt);
2814 COPY_NODE_FIELD(sourcetype);
2815 COPY_NODE_FIELD(targettype);
2816 COPY_SCALAR_FIELD(behavior);
2817 COPY_SCALAR_FIELD(missing_ok);
2822 static PrepareStmt *
2823 _copyPrepareStmt(PrepareStmt *from)
2825 PrepareStmt *newnode = makeNode(PrepareStmt);
2827 COPY_STRING_FIELD(name);
2828 COPY_NODE_FIELD(argtypes);
2829 COPY_NODE_FIELD(query);
2834 static ExecuteStmt *
2835 _copyExecuteStmt(ExecuteStmt *from)
2837 ExecuteStmt *newnode = makeNode(ExecuteStmt);
2839 COPY_STRING_FIELD(name);
2840 COPY_NODE_FIELD(into);
2841 COPY_NODE_FIELD(params);
2846 static DeallocateStmt *
2847 _copyDeallocateStmt(DeallocateStmt *from)
2849 DeallocateStmt *newnode = makeNode(DeallocateStmt);
2851 COPY_STRING_FIELD(name);
2856 static DropOwnedStmt *
2857 _copyDropOwnedStmt(DropOwnedStmt *from)
2859 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
2861 COPY_NODE_FIELD(roles);
2862 COPY_SCALAR_FIELD(behavior);
2867 static ReassignOwnedStmt *
2868 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
2870 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
2872 COPY_NODE_FIELD(roles);
2873 COPY_SCALAR_FIELD(newrole);
2878 /* ****************************************************************
2879 * pg_list.h copy functions
2880 * ****************************************************************
2884 * Perform a deep copy of the specified list, using copyObject(). The
2885 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
2886 * need deep copies, so they should be copied via list_copy()
2888 #define COPY_NODE_CELL(new, old) \
2889 (new) = (ListCell *) palloc(sizeof(ListCell)); \
2890 lfirst(new) = copyObject(lfirst(old));
2893 _copyList(List *from)
2899 Assert(list_length(from) >= 1);
2901 new = makeNode(List);
2902 new->length = from->length;
2904 COPY_NODE_CELL(new->head, from->head);
2905 prev_new = new->head;
2906 curr_old = lnext(from->head);
2910 COPY_NODE_CELL(prev_new->next, curr_old);
2911 prev_new = prev_new->next;
2912 curr_old = curr_old->next;
2914 prev_new->next = NULL;
2915 new->tail = prev_new;
2920 /* ****************************************************************
2921 * value.h copy functions
2922 * ****************************************************************
2925 _copyValue(Value *from)
2927 Value *newnode = makeNode(Value);
2929 /* See also _copyAConst when changing this code! */
2931 COPY_SCALAR_FIELD(type);
2935 COPY_SCALAR_FIELD(val.ival);
2940 COPY_STRING_FIELD(val.str);
2946 elog(ERROR, "unrecognized node type: %d",
2956 * Create a copy of a Node tree or list. This is a "deep" copy: all
2957 * substructure is copied too, recursively.
2960 copyObject(void *from)
2967 switch (nodeTag(from))
2973 retval = _copyPlannedStmt(from);
2976 retval = _copyPlan(from);
2979 retval = _copyResult(from);
2982 retval = _copyAppend(from);
2985 retval = _copyBitmapAnd(from);
2988 retval = _copyBitmapOr(from);
2991 retval = _copyScan(from);
2994 retval = _copySeqScan(from);
2997 retval = _copyIndexScan(from);
2999 case T_BitmapIndexScan:
3000 retval = _copyBitmapIndexScan(from);
3002 case T_BitmapHeapScan:
3003 retval = _copyBitmapHeapScan(from);
3006 retval = _copyTidScan(from);
3008 case T_SubqueryScan:
3009 retval = _copySubqueryScan(from);
3011 case T_FunctionScan:
3012 retval = _copyFunctionScan(from);
3015 retval = _copyValuesScan(from);
3018 retval = _copyJoin(from);
3021 retval = _copyNestLoop(from);
3024 retval = _copyMergeJoin(from);
3027 retval = _copyHashJoin(from);
3030 retval = _copyMaterial(from);
3033 retval = _copySort(from);
3036 retval = _copyGroup(from);
3039 retval = _copyAgg(from);
3042 retval = _copyUnique(from);
3045 retval = _copyHash(from);
3048 retval = _copySetOp(from);
3051 retval = _copyLimit(from);
3058 retval = _copyAlias(from);
3061 retval = _copyRangeVar(from);
3064 retval = _copyIntoClause(from);
3067 retval = _copyVar(from);
3070 retval = _copyConst(from);
3073 retval = _copyParam(from);
3076 retval = _copyAggref(from);
3079 retval = _copyArrayRef(from);
3082 retval = _copyFuncExpr(from);
3085 retval = _copyOpExpr(from);
3087 case T_DistinctExpr:
3088 retval = _copyDistinctExpr(from);
3090 case T_ScalarArrayOpExpr:
3091 retval = _copyScalarArrayOpExpr(from);
3094 retval = _copyBoolExpr(from);
3097 retval = _copySubLink(from);
3100 retval = _copySubPlan(from);
3103 retval = _copyFieldSelect(from);
3106 retval = _copyFieldStore(from);
3109 retval = _copyRelabelType(from);
3111 case T_ArrayCoerceExpr:
3112 retval = _copyArrayCoerceExpr(from);
3114 case T_ConvertRowtypeExpr:
3115 retval = _copyConvertRowtypeExpr(from);
3118 retval = _copyCaseExpr(from);
3121 retval = _copyCaseWhen(from);
3123 case T_CaseTestExpr:
3124 retval = _copyCaseTestExpr(from);
3127 retval = _copyArrayExpr(from);
3130 retval = _copyRowExpr(from);
3132 case T_RowCompareExpr:
3133 retval = _copyRowCompareExpr(from);
3135 case T_CoalesceExpr:
3136 retval = _copyCoalesceExpr(from);
3139 retval = _copyMinMaxExpr(from);
3142 retval = _copyXmlExpr(from);
3145 retval = _copyNullIfExpr(from);
3148 retval = _copyNullTest(from);
3151 retval = _copyBooleanTest(from);
3153 case T_CoerceToDomain:
3154 retval = _copyCoerceToDomain(from);
3156 case T_CoerceToDomainValue:
3157 retval = _copyCoerceToDomainValue(from);
3159 case T_SetToDefault:
3160 retval = _copySetToDefault(from);
3163 retval = _copyTargetEntry(from);
3166 retval = _copyRangeTblRef(from);
3169 retval = _copyJoinExpr(from);
3172 retval = _copyFromExpr(from);
3179 retval = _copyPathKey(from);
3181 case T_RestrictInfo:
3182 retval = _copyRestrictInfo(from);
3184 case T_OuterJoinInfo:
3185 retval = _copyOuterJoinInfo(from);
3187 case T_InClauseInfo:
3188 retval = _copyInClauseInfo(from);
3190 case T_AppendRelInfo:
3191 retval = _copyAppendRelInfo(from);
3202 retval = _copyValue(from);
3209 retval = _copyList(from);
3213 * Lists of integers and OIDs don't need to be deep-copied, so we
3214 * perform a shallow copy via list_copy()
3218 retval = list_copy(from);
3225 retval = _copyQuery(from);
3228 retval = _copyInsertStmt(from);
3231 retval = _copyDeleteStmt(from);
3234 retval = _copyUpdateStmt(from);
3237 retval = _copySelectStmt(from);
3239 case T_SetOperationStmt:
3240 retval = _copySetOperationStmt(from);
3242 case T_AlterTableStmt:
3243 retval = _copyAlterTableStmt(from);
3245 case T_AlterTableCmd:
3246 retval = _copyAlterTableCmd(from);
3248 case T_AlterDomainStmt:
3249 retval = _copyAlterDomainStmt(from);
3252 retval = _copyGrantStmt(from);
3254 case T_GrantRoleStmt:
3255 retval = _copyGrantRoleStmt(from);
3257 case T_DeclareCursorStmt:
3258 retval = _copyDeclareCursorStmt(from);
3260 case T_ClosePortalStmt:
3261 retval = _copyClosePortalStmt(from);
3264 retval = _copyClusterStmt(from);
3267 retval = _copyCopyStmt(from);
3270 retval = _copyCreateStmt(from);
3273 retval = _copyInhRelation(from);
3276 retval = _copyDefineStmt(from);
3279 retval = _copyDropStmt(from);
3281 case T_TruncateStmt:
3282 retval = _copyTruncateStmt(from);
3285 retval = _copyCommentStmt(from);
3288 retval = _copyFetchStmt(from);
3291 retval = _copyIndexStmt(from);
3293 case T_CreateFunctionStmt:
3294 retval = _copyCreateFunctionStmt(from);
3296 case T_FunctionParameter:
3297 retval = _copyFunctionParameter(from);
3299 case T_AlterFunctionStmt:
3300 retval = _copyAlterFunctionStmt(from);
3302 case T_RemoveFuncStmt:
3303 retval = _copyRemoveFuncStmt(from);
3305 case T_RemoveOpClassStmt:
3306 retval = _copyRemoveOpClassStmt(from);
3308 case T_RemoveOpFamilyStmt:
3309 retval = _copyRemoveOpFamilyStmt(from);
3312 retval = _copyRenameStmt(from);
3314 case T_AlterObjectSchemaStmt:
3315 retval = _copyAlterObjectSchemaStmt(from);
3317 case T_AlterOwnerStmt:
3318 retval = _copyAlterOwnerStmt(from);
3321 retval = _copyRuleStmt(from);
3324 retval = _copyNotifyStmt(from);
3327 retval = _copyListenStmt(from);
3329 case T_UnlistenStmt:
3330 retval = _copyUnlistenStmt(from);
3332 case T_TransactionStmt:
3333 retval = _copyTransactionStmt(from);
3335 case T_CompositeTypeStmt:
3336 retval = _copyCompositeTypeStmt(from);
3338 case T_CreateEnumStmt:
3339 retval = _copyCreateEnumStmt(from);
3342 retval = _copyViewStmt(from);
3345 retval = _copyLoadStmt(from);
3347 case T_CreateDomainStmt:
3348 retval = _copyCreateDomainStmt(from);
3350 case T_CreateOpClassStmt:
3351 retval = _copyCreateOpClassStmt(from);
3353 case T_CreateOpClassItem:
3354 retval = _copyCreateOpClassItem(from);
3356 case T_CreateOpFamilyStmt:
3357 retval = _copyCreateOpFamilyStmt(from);
3359 case T_AlterOpFamilyStmt:
3360 retval = _copyAlterOpFamilyStmt(from);
3362 case T_CreatedbStmt:
3363 retval = _copyCreatedbStmt(from);
3365 case T_AlterDatabaseStmt:
3366 retval = _copyAlterDatabaseStmt(from);
3368 case T_AlterDatabaseSetStmt:
3369 retval = _copyAlterDatabaseSetStmt(from);
3372 retval = _copyDropdbStmt(from);
3375 retval = _copyVacuumStmt(from);
3378 retval = _copyExplainStmt(from);
3380 case T_CreateSeqStmt:
3381 retval = _copyCreateSeqStmt(from);
3383 case T_AlterSeqStmt:
3384 retval = _copyAlterSeqStmt(from);
3386 case T_VariableSetStmt:
3387 retval = _copyVariableSetStmt(from);
3389 case T_VariableShowStmt:
3390 retval = _copyVariableShowStmt(from);
3392 case T_VariableResetStmt:
3393 retval = _copyVariableResetStmt(from);
3396 retval = _copyDiscardStmt(from);
3398 case T_CreateTableSpaceStmt:
3399 retval = _copyCreateTableSpaceStmt(from);
3401 case T_DropTableSpaceStmt:
3402 retval = _copyDropTableSpaceStmt(from);
3404 case T_CreateTrigStmt:
3405 retval = _copyCreateTrigStmt(from);
3407 case T_DropPropertyStmt:
3408 retval = _copyDropPropertyStmt(from);
3410 case T_CreatePLangStmt:
3411 retval = _copyCreatePLangStmt(from);
3413 case T_DropPLangStmt:
3414 retval = _copyDropPLangStmt(from);
3416 case T_CreateRoleStmt:
3417 retval = _copyCreateRoleStmt(from);
3419 case T_AlterRoleStmt:
3420 retval = _copyAlterRoleStmt(from);
3422 case T_AlterRoleSetStmt:
3423 retval = _copyAlterRoleSetStmt(from);
3425 case T_DropRoleStmt:
3426 retval = _copyDropRoleStmt(from);
3429 retval = _copyLockStmt(from);
3431 case T_ConstraintsSetStmt:
3432 retval = _copyConstraintsSetStmt(from);
3435 retval = _copyReindexStmt(from);
3437 case T_CheckPointStmt:
3438 retval = (void *) makeNode(CheckPointStmt);
3440 case T_CreateSchemaStmt:
3441 retval = _copyCreateSchemaStmt(from);
3443 case T_CreateConversionStmt:
3444 retval = _copyCreateConversionStmt(from);
3446 case T_CreateCastStmt:
3447 retval = _copyCreateCastStmt(from);
3449 case T_DropCastStmt:
3450 retval = _copyDropCastStmt(from);
3453 retval = _copyPrepareStmt(from);
3456 retval = _copyExecuteStmt(from);
3458 case T_DeallocateStmt:
3459 retval = _copyDeallocateStmt(from);
3461 case T_DropOwnedStmt:
3462 retval = _copyDropOwnedStmt(from);
3464 case T_ReassignOwnedStmt:
3465 retval = _copyReassignOwnedStmt(from);
3469 retval = _copyAExpr(from);
3472 retval = _copyColumnRef(from);
3475 retval = _copyParamRef(from);
3478 retval = _copyAConst(from);
3481 retval = _copyFuncCall(from);
3484 retval = _copyAIndices(from);
3486 case T_A_Indirection:
3487 retval = _copyA_Indirection(from);
3490 retval = _copyResTarget(from);
3493 retval = _copyTypeCast(from);
3496 retval = _copySortBy(from);
3498 case T_RangeSubselect:
3499 retval = _copyRangeSubselect(from);
3501 case T_RangeFunction:
3502 retval = _copyRangeFunction(from);
3505 retval = _copyTypeName(from);
3508 retval = _copyIndexElem(from);
3511 retval = _copyColumnDef(from);
3514 retval = _copyConstraint(from);
3517 retval = _copyDefElem(from);
3519 case T_LockingClause:
3520 retval = _copyLockingClause(from);
3522 case T_RangeTblEntry:
3523 retval = _copyRangeTblEntry(from);
3526 retval = _copySortClause(from);
3529 retval = _copyGroupClause(from);
3531 case T_RowMarkClause:
3532 retval = _copyRowMarkClause(from);
3534 case T_FkConstraint:
3535 retval = _copyFkConstraint(from);
3538 retval = _copyPrivGrantee(from);
3540 case T_FuncWithArgs:
3541 retval = _copyFuncWithArgs(from);
3543 case T_XmlSerialize:
3544 retval = _copyXmlSerialize(from);
3548 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3549 retval = from; /* keep compiler quiet */