Core support for "extensions", which are packages of SQL objects.
[pgsql.git] / src / backend / nodes / copyfuncs.c
blob851186146dd78f0f40f619380a6d0b1eb8c5ecf6
1 /*-------------------------------------------------------------------------
3 * copyfuncs.c
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-2011, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
17 * IDENTIFICATION
18 * src/backend/nodes/copyfuncs.c
20 *-------------------------------------------------------------------------
23 #include "postgres.h"
25 #include "miscadmin.h"
26 #include "nodes/plannodes.h"
27 #include "nodes/relation.h"
28 #include "utils/datum.h"
32 * Macros to simplify copying of different kinds of fields. Use these
33 * wherever possible to reduce the chance for silly typos. Note that these
34 * hard-wire the convention that the local variables in a Copy routine are
35 * named 'newnode' and 'from'.
38 /* Copy a simple scalar field (int, float, bool, enum, etc) */
39 #define COPY_SCALAR_FIELD(fldname) \
40 (newnode->fldname = from->fldname)
42 /* Copy a field that is a pointer to some kind of Node or Node tree */
43 #define COPY_NODE_FIELD(fldname) \
44 (newnode->fldname = copyObject(from->fldname))
46 /* Copy a field that is a pointer to a Bitmapset */
47 #define COPY_BITMAPSET_FIELD(fldname) \
48 (newnode->fldname = bms_copy(from->fldname))
50 /* Copy a field that is a pointer to a C string, or perhaps NULL */
51 #define COPY_STRING_FIELD(fldname) \
52 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
54 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
55 #define COPY_POINTER_FIELD(fldname, sz) \
56 do { \
57 Size _size = (sz); \
58 newnode->fldname = palloc(_size); \
59 memcpy(newnode->fldname, from->fldname, _size); \
60 } while (0)
62 /* Copy a parse location field (for Copy, this is same as scalar case) */
63 #define COPY_LOCATION_FIELD(fldname) \
64 (newnode->fldname = from->fldname)
67 /* ****************************************************************
68 * plannodes.h copy functions
69 * ****************************************************************
73 * _copyPlannedStmt
75 static PlannedStmt *
76 _copyPlannedStmt(PlannedStmt *from)
78 PlannedStmt *newnode = makeNode(PlannedStmt);
80 COPY_SCALAR_FIELD(commandType);
81 COPY_SCALAR_FIELD(hasReturning);
82 COPY_SCALAR_FIELD(canSetTag);
83 COPY_SCALAR_FIELD(transientPlan);
84 COPY_NODE_FIELD(planTree);
85 COPY_NODE_FIELD(rtable);
86 COPY_NODE_FIELD(resultRelations);
87 COPY_NODE_FIELD(utilityStmt);
88 COPY_NODE_FIELD(intoClause);
89 COPY_NODE_FIELD(subplans);
90 COPY_BITMAPSET_FIELD(rewindPlanIDs);
91 COPY_NODE_FIELD(rowMarks);
92 COPY_NODE_FIELD(relationOids);
93 COPY_NODE_FIELD(invalItems);
94 COPY_SCALAR_FIELD(nParamExec);
96 return newnode;
100 * CopyPlanFields
102 * This function copies the fields of the Plan node. It is used by
103 * all the copy functions for classes which inherit from Plan.
105 static void
106 CopyPlanFields(Plan *from, Plan *newnode)
108 COPY_SCALAR_FIELD(startup_cost);
109 COPY_SCALAR_FIELD(total_cost);
110 COPY_SCALAR_FIELD(plan_rows);
111 COPY_SCALAR_FIELD(plan_width);
112 COPY_NODE_FIELD(targetlist);
113 COPY_NODE_FIELD(qual);
114 COPY_NODE_FIELD(lefttree);
115 COPY_NODE_FIELD(righttree);
116 COPY_NODE_FIELD(initPlan);
117 COPY_BITMAPSET_FIELD(extParam);
118 COPY_BITMAPSET_FIELD(allParam);
122 * _copyPlan
124 static Plan *
125 _copyPlan(Plan *from)
127 Plan *newnode = makeNode(Plan);
130 * copy node superclass fields
132 CopyPlanFields(from, newnode);
134 return newnode;
139 * _copyResult
141 static Result *
142 _copyResult(Result *from)
144 Result *newnode = makeNode(Result);
147 * copy node superclass fields
149 CopyPlanFields((Plan *) from, (Plan *) newnode);
152 * copy remainder of node
154 COPY_NODE_FIELD(resconstantqual);
156 return newnode;
160 * _copyModifyTable
162 static ModifyTable *
163 _copyModifyTable(ModifyTable *from)
165 ModifyTable *newnode = makeNode(ModifyTable);
168 * copy node superclass fields
170 CopyPlanFields((Plan *) from, (Plan *) newnode);
173 * copy remainder of node
175 COPY_SCALAR_FIELD(operation);
176 COPY_NODE_FIELD(resultRelations);
177 COPY_NODE_FIELD(plans);
178 COPY_NODE_FIELD(returningLists);
179 COPY_NODE_FIELD(rowMarks);
180 COPY_SCALAR_FIELD(epqParam);
182 return newnode;
186 * _copyAppend
188 static Append *
189 _copyAppend(Append *from)
191 Append *newnode = makeNode(Append);
194 * copy node superclass fields
196 CopyPlanFields((Plan *) from, (Plan *) newnode);
199 * copy remainder of node
201 COPY_NODE_FIELD(appendplans);
203 return newnode;
207 * _copyMergeAppend
209 static MergeAppend *
210 _copyMergeAppend(MergeAppend *from)
212 MergeAppend *newnode = makeNode(MergeAppend);
215 * copy node superclass fields
217 CopyPlanFields((Plan *) from, (Plan *) newnode);
220 * copy remainder of node
222 COPY_NODE_FIELD(mergeplans);
223 COPY_SCALAR_FIELD(numCols);
224 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
225 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
226 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
227 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
229 return newnode;
233 * _copyRecursiveUnion
235 static RecursiveUnion *
236 _copyRecursiveUnion(RecursiveUnion *from)
238 RecursiveUnion *newnode = makeNode(RecursiveUnion);
241 * copy node superclass fields
243 CopyPlanFields((Plan *) from, (Plan *) newnode);
246 * copy remainder of node
248 COPY_SCALAR_FIELD(wtParam);
249 COPY_SCALAR_FIELD(numCols);
250 if (from->numCols > 0)
252 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
253 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
255 COPY_SCALAR_FIELD(numGroups);
257 return newnode;
261 * _copyBitmapAnd
263 static BitmapAnd *
264 _copyBitmapAnd(BitmapAnd *from)
266 BitmapAnd *newnode = makeNode(BitmapAnd);
269 * copy node superclass fields
271 CopyPlanFields((Plan *) from, (Plan *) newnode);
274 * copy remainder of node
276 COPY_NODE_FIELD(bitmapplans);
278 return newnode;
282 * _copyBitmapOr
284 static BitmapOr *
285 _copyBitmapOr(BitmapOr *from)
287 BitmapOr *newnode = makeNode(BitmapOr);
290 * copy node superclass fields
292 CopyPlanFields((Plan *) from, (Plan *) newnode);
295 * copy remainder of node
297 COPY_NODE_FIELD(bitmapplans);
299 return newnode;
304 * CopyScanFields
306 * This function copies the fields of the Scan node. It is used by
307 * all the copy functions for classes which inherit from Scan.
309 static void
310 CopyScanFields(Scan *from, Scan *newnode)
312 CopyPlanFields((Plan *) from, (Plan *) newnode);
314 COPY_SCALAR_FIELD(scanrelid);
318 * _copyScan
320 static Scan *
321 _copyScan(Scan *from)
323 Scan *newnode = makeNode(Scan);
326 * copy node superclass fields
328 CopyScanFields((Scan *) from, (Scan *) newnode);
330 return newnode;
334 * _copySeqScan
336 static SeqScan *
337 _copySeqScan(SeqScan *from)
339 SeqScan *newnode = makeNode(SeqScan);
342 * copy node superclass fields
344 CopyScanFields((Scan *) from, (Scan *) newnode);
346 return newnode;
350 * _copyIndexScan
352 static IndexScan *
353 _copyIndexScan(IndexScan *from)
355 IndexScan *newnode = makeNode(IndexScan);
358 * copy node superclass fields
360 CopyScanFields((Scan *) from, (Scan *) newnode);
363 * copy remainder of node
365 COPY_SCALAR_FIELD(indexid);
366 COPY_NODE_FIELD(indexqual);
367 COPY_NODE_FIELD(indexqualorig);
368 COPY_NODE_FIELD(indexorderby);
369 COPY_NODE_FIELD(indexorderbyorig);
370 COPY_SCALAR_FIELD(indexorderdir);
372 return newnode;
376 * _copyBitmapIndexScan
378 static BitmapIndexScan *
379 _copyBitmapIndexScan(BitmapIndexScan *from)
381 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
384 * copy node superclass fields
386 CopyScanFields((Scan *) from, (Scan *) newnode);
389 * copy remainder of node
391 COPY_SCALAR_FIELD(indexid);
392 COPY_NODE_FIELD(indexqual);
393 COPY_NODE_FIELD(indexqualorig);
395 return newnode;
399 * _copyBitmapHeapScan
401 static BitmapHeapScan *
402 _copyBitmapHeapScan(BitmapHeapScan *from)
404 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
407 * copy node superclass fields
409 CopyScanFields((Scan *) from, (Scan *) newnode);
412 * copy remainder of node
414 COPY_NODE_FIELD(bitmapqualorig);
416 return newnode;
420 * _copyTidScan
422 static TidScan *
423 _copyTidScan(TidScan *from)
425 TidScan *newnode = makeNode(TidScan);
428 * copy node superclass fields
430 CopyScanFields((Scan *) from, (Scan *) newnode);
433 * copy remainder of node
435 COPY_NODE_FIELD(tidquals);
437 return newnode;
441 * _copySubqueryScan
443 static SubqueryScan *
444 _copySubqueryScan(SubqueryScan *from)
446 SubqueryScan *newnode = makeNode(SubqueryScan);
449 * copy node superclass fields
451 CopyScanFields((Scan *) from, (Scan *) newnode);
454 * copy remainder of node
456 COPY_NODE_FIELD(subplan);
457 COPY_NODE_FIELD(subrtable);
458 COPY_NODE_FIELD(subrowmark);
460 return newnode;
464 * _copyFunctionScan
466 static FunctionScan *
467 _copyFunctionScan(FunctionScan *from)
469 FunctionScan *newnode = makeNode(FunctionScan);
472 * copy node superclass fields
474 CopyScanFields((Scan *) from, (Scan *) newnode);
477 * copy remainder of node
479 COPY_NODE_FIELD(funcexpr);
480 COPY_NODE_FIELD(funccolnames);
481 COPY_NODE_FIELD(funccoltypes);
482 COPY_NODE_FIELD(funccoltypmods);
483 COPY_NODE_FIELD(funccolcollations);
485 return newnode;
489 * _copyValuesScan
491 static ValuesScan *
492 _copyValuesScan(ValuesScan *from)
494 ValuesScan *newnode = makeNode(ValuesScan);
497 * copy node superclass fields
499 CopyScanFields((Scan *) from, (Scan *) newnode);
502 * copy remainder of node
504 COPY_NODE_FIELD(values_lists);
506 return newnode;
510 * _copyCteScan
512 static CteScan *
513 _copyCteScan(CteScan *from)
515 CteScan *newnode = makeNode(CteScan);
518 * copy node superclass fields
520 CopyScanFields((Scan *) from, (Scan *) newnode);
523 * copy remainder of node
525 COPY_SCALAR_FIELD(ctePlanId);
526 COPY_SCALAR_FIELD(cteParam);
528 return newnode;
532 * _copyWorkTableScan
534 static WorkTableScan *
535 _copyWorkTableScan(WorkTableScan *from)
537 WorkTableScan *newnode = makeNode(WorkTableScan);
540 * copy node superclass fields
542 CopyScanFields((Scan *) from, (Scan *) newnode);
545 * copy remainder of node
547 COPY_SCALAR_FIELD(wtParam);
549 return newnode;
553 * CopyJoinFields
555 * This function copies the fields of the Join node. It is used by
556 * all the copy functions for classes which inherit from Join.
558 static void
559 CopyJoinFields(Join *from, Join *newnode)
561 CopyPlanFields((Plan *) from, (Plan *) newnode);
563 COPY_SCALAR_FIELD(jointype);
564 COPY_NODE_FIELD(joinqual);
569 * _copyJoin
571 static Join *
572 _copyJoin(Join *from)
574 Join *newnode = makeNode(Join);
577 * copy node superclass fields
579 CopyJoinFields(from, newnode);
581 return newnode;
586 * _copyNestLoop
588 static NestLoop *
589 _copyNestLoop(NestLoop *from)
591 NestLoop *newnode = makeNode(NestLoop);
594 * copy node superclass fields
596 CopyJoinFields((Join *) from, (Join *) newnode);
599 * copy remainder of node
601 COPY_NODE_FIELD(nestParams);
603 return newnode;
608 * _copyMergeJoin
610 static MergeJoin *
611 _copyMergeJoin(MergeJoin *from)
613 MergeJoin *newnode = makeNode(MergeJoin);
614 int numCols;
617 * copy node superclass fields
619 CopyJoinFields((Join *) from, (Join *) newnode);
622 * copy remainder of node
624 COPY_NODE_FIELD(mergeclauses);
625 numCols = list_length(from->mergeclauses);
626 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
627 COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
628 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
629 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
631 return newnode;
635 * _copyHashJoin
637 static HashJoin *
638 _copyHashJoin(HashJoin *from)
640 HashJoin *newnode = makeNode(HashJoin);
643 * copy node superclass fields
645 CopyJoinFields((Join *) from, (Join *) newnode);
648 * copy remainder of node
650 COPY_NODE_FIELD(hashclauses);
652 return newnode;
657 * _copyMaterial
659 static Material *
660 _copyMaterial(Material *from)
662 Material *newnode = makeNode(Material);
665 * copy node superclass fields
667 CopyPlanFields((Plan *) from, (Plan *) newnode);
669 return newnode;
674 * _copySort
676 static Sort *
677 _copySort(Sort *from)
679 Sort *newnode = makeNode(Sort);
682 * copy node superclass fields
684 CopyPlanFields((Plan *) from, (Plan *) newnode);
686 COPY_SCALAR_FIELD(numCols);
687 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
688 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
689 COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
690 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
692 return newnode;
697 * _copyGroup
699 static Group *
700 _copyGroup(Group *from)
702 Group *newnode = makeNode(Group);
704 CopyPlanFields((Plan *) from, (Plan *) newnode);
706 COPY_SCALAR_FIELD(numCols);
707 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
708 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
710 return newnode;
714 * _copyAgg
716 static Agg *
717 _copyAgg(Agg *from)
719 Agg *newnode = makeNode(Agg);
721 CopyPlanFields((Plan *) from, (Plan *) newnode);
723 COPY_SCALAR_FIELD(aggstrategy);
724 COPY_SCALAR_FIELD(numCols);
725 if (from->numCols > 0)
727 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
728 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
730 COPY_SCALAR_FIELD(numGroups);
732 return newnode;
736 * _copyWindowAgg
738 static WindowAgg *
739 _copyWindowAgg(WindowAgg *from)
741 WindowAgg *newnode = makeNode(WindowAgg);
743 CopyPlanFields((Plan *) from, (Plan *) newnode);
745 COPY_SCALAR_FIELD(winref);
746 COPY_SCALAR_FIELD(partNumCols);
747 if (from->partNumCols > 0)
749 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
750 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
752 COPY_SCALAR_FIELD(ordNumCols);
753 if (from->ordNumCols > 0)
755 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
756 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
758 COPY_SCALAR_FIELD(frameOptions);
759 COPY_NODE_FIELD(startOffset);
760 COPY_NODE_FIELD(endOffset);
762 return newnode;
766 * _copyUnique
768 static Unique *
769 _copyUnique(Unique *from)
771 Unique *newnode = makeNode(Unique);
774 * copy node superclass fields
776 CopyPlanFields((Plan *) from, (Plan *) newnode);
779 * copy remainder of node
781 COPY_SCALAR_FIELD(numCols);
782 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
783 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
785 return newnode;
789 * _copyHash
791 static Hash *
792 _copyHash(Hash *from)
794 Hash *newnode = makeNode(Hash);
797 * copy node superclass fields
799 CopyPlanFields((Plan *) from, (Plan *) newnode);
802 * copy remainder of node
804 COPY_SCALAR_FIELD(skewTable);
805 COPY_SCALAR_FIELD(skewColumn);
806 COPY_SCALAR_FIELD(skewInherit);
807 COPY_SCALAR_FIELD(skewColType);
808 COPY_SCALAR_FIELD(skewColTypmod);
810 return newnode;
814 * _copySetOp
816 static SetOp *
817 _copySetOp(SetOp *from)
819 SetOp *newnode = makeNode(SetOp);
822 * copy node superclass fields
824 CopyPlanFields((Plan *) from, (Plan *) newnode);
827 * copy remainder of node
829 COPY_SCALAR_FIELD(cmd);
830 COPY_SCALAR_FIELD(strategy);
831 COPY_SCALAR_FIELD(numCols);
832 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
833 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
834 COPY_SCALAR_FIELD(flagColIdx);
835 COPY_SCALAR_FIELD(firstFlag);
836 COPY_SCALAR_FIELD(numGroups);
838 return newnode;
842 * _copyLockRows
844 static LockRows *
845 _copyLockRows(LockRows *from)
847 LockRows *newnode = makeNode(LockRows);
850 * copy node superclass fields
852 CopyPlanFields((Plan *) from, (Plan *) newnode);
855 * copy remainder of node
857 COPY_NODE_FIELD(rowMarks);
858 COPY_SCALAR_FIELD(epqParam);
860 return newnode;
864 * _copyLimit
866 static Limit *
867 _copyLimit(Limit *from)
869 Limit *newnode = makeNode(Limit);
872 * copy node superclass fields
874 CopyPlanFields((Plan *) from, (Plan *) newnode);
877 * copy remainder of node
879 COPY_NODE_FIELD(limitOffset);
880 COPY_NODE_FIELD(limitCount);
882 return newnode;
886 * _copyNestLoopParam
888 static NestLoopParam *
889 _copyNestLoopParam(NestLoopParam *from)
891 NestLoopParam *newnode = makeNode(NestLoopParam);
893 COPY_SCALAR_FIELD(paramno);
894 COPY_NODE_FIELD(paramval);
896 return newnode;
900 * _copyPlanRowMark
902 static PlanRowMark *
903 _copyPlanRowMark(PlanRowMark *from)
905 PlanRowMark *newnode = makeNode(PlanRowMark);
907 COPY_SCALAR_FIELD(rti);
908 COPY_SCALAR_FIELD(prti);
909 COPY_SCALAR_FIELD(markType);
910 COPY_SCALAR_FIELD(noWait);
911 COPY_SCALAR_FIELD(isParent);
913 return newnode;
917 * _copyPlanInvalItem
919 static PlanInvalItem *
920 _copyPlanInvalItem(PlanInvalItem *from)
922 PlanInvalItem *newnode = makeNode(PlanInvalItem);
924 COPY_SCALAR_FIELD(cacheId);
925 /* tupleId isn't really a "scalar", but this works anyway */
926 COPY_SCALAR_FIELD(tupleId);
928 return newnode;
931 /* ****************************************************************
932 * primnodes.h copy functions
933 * ****************************************************************
937 * _copyAlias
939 static Alias *
940 _copyAlias(Alias *from)
942 Alias *newnode = makeNode(Alias);
944 COPY_STRING_FIELD(aliasname);
945 COPY_NODE_FIELD(colnames);
947 return newnode;
951 * _copyRangeVar
953 static RangeVar *
954 _copyRangeVar(RangeVar *from)
956 RangeVar *newnode = makeNode(RangeVar);
958 COPY_STRING_FIELD(catalogname);
959 COPY_STRING_FIELD(schemaname);
960 COPY_STRING_FIELD(relname);
961 COPY_SCALAR_FIELD(inhOpt);
962 COPY_SCALAR_FIELD(relpersistence);
963 COPY_NODE_FIELD(alias);
964 COPY_LOCATION_FIELD(location);
966 return newnode;
970 * _copyIntoClause
972 static IntoClause *
973 _copyIntoClause(IntoClause *from)
975 IntoClause *newnode = makeNode(IntoClause);
977 COPY_NODE_FIELD(rel);
978 COPY_NODE_FIELD(colNames);
979 COPY_NODE_FIELD(options);
980 COPY_SCALAR_FIELD(onCommit);
981 COPY_STRING_FIELD(tableSpaceName);
983 return newnode;
987 * We don't need a _copyExpr because Expr is an abstract supertype which
988 * should never actually get instantiated. Also, since it has no common
989 * fields except NodeTag, there's no need for a helper routine to factor
990 * out copying the common fields...
994 * _copyVar
996 static Var *
997 _copyVar(Var *from)
999 Var *newnode = makeNode(Var);
1001 COPY_SCALAR_FIELD(varno);
1002 COPY_SCALAR_FIELD(varattno);
1003 COPY_SCALAR_FIELD(vartype);
1004 COPY_SCALAR_FIELD(vartypmod);
1005 COPY_SCALAR_FIELD(varcollid);
1006 COPY_SCALAR_FIELD(varlevelsup);
1007 COPY_SCALAR_FIELD(varnoold);
1008 COPY_SCALAR_FIELD(varoattno);
1009 COPY_LOCATION_FIELD(location);
1011 return newnode;
1015 * _copyConst
1017 static Const *
1018 _copyConst(Const *from)
1020 Const *newnode = makeNode(Const);
1022 COPY_SCALAR_FIELD(consttype);
1023 COPY_SCALAR_FIELD(consttypmod);
1024 COPY_SCALAR_FIELD(constcollid);
1025 COPY_SCALAR_FIELD(constlen);
1027 if (from->constbyval || from->constisnull)
1030 * passed by value so just copy the datum. Also, don't try to copy
1031 * struct when value is null!
1033 newnode->constvalue = from->constvalue;
1035 else
1038 * passed by reference. We need a palloc'd copy.
1040 newnode->constvalue = datumCopy(from->constvalue,
1041 from->constbyval,
1042 from->constlen);
1045 COPY_SCALAR_FIELD(constisnull);
1046 COPY_SCALAR_FIELD(constbyval);
1047 COPY_LOCATION_FIELD(location);
1049 return newnode;
1053 * _copyParam
1055 static Param *
1056 _copyParam(Param *from)
1058 Param *newnode = makeNode(Param);
1060 COPY_SCALAR_FIELD(paramkind);
1061 COPY_SCALAR_FIELD(paramid);
1062 COPY_SCALAR_FIELD(paramtype);
1063 COPY_SCALAR_FIELD(paramtypmod);
1064 COPY_SCALAR_FIELD(paramcollation);
1065 COPY_LOCATION_FIELD(location);
1067 return newnode;
1071 * _copyAggref
1073 static Aggref *
1074 _copyAggref(Aggref *from)
1076 Aggref *newnode = makeNode(Aggref);
1078 COPY_SCALAR_FIELD(aggfnoid);
1079 COPY_SCALAR_FIELD(aggtype);
1080 COPY_NODE_FIELD(args);
1081 COPY_NODE_FIELD(aggorder);
1082 COPY_NODE_FIELD(aggdistinct);
1083 COPY_SCALAR_FIELD(aggstar);
1084 COPY_SCALAR_FIELD(agglevelsup);
1085 COPY_SCALAR_FIELD(collid);
1086 COPY_LOCATION_FIELD(location);
1088 return newnode;
1092 * _copyWindowFunc
1094 static WindowFunc *
1095 _copyWindowFunc(WindowFunc *from)
1097 WindowFunc *newnode = makeNode(WindowFunc);
1099 COPY_SCALAR_FIELD(winfnoid);
1100 COPY_SCALAR_FIELD(wintype);
1101 COPY_NODE_FIELD(args);
1102 COPY_SCALAR_FIELD(winref);
1103 COPY_SCALAR_FIELD(winstar);
1104 COPY_SCALAR_FIELD(winagg);
1105 COPY_SCALAR_FIELD(collid);
1106 COPY_LOCATION_FIELD(location);
1108 return newnode;
1112 * _copyArrayRef
1114 static ArrayRef *
1115 _copyArrayRef(ArrayRef *from)
1117 ArrayRef *newnode = makeNode(ArrayRef);
1119 COPY_SCALAR_FIELD(refarraytype);
1120 COPY_SCALAR_FIELD(refelemtype);
1121 COPY_SCALAR_FIELD(reftypmod);
1122 COPY_SCALAR_FIELD(refcollid);
1123 COPY_NODE_FIELD(refupperindexpr);
1124 COPY_NODE_FIELD(reflowerindexpr);
1125 COPY_NODE_FIELD(refexpr);
1126 COPY_NODE_FIELD(refassgnexpr);
1128 return newnode;
1132 * _copyFuncExpr
1134 static FuncExpr *
1135 _copyFuncExpr(FuncExpr *from)
1137 FuncExpr *newnode = makeNode(FuncExpr);
1139 COPY_SCALAR_FIELD(funcid);
1140 COPY_SCALAR_FIELD(funcresulttype);
1141 COPY_SCALAR_FIELD(funcretset);
1142 COPY_SCALAR_FIELD(funcformat);
1143 COPY_NODE_FIELD(args);
1144 COPY_SCALAR_FIELD(collid);
1145 COPY_LOCATION_FIELD(location);
1147 return newnode;
1151 * _copyNamedArgExpr *
1153 static NamedArgExpr *
1154 _copyNamedArgExpr(NamedArgExpr *from)
1156 NamedArgExpr *newnode = makeNode(NamedArgExpr);
1158 COPY_NODE_FIELD(arg);
1159 COPY_STRING_FIELD(name);
1160 COPY_SCALAR_FIELD(argnumber);
1161 COPY_LOCATION_FIELD(location);
1163 return newnode;
1167 * _copyOpExpr
1169 static OpExpr *
1170 _copyOpExpr(OpExpr *from)
1172 OpExpr *newnode = makeNode(OpExpr);
1174 COPY_SCALAR_FIELD(opno);
1175 COPY_SCALAR_FIELD(opfuncid);
1176 COPY_SCALAR_FIELD(opresulttype);
1177 COPY_SCALAR_FIELD(opretset);
1178 COPY_NODE_FIELD(args);
1179 COPY_SCALAR_FIELD(collid);
1180 COPY_LOCATION_FIELD(location);
1182 return newnode;
1186 * _copyDistinctExpr (same as OpExpr)
1188 static DistinctExpr *
1189 _copyDistinctExpr(DistinctExpr *from)
1191 DistinctExpr *newnode = makeNode(DistinctExpr);
1193 COPY_SCALAR_FIELD(opno);
1194 COPY_SCALAR_FIELD(opfuncid);
1195 COPY_SCALAR_FIELD(opresulttype);
1196 COPY_SCALAR_FIELD(opretset);
1197 COPY_NODE_FIELD(args);
1198 COPY_SCALAR_FIELD(collid);
1199 COPY_LOCATION_FIELD(location);
1201 return newnode;
1205 * _copyScalarArrayOpExpr
1207 static ScalarArrayOpExpr *
1208 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
1210 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1212 COPY_SCALAR_FIELD(opno);
1213 COPY_SCALAR_FIELD(opfuncid);
1214 COPY_SCALAR_FIELD(useOr);
1215 COPY_NODE_FIELD(args);
1216 COPY_SCALAR_FIELD(collid);
1217 COPY_LOCATION_FIELD(location);
1219 return newnode;
1223 * _copyBoolExpr
1225 static BoolExpr *
1226 _copyBoolExpr(BoolExpr *from)
1228 BoolExpr *newnode = makeNode(BoolExpr);
1230 COPY_SCALAR_FIELD(boolop);
1231 COPY_NODE_FIELD(args);
1232 COPY_LOCATION_FIELD(location);
1234 return newnode;
1238 * _copySubLink
1240 static SubLink *
1241 _copySubLink(SubLink *from)
1243 SubLink *newnode = makeNode(SubLink);
1245 COPY_SCALAR_FIELD(subLinkType);
1246 COPY_NODE_FIELD(testexpr);
1247 COPY_NODE_FIELD(operName);
1248 COPY_NODE_FIELD(subselect);
1249 COPY_LOCATION_FIELD(location);
1251 return newnode;
1255 * _copySubPlan
1257 static SubPlan *
1258 _copySubPlan(SubPlan *from)
1260 SubPlan *newnode = makeNode(SubPlan);
1262 COPY_SCALAR_FIELD(subLinkType);
1263 COPY_NODE_FIELD(testexpr);
1264 COPY_NODE_FIELD(paramIds);
1265 COPY_SCALAR_FIELD(plan_id);
1266 COPY_STRING_FIELD(plan_name);
1267 COPY_SCALAR_FIELD(firstColType);
1268 COPY_SCALAR_FIELD(firstColTypmod);
1269 COPY_SCALAR_FIELD(firstColCollation);
1270 COPY_SCALAR_FIELD(useHashTable);
1271 COPY_SCALAR_FIELD(unknownEqFalse);
1272 COPY_NODE_FIELD(setParam);
1273 COPY_NODE_FIELD(parParam);
1274 COPY_NODE_FIELD(args);
1275 COPY_SCALAR_FIELD(startup_cost);
1276 COPY_SCALAR_FIELD(per_call_cost);
1278 return newnode;
1282 * _copyAlternativeSubPlan
1284 static AlternativeSubPlan *
1285 _copyAlternativeSubPlan(AlternativeSubPlan *from)
1287 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1289 COPY_NODE_FIELD(subplans);
1291 return newnode;
1295 * _copyFieldSelect
1297 static FieldSelect *
1298 _copyFieldSelect(FieldSelect *from)
1300 FieldSelect *newnode = makeNode(FieldSelect);
1302 COPY_NODE_FIELD(arg);
1303 COPY_SCALAR_FIELD(fieldnum);
1304 COPY_SCALAR_FIELD(resulttype);
1305 COPY_SCALAR_FIELD(resulttypmod);
1306 COPY_SCALAR_FIELD(resultcollation);
1308 return newnode;
1312 * _copyFieldStore
1314 static FieldStore *
1315 _copyFieldStore(FieldStore *from)
1317 FieldStore *newnode = makeNode(FieldStore);
1319 COPY_NODE_FIELD(arg);
1320 COPY_NODE_FIELD(newvals);
1321 COPY_NODE_FIELD(fieldnums);
1322 COPY_SCALAR_FIELD(resulttype);
1324 return newnode;
1328 * _copyRelabelType
1330 static RelabelType *
1331 _copyRelabelType(RelabelType *from)
1333 RelabelType *newnode = makeNode(RelabelType);
1335 COPY_NODE_FIELD(arg);
1336 COPY_SCALAR_FIELD(resulttype);
1337 COPY_SCALAR_FIELD(resulttypmod);
1338 COPY_SCALAR_FIELD(relabelformat);
1339 COPY_LOCATION_FIELD(location);
1341 return newnode;
1345 * _copyCoerceViaIO
1347 static CoerceViaIO *
1348 _copyCoerceViaIO(CoerceViaIO *from)
1350 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1352 COPY_NODE_FIELD(arg);
1353 COPY_SCALAR_FIELD(resulttype);
1354 COPY_SCALAR_FIELD(coerceformat);
1355 COPY_LOCATION_FIELD(location);
1357 return newnode;
1361 * _copyArrayCoerceExpr
1363 static ArrayCoerceExpr *
1364 _copyArrayCoerceExpr(ArrayCoerceExpr *from)
1366 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1368 COPY_NODE_FIELD(arg);
1369 COPY_SCALAR_FIELD(elemfuncid);
1370 COPY_SCALAR_FIELD(resulttype);
1371 COPY_SCALAR_FIELD(resulttypmod);
1372 COPY_SCALAR_FIELD(isExplicit);
1373 COPY_SCALAR_FIELD(coerceformat);
1374 COPY_LOCATION_FIELD(location);
1376 return newnode;
1380 * _copyConvertRowtypeExpr
1382 static ConvertRowtypeExpr *
1383 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
1385 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1387 COPY_NODE_FIELD(arg);
1388 COPY_SCALAR_FIELD(resulttype);
1389 COPY_SCALAR_FIELD(convertformat);
1390 COPY_LOCATION_FIELD(location);
1392 return newnode;
1396 * _copyCaseExpr
1398 static CaseExpr *
1399 _copyCaseExpr(CaseExpr *from)
1401 CaseExpr *newnode = makeNode(CaseExpr);
1403 COPY_SCALAR_FIELD(casetype);
1404 COPY_SCALAR_FIELD(casecollation);
1405 COPY_NODE_FIELD(arg);
1406 COPY_NODE_FIELD(args);
1407 COPY_NODE_FIELD(defresult);
1408 COPY_LOCATION_FIELD(location);
1410 return newnode;
1414 * _copyCaseWhen
1416 static CaseWhen *
1417 _copyCaseWhen(CaseWhen *from)
1419 CaseWhen *newnode = makeNode(CaseWhen);
1421 COPY_NODE_FIELD(expr);
1422 COPY_NODE_FIELD(result);
1423 COPY_LOCATION_FIELD(location);
1425 return newnode;
1429 * _copyCaseTestExpr
1431 static CaseTestExpr *
1432 _copyCaseTestExpr(CaseTestExpr *from)
1434 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1436 COPY_SCALAR_FIELD(typeId);
1437 COPY_SCALAR_FIELD(typeMod);
1438 COPY_SCALAR_FIELD(collation);
1440 return newnode;
1444 * _copyArrayExpr
1446 static ArrayExpr *
1447 _copyArrayExpr(ArrayExpr *from)
1449 ArrayExpr *newnode = makeNode(ArrayExpr);
1451 COPY_SCALAR_FIELD(array_typeid);
1452 COPY_SCALAR_FIELD(element_typeid);
1453 COPY_NODE_FIELD(elements);
1454 COPY_SCALAR_FIELD(multidims);
1455 COPY_LOCATION_FIELD(location);
1457 return newnode;
1461 * _copyRowExpr
1463 static RowExpr *
1464 _copyRowExpr(RowExpr *from)
1466 RowExpr *newnode = makeNode(RowExpr);
1468 COPY_NODE_FIELD(args);
1469 COPY_SCALAR_FIELD(row_typeid);
1470 COPY_SCALAR_FIELD(row_format);
1471 COPY_NODE_FIELD(colnames);
1472 COPY_LOCATION_FIELD(location);
1474 return newnode;
1478 * _copyRowCompareExpr
1480 static RowCompareExpr *
1481 _copyRowCompareExpr(RowCompareExpr *from)
1483 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1485 COPY_SCALAR_FIELD(rctype);
1486 COPY_NODE_FIELD(opnos);
1487 COPY_NODE_FIELD(opfamilies);
1488 COPY_NODE_FIELD(collids);
1489 COPY_NODE_FIELD(largs);
1490 COPY_NODE_FIELD(rargs);
1492 return newnode;
1496 * _copyCoalesceExpr
1498 static CoalesceExpr *
1499 _copyCoalesceExpr(CoalesceExpr *from)
1501 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1503 COPY_SCALAR_FIELD(coalescetype);
1504 COPY_SCALAR_FIELD(coalescecollation);
1505 COPY_NODE_FIELD(args);
1506 COPY_LOCATION_FIELD(location);
1508 return newnode;
1512 * _copyMinMaxExpr
1514 static MinMaxExpr *
1515 _copyMinMaxExpr(MinMaxExpr *from)
1517 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1519 COPY_SCALAR_FIELD(minmaxtype);
1520 COPY_SCALAR_FIELD(op);
1521 COPY_NODE_FIELD(args);
1522 COPY_SCALAR_FIELD(collid);
1523 COPY_LOCATION_FIELD(location);
1525 return newnode;
1529 * _copyXmlExpr
1531 static XmlExpr *
1532 _copyXmlExpr(XmlExpr *from)
1534 XmlExpr *newnode = makeNode(XmlExpr);
1536 COPY_SCALAR_FIELD(op);
1537 COPY_STRING_FIELD(name);
1538 COPY_NODE_FIELD(named_args);
1539 COPY_NODE_FIELD(arg_names);
1540 COPY_NODE_FIELD(args);
1541 COPY_SCALAR_FIELD(xmloption);
1542 COPY_SCALAR_FIELD(type);
1543 COPY_SCALAR_FIELD(typmod);
1544 COPY_LOCATION_FIELD(location);
1546 return newnode;
1550 * _copyNullIfExpr (same as OpExpr)
1552 static NullIfExpr *
1553 _copyNullIfExpr(NullIfExpr *from)
1555 NullIfExpr *newnode = makeNode(NullIfExpr);
1557 COPY_SCALAR_FIELD(opno);
1558 COPY_SCALAR_FIELD(opfuncid);
1559 COPY_SCALAR_FIELD(opresulttype);
1560 COPY_SCALAR_FIELD(opretset);
1561 COPY_NODE_FIELD(args);
1562 COPY_LOCATION_FIELD(location);
1564 return newnode;
1568 * _copyNullTest
1570 static NullTest *
1571 _copyNullTest(NullTest *from)
1573 NullTest *newnode = makeNode(NullTest);
1575 COPY_NODE_FIELD(arg);
1576 COPY_SCALAR_FIELD(nulltesttype);
1577 COPY_SCALAR_FIELD(argisrow);
1579 return newnode;
1583 * _copyBooleanTest
1585 static BooleanTest *
1586 _copyBooleanTest(BooleanTest *from)
1588 BooleanTest *newnode = makeNode(BooleanTest);
1590 COPY_NODE_FIELD(arg);
1591 COPY_SCALAR_FIELD(booltesttype);
1593 return newnode;
1597 * _copyCoerceToDomain
1599 static CoerceToDomain *
1600 _copyCoerceToDomain(CoerceToDomain *from)
1602 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1604 COPY_NODE_FIELD(arg);
1605 COPY_SCALAR_FIELD(resulttype);
1606 COPY_SCALAR_FIELD(resulttypmod);
1607 COPY_SCALAR_FIELD(coercionformat);
1608 COPY_LOCATION_FIELD(location);
1610 return newnode;
1614 * _copyCoerceToDomainValue
1616 static CoerceToDomainValue *
1617 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1619 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1621 COPY_SCALAR_FIELD(typeId);
1622 COPY_SCALAR_FIELD(typeMod);
1623 COPY_LOCATION_FIELD(location);
1625 return newnode;
1629 * _copySetToDefault
1631 static SetToDefault *
1632 _copySetToDefault(SetToDefault *from)
1634 SetToDefault *newnode = makeNode(SetToDefault);
1636 COPY_SCALAR_FIELD(typeId);
1637 COPY_SCALAR_FIELD(typeMod);
1638 COPY_SCALAR_FIELD(collid);
1639 COPY_LOCATION_FIELD(location);
1641 return newnode;
1645 * _copyCurrentOfExpr
1647 static CurrentOfExpr *
1648 _copyCurrentOfExpr(CurrentOfExpr *from)
1650 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1652 COPY_SCALAR_FIELD(cvarno);
1653 COPY_STRING_FIELD(cursor_name);
1654 COPY_SCALAR_FIELD(cursor_param);
1656 return newnode;
1660 * _copyTargetEntry
1662 static TargetEntry *
1663 _copyTargetEntry(TargetEntry *from)
1665 TargetEntry *newnode = makeNode(TargetEntry);
1667 COPY_NODE_FIELD(expr);
1668 COPY_SCALAR_FIELD(resno);
1669 COPY_STRING_FIELD(resname);
1670 COPY_SCALAR_FIELD(ressortgroupref);
1671 COPY_SCALAR_FIELD(resorigtbl);
1672 COPY_SCALAR_FIELD(resorigcol);
1673 COPY_SCALAR_FIELD(resjunk);
1675 return newnode;
1679 * _copyRangeTblRef
1681 static RangeTblRef *
1682 _copyRangeTblRef(RangeTblRef *from)
1684 RangeTblRef *newnode = makeNode(RangeTblRef);
1686 COPY_SCALAR_FIELD(rtindex);
1688 return newnode;
1692 * _copyJoinExpr
1694 static JoinExpr *
1695 _copyJoinExpr(JoinExpr *from)
1697 JoinExpr *newnode = makeNode(JoinExpr);
1699 COPY_SCALAR_FIELD(jointype);
1700 COPY_SCALAR_FIELD(isNatural);
1701 COPY_NODE_FIELD(larg);
1702 COPY_NODE_FIELD(rarg);
1703 COPY_NODE_FIELD(usingClause);
1704 COPY_NODE_FIELD(quals);
1705 COPY_NODE_FIELD(alias);
1706 COPY_SCALAR_FIELD(rtindex);
1708 return newnode;
1712 * _copyFromExpr
1714 static FromExpr *
1715 _copyFromExpr(FromExpr *from)
1717 FromExpr *newnode = makeNode(FromExpr);
1719 COPY_NODE_FIELD(fromlist);
1720 COPY_NODE_FIELD(quals);
1722 return newnode;
1725 /* ****************************************************************
1726 * relation.h copy functions
1728 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1729 * There are some subsidiary structs that are useful to copy, though.
1730 * ****************************************************************
1734 * _copyPathKey
1736 static PathKey *
1737 _copyPathKey(PathKey *from)
1739 PathKey *newnode = makeNode(PathKey);
1741 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1742 COPY_SCALAR_FIELD(pk_eclass);
1743 COPY_SCALAR_FIELD(pk_opfamily);
1744 COPY_SCALAR_FIELD(pk_collation);
1745 COPY_SCALAR_FIELD(pk_strategy);
1746 COPY_SCALAR_FIELD(pk_nulls_first);
1748 return newnode;
1752 * _copyRestrictInfo
1754 static RestrictInfo *
1755 _copyRestrictInfo(RestrictInfo *from)
1757 RestrictInfo *newnode = makeNode(RestrictInfo);
1759 COPY_NODE_FIELD(clause);
1760 COPY_SCALAR_FIELD(is_pushed_down);
1761 COPY_SCALAR_FIELD(outerjoin_delayed);
1762 COPY_SCALAR_FIELD(can_join);
1763 COPY_SCALAR_FIELD(pseudoconstant);
1764 COPY_BITMAPSET_FIELD(clause_relids);
1765 COPY_BITMAPSET_FIELD(required_relids);
1766 COPY_BITMAPSET_FIELD(nullable_relids);
1767 COPY_BITMAPSET_FIELD(left_relids);
1768 COPY_BITMAPSET_FIELD(right_relids);
1769 COPY_NODE_FIELD(orclause);
1770 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1771 COPY_SCALAR_FIELD(parent_ec);
1772 COPY_SCALAR_FIELD(eval_cost);
1773 COPY_SCALAR_FIELD(norm_selec);
1774 COPY_SCALAR_FIELD(outer_selec);
1775 COPY_NODE_FIELD(mergeopfamilies);
1776 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1777 COPY_SCALAR_FIELD(left_ec);
1778 COPY_SCALAR_FIELD(right_ec);
1779 COPY_SCALAR_FIELD(left_em);
1780 COPY_SCALAR_FIELD(right_em);
1781 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1782 newnode->scansel_cache = NIL;
1783 COPY_SCALAR_FIELD(outer_is_left);
1784 COPY_SCALAR_FIELD(hashjoinoperator);
1785 COPY_SCALAR_FIELD(left_bucketsize);
1786 COPY_SCALAR_FIELD(right_bucketsize);
1788 return newnode;
1792 * _copyPlaceHolderVar
1794 static PlaceHolderVar *
1795 _copyPlaceHolderVar(PlaceHolderVar *from)
1797 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
1799 COPY_NODE_FIELD(phexpr);
1800 COPY_BITMAPSET_FIELD(phrels);
1801 COPY_SCALAR_FIELD(phid);
1802 COPY_SCALAR_FIELD(phlevelsup);
1804 return newnode;
1808 * _copySpecialJoinInfo
1810 static SpecialJoinInfo *
1811 _copySpecialJoinInfo(SpecialJoinInfo *from)
1813 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
1815 COPY_BITMAPSET_FIELD(min_lefthand);
1816 COPY_BITMAPSET_FIELD(min_righthand);
1817 COPY_BITMAPSET_FIELD(syn_lefthand);
1818 COPY_BITMAPSET_FIELD(syn_righthand);
1819 COPY_SCALAR_FIELD(jointype);
1820 COPY_SCALAR_FIELD(lhs_strict);
1821 COPY_SCALAR_FIELD(delay_upper_joins);
1822 COPY_NODE_FIELD(join_quals);
1824 return newnode;
1828 * _copyAppendRelInfo
1830 static AppendRelInfo *
1831 _copyAppendRelInfo(AppendRelInfo *from)
1833 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1835 COPY_SCALAR_FIELD(parent_relid);
1836 COPY_SCALAR_FIELD(child_relid);
1837 COPY_SCALAR_FIELD(parent_reltype);
1838 COPY_SCALAR_FIELD(child_reltype);
1839 COPY_NODE_FIELD(translated_vars);
1840 COPY_SCALAR_FIELD(parent_reloid);
1842 return newnode;
1846 * _copyPlaceHolderInfo
1848 static PlaceHolderInfo *
1849 _copyPlaceHolderInfo(PlaceHolderInfo *from)
1851 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
1853 COPY_SCALAR_FIELD(phid);
1854 COPY_NODE_FIELD(ph_var);
1855 COPY_BITMAPSET_FIELD(ph_eval_at);
1856 COPY_BITMAPSET_FIELD(ph_needed);
1857 COPY_BITMAPSET_FIELD(ph_may_need);
1858 COPY_SCALAR_FIELD(ph_width);
1860 return newnode;
1864 * _copyMinMaxAggInfo
1866 static MinMaxAggInfo *
1867 _copyMinMaxAggInfo(MinMaxAggInfo *from)
1869 MinMaxAggInfo *newnode = makeNode(MinMaxAggInfo);
1871 COPY_SCALAR_FIELD(aggfnoid);
1872 COPY_SCALAR_FIELD(aggsortop);
1873 COPY_NODE_FIELD(target);
1874 COPY_NODE_FIELD(pathkeys);
1876 return newnode;
1879 /* ****************************************************************
1880 * parsenodes.h copy functions
1881 * ****************************************************************
1884 static RangeTblEntry *
1885 _copyRangeTblEntry(RangeTblEntry *from)
1887 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1889 COPY_SCALAR_FIELD(rtekind);
1890 COPY_SCALAR_FIELD(relid);
1891 COPY_NODE_FIELD(subquery);
1892 COPY_SCALAR_FIELD(jointype);
1893 COPY_NODE_FIELD(joinaliasvars);
1894 COPY_NODE_FIELD(funcexpr);
1895 COPY_NODE_FIELD(funccoltypes);
1896 COPY_NODE_FIELD(funccoltypmods);
1897 COPY_NODE_FIELD(funccolcollations);
1898 COPY_NODE_FIELD(values_lists);
1899 COPY_STRING_FIELD(ctename);
1900 COPY_SCALAR_FIELD(ctelevelsup);
1901 COPY_SCALAR_FIELD(self_reference);
1902 COPY_NODE_FIELD(ctecoltypes);
1903 COPY_NODE_FIELD(ctecoltypmods);
1904 COPY_NODE_FIELD(ctecolcollations);
1905 COPY_NODE_FIELD(alias);
1906 COPY_NODE_FIELD(eref);
1907 COPY_SCALAR_FIELD(inh);
1908 COPY_SCALAR_FIELD(inFromCl);
1909 COPY_SCALAR_FIELD(requiredPerms);
1910 COPY_SCALAR_FIELD(checkAsUser);
1911 COPY_BITMAPSET_FIELD(selectedCols);
1912 COPY_BITMAPSET_FIELD(modifiedCols);
1914 return newnode;
1917 static SortGroupClause *
1918 _copySortGroupClause(SortGroupClause *from)
1920 SortGroupClause *newnode = makeNode(SortGroupClause);
1922 COPY_SCALAR_FIELD(tleSortGroupRef);
1923 COPY_SCALAR_FIELD(eqop);
1924 COPY_SCALAR_FIELD(sortop);
1925 COPY_SCALAR_FIELD(nulls_first);
1926 COPY_SCALAR_FIELD(hashable);
1928 return newnode;
1931 static WindowClause *
1932 _copyWindowClause(WindowClause *from)
1934 WindowClause *newnode = makeNode(WindowClause);
1936 COPY_STRING_FIELD(name);
1937 COPY_STRING_FIELD(refname);
1938 COPY_NODE_FIELD(partitionClause);
1939 COPY_NODE_FIELD(orderClause);
1940 COPY_SCALAR_FIELD(frameOptions);
1941 COPY_NODE_FIELD(startOffset);
1942 COPY_NODE_FIELD(endOffset);
1943 COPY_SCALAR_FIELD(winref);
1944 COPY_SCALAR_FIELD(copiedOrder);
1946 return newnode;
1949 static RowMarkClause *
1950 _copyRowMarkClause(RowMarkClause *from)
1952 RowMarkClause *newnode = makeNode(RowMarkClause);
1954 COPY_SCALAR_FIELD(rti);
1955 COPY_SCALAR_FIELD(forUpdate);
1956 COPY_SCALAR_FIELD(noWait);
1957 COPY_SCALAR_FIELD(pushedDown);
1959 return newnode;
1962 static WithClause *
1963 _copyWithClause(WithClause *from)
1965 WithClause *newnode = makeNode(WithClause);
1967 COPY_NODE_FIELD(ctes);
1968 COPY_SCALAR_FIELD(recursive);
1969 COPY_LOCATION_FIELD(location);
1971 return newnode;
1974 static CommonTableExpr *
1975 _copyCommonTableExpr(CommonTableExpr *from)
1977 CommonTableExpr *newnode = makeNode(CommonTableExpr);
1979 COPY_STRING_FIELD(ctename);
1980 COPY_NODE_FIELD(aliascolnames);
1981 COPY_NODE_FIELD(ctequery);
1982 COPY_LOCATION_FIELD(location);
1983 COPY_SCALAR_FIELD(cterecursive);
1984 COPY_SCALAR_FIELD(cterefcount);
1985 COPY_NODE_FIELD(ctecolnames);
1986 COPY_NODE_FIELD(ctecoltypes);
1987 COPY_NODE_FIELD(ctecoltypmods);
1988 COPY_NODE_FIELD(ctecolcollations);
1990 return newnode;
1993 static A_Expr *
1994 _copyAExpr(A_Expr *from)
1996 A_Expr *newnode = makeNode(A_Expr);
1998 COPY_SCALAR_FIELD(kind);
1999 COPY_NODE_FIELD(name);
2000 COPY_NODE_FIELD(lexpr);
2001 COPY_NODE_FIELD(rexpr);
2002 COPY_LOCATION_FIELD(location);
2004 return newnode;
2007 static ColumnRef *
2008 _copyColumnRef(ColumnRef *from)
2010 ColumnRef *newnode = makeNode(ColumnRef);
2012 COPY_NODE_FIELD(fields);
2013 COPY_LOCATION_FIELD(location);
2015 return newnode;
2018 static ParamRef *
2019 _copyParamRef(ParamRef *from)
2021 ParamRef *newnode = makeNode(ParamRef);
2023 COPY_SCALAR_FIELD(number);
2024 COPY_LOCATION_FIELD(location);
2026 return newnode;
2029 static A_Const *
2030 _copyAConst(A_Const *from)
2032 A_Const *newnode = makeNode(A_Const);
2034 /* This part must duplicate _copyValue */
2035 COPY_SCALAR_FIELD(val.type);
2036 switch (from->val.type)
2038 case T_Integer:
2039 COPY_SCALAR_FIELD(val.val.ival);
2040 break;
2041 case T_Float:
2042 case T_String:
2043 case T_BitString:
2044 COPY_STRING_FIELD(val.val.str);
2045 break;
2046 case T_Null:
2047 /* nothing to do */
2048 break;
2049 default:
2050 elog(ERROR, "unrecognized node type: %d",
2051 (int) from->val.type);
2052 break;
2055 COPY_LOCATION_FIELD(location);
2057 return newnode;
2060 static FuncCall *
2061 _copyFuncCall(FuncCall *from)
2063 FuncCall *newnode = makeNode(FuncCall);
2065 COPY_NODE_FIELD(funcname);
2066 COPY_NODE_FIELD(args);
2067 COPY_NODE_FIELD(agg_order);
2068 COPY_SCALAR_FIELD(agg_star);
2069 COPY_SCALAR_FIELD(agg_distinct);
2070 COPY_SCALAR_FIELD(func_variadic);
2071 COPY_NODE_FIELD(over);
2072 COPY_LOCATION_FIELD(location);
2074 return newnode;
2077 static A_Star *
2078 _copyAStar(A_Star *from)
2080 A_Star *newnode = makeNode(A_Star);
2082 return newnode;
2085 static A_Indices *
2086 _copyAIndices(A_Indices *from)
2088 A_Indices *newnode = makeNode(A_Indices);
2090 COPY_NODE_FIELD(lidx);
2091 COPY_NODE_FIELD(uidx);
2093 return newnode;
2096 static A_Indirection *
2097 _copyA_Indirection(A_Indirection *from)
2099 A_Indirection *newnode = makeNode(A_Indirection);
2101 COPY_NODE_FIELD(arg);
2102 COPY_NODE_FIELD(indirection);
2104 return newnode;
2107 static A_ArrayExpr *
2108 _copyA_ArrayExpr(A_ArrayExpr *from)
2110 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2112 COPY_NODE_FIELD(elements);
2113 COPY_LOCATION_FIELD(location);
2115 return newnode;
2118 static ResTarget *
2119 _copyResTarget(ResTarget *from)
2121 ResTarget *newnode = makeNode(ResTarget);
2123 COPY_STRING_FIELD(name);
2124 COPY_NODE_FIELD(indirection);
2125 COPY_NODE_FIELD(val);
2126 COPY_LOCATION_FIELD(location);
2128 return newnode;
2131 static TypeName *
2132 _copyTypeName(TypeName *from)
2134 TypeName *newnode = makeNode(TypeName);
2136 COPY_NODE_FIELD(names);
2137 COPY_SCALAR_FIELD(typeOid);
2138 COPY_SCALAR_FIELD(setof);
2139 COPY_SCALAR_FIELD(pct_type);
2140 COPY_NODE_FIELD(typmods);
2141 COPY_SCALAR_FIELD(typemod);
2142 COPY_NODE_FIELD(arrayBounds);
2143 COPY_NODE_FIELD(collnames);
2144 COPY_SCALAR_FIELD(collOid);
2145 COPY_LOCATION_FIELD(location);
2147 return newnode;
2150 static SortBy *
2151 _copySortBy(SortBy *from)
2153 SortBy *newnode = makeNode(SortBy);
2155 COPY_NODE_FIELD(node);
2156 COPY_SCALAR_FIELD(sortby_dir);
2157 COPY_SCALAR_FIELD(sortby_nulls);
2158 COPY_NODE_FIELD(useOp);
2159 COPY_LOCATION_FIELD(location);
2161 return newnode;
2164 static WindowDef *
2165 _copyWindowDef(WindowDef *from)
2167 WindowDef *newnode = makeNode(WindowDef);
2169 COPY_STRING_FIELD(name);
2170 COPY_STRING_FIELD(refname);
2171 COPY_NODE_FIELD(partitionClause);
2172 COPY_NODE_FIELD(orderClause);
2173 COPY_SCALAR_FIELD(frameOptions);
2174 COPY_NODE_FIELD(startOffset);
2175 COPY_NODE_FIELD(endOffset);
2176 COPY_LOCATION_FIELD(location);
2178 return newnode;
2181 static RangeSubselect *
2182 _copyRangeSubselect(RangeSubselect *from)
2184 RangeSubselect *newnode = makeNode(RangeSubselect);
2186 COPY_NODE_FIELD(subquery);
2187 COPY_NODE_FIELD(alias);
2189 return newnode;
2192 static RangeFunction *
2193 _copyRangeFunction(RangeFunction *from)
2195 RangeFunction *newnode = makeNode(RangeFunction);
2197 COPY_NODE_FIELD(funccallnode);
2198 COPY_NODE_FIELD(alias);
2199 COPY_NODE_FIELD(coldeflist);
2201 return newnode;
2204 static TypeCast *
2205 _copyTypeCast(TypeCast *from)
2207 TypeCast *newnode = makeNode(TypeCast);
2209 COPY_NODE_FIELD(arg);
2210 COPY_NODE_FIELD(typeName);
2211 COPY_LOCATION_FIELD(location);
2213 return newnode;
2216 static CollateClause *
2217 _copyCollateClause(CollateClause *from)
2219 CollateClause *newnode = makeNode(CollateClause);
2221 COPY_NODE_FIELD(arg);
2222 COPY_NODE_FIELD(collnames);
2223 COPY_SCALAR_FIELD(collOid);
2224 COPY_LOCATION_FIELD(location);
2226 return newnode;
2229 static IndexElem *
2230 _copyIndexElem(IndexElem *from)
2232 IndexElem *newnode = makeNode(IndexElem);
2234 COPY_STRING_FIELD(name);
2235 COPY_NODE_FIELD(expr);
2236 COPY_STRING_FIELD(indexcolname);
2237 COPY_NODE_FIELD(collation);
2238 COPY_NODE_FIELD(opclass);
2239 COPY_SCALAR_FIELD(ordering);
2240 COPY_SCALAR_FIELD(nulls_ordering);
2242 return newnode;
2245 static ColumnDef *
2246 _copyColumnDef(ColumnDef *from)
2248 ColumnDef *newnode = makeNode(ColumnDef);
2250 COPY_STRING_FIELD(colname);
2251 COPY_NODE_FIELD(typeName);
2252 COPY_SCALAR_FIELD(inhcount);
2253 COPY_SCALAR_FIELD(is_local);
2254 COPY_SCALAR_FIELD(is_not_null);
2255 COPY_SCALAR_FIELD(storage);
2256 COPY_NODE_FIELD(raw_default);
2257 COPY_NODE_FIELD(cooked_default);
2258 COPY_NODE_FIELD(constraints);
2260 return newnode;
2263 static Constraint *
2264 _copyConstraint(Constraint *from)
2266 Constraint *newnode = makeNode(Constraint);
2268 COPY_SCALAR_FIELD(contype);
2269 COPY_STRING_FIELD(conname);
2270 COPY_SCALAR_FIELD(deferrable);
2271 COPY_SCALAR_FIELD(initdeferred);
2272 COPY_LOCATION_FIELD(location);
2273 COPY_NODE_FIELD(raw_expr);
2274 COPY_STRING_FIELD(cooked_expr);
2275 COPY_NODE_FIELD(keys);
2276 COPY_NODE_FIELD(exclusions);
2277 COPY_NODE_FIELD(options);
2278 COPY_STRING_FIELD(indexname);
2279 COPY_STRING_FIELD(indexspace);
2280 COPY_STRING_FIELD(access_method);
2281 COPY_NODE_FIELD(where_clause);
2282 COPY_NODE_FIELD(pktable);
2283 COPY_NODE_FIELD(fk_attrs);
2284 COPY_NODE_FIELD(pk_attrs);
2285 COPY_SCALAR_FIELD(fk_matchtype);
2286 COPY_SCALAR_FIELD(fk_upd_action);
2287 COPY_SCALAR_FIELD(fk_del_action);
2288 COPY_SCALAR_FIELD(skip_validation);
2290 return newnode;
2293 static DefElem *
2294 _copyDefElem(DefElem *from)
2296 DefElem *newnode = makeNode(DefElem);
2298 COPY_STRING_FIELD(defnamespace);
2299 COPY_STRING_FIELD(defname);
2300 COPY_NODE_FIELD(arg);
2301 COPY_SCALAR_FIELD(defaction);
2303 return newnode;
2306 static LockingClause *
2307 _copyLockingClause(LockingClause *from)
2309 LockingClause *newnode = makeNode(LockingClause);
2311 COPY_NODE_FIELD(lockedRels);
2312 COPY_SCALAR_FIELD(forUpdate);
2313 COPY_SCALAR_FIELD(noWait);
2315 return newnode;
2318 static XmlSerialize *
2319 _copyXmlSerialize(XmlSerialize *from)
2321 XmlSerialize *newnode = makeNode(XmlSerialize);
2323 COPY_SCALAR_FIELD(xmloption);
2324 COPY_NODE_FIELD(expr);
2325 COPY_NODE_FIELD(typeName);
2326 COPY_LOCATION_FIELD(location);
2328 return newnode;
2331 static Query *
2332 _copyQuery(Query *from)
2334 Query *newnode = makeNode(Query);
2336 COPY_SCALAR_FIELD(commandType);
2337 COPY_SCALAR_FIELD(querySource);
2338 COPY_SCALAR_FIELD(canSetTag);
2339 COPY_NODE_FIELD(utilityStmt);
2340 COPY_SCALAR_FIELD(resultRelation);
2341 COPY_NODE_FIELD(intoClause);
2342 COPY_SCALAR_FIELD(hasAggs);
2343 COPY_SCALAR_FIELD(hasWindowFuncs);
2344 COPY_SCALAR_FIELD(hasSubLinks);
2345 COPY_SCALAR_FIELD(hasDistinctOn);
2346 COPY_SCALAR_FIELD(hasRecursive);
2347 COPY_SCALAR_FIELD(hasForUpdate);
2348 COPY_NODE_FIELD(cteList);
2349 COPY_NODE_FIELD(rtable);
2350 COPY_NODE_FIELD(jointree);
2351 COPY_NODE_FIELD(targetList);
2352 COPY_NODE_FIELD(returningList);
2353 COPY_NODE_FIELD(groupClause);
2354 COPY_NODE_FIELD(havingQual);
2355 COPY_NODE_FIELD(windowClause);
2356 COPY_NODE_FIELD(distinctClause);
2357 COPY_NODE_FIELD(sortClause);
2358 COPY_NODE_FIELD(limitOffset);
2359 COPY_NODE_FIELD(limitCount);
2360 COPY_NODE_FIELD(rowMarks);
2361 COPY_NODE_FIELD(setOperations);
2362 COPY_NODE_FIELD(constraintDeps);
2364 return newnode;
2367 static InsertStmt *
2368 _copyInsertStmt(InsertStmt *from)
2370 InsertStmt *newnode = makeNode(InsertStmt);
2372 COPY_NODE_FIELD(relation);
2373 COPY_NODE_FIELD(cols);
2374 COPY_NODE_FIELD(selectStmt);
2375 COPY_NODE_FIELD(returningList);
2376 COPY_NODE_FIELD(withClause);
2378 return newnode;
2381 static DeleteStmt *
2382 _copyDeleteStmt(DeleteStmt *from)
2384 DeleteStmt *newnode = makeNode(DeleteStmt);
2386 COPY_NODE_FIELD(relation);
2387 COPY_NODE_FIELD(usingClause);
2388 COPY_NODE_FIELD(whereClause);
2389 COPY_NODE_FIELD(returningList);
2390 COPY_NODE_FIELD(withClause);
2392 return newnode;
2395 static UpdateStmt *
2396 _copyUpdateStmt(UpdateStmt *from)
2398 UpdateStmt *newnode = makeNode(UpdateStmt);
2400 COPY_NODE_FIELD(relation);
2401 COPY_NODE_FIELD(targetList);
2402 COPY_NODE_FIELD(whereClause);
2403 COPY_NODE_FIELD(fromClause);
2404 COPY_NODE_FIELD(returningList);
2405 COPY_NODE_FIELD(withClause);
2407 return newnode;
2410 static SelectStmt *
2411 _copySelectStmt(SelectStmt *from)
2413 SelectStmt *newnode = makeNode(SelectStmt);
2415 COPY_NODE_FIELD(distinctClause);
2416 COPY_NODE_FIELD(intoClause);
2417 COPY_NODE_FIELD(targetList);
2418 COPY_NODE_FIELD(fromClause);
2419 COPY_NODE_FIELD(whereClause);
2420 COPY_NODE_FIELD(groupClause);
2421 COPY_NODE_FIELD(havingClause);
2422 COPY_NODE_FIELD(windowClause);
2423 COPY_NODE_FIELD(withClause);
2424 COPY_NODE_FIELD(valuesLists);
2425 COPY_NODE_FIELD(sortClause);
2426 COPY_NODE_FIELD(limitOffset);
2427 COPY_NODE_FIELD(limitCount);
2428 COPY_NODE_FIELD(lockingClause);
2429 COPY_SCALAR_FIELD(op);
2430 COPY_SCALAR_FIELD(all);
2431 COPY_NODE_FIELD(larg);
2432 COPY_NODE_FIELD(rarg);
2434 return newnode;
2437 static SetOperationStmt *
2438 _copySetOperationStmt(SetOperationStmt *from)
2440 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2442 COPY_SCALAR_FIELD(op);
2443 COPY_SCALAR_FIELD(all);
2444 COPY_NODE_FIELD(larg);
2445 COPY_NODE_FIELD(rarg);
2446 COPY_NODE_FIELD(colTypes);
2447 COPY_NODE_FIELD(colTypmods);
2448 COPY_NODE_FIELD(colCollations);
2449 COPY_NODE_FIELD(groupClauses);
2451 return newnode;
2454 static AlterTableStmt *
2455 _copyAlterTableStmt(AlterTableStmt *from)
2457 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2459 COPY_NODE_FIELD(relation);
2460 COPY_NODE_FIELD(cmds);
2461 COPY_SCALAR_FIELD(relkind);
2463 return newnode;
2466 static AlterTableCmd *
2467 _copyAlterTableCmd(AlterTableCmd *from)
2469 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2471 COPY_SCALAR_FIELD(subtype);
2472 COPY_STRING_FIELD(name);
2473 COPY_NODE_FIELD(def);
2474 COPY_NODE_FIELD(transform);
2475 COPY_SCALAR_FIELD(behavior);
2476 COPY_SCALAR_FIELD(missing_ok);
2478 return newnode;
2481 static AlterDomainStmt *
2482 _copyAlterDomainStmt(AlterDomainStmt *from)
2484 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2486 COPY_SCALAR_FIELD(subtype);
2487 COPY_NODE_FIELD(typeName);
2488 COPY_STRING_FIELD(name);
2489 COPY_NODE_FIELD(def);
2490 COPY_SCALAR_FIELD(behavior);
2492 return newnode;
2495 static GrantStmt *
2496 _copyGrantStmt(GrantStmt *from)
2498 GrantStmt *newnode = makeNode(GrantStmt);
2500 COPY_SCALAR_FIELD(is_grant);
2501 COPY_SCALAR_FIELD(targtype);
2502 COPY_SCALAR_FIELD(objtype);
2503 COPY_NODE_FIELD(objects);
2504 COPY_NODE_FIELD(privileges);
2505 COPY_NODE_FIELD(grantees);
2506 COPY_SCALAR_FIELD(grant_option);
2507 COPY_SCALAR_FIELD(behavior);
2509 return newnode;
2512 static PrivGrantee *
2513 _copyPrivGrantee(PrivGrantee *from)
2515 PrivGrantee *newnode = makeNode(PrivGrantee);
2517 COPY_STRING_FIELD(rolname);
2519 return newnode;
2522 static FuncWithArgs *
2523 _copyFuncWithArgs(FuncWithArgs *from)
2525 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2527 COPY_NODE_FIELD(funcname);
2528 COPY_NODE_FIELD(funcargs);
2530 return newnode;
2533 static AccessPriv *
2534 _copyAccessPriv(AccessPriv *from)
2536 AccessPriv *newnode = makeNode(AccessPriv);
2538 COPY_STRING_FIELD(priv_name);
2539 COPY_NODE_FIELD(cols);
2541 return newnode;
2544 static GrantRoleStmt *
2545 _copyGrantRoleStmt(GrantRoleStmt *from)
2547 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2549 COPY_NODE_FIELD(granted_roles);
2550 COPY_NODE_FIELD(grantee_roles);
2551 COPY_SCALAR_FIELD(is_grant);
2552 COPY_SCALAR_FIELD(admin_opt);
2553 COPY_STRING_FIELD(grantor);
2554 COPY_SCALAR_FIELD(behavior);
2556 return newnode;
2559 static AlterDefaultPrivilegesStmt *
2560 _copyAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *from)
2562 AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2564 COPY_NODE_FIELD(options);
2565 COPY_NODE_FIELD(action);
2567 return newnode;
2570 static DeclareCursorStmt *
2571 _copyDeclareCursorStmt(DeclareCursorStmt *from)
2573 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2575 COPY_STRING_FIELD(portalname);
2576 COPY_SCALAR_FIELD(options);
2577 COPY_NODE_FIELD(query);
2579 return newnode;
2582 static ClosePortalStmt *
2583 _copyClosePortalStmt(ClosePortalStmt *from)
2585 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2587 COPY_STRING_FIELD(portalname);
2589 return newnode;
2592 static ClusterStmt *
2593 _copyClusterStmt(ClusterStmt *from)
2595 ClusterStmt *newnode = makeNode(ClusterStmt);
2597 COPY_NODE_FIELD(relation);
2598 COPY_STRING_FIELD(indexname);
2599 COPY_SCALAR_FIELD(verbose);
2601 return newnode;
2604 static CopyStmt *
2605 _copyCopyStmt(CopyStmt *from)
2607 CopyStmt *newnode = makeNode(CopyStmt);
2609 COPY_NODE_FIELD(relation);
2610 COPY_NODE_FIELD(query);
2611 COPY_NODE_FIELD(attlist);
2612 COPY_SCALAR_FIELD(is_from);
2613 COPY_STRING_FIELD(filename);
2614 COPY_NODE_FIELD(options);
2616 return newnode;
2620 * CopyCreateStmtFields
2622 * This function copies the fields of the CreateStmt node. It is used by
2623 * copy functions for classes which inherit from CreateStmt.
2625 static void
2626 CopyCreateStmtFields(CreateStmt *from, CreateStmt *newnode)
2628 COPY_NODE_FIELD(relation);
2629 COPY_NODE_FIELD(tableElts);
2630 COPY_NODE_FIELD(inhRelations);
2631 COPY_NODE_FIELD(ofTypename);
2632 COPY_NODE_FIELD(constraints);
2633 COPY_NODE_FIELD(options);
2634 COPY_SCALAR_FIELD(oncommit);
2635 COPY_STRING_FIELD(tablespacename);
2636 COPY_SCALAR_FIELD(if_not_exists);
2639 static CreateStmt *
2640 _copyCreateStmt(CreateStmt *from)
2642 CreateStmt *newnode = makeNode(CreateStmt);
2644 CopyCreateStmtFields(from, newnode);
2646 return newnode;
2649 static InhRelation *
2650 _copyInhRelation(InhRelation *from)
2652 InhRelation *newnode = makeNode(InhRelation);
2654 COPY_NODE_FIELD(relation);
2655 COPY_SCALAR_FIELD(options);
2657 return newnode;
2660 static DefineStmt *
2661 _copyDefineStmt(DefineStmt *from)
2663 DefineStmt *newnode = makeNode(DefineStmt);
2665 COPY_SCALAR_FIELD(kind);
2666 COPY_SCALAR_FIELD(oldstyle);
2667 COPY_NODE_FIELD(defnames);
2668 COPY_NODE_FIELD(args);
2669 COPY_NODE_FIELD(definition);
2671 return newnode;
2674 static DropStmt *
2675 _copyDropStmt(DropStmt *from)
2677 DropStmt *newnode = makeNode(DropStmt);
2679 COPY_NODE_FIELD(objects);
2680 COPY_SCALAR_FIELD(removeType);
2681 COPY_SCALAR_FIELD(behavior);
2682 COPY_SCALAR_FIELD(missing_ok);
2684 return newnode;
2687 static TruncateStmt *
2688 _copyTruncateStmt(TruncateStmt *from)
2690 TruncateStmt *newnode = makeNode(TruncateStmt);
2692 COPY_NODE_FIELD(relations);
2693 COPY_SCALAR_FIELD(restart_seqs);
2694 COPY_SCALAR_FIELD(behavior);
2696 return newnode;
2699 static CommentStmt *
2700 _copyCommentStmt(CommentStmt *from)
2702 CommentStmt *newnode = makeNode(CommentStmt);
2704 COPY_SCALAR_FIELD(objtype);
2705 COPY_NODE_FIELD(objname);
2706 COPY_NODE_FIELD(objargs);
2707 COPY_STRING_FIELD(comment);
2709 return newnode;
2712 static SecLabelStmt *
2713 _copySecLabelStmt(SecLabelStmt *from)
2715 SecLabelStmt *newnode = makeNode(SecLabelStmt);
2717 COPY_SCALAR_FIELD(objtype);
2718 COPY_NODE_FIELD(objname);
2719 COPY_NODE_FIELD(objargs);
2720 COPY_STRING_FIELD(provider);
2721 COPY_STRING_FIELD(label);
2723 return newnode;
2726 static FetchStmt *
2727 _copyFetchStmt(FetchStmt *from)
2729 FetchStmt *newnode = makeNode(FetchStmt);
2731 COPY_SCALAR_FIELD(direction);
2732 COPY_SCALAR_FIELD(howMany);
2733 COPY_STRING_FIELD(portalname);
2734 COPY_SCALAR_FIELD(ismove);
2736 return newnode;
2739 static IndexStmt *
2740 _copyIndexStmt(IndexStmt *from)
2742 IndexStmt *newnode = makeNode(IndexStmt);
2744 COPY_STRING_FIELD(idxname);
2745 COPY_NODE_FIELD(relation);
2746 COPY_STRING_FIELD(accessMethod);
2747 COPY_STRING_FIELD(tableSpace);
2748 COPY_NODE_FIELD(indexParams);
2749 COPY_NODE_FIELD(options);
2750 COPY_NODE_FIELD(whereClause);
2751 COPY_NODE_FIELD(excludeOpNames);
2752 COPY_SCALAR_FIELD(indexOid);
2753 COPY_SCALAR_FIELD(unique);
2754 COPY_SCALAR_FIELD(primary);
2755 COPY_SCALAR_FIELD(isconstraint);
2756 COPY_SCALAR_FIELD(deferrable);
2757 COPY_SCALAR_FIELD(initdeferred);
2758 COPY_SCALAR_FIELD(concurrent);
2760 return newnode;
2763 static CreateFunctionStmt *
2764 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2766 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2768 COPY_SCALAR_FIELD(replace);
2769 COPY_NODE_FIELD(funcname);
2770 COPY_NODE_FIELD(parameters);
2771 COPY_NODE_FIELD(returnType);
2772 COPY_NODE_FIELD(options);
2773 COPY_NODE_FIELD(withClause);
2775 return newnode;
2778 static FunctionParameter *
2779 _copyFunctionParameter(FunctionParameter *from)
2781 FunctionParameter *newnode = makeNode(FunctionParameter);
2783 COPY_STRING_FIELD(name);
2784 COPY_NODE_FIELD(argType);
2785 COPY_SCALAR_FIELD(mode);
2786 COPY_NODE_FIELD(defexpr);
2788 return newnode;
2791 static AlterFunctionStmt *
2792 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2794 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2796 COPY_NODE_FIELD(func);
2797 COPY_NODE_FIELD(actions);
2799 return newnode;
2802 static RemoveFuncStmt *
2803 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2805 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2807 COPY_SCALAR_FIELD(kind);
2808 COPY_NODE_FIELD(name);
2809 COPY_NODE_FIELD(args);
2810 COPY_SCALAR_FIELD(behavior);
2811 COPY_SCALAR_FIELD(missing_ok);
2813 return newnode;
2816 static DoStmt *
2817 _copyDoStmt(DoStmt *from)
2819 DoStmt *newnode = makeNode(DoStmt);
2821 COPY_NODE_FIELD(args);
2823 return newnode;
2826 static RemoveOpClassStmt *
2827 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2829 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2831 COPY_NODE_FIELD(opclassname);
2832 COPY_STRING_FIELD(amname);
2833 COPY_SCALAR_FIELD(behavior);
2834 COPY_SCALAR_FIELD(missing_ok);
2836 return newnode;
2839 static RemoveOpFamilyStmt *
2840 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2842 RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2844 COPY_NODE_FIELD(opfamilyname);
2845 COPY_STRING_FIELD(amname);
2846 COPY_SCALAR_FIELD(behavior);
2847 COPY_SCALAR_FIELD(missing_ok);
2849 return newnode;
2852 static RenameStmt *
2853 _copyRenameStmt(RenameStmt *from)
2855 RenameStmt *newnode = makeNode(RenameStmt);
2857 COPY_SCALAR_FIELD(renameType);
2858 COPY_NODE_FIELD(relation);
2859 COPY_NODE_FIELD(object);
2860 COPY_NODE_FIELD(objarg);
2861 COPY_STRING_FIELD(subname);
2862 COPY_STRING_FIELD(newname);
2863 COPY_SCALAR_FIELD(behavior);
2865 return newnode;
2868 static AlterObjectSchemaStmt *
2869 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2871 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2873 COPY_SCALAR_FIELD(objectType);
2874 COPY_NODE_FIELD(relation);
2875 COPY_NODE_FIELD(object);
2876 COPY_NODE_FIELD(objarg);
2877 COPY_STRING_FIELD(addname);
2878 COPY_STRING_FIELD(newschema);
2880 return newnode;
2883 static AlterOwnerStmt *
2884 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2886 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2888 COPY_SCALAR_FIELD(objectType);
2889 COPY_NODE_FIELD(relation);
2890 COPY_NODE_FIELD(object);
2891 COPY_NODE_FIELD(objarg);
2892 COPY_STRING_FIELD(addname);
2893 COPY_STRING_FIELD(newowner);
2895 return newnode;
2898 static RuleStmt *
2899 _copyRuleStmt(RuleStmt *from)
2901 RuleStmt *newnode = makeNode(RuleStmt);
2903 COPY_NODE_FIELD(relation);
2904 COPY_STRING_FIELD(rulename);
2905 COPY_NODE_FIELD(whereClause);
2906 COPY_SCALAR_FIELD(event);
2907 COPY_SCALAR_FIELD(instead);
2908 COPY_NODE_FIELD(actions);
2909 COPY_SCALAR_FIELD(replace);
2911 return newnode;
2914 static NotifyStmt *
2915 _copyNotifyStmt(NotifyStmt *from)
2917 NotifyStmt *newnode = makeNode(NotifyStmt);
2919 COPY_STRING_FIELD(conditionname);
2920 COPY_STRING_FIELD(payload);
2922 return newnode;
2925 static ListenStmt *
2926 _copyListenStmt(ListenStmt *from)
2928 ListenStmt *newnode = makeNode(ListenStmt);
2930 COPY_STRING_FIELD(conditionname);
2932 return newnode;
2935 static UnlistenStmt *
2936 _copyUnlistenStmt(UnlistenStmt *from)
2938 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2940 COPY_STRING_FIELD(conditionname);
2942 return newnode;
2945 static TransactionStmt *
2946 _copyTransactionStmt(TransactionStmt *from)
2948 TransactionStmt *newnode = makeNode(TransactionStmt);
2950 COPY_SCALAR_FIELD(kind);
2951 COPY_NODE_FIELD(options);
2952 COPY_STRING_FIELD(gid);
2954 return newnode;
2957 static CompositeTypeStmt *
2958 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2960 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2962 COPY_NODE_FIELD(typevar);
2963 COPY_NODE_FIELD(coldeflist);
2965 return newnode;
2968 static CreateEnumStmt *
2969 _copyCreateEnumStmt(CreateEnumStmt *from)
2971 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
2973 COPY_NODE_FIELD(typeName);
2974 COPY_NODE_FIELD(vals);
2976 return newnode;
2979 static AlterEnumStmt *
2980 _copyAlterEnumStmt(AlterEnumStmt *from)
2982 AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
2984 COPY_NODE_FIELD(typeName);
2985 COPY_STRING_FIELD(newVal);
2986 COPY_STRING_FIELD(newValNeighbor);
2987 COPY_SCALAR_FIELD(newValIsAfter);
2989 return newnode;
2992 static ViewStmt *
2993 _copyViewStmt(ViewStmt *from)
2995 ViewStmt *newnode = makeNode(ViewStmt);
2997 COPY_NODE_FIELD(view);
2998 COPY_NODE_FIELD(aliases);
2999 COPY_NODE_FIELD(query);
3000 COPY_SCALAR_FIELD(replace);
3002 return newnode;
3005 static LoadStmt *
3006 _copyLoadStmt(LoadStmt *from)
3008 LoadStmt *newnode = makeNode(LoadStmt);
3010 COPY_STRING_FIELD(filename);
3012 return newnode;
3015 static CreateDomainStmt *
3016 _copyCreateDomainStmt(CreateDomainStmt *from)
3018 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3020 COPY_NODE_FIELD(domainname);
3021 COPY_NODE_FIELD(typeName);
3022 COPY_NODE_FIELD(constraints);
3024 return newnode;
3027 static CreateOpClassStmt *
3028 _copyCreateOpClassStmt(CreateOpClassStmt *from)
3030 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3032 COPY_NODE_FIELD(opclassname);
3033 COPY_NODE_FIELD(opfamilyname);
3034 COPY_STRING_FIELD(amname);
3035 COPY_NODE_FIELD(datatype);
3036 COPY_NODE_FIELD(items);
3037 COPY_SCALAR_FIELD(isDefault);
3039 return newnode;
3042 static CreateOpClassItem *
3043 _copyCreateOpClassItem(CreateOpClassItem *from)
3045 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3047 COPY_SCALAR_FIELD(itemtype);
3048 COPY_NODE_FIELD(name);
3049 COPY_NODE_FIELD(args);
3050 COPY_SCALAR_FIELD(number);
3051 COPY_NODE_FIELD(order_family);
3052 COPY_NODE_FIELD(class_args);
3053 COPY_NODE_FIELD(storedtype);
3055 return newnode;
3058 static CreateOpFamilyStmt *
3059 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
3061 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3063 COPY_NODE_FIELD(opfamilyname);
3064 COPY_STRING_FIELD(amname);
3066 return newnode;
3069 static AlterOpFamilyStmt *
3070 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
3072 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3074 COPY_NODE_FIELD(opfamilyname);
3075 COPY_STRING_FIELD(amname);
3076 COPY_SCALAR_FIELD(isDrop);
3077 COPY_NODE_FIELD(items);
3079 return newnode;
3082 static CreatedbStmt *
3083 _copyCreatedbStmt(CreatedbStmt *from)
3085 CreatedbStmt *newnode = makeNode(CreatedbStmt);
3087 COPY_STRING_FIELD(dbname);
3088 COPY_NODE_FIELD(options);
3090 return newnode;
3093 static AlterDatabaseStmt *
3094 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
3096 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3098 COPY_STRING_FIELD(dbname);
3099 COPY_NODE_FIELD(options);
3101 return newnode;
3104 static AlterDatabaseSetStmt *
3105 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
3107 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3109 COPY_STRING_FIELD(dbname);
3110 COPY_NODE_FIELD(setstmt);
3112 return newnode;
3115 static DropdbStmt *
3116 _copyDropdbStmt(DropdbStmt *from)
3118 DropdbStmt *newnode = makeNode(DropdbStmt);
3120 COPY_STRING_FIELD(dbname);
3121 COPY_SCALAR_FIELD(missing_ok);
3123 return newnode;
3126 static VacuumStmt *
3127 _copyVacuumStmt(VacuumStmt *from)
3129 VacuumStmt *newnode = makeNode(VacuumStmt);
3131 COPY_SCALAR_FIELD(options);
3132 COPY_SCALAR_FIELD(freeze_min_age);
3133 COPY_SCALAR_FIELD(freeze_table_age);
3134 COPY_NODE_FIELD(relation);
3135 COPY_NODE_FIELD(va_cols);
3137 return newnode;
3140 static ExplainStmt *
3141 _copyExplainStmt(ExplainStmt *from)
3143 ExplainStmt *newnode = makeNode(ExplainStmt);
3145 COPY_NODE_FIELD(query);
3146 COPY_NODE_FIELD(options);
3148 return newnode;
3151 static CreateSeqStmt *
3152 _copyCreateSeqStmt(CreateSeqStmt *from)
3154 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3156 COPY_NODE_FIELD(sequence);
3157 COPY_NODE_FIELD(options);
3158 COPY_SCALAR_FIELD(ownerId);
3160 return newnode;
3163 static AlterSeqStmt *
3164 _copyAlterSeqStmt(AlterSeqStmt *from)
3166 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3168 COPY_NODE_FIELD(sequence);
3169 COPY_NODE_FIELD(options);
3171 return newnode;
3174 static VariableSetStmt *
3175 _copyVariableSetStmt(VariableSetStmt *from)
3177 VariableSetStmt *newnode = makeNode(VariableSetStmt);
3179 COPY_SCALAR_FIELD(kind);
3180 COPY_STRING_FIELD(name);
3181 COPY_NODE_FIELD(args);
3182 COPY_SCALAR_FIELD(is_local);
3184 return newnode;
3187 static VariableShowStmt *
3188 _copyVariableShowStmt(VariableShowStmt *from)
3190 VariableShowStmt *newnode = makeNode(VariableShowStmt);
3192 COPY_STRING_FIELD(name);
3194 return newnode;
3197 static DiscardStmt *
3198 _copyDiscardStmt(DiscardStmt *from)
3200 DiscardStmt *newnode = makeNode(DiscardStmt);
3202 COPY_SCALAR_FIELD(target);
3204 return newnode;
3207 static CreateTableSpaceStmt *
3208 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
3210 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3212 COPY_STRING_FIELD(tablespacename);
3213 COPY_STRING_FIELD(owner);
3214 COPY_STRING_FIELD(location);
3216 return newnode;
3219 static DropTableSpaceStmt *
3220 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
3222 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3224 COPY_STRING_FIELD(tablespacename);
3225 COPY_SCALAR_FIELD(missing_ok);
3227 return newnode;
3230 static AlterTableSpaceOptionsStmt *
3231 _copyAlterTableSpaceOptionsStmt(AlterTableSpaceOptionsStmt *from)
3233 AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3235 COPY_STRING_FIELD(tablespacename);
3236 COPY_NODE_FIELD(options);
3237 COPY_SCALAR_FIELD(isReset);
3239 return newnode;
3242 static CreateExtensionStmt *
3243 _copyCreateExtensionStmt(CreateExtensionStmt *from)
3245 CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3247 COPY_STRING_FIELD(extname);
3248 COPY_NODE_FIELD(options);
3250 return newnode;
3253 static CreateFdwStmt *
3254 _copyCreateFdwStmt(CreateFdwStmt *from)
3256 CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3258 COPY_STRING_FIELD(fdwname);
3259 COPY_NODE_FIELD(validator);
3260 COPY_NODE_FIELD(options);
3262 return newnode;
3265 static AlterFdwStmt *
3266 _copyAlterFdwStmt(AlterFdwStmt *from)
3268 AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3270 COPY_STRING_FIELD(fdwname);
3271 COPY_NODE_FIELD(validator);
3272 COPY_SCALAR_FIELD(change_validator);
3273 COPY_NODE_FIELD(options);
3275 return newnode;
3278 static DropFdwStmt *
3279 _copyDropFdwStmt(DropFdwStmt *from)
3281 DropFdwStmt *newnode = makeNode(DropFdwStmt);
3283 COPY_STRING_FIELD(fdwname);
3284 COPY_SCALAR_FIELD(missing_ok);
3285 COPY_SCALAR_FIELD(behavior);
3287 return newnode;
3290 static CreateForeignServerStmt *
3291 _copyCreateForeignServerStmt(CreateForeignServerStmt *from)
3293 CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3295 COPY_STRING_FIELD(servername);
3296 COPY_STRING_FIELD(servertype);
3297 COPY_STRING_FIELD(version);
3298 COPY_STRING_FIELD(fdwname);
3299 COPY_NODE_FIELD(options);
3301 return newnode;
3304 static AlterForeignServerStmt *
3305 _copyAlterForeignServerStmt(AlterForeignServerStmt *from)
3307 AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3309 COPY_STRING_FIELD(servername);
3310 COPY_STRING_FIELD(version);
3311 COPY_NODE_FIELD(options);
3312 COPY_SCALAR_FIELD(has_version);
3314 return newnode;
3317 static DropForeignServerStmt *
3318 _copyDropForeignServerStmt(DropForeignServerStmt *from)
3320 DropForeignServerStmt *newnode = makeNode(DropForeignServerStmt);
3322 COPY_STRING_FIELD(servername);
3323 COPY_SCALAR_FIELD(missing_ok);
3324 COPY_SCALAR_FIELD(behavior);
3326 return newnode;
3329 static CreateUserMappingStmt *
3330 _copyCreateUserMappingStmt(CreateUserMappingStmt *from)
3332 CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3334 COPY_STRING_FIELD(username);
3335 COPY_STRING_FIELD(servername);
3336 COPY_NODE_FIELD(options);
3338 return newnode;
3341 static AlterUserMappingStmt *
3342 _copyAlterUserMappingStmt(AlterUserMappingStmt *from)
3344 AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3346 COPY_STRING_FIELD(username);
3347 COPY_STRING_FIELD(servername);
3348 COPY_NODE_FIELD(options);
3350 return newnode;
3353 static DropUserMappingStmt *
3354 _copyDropUserMappingStmt(DropUserMappingStmt *from)
3356 DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3358 COPY_STRING_FIELD(username);
3359 COPY_STRING_FIELD(servername);
3360 COPY_SCALAR_FIELD(missing_ok);
3362 return newnode;
3365 static CreateForeignTableStmt *
3366 _copyCreateForeignTableStmt(CreateForeignTableStmt *from)
3368 CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3370 CopyCreateStmtFields((CreateStmt *) from, (CreateStmt *) newnode);
3372 COPY_STRING_FIELD(servername);
3373 COPY_NODE_FIELD(options);
3375 return newnode;
3378 static CreateTrigStmt *
3379 _copyCreateTrigStmt(CreateTrigStmt *from)
3381 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3383 COPY_STRING_FIELD(trigname);
3384 COPY_NODE_FIELD(relation);
3385 COPY_NODE_FIELD(funcname);
3386 COPY_NODE_FIELD(args);
3387 COPY_SCALAR_FIELD(row);
3388 COPY_SCALAR_FIELD(timing);
3389 COPY_SCALAR_FIELD(events);
3390 COPY_NODE_FIELD(columns);
3391 COPY_NODE_FIELD(whenClause);
3392 COPY_SCALAR_FIELD(isconstraint);
3393 COPY_SCALAR_FIELD(deferrable);
3394 COPY_SCALAR_FIELD(initdeferred);
3395 COPY_NODE_FIELD(constrrel);
3397 return newnode;
3400 static DropPropertyStmt *
3401 _copyDropPropertyStmt(DropPropertyStmt *from)
3403 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
3405 COPY_NODE_FIELD(relation);
3406 COPY_STRING_FIELD(property);
3407 COPY_SCALAR_FIELD(removeType);
3408 COPY_SCALAR_FIELD(behavior);
3409 COPY_SCALAR_FIELD(missing_ok);
3411 return newnode;
3414 static CreatePLangStmt *
3415 _copyCreatePLangStmt(CreatePLangStmt *from)
3417 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3419 COPY_SCALAR_FIELD(replace);
3420 COPY_STRING_FIELD(plname);
3421 COPY_NODE_FIELD(plhandler);
3422 COPY_NODE_FIELD(plinline);
3423 COPY_NODE_FIELD(plvalidator);
3424 COPY_SCALAR_FIELD(pltrusted);
3426 return newnode;
3429 static DropPLangStmt *
3430 _copyDropPLangStmt(DropPLangStmt *from)
3432 DropPLangStmt *newnode = makeNode(DropPLangStmt);
3434 COPY_STRING_FIELD(plname);
3435 COPY_SCALAR_FIELD(behavior);
3436 COPY_SCALAR_FIELD(missing_ok);
3438 return newnode;
3441 static CreateRoleStmt *
3442 _copyCreateRoleStmt(CreateRoleStmt *from)
3444 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3446 COPY_SCALAR_FIELD(stmt_type);
3447 COPY_STRING_FIELD(role);
3448 COPY_NODE_FIELD(options);
3450 return newnode;
3453 static AlterRoleStmt *
3454 _copyAlterRoleStmt(AlterRoleStmt *from)
3456 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3458 COPY_STRING_FIELD(role);
3459 COPY_NODE_FIELD(options);
3460 COPY_SCALAR_FIELD(action);
3462 return newnode;
3465 static AlterRoleSetStmt *
3466 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
3468 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3470 COPY_STRING_FIELD(role);
3471 COPY_STRING_FIELD(database);
3472 COPY_NODE_FIELD(setstmt);
3474 return newnode;
3477 static DropRoleStmt *
3478 _copyDropRoleStmt(DropRoleStmt *from)
3480 DropRoleStmt *newnode = makeNode(DropRoleStmt);
3482 COPY_NODE_FIELD(roles);
3483 COPY_SCALAR_FIELD(missing_ok);
3485 return newnode;
3488 static LockStmt *
3489 _copyLockStmt(LockStmt *from)
3491 LockStmt *newnode = makeNode(LockStmt);
3493 COPY_NODE_FIELD(relations);
3494 COPY_SCALAR_FIELD(mode);
3495 COPY_SCALAR_FIELD(nowait);
3497 return newnode;
3500 static ConstraintsSetStmt *
3501 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
3503 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3505 COPY_NODE_FIELD(constraints);
3506 COPY_SCALAR_FIELD(deferred);
3508 return newnode;
3511 static ReindexStmt *
3512 _copyReindexStmt(ReindexStmt *from)
3514 ReindexStmt *newnode = makeNode(ReindexStmt);
3516 COPY_SCALAR_FIELD(kind);
3517 COPY_NODE_FIELD(relation);
3518 COPY_STRING_FIELD(name);
3519 COPY_SCALAR_FIELD(do_system);
3520 COPY_SCALAR_FIELD(do_user);
3522 return newnode;
3525 static CreateSchemaStmt *
3526 _copyCreateSchemaStmt(CreateSchemaStmt *from)
3528 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3530 COPY_STRING_FIELD(schemaname);
3531 COPY_STRING_FIELD(authid);
3532 COPY_NODE_FIELD(schemaElts);
3534 return newnode;
3537 static CreateConversionStmt *
3538 _copyCreateConversionStmt(CreateConversionStmt *from)
3540 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3542 COPY_NODE_FIELD(conversion_name);
3543 COPY_STRING_FIELD(for_encoding_name);
3544 COPY_STRING_FIELD(to_encoding_name);
3545 COPY_NODE_FIELD(func_name);
3546 COPY_SCALAR_FIELD(def);
3548 return newnode;
3551 static CreateCastStmt *
3552 _copyCreateCastStmt(CreateCastStmt *from)
3554 CreateCastStmt *newnode = makeNode(CreateCastStmt);
3556 COPY_NODE_FIELD(sourcetype);
3557 COPY_NODE_FIELD(targettype);
3558 COPY_NODE_FIELD(func);
3559 COPY_SCALAR_FIELD(context);
3560 COPY_SCALAR_FIELD(inout);
3562 return newnode;
3565 static DropCastStmt *
3566 _copyDropCastStmt(DropCastStmt *from)
3568 DropCastStmt *newnode = makeNode(DropCastStmt);
3570 COPY_NODE_FIELD(sourcetype);
3571 COPY_NODE_FIELD(targettype);
3572 COPY_SCALAR_FIELD(behavior);
3573 COPY_SCALAR_FIELD(missing_ok);
3575 return newnode;
3578 static PrepareStmt *
3579 _copyPrepareStmt(PrepareStmt *from)
3581 PrepareStmt *newnode = makeNode(PrepareStmt);
3583 COPY_STRING_FIELD(name);
3584 COPY_NODE_FIELD(argtypes);
3585 COPY_NODE_FIELD(query);
3587 return newnode;
3590 static ExecuteStmt *
3591 _copyExecuteStmt(ExecuteStmt *from)
3593 ExecuteStmt *newnode = makeNode(ExecuteStmt);
3595 COPY_STRING_FIELD(name);
3596 COPY_NODE_FIELD(into);
3597 COPY_NODE_FIELD(params);
3599 return newnode;
3602 static DeallocateStmt *
3603 _copyDeallocateStmt(DeallocateStmt *from)
3605 DeallocateStmt *newnode = makeNode(DeallocateStmt);
3607 COPY_STRING_FIELD(name);
3609 return newnode;
3612 static DropOwnedStmt *
3613 _copyDropOwnedStmt(DropOwnedStmt *from)
3615 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3617 COPY_NODE_FIELD(roles);
3618 COPY_SCALAR_FIELD(behavior);
3620 return newnode;
3623 static ReassignOwnedStmt *
3624 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
3626 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3628 COPY_NODE_FIELD(roles);
3629 COPY_SCALAR_FIELD(newrole);
3631 return newnode;
3634 static AlterTSDictionaryStmt *
3635 _copyAlterTSDictionaryStmt(AlterTSDictionaryStmt *from)
3637 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3639 COPY_NODE_FIELD(dictname);
3640 COPY_NODE_FIELD(options);
3642 return newnode;
3645 static AlterTSConfigurationStmt *
3646 _copyAlterTSConfigurationStmt(AlterTSConfigurationStmt *from)
3648 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3650 COPY_NODE_FIELD(cfgname);
3651 COPY_NODE_FIELD(tokentype);
3652 COPY_NODE_FIELD(dicts);
3653 COPY_SCALAR_FIELD(override);
3654 COPY_SCALAR_FIELD(replace);
3655 COPY_SCALAR_FIELD(missing_ok);
3657 return newnode;
3660 /* ****************************************************************
3661 * pg_list.h copy functions
3662 * ****************************************************************
3666 * Perform a deep copy of the specified list, using copyObject(). The
3667 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
3668 * need deep copies, so they should be copied via list_copy()
3670 #define COPY_NODE_CELL(new, old) \
3671 (new) = (ListCell *) palloc(sizeof(ListCell)); \
3672 lfirst(new) = copyObject(lfirst(old));
3674 static List *
3675 _copyList(List *from)
3677 List *new;
3678 ListCell *curr_old;
3679 ListCell *prev_new;
3681 Assert(list_length(from) >= 1);
3683 new = makeNode(List);
3684 new->length = from->length;
3686 COPY_NODE_CELL(new->head, from->head);
3687 prev_new = new->head;
3688 curr_old = lnext(from->head);
3690 while (curr_old)
3692 COPY_NODE_CELL(prev_new->next, curr_old);
3693 prev_new = prev_new->next;
3694 curr_old = curr_old->next;
3696 prev_new->next = NULL;
3697 new->tail = prev_new;
3699 return new;
3702 /* ****************************************************************
3703 * value.h copy functions
3704 * ****************************************************************
3706 static Value *
3707 _copyValue(Value *from)
3709 Value *newnode = makeNode(Value);
3711 /* See also _copyAConst when changing this code! */
3713 COPY_SCALAR_FIELD(type);
3714 switch (from->type)
3716 case T_Integer:
3717 COPY_SCALAR_FIELD(val.ival);
3718 break;
3719 case T_Float:
3720 case T_String:
3721 case T_BitString:
3722 COPY_STRING_FIELD(val.str);
3723 break;
3724 case T_Null:
3725 /* nothing to do */
3726 break;
3727 default:
3728 elog(ERROR, "unrecognized node type: %d",
3729 (int) from->type);
3730 break;
3732 return newnode;
3736 * copyObject
3738 * Create a copy of a Node tree or list. This is a "deep" copy: all
3739 * substructure is copied too, recursively.
3741 void *
3742 copyObject(void *from)
3744 void *retval;
3746 if (from == NULL)
3747 return NULL;
3749 /* Guard against stack overflow due to overly complex expressions */
3750 check_stack_depth();
3752 switch (nodeTag(from))
3755 * PLAN NODES
3757 case T_PlannedStmt:
3758 retval = _copyPlannedStmt(from);
3759 break;
3760 case T_Plan:
3761 retval = _copyPlan(from);
3762 break;
3763 case T_Result:
3764 retval = _copyResult(from);
3765 break;
3766 case T_ModifyTable:
3767 retval = _copyModifyTable(from);
3768 break;
3769 case T_Append:
3770 retval = _copyAppend(from);
3771 break;
3772 case T_MergeAppend:
3773 retval = _copyMergeAppend(from);
3774 break;
3775 case T_RecursiveUnion:
3776 retval = _copyRecursiveUnion(from);
3777 break;
3778 case T_BitmapAnd:
3779 retval = _copyBitmapAnd(from);
3780 break;
3781 case T_BitmapOr:
3782 retval = _copyBitmapOr(from);
3783 break;
3784 case T_Scan:
3785 retval = _copyScan(from);
3786 break;
3787 case T_SeqScan:
3788 retval = _copySeqScan(from);
3789 break;
3790 case T_IndexScan:
3791 retval = _copyIndexScan(from);
3792 break;
3793 case T_BitmapIndexScan:
3794 retval = _copyBitmapIndexScan(from);
3795 break;
3796 case T_BitmapHeapScan:
3797 retval = _copyBitmapHeapScan(from);
3798 break;
3799 case T_TidScan:
3800 retval = _copyTidScan(from);
3801 break;
3802 case T_SubqueryScan:
3803 retval = _copySubqueryScan(from);
3804 break;
3805 case T_FunctionScan:
3806 retval = _copyFunctionScan(from);
3807 break;
3808 case T_ValuesScan:
3809 retval = _copyValuesScan(from);
3810 break;
3811 case T_CteScan:
3812 retval = _copyCteScan(from);
3813 break;
3814 case T_WorkTableScan:
3815 retval = _copyWorkTableScan(from);
3816 break;
3817 case T_Join:
3818 retval = _copyJoin(from);
3819 break;
3820 case T_NestLoop:
3821 retval = _copyNestLoop(from);
3822 break;
3823 case T_MergeJoin:
3824 retval = _copyMergeJoin(from);
3825 break;
3826 case T_HashJoin:
3827 retval = _copyHashJoin(from);
3828 break;
3829 case T_Material:
3830 retval = _copyMaterial(from);
3831 break;
3832 case T_Sort:
3833 retval = _copySort(from);
3834 break;
3835 case T_Group:
3836 retval = _copyGroup(from);
3837 break;
3838 case T_Agg:
3839 retval = _copyAgg(from);
3840 break;
3841 case T_WindowAgg:
3842 retval = _copyWindowAgg(from);
3843 break;
3844 case T_Unique:
3845 retval = _copyUnique(from);
3846 break;
3847 case T_Hash:
3848 retval = _copyHash(from);
3849 break;
3850 case T_SetOp:
3851 retval = _copySetOp(from);
3852 break;
3853 case T_LockRows:
3854 retval = _copyLockRows(from);
3855 break;
3856 case T_Limit:
3857 retval = _copyLimit(from);
3858 break;
3859 case T_NestLoopParam:
3860 retval = _copyNestLoopParam(from);
3861 break;
3862 case T_PlanRowMark:
3863 retval = _copyPlanRowMark(from);
3864 break;
3865 case T_PlanInvalItem:
3866 retval = _copyPlanInvalItem(from);
3867 break;
3870 * PRIMITIVE NODES
3872 case T_Alias:
3873 retval = _copyAlias(from);
3874 break;
3875 case T_RangeVar:
3876 retval = _copyRangeVar(from);
3877 break;
3878 case T_IntoClause:
3879 retval = _copyIntoClause(from);
3880 break;
3881 case T_Var:
3882 retval = _copyVar(from);
3883 break;
3884 case T_Const:
3885 retval = _copyConst(from);
3886 break;
3887 case T_Param:
3888 retval = _copyParam(from);
3889 break;
3890 case T_Aggref:
3891 retval = _copyAggref(from);
3892 break;
3893 case T_WindowFunc:
3894 retval = _copyWindowFunc(from);
3895 break;
3896 case T_ArrayRef:
3897 retval = _copyArrayRef(from);
3898 break;
3899 case T_FuncExpr:
3900 retval = _copyFuncExpr(from);
3901 break;
3902 case T_NamedArgExpr:
3903 retval = _copyNamedArgExpr(from);
3904 break;
3905 case T_OpExpr:
3906 retval = _copyOpExpr(from);
3907 break;
3908 case T_DistinctExpr:
3909 retval = _copyDistinctExpr(from);
3910 break;
3911 case T_ScalarArrayOpExpr:
3912 retval = _copyScalarArrayOpExpr(from);
3913 break;
3914 case T_BoolExpr:
3915 retval = _copyBoolExpr(from);
3916 break;
3917 case T_SubLink:
3918 retval = _copySubLink(from);
3919 break;
3920 case T_SubPlan:
3921 retval = _copySubPlan(from);
3922 break;
3923 case T_AlternativeSubPlan:
3924 retval = _copyAlternativeSubPlan(from);
3925 break;
3926 case T_FieldSelect:
3927 retval = _copyFieldSelect(from);
3928 break;
3929 case T_FieldStore:
3930 retval = _copyFieldStore(from);
3931 break;
3932 case T_RelabelType:
3933 retval = _copyRelabelType(from);
3934 break;
3935 case T_CoerceViaIO:
3936 retval = _copyCoerceViaIO(from);
3937 break;
3938 case T_ArrayCoerceExpr:
3939 retval = _copyArrayCoerceExpr(from);
3940 break;
3941 case T_ConvertRowtypeExpr:
3942 retval = _copyConvertRowtypeExpr(from);
3943 break;
3944 case T_CaseExpr:
3945 retval = _copyCaseExpr(from);
3946 break;
3947 case T_CaseWhen:
3948 retval = _copyCaseWhen(from);
3949 break;
3950 case T_CaseTestExpr:
3951 retval = _copyCaseTestExpr(from);
3952 break;
3953 case T_ArrayExpr:
3954 retval = _copyArrayExpr(from);
3955 break;
3956 case T_RowExpr:
3957 retval = _copyRowExpr(from);
3958 break;
3959 case T_RowCompareExpr:
3960 retval = _copyRowCompareExpr(from);
3961 break;
3962 case T_CoalesceExpr:
3963 retval = _copyCoalesceExpr(from);
3964 break;
3965 case T_MinMaxExpr:
3966 retval = _copyMinMaxExpr(from);
3967 break;
3968 case T_XmlExpr:
3969 retval = _copyXmlExpr(from);
3970 break;
3971 case T_NullIfExpr:
3972 retval = _copyNullIfExpr(from);
3973 break;
3974 case T_NullTest:
3975 retval = _copyNullTest(from);
3976 break;
3977 case T_BooleanTest:
3978 retval = _copyBooleanTest(from);
3979 break;
3980 case T_CoerceToDomain:
3981 retval = _copyCoerceToDomain(from);
3982 break;
3983 case T_CoerceToDomainValue:
3984 retval = _copyCoerceToDomainValue(from);
3985 break;
3986 case T_SetToDefault:
3987 retval = _copySetToDefault(from);
3988 break;
3989 case T_CurrentOfExpr:
3990 retval = _copyCurrentOfExpr(from);
3991 break;
3992 case T_TargetEntry:
3993 retval = _copyTargetEntry(from);
3994 break;
3995 case T_RangeTblRef:
3996 retval = _copyRangeTblRef(from);
3997 break;
3998 case T_JoinExpr:
3999 retval = _copyJoinExpr(from);
4000 break;
4001 case T_FromExpr:
4002 retval = _copyFromExpr(from);
4003 break;
4006 * RELATION NODES
4008 case T_PathKey:
4009 retval = _copyPathKey(from);
4010 break;
4011 case T_RestrictInfo:
4012 retval = _copyRestrictInfo(from);
4013 break;
4014 case T_PlaceHolderVar:
4015 retval = _copyPlaceHolderVar(from);
4016 break;
4017 case T_SpecialJoinInfo:
4018 retval = _copySpecialJoinInfo(from);
4019 break;
4020 case T_AppendRelInfo:
4021 retval = _copyAppendRelInfo(from);
4022 break;
4023 case T_PlaceHolderInfo:
4024 retval = _copyPlaceHolderInfo(from);
4025 break;
4026 case T_MinMaxAggInfo:
4027 retval = _copyMinMaxAggInfo(from);
4028 break;
4031 * VALUE NODES
4033 case T_Integer:
4034 case T_Float:
4035 case T_String:
4036 case T_BitString:
4037 case T_Null:
4038 retval = _copyValue(from);
4039 break;
4042 * LIST NODES
4044 case T_List:
4045 retval = _copyList(from);
4046 break;
4049 * Lists of integers and OIDs don't need to be deep-copied, so we
4050 * perform a shallow copy via list_copy()
4052 case T_IntList:
4053 case T_OidList:
4054 retval = list_copy(from);
4055 break;
4058 * PARSE NODES
4060 case T_Query:
4061 retval = _copyQuery(from);
4062 break;
4063 case T_InsertStmt:
4064 retval = _copyInsertStmt(from);
4065 break;
4066 case T_DeleteStmt:
4067 retval = _copyDeleteStmt(from);
4068 break;
4069 case T_UpdateStmt:
4070 retval = _copyUpdateStmt(from);
4071 break;
4072 case T_SelectStmt:
4073 retval = _copySelectStmt(from);
4074 break;
4075 case T_SetOperationStmt:
4076 retval = _copySetOperationStmt(from);
4077 break;
4078 case T_AlterTableStmt:
4079 retval = _copyAlterTableStmt(from);
4080 break;
4081 case T_AlterTableCmd:
4082 retval = _copyAlterTableCmd(from);
4083 break;
4084 case T_AlterDomainStmt:
4085 retval = _copyAlterDomainStmt(from);
4086 break;
4087 case T_GrantStmt:
4088 retval = _copyGrantStmt(from);
4089 break;
4090 case T_GrantRoleStmt:
4091 retval = _copyGrantRoleStmt(from);
4092 break;
4093 case T_AlterDefaultPrivilegesStmt:
4094 retval = _copyAlterDefaultPrivilegesStmt(from);
4095 break;
4096 case T_DeclareCursorStmt:
4097 retval = _copyDeclareCursorStmt(from);
4098 break;
4099 case T_ClosePortalStmt:
4100 retval = _copyClosePortalStmt(from);
4101 break;
4102 case T_ClusterStmt:
4103 retval = _copyClusterStmt(from);
4104 break;
4105 case T_CopyStmt:
4106 retval = _copyCopyStmt(from);
4107 break;
4108 case T_CreateStmt:
4109 retval = _copyCreateStmt(from);
4110 break;
4111 case T_InhRelation:
4112 retval = _copyInhRelation(from);
4113 break;
4114 case T_DefineStmt:
4115 retval = _copyDefineStmt(from);
4116 break;
4117 case T_DropStmt:
4118 retval = _copyDropStmt(from);
4119 break;
4120 case T_TruncateStmt:
4121 retval = _copyTruncateStmt(from);
4122 break;
4123 case T_CommentStmt:
4124 retval = _copyCommentStmt(from);
4125 break;
4126 case T_SecLabelStmt:
4127 retval = _copySecLabelStmt(from);
4128 break;
4129 case T_FetchStmt:
4130 retval = _copyFetchStmt(from);
4131 break;
4132 case T_IndexStmt:
4133 retval = _copyIndexStmt(from);
4134 break;
4135 case T_CreateFunctionStmt:
4136 retval = _copyCreateFunctionStmt(from);
4137 break;
4138 case T_FunctionParameter:
4139 retval = _copyFunctionParameter(from);
4140 break;
4141 case T_AlterFunctionStmt:
4142 retval = _copyAlterFunctionStmt(from);
4143 break;
4144 case T_RemoveFuncStmt:
4145 retval = _copyRemoveFuncStmt(from);
4146 break;
4147 case T_DoStmt:
4148 retval = _copyDoStmt(from);
4149 break;
4150 case T_RemoveOpClassStmt:
4151 retval = _copyRemoveOpClassStmt(from);
4152 break;
4153 case T_RemoveOpFamilyStmt:
4154 retval = _copyRemoveOpFamilyStmt(from);
4155 break;
4156 case T_RenameStmt:
4157 retval = _copyRenameStmt(from);
4158 break;
4159 case T_AlterObjectSchemaStmt:
4160 retval = _copyAlterObjectSchemaStmt(from);
4161 break;
4162 case T_AlterOwnerStmt:
4163 retval = _copyAlterOwnerStmt(from);
4164 break;
4165 case T_RuleStmt:
4166 retval = _copyRuleStmt(from);
4167 break;
4168 case T_NotifyStmt:
4169 retval = _copyNotifyStmt(from);
4170 break;
4171 case T_ListenStmt:
4172 retval = _copyListenStmt(from);
4173 break;
4174 case T_UnlistenStmt:
4175 retval = _copyUnlistenStmt(from);
4176 break;
4177 case T_TransactionStmt:
4178 retval = _copyTransactionStmt(from);
4179 break;
4180 case T_CompositeTypeStmt:
4181 retval = _copyCompositeTypeStmt(from);
4182 break;
4183 case T_CreateEnumStmt:
4184 retval = _copyCreateEnumStmt(from);
4185 break;
4186 case T_AlterEnumStmt:
4187 retval = _copyAlterEnumStmt(from);
4188 break;
4189 case T_ViewStmt:
4190 retval = _copyViewStmt(from);
4191 break;
4192 case T_LoadStmt:
4193 retval = _copyLoadStmt(from);
4194 break;
4195 case T_CreateDomainStmt:
4196 retval = _copyCreateDomainStmt(from);
4197 break;
4198 case T_CreateOpClassStmt:
4199 retval = _copyCreateOpClassStmt(from);
4200 break;
4201 case T_CreateOpClassItem:
4202 retval = _copyCreateOpClassItem(from);
4203 break;
4204 case T_CreateOpFamilyStmt:
4205 retval = _copyCreateOpFamilyStmt(from);
4206 break;
4207 case T_AlterOpFamilyStmt:
4208 retval = _copyAlterOpFamilyStmt(from);
4209 break;
4210 case T_CreatedbStmt:
4211 retval = _copyCreatedbStmt(from);
4212 break;
4213 case T_AlterDatabaseStmt:
4214 retval = _copyAlterDatabaseStmt(from);
4215 break;
4216 case T_AlterDatabaseSetStmt:
4217 retval = _copyAlterDatabaseSetStmt(from);
4218 break;
4219 case T_DropdbStmt:
4220 retval = _copyDropdbStmt(from);
4221 break;
4222 case T_VacuumStmt:
4223 retval = _copyVacuumStmt(from);
4224 break;
4225 case T_ExplainStmt:
4226 retval = _copyExplainStmt(from);
4227 break;
4228 case T_CreateSeqStmt:
4229 retval = _copyCreateSeqStmt(from);
4230 break;
4231 case T_AlterSeqStmt:
4232 retval = _copyAlterSeqStmt(from);
4233 break;
4234 case T_VariableSetStmt:
4235 retval = _copyVariableSetStmt(from);
4236 break;
4237 case T_VariableShowStmt:
4238 retval = _copyVariableShowStmt(from);
4239 break;
4240 case T_DiscardStmt:
4241 retval = _copyDiscardStmt(from);
4242 break;
4243 case T_CreateTableSpaceStmt:
4244 retval = _copyCreateTableSpaceStmt(from);
4245 break;
4246 case T_DropTableSpaceStmt:
4247 retval = _copyDropTableSpaceStmt(from);
4248 break;
4249 case T_AlterTableSpaceOptionsStmt:
4250 retval = _copyAlterTableSpaceOptionsStmt(from);
4251 break;
4252 case T_CreateExtensionStmt:
4253 retval = _copyCreateExtensionStmt(from);
4254 break;
4255 case T_CreateFdwStmt:
4256 retval = _copyCreateFdwStmt(from);
4257 break;
4258 case T_AlterFdwStmt:
4259 retval = _copyAlterFdwStmt(from);
4260 break;
4261 case T_DropFdwStmt:
4262 retval = _copyDropFdwStmt(from);
4263 break;
4264 case T_CreateForeignServerStmt:
4265 retval = _copyCreateForeignServerStmt(from);
4266 break;
4267 case T_AlterForeignServerStmt:
4268 retval = _copyAlterForeignServerStmt(from);
4269 break;
4270 case T_DropForeignServerStmt:
4271 retval = _copyDropForeignServerStmt(from);
4272 break;
4273 case T_CreateUserMappingStmt:
4274 retval = _copyCreateUserMappingStmt(from);
4275 break;
4276 case T_AlterUserMappingStmt:
4277 retval = _copyAlterUserMappingStmt(from);
4278 break;
4279 case T_DropUserMappingStmt:
4280 retval = _copyDropUserMappingStmt(from);
4281 break;
4282 case T_CreateForeignTableStmt:
4283 retval = _copyCreateForeignTableStmt(from);
4284 break;
4285 case T_CreateTrigStmt:
4286 retval = _copyCreateTrigStmt(from);
4287 break;
4288 case T_DropPropertyStmt:
4289 retval = _copyDropPropertyStmt(from);
4290 break;
4291 case T_CreatePLangStmt:
4292 retval = _copyCreatePLangStmt(from);
4293 break;
4294 case T_DropPLangStmt:
4295 retval = _copyDropPLangStmt(from);
4296 break;
4297 case T_CreateRoleStmt:
4298 retval = _copyCreateRoleStmt(from);
4299 break;
4300 case T_AlterRoleStmt:
4301 retval = _copyAlterRoleStmt(from);
4302 break;
4303 case T_AlterRoleSetStmt:
4304 retval = _copyAlterRoleSetStmt(from);
4305 break;
4306 case T_DropRoleStmt:
4307 retval = _copyDropRoleStmt(from);
4308 break;
4309 case T_LockStmt:
4310 retval = _copyLockStmt(from);
4311 break;
4312 case T_ConstraintsSetStmt:
4313 retval = _copyConstraintsSetStmt(from);
4314 break;
4315 case T_ReindexStmt:
4316 retval = _copyReindexStmt(from);
4317 break;
4318 case T_CheckPointStmt:
4319 retval = (void *) makeNode(CheckPointStmt);
4320 break;
4321 case T_CreateSchemaStmt:
4322 retval = _copyCreateSchemaStmt(from);
4323 break;
4324 case T_CreateConversionStmt:
4325 retval = _copyCreateConversionStmt(from);
4326 break;
4327 case T_CreateCastStmt:
4328 retval = _copyCreateCastStmt(from);
4329 break;
4330 case T_DropCastStmt:
4331 retval = _copyDropCastStmt(from);
4332 break;
4333 case T_PrepareStmt:
4334 retval = _copyPrepareStmt(from);
4335 break;
4336 case T_ExecuteStmt:
4337 retval = _copyExecuteStmt(from);
4338 break;
4339 case T_DeallocateStmt:
4340 retval = _copyDeallocateStmt(from);
4341 break;
4342 case T_DropOwnedStmt:
4343 retval = _copyDropOwnedStmt(from);
4344 break;
4345 case T_ReassignOwnedStmt:
4346 retval = _copyReassignOwnedStmt(from);
4347 break;
4348 case T_AlterTSDictionaryStmt:
4349 retval = _copyAlterTSDictionaryStmt(from);
4350 break;
4351 case T_AlterTSConfigurationStmt:
4352 retval = _copyAlterTSConfigurationStmt(from);
4353 break;
4355 case T_A_Expr:
4356 retval = _copyAExpr(from);
4357 break;
4358 case T_ColumnRef:
4359 retval = _copyColumnRef(from);
4360 break;
4361 case T_ParamRef:
4362 retval = _copyParamRef(from);
4363 break;
4364 case T_A_Const:
4365 retval = _copyAConst(from);
4366 break;
4367 case T_FuncCall:
4368 retval = _copyFuncCall(from);
4369 break;
4370 case T_A_Star:
4371 retval = _copyAStar(from);
4372 break;
4373 case T_A_Indices:
4374 retval = _copyAIndices(from);
4375 break;
4376 case T_A_Indirection:
4377 retval = _copyA_Indirection(from);
4378 break;
4379 case T_A_ArrayExpr:
4380 retval = _copyA_ArrayExpr(from);
4381 break;
4382 case T_ResTarget:
4383 retval = _copyResTarget(from);
4384 break;
4385 case T_TypeCast:
4386 retval = _copyTypeCast(from);
4387 break;
4388 case T_CollateClause:
4389 retval = _copyCollateClause(from);
4390 break;
4391 case T_SortBy:
4392 retval = _copySortBy(from);
4393 break;
4394 case T_WindowDef:
4395 retval = _copyWindowDef(from);
4396 break;
4397 case T_RangeSubselect:
4398 retval = _copyRangeSubselect(from);
4399 break;
4400 case T_RangeFunction:
4401 retval = _copyRangeFunction(from);
4402 break;
4403 case T_TypeName:
4404 retval = _copyTypeName(from);
4405 break;
4406 case T_IndexElem:
4407 retval = _copyIndexElem(from);
4408 break;
4409 case T_ColumnDef:
4410 retval = _copyColumnDef(from);
4411 break;
4412 case T_Constraint:
4413 retval = _copyConstraint(from);
4414 break;
4415 case T_DefElem:
4416 retval = _copyDefElem(from);
4417 break;
4418 case T_LockingClause:
4419 retval = _copyLockingClause(from);
4420 break;
4421 case T_RangeTblEntry:
4422 retval = _copyRangeTblEntry(from);
4423 break;
4424 case T_SortGroupClause:
4425 retval = _copySortGroupClause(from);
4426 break;
4427 case T_WindowClause:
4428 retval = _copyWindowClause(from);
4429 break;
4430 case T_RowMarkClause:
4431 retval = _copyRowMarkClause(from);
4432 break;
4433 case T_WithClause:
4434 retval = _copyWithClause(from);
4435 break;
4436 case T_CommonTableExpr:
4437 retval = _copyCommonTableExpr(from);
4438 break;
4439 case T_PrivGrantee:
4440 retval = _copyPrivGrantee(from);
4441 break;
4442 case T_FuncWithArgs:
4443 retval = _copyFuncWithArgs(from);
4444 break;
4445 case T_AccessPriv:
4446 retval = _copyAccessPriv(from);
4447 break;
4448 case T_XmlSerialize:
4449 retval = _copyXmlSerialize(from);
4450 break;
4452 default:
4453 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4454 retval = from; /* keep compiler quiet */
4455 break;
4458 return retval;