1 /*-------------------------------------------------------------------------
4 * Copy functions for Postgres tree nodes.
6 * NOTE: we currently support copying all node types found in parse and
7 * plan trees. We do not support copying executor state trees; there
8 * is no need for that, and no point in maintaining all the code that
9 * would be needed. We also do not support copying Path trees, mainly
10 * because the circular linkages between RelOptInfo and Path nodes can't
11 * be handled easily in a simple depth-first traversal.
14 * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
18 * src/backend/nodes/copyfuncs.c
20 *-------------------------------------------------------------------------
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) \
58 newnode->fldname = palloc(_size); \
59 memcpy(newnode->fldname, from->fldname, _size); \
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 * ****************************************************************
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
);
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.
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
);
125 _copyPlan(Plan
*from
)
127 Plan
*newnode
= makeNode(Plan
);
130 * copy node superclass fields
132 CopyPlanFields(from
, newnode
);
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
);
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
);
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
);
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));
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
);
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
);
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
);
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.
310 CopyScanFields(Scan
*from
, Scan
*newnode
)
312 CopyPlanFields((Plan
*) from
, (Plan
*) newnode
);
314 COPY_SCALAR_FIELD(scanrelid
);
321 _copyScan(Scan
*from
)
323 Scan
*newnode
= makeNode(Scan
);
326 * copy node superclass fields
328 CopyScanFields((Scan
*) from
, (Scan
*) newnode
);
337 _copySeqScan(SeqScan
*from
)
339 SeqScan
*newnode
= makeNode(SeqScan
);
342 * copy node superclass fields
344 CopyScanFields((Scan
*) from
, (Scan
*) newnode
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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.
559 CopyJoinFields(Join
*from
, Join
*newnode
)
561 CopyPlanFields((Plan
*) from
, (Plan
*) newnode
);
563 COPY_SCALAR_FIELD(jointype
);
564 COPY_NODE_FIELD(joinqual
);
572 _copyJoin(Join
*from
)
574 Join
*newnode
= makeNode(Join
);
577 * copy node superclass fields
579 CopyJoinFields(from
, newnode
);
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
);
611 _copyMergeJoin(MergeJoin
*from
)
613 MergeJoin
*newnode
= makeNode(MergeJoin
);
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));
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
);
660 _copyMaterial(Material
*from
)
662 Material
*newnode
= makeNode(Material
);
665 * copy node superclass fields
667 CopyPlanFields((Plan
*) from
, (Plan
*) newnode
);
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));
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
));
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
);
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
);
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
));
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
);
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
);
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
);
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
);
888 static NestLoopParam
*
889 _copyNestLoopParam(NestLoopParam
*from
)
891 NestLoopParam
*newnode
= makeNode(NestLoopParam
);
893 COPY_SCALAR_FIELD(paramno
);
894 COPY_NODE_FIELD(paramval
);
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
);
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
);
931 /* ****************************************************************
932 * primnodes.h copy functions
933 * ****************************************************************
940 _copyAlias(Alias
*from
)
942 Alias
*newnode
= makeNode(Alias
);
944 COPY_STRING_FIELD(aliasname
);
945 COPY_NODE_FIELD(colnames
);
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
);
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
);
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...
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
);
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
;
1038 * passed by reference. We need a palloc'd copy.
1040 newnode
->constvalue
= datumCopy(from
->constvalue
,
1045 COPY_SCALAR_FIELD(constisnull
);
1046 COPY_SCALAR_FIELD(constbyval
);
1047 COPY_LOCATION_FIELD(location
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
1226 _copyBoolExpr(BoolExpr
*from
)
1228 BoolExpr
*newnode
= makeNode(BoolExpr
);
1230 COPY_SCALAR_FIELD(boolop
);
1231 COPY_NODE_FIELD(args
);
1232 COPY_LOCATION_FIELD(location
);
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
);
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
);
1282 * _copyAlternativeSubPlan
1284 static AlternativeSubPlan
*
1285 _copyAlternativeSubPlan(AlternativeSubPlan
*from
)
1287 AlternativeSubPlan
*newnode
= makeNode(AlternativeSubPlan
);
1289 COPY_NODE_FIELD(subplans
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
1417 _copyCaseWhen(CaseWhen
*from
)
1419 CaseWhen
*newnode
= makeNode(CaseWhen
);
1421 COPY_NODE_FIELD(expr
);
1422 COPY_NODE_FIELD(result
);
1423 COPY_LOCATION_FIELD(location
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
1550 * _copyNullIfExpr (same as OpExpr)
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
);
1571 _copyNullTest(NullTest
*from
)
1573 NullTest
*newnode
= makeNode(NullTest
);
1575 COPY_NODE_FIELD(arg
);
1576 COPY_SCALAR_FIELD(nulltesttype
);
1577 COPY_SCALAR_FIELD(argisrow
);
1585 static BooleanTest
*
1586 _copyBooleanTest(BooleanTest
*from
)
1588 BooleanTest
*newnode
= makeNode(BooleanTest
);
1590 COPY_NODE_FIELD(arg
);
1591 COPY_SCALAR_FIELD(booltesttype
);
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
);
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
);
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
);
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
);
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
);
1681 static RangeTblRef
*
1682 _copyRangeTblRef(RangeTblRef
*from
)
1684 RangeTblRef
*newnode
= makeNode(RangeTblRef
);
1686 COPY_SCALAR_FIELD(rtindex
);
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
);
1715 _copyFromExpr(FromExpr
*from
)
1717 FromExpr
*newnode
= makeNode(FromExpr
);
1719 COPY_NODE_FIELD(fromlist
);
1720 COPY_NODE_FIELD(quals
);
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 * ****************************************************************
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
1963 _copyWithClause(WithClause
*from
)
1965 WithClause
*newnode
= makeNode(WithClause
);
1967 COPY_NODE_FIELD(ctes
);
1968 COPY_SCALAR_FIELD(recursive
);
1969 COPY_LOCATION_FIELD(location
);
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
);
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
);
2008 _copyColumnRef(ColumnRef
*from
)
2010 ColumnRef
*newnode
= makeNode(ColumnRef
);
2012 COPY_NODE_FIELD(fields
);
2013 COPY_LOCATION_FIELD(location
);
2019 _copyParamRef(ParamRef
*from
)
2021 ParamRef
*newnode
= makeNode(ParamRef
);
2023 COPY_SCALAR_FIELD(number
);
2024 COPY_LOCATION_FIELD(location
);
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
)
2039 COPY_SCALAR_FIELD(val
.val
.ival
);
2044 COPY_STRING_FIELD(val
.val
.str
);
2050 elog(ERROR
, "unrecognized node type: %d",
2051 (int) from
->val
.type
);
2055 COPY_LOCATION_FIELD(location
);
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
);
2078 _copyAStar(A_Star
*from
)
2080 A_Star
*newnode
= makeNode(A_Star
);
2086 _copyAIndices(A_Indices
*from
)
2088 A_Indices
*newnode
= makeNode(A_Indices
);
2090 COPY_NODE_FIELD(lidx
);
2091 COPY_NODE_FIELD(uidx
);
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
);
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
);
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
);
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
);
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
);
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
);
2181 static RangeSubselect
*
2182 _copyRangeSubselect(RangeSubselect
*from
)
2184 RangeSubselect
*newnode
= makeNode(RangeSubselect
);
2186 COPY_NODE_FIELD(subquery
);
2187 COPY_NODE_FIELD(alias
);
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
);
2205 _copyTypeCast(TypeCast
*from
)
2207 TypeCast
*newnode
= makeNode(TypeCast
);
2209 COPY_NODE_FIELD(arg
);
2210 COPY_NODE_FIELD(typeName
);
2211 COPY_LOCATION_FIELD(location
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
2512 static PrivGrantee
*
2513 _copyPrivGrantee(PrivGrantee
*from
)
2515 PrivGrantee
*newnode
= makeNode(PrivGrantee
);
2517 COPY_STRING_FIELD(rolname
);
2522 static FuncWithArgs
*
2523 _copyFuncWithArgs(FuncWithArgs
*from
)
2525 FuncWithArgs
*newnode
= makeNode(FuncWithArgs
);
2527 COPY_NODE_FIELD(funcname
);
2528 COPY_NODE_FIELD(funcargs
);
2534 _copyAccessPriv(AccessPriv
*from
)
2536 AccessPriv
*newnode
= makeNode(AccessPriv
);
2538 COPY_STRING_FIELD(priv_name
);
2539 COPY_NODE_FIELD(cols
);
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
);
2559 static AlterDefaultPrivilegesStmt
*
2560 _copyAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt
*from
)
2562 AlterDefaultPrivilegesStmt
*newnode
= makeNode(AlterDefaultPrivilegesStmt
);
2564 COPY_NODE_FIELD(options
);
2565 COPY_NODE_FIELD(action
);
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
);
2582 static ClosePortalStmt
*
2583 _copyClosePortalStmt(ClosePortalStmt
*from
)
2585 ClosePortalStmt
*newnode
= makeNode(ClosePortalStmt
);
2587 COPY_STRING_FIELD(portalname
);
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
);
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
);
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.
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
);
2640 _copyCreateStmt(CreateStmt
*from
)
2642 CreateStmt
*newnode
= makeNode(CreateStmt
);
2644 CopyCreateStmtFields(from
, newnode
);
2649 static InhRelation
*
2650 _copyInhRelation(InhRelation
*from
)
2652 InhRelation
*newnode
= makeNode(InhRelation
);
2654 COPY_NODE_FIELD(relation
);
2655 COPY_SCALAR_FIELD(options
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
2791 static AlterFunctionStmt
*
2792 _copyAlterFunctionStmt(AlterFunctionStmt
*from
)
2794 AlterFunctionStmt
*newnode
= makeNode(AlterFunctionStmt
);
2796 COPY_NODE_FIELD(func
);
2797 COPY_NODE_FIELD(actions
);
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
);
2817 _copyDoStmt(DoStmt
*from
)
2819 DoStmt
*newnode
= makeNode(DoStmt
);
2821 COPY_NODE_FIELD(args
);
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
);
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
);
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
);
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
);
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
);
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
);
2915 _copyNotifyStmt(NotifyStmt
*from
)
2917 NotifyStmt
*newnode
= makeNode(NotifyStmt
);
2919 COPY_STRING_FIELD(conditionname
);
2920 COPY_STRING_FIELD(payload
);
2926 _copyListenStmt(ListenStmt
*from
)
2928 ListenStmt
*newnode
= makeNode(ListenStmt
);
2930 COPY_STRING_FIELD(conditionname
);
2935 static UnlistenStmt
*
2936 _copyUnlistenStmt(UnlistenStmt
*from
)
2938 UnlistenStmt
*newnode
= makeNode(UnlistenStmt
);
2940 COPY_STRING_FIELD(conditionname
);
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
);
2957 static CompositeTypeStmt
*
2958 _copyCompositeTypeStmt(CompositeTypeStmt
*from
)
2960 CompositeTypeStmt
*newnode
= makeNode(CompositeTypeStmt
);
2962 COPY_NODE_FIELD(typevar
);
2963 COPY_NODE_FIELD(coldeflist
);
2968 static CreateEnumStmt
*
2969 _copyCreateEnumStmt(CreateEnumStmt
*from
)
2971 CreateEnumStmt
*newnode
= makeNode(CreateEnumStmt
);
2973 COPY_NODE_FIELD(typeName
);
2974 COPY_NODE_FIELD(vals
);
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
);
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
);
3006 _copyLoadStmt(LoadStmt
*from
)
3008 LoadStmt
*newnode
= makeNode(LoadStmt
);
3010 COPY_STRING_FIELD(filename
);
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
);
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
);
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
);
3058 static CreateOpFamilyStmt
*
3059 _copyCreateOpFamilyStmt(CreateOpFamilyStmt
*from
)
3061 CreateOpFamilyStmt
*newnode
= makeNode(CreateOpFamilyStmt
);
3063 COPY_NODE_FIELD(opfamilyname
);
3064 COPY_STRING_FIELD(amname
);
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
);
3082 static CreatedbStmt
*
3083 _copyCreatedbStmt(CreatedbStmt
*from
)
3085 CreatedbStmt
*newnode
= makeNode(CreatedbStmt
);
3087 COPY_STRING_FIELD(dbname
);
3088 COPY_NODE_FIELD(options
);
3093 static AlterDatabaseStmt
*
3094 _copyAlterDatabaseStmt(AlterDatabaseStmt
*from
)
3096 AlterDatabaseStmt
*newnode
= makeNode(AlterDatabaseStmt
);
3098 COPY_STRING_FIELD(dbname
);
3099 COPY_NODE_FIELD(options
);
3104 static AlterDatabaseSetStmt
*
3105 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt
*from
)
3107 AlterDatabaseSetStmt
*newnode
= makeNode(AlterDatabaseSetStmt
);
3109 COPY_STRING_FIELD(dbname
);
3110 COPY_NODE_FIELD(setstmt
);
3116 _copyDropdbStmt(DropdbStmt
*from
)
3118 DropdbStmt
*newnode
= makeNode(DropdbStmt
);
3120 COPY_STRING_FIELD(dbname
);
3121 COPY_SCALAR_FIELD(missing_ok
);
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
);
3140 static ExplainStmt
*
3141 _copyExplainStmt(ExplainStmt
*from
)
3143 ExplainStmt
*newnode
= makeNode(ExplainStmt
);
3145 COPY_NODE_FIELD(query
);
3146 COPY_NODE_FIELD(options
);
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
);
3163 static AlterSeqStmt
*
3164 _copyAlterSeqStmt(AlterSeqStmt
*from
)
3166 AlterSeqStmt
*newnode
= makeNode(AlterSeqStmt
);
3168 COPY_NODE_FIELD(sequence
);
3169 COPY_NODE_FIELD(options
);
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
);
3187 static VariableShowStmt
*
3188 _copyVariableShowStmt(VariableShowStmt
*from
)
3190 VariableShowStmt
*newnode
= makeNode(VariableShowStmt
);
3192 COPY_STRING_FIELD(name
);
3197 static DiscardStmt
*
3198 _copyDiscardStmt(DiscardStmt
*from
)
3200 DiscardStmt
*newnode
= makeNode(DiscardStmt
);
3202 COPY_SCALAR_FIELD(target
);
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
);
3219 static DropTableSpaceStmt
*
3220 _copyDropTableSpaceStmt(DropTableSpaceStmt
*from
)
3222 DropTableSpaceStmt
*newnode
= makeNode(DropTableSpaceStmt
);
3224 COPY_STRING_FIELD(tablespacename
);
3225 COPY_SCALAR_FIELD(missing_ok
);
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
);
3242 static CreateExtensionStmt
*
3243 _copyCreateExtensionStmt(CreateExtensionStmt
*from
)
3245 CreateExtensionStmt
*newnode
= makeNode(CreateExtensionStmt
);
3247 COPY_STRING_FIELD(extname
);
3248 COPY_NODE_FIELD(options
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
3477 static DropRoleStmt
*
3478 _copyDropRoleStmt(DropRoleStmt
*from
)
3480 DropRoleStmt
*newnode
= makeNode(DropRoleStmt
);
3482 COPY_NODE_FIELD(roles
);
3483 COPY_SCALAR_FIELD(missing_ok
);
3489 _copyLockStmt(LockStmt
*from
)
3491 LockStmt
*newnode
= makeNode(LockStmt
);
3493 COPY_NODE_FIELD(relations
);
3494 COPY_SCALAR_FIELD(mode
);
3495 COPY_SCALAR_FIELD(nowait
);
3500 static ConstraintsSetStmt
*
3501 _copyConstraintsSetStmt(ConstraintsSetStmt
*from
)
3503 ConstraintsSetStmt
*newnode
= makeNode(ConstraintsSetStmt
);
3505 COPY_NODE_FIELD(constraints
);
3506 COPY_SCALAR_FIELD(deferred
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
3602 static DeallocateStmt
*
3603 _copyDeallocateStmt(DeallocateStmt
*from
)
3605 DeallocateStmt
*newnode
= makeNode(DeallocateStmt
);
3607 COPY_STRING_FIELD(name
);
3612 static DropOwnedStmt
*
3613 _copyDropOwnedStmt(DropOwnedStmt
*from
)
3615 DropOwnedStmt
*newnode
= makeNode(DropOwnedStmt
);
3617 COPY_NODE_FIELD(roles
);
3618 COPY_SCALAR_FIELD(behavior
);
3623 static ReassignOwnedStmt
*
3624 _copyReassignOwnedStmt(ReassignOwnedStmt
*from
)
3626 ReassignOwnedStmt
*newnode
= makeNode(ReassignOwnedStmt
);
3628 COPY_NODE_FIELD(roles
);
3629 COPY_SCALAR_FIELD(newrole
);
3634 static AlterTSDictionaryStmt
*
3635 _copyAlterTSDictionaryStmt(AlterTSDictionaryStmt
*from
)
3637 AlterTSDictionaryStmt
*newnode
= makeNode(AlterTSDictionaryStmt
);
3639 COPY_NODE_FIELD(dictname
);
3640 COPY_NODE_FIELD(options
);
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
);
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));
3675 _copyList(List
*from
)
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
);
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
;
3702 /* ****************************************************************
3703 * value.h copy functions
3704 * ****************************************************************
3707 _copyValue(Value
*from
)
3709 Value
*newnode
= makeNode(Value
);
3711 /* See also _copyAConst when changing this code! */
3713 COPY_SCALAR_FIELD(type
);
3717 COPY_SCALAR_FIELD(val
.ival
);
3722 COPY_STRING_FIELD(val
.str
);
3728 elog(ERROR
, "unrecognized node type: %d",
3738 * Create a copy of a Node tree or list. This is a "deep" copy: all
3739 * substructure is copied too, recursively.
3742 copyObject(void *from
)
3749 /* Guard against stack overflow due to overly complex expressions */
3750 check_stack_depth();
3752 switch (nodeTag(from
))
3758 retval
= _copyPlannedStmt(from
);
3761 retval
= _copyPlan(from
);
3764 retval
= _copyResult(from
);
3767 retval
= _copyModifyTable(from
);
3770 retval
= _copyAppend(from
);
3773 retval
= _copyMergeAppend(from
);
3775 case T_RecursiveUnion
:
3776 retval
= _copyRecursiveUnion(from
);
3779 retval
= _copyBitmapAnd(from
);
3782 retval
= _copyBitmapOr(from
);
3785 retval
= _copyScan(from
);
3788 retval
= _copySeqScan(from
);
3791 retval
= _copyIndexScan(from
);
3793 case T_BitmapIndexScan
:
3794 retval
= _copyBitmapIndexScan(from
);
3796 case T_BitmapHeapScan
:
3797 retval
= _copyBitmapHeapScan(from
);
3800 retval
= _copyTidScan(from
);
3802 case T_SubqueryScan
:
3803 retval
= _copySubqueryScan(from
);
3805 case T_FunctionScan
:
3806 retval
= _copyFunctionScan(from
);
3809 retval
= _copyValuesScan(from
);
3812 retval
= _copyCteScan(from
);
3814 case T_WorkTableScan
:
3815 retval
= _copyWorkTableScan(from
);
3818 retval
= _copyJoin(from
);
3821 retval
= _copyNestLoop(from
);
3824 retval
= _copyMergeJoin(from
);
3827 retval
= _copyHashJoin(from
);
3830 retval
= _copyMaterial(from
);
3833 retval
= _copySort(from
);
3836 retval
= _copyGroup(from
);
3839 retval
= _copyAgg(from
);
3842 retval
= _copyWindowAgg(from
);
3845 retval
= _copyUnique(from
);
3848 retval
= _copyHash(from
);
3851 retval
= _copySetOp(from
);
3854 retval
= _copyLockRows(from
);
3857 retval
= _copyLimit(from
);
3859 case T_NestLoopParam
:
3860 retval
= _copyNestLoopParam(from
);
3863 retval
= _copyPlanRowMark(from
);
3865 case T_PlanInvalItem
:
3866 retval
= _copyPlanInvalItem(from
);
3873 retval
= _copyAlias(from
);
3876 retval
= _copyRangeVar(from
);
3879 retval
= _copyIntoClause(from
);
3882 retval
= _copyVar(from
);
3885 retval
= _copyConst(from
);
3888 retval
= _copyParam(from
);
3891 retval
= _copyAggref(from
);
3894 retval
= _copyWindowFunc(from
);
3897 retval
= _copyArrayRef(from
);
3900 retval
= _copyFuncExpr(from
);
3902 case T_NamedArgExpr
:
3903 retval
= _copyNamedArgExpr(from
);
3906 retval
= _copyOpExpr(from
);
3908 case T_DistinctExpr
:
3909 retval
= _copyDistinctExpr(from
);
3911 case T_ScalarArrayOpExpr
:
3912 retval
= _copyScalarArrayOpExpr(from
);
3915 retval
= _copyBoolExpr(from
);
3918 retval
= _copySubLink(from
);
3921 retval
= _copySubPlan(from
);
3923 case T_AlternativeSubPlan
:
3924 retval
= _copyAlternativeSubPlan(from
);
3927 retval
= _copyFieldSelect(from
);
3930 retval
= _copyFieldStore(from
);
3933 retval
= _copyRelabelType(from
);
3936 retval
= _copyCoerceViaIO(from
);
3938 case T_ArrayCoerceExpr
:
3939 retval
= _copyArrayCoerceExpr(from
);
3941 case T_ConvertRowtypeExpr
:
3942 retval
= _copyConvertRowtypeExpr(from
);
3945 retval
= _copyCaseExpr(from
);
3948 retval
= _copyCaseWhen(from
);
3950 case T_CaseTestExpr
:
3951 retval
= _copyCaseTestExpr(from
);
3954 retval
= _copyArrayExpr(from
);
3957 retval
= _copyRowExpr(from
);
3959 case T_RowCompareExpr
:
3960 retval
= _copyRowCompareExpr(from
);
3962 case T_CoalesceExpr
:
3963 retval
= _copyCoalesceExpr(from
);
3966 retval
= _copyMinMaxExpr(from
);
3969 retval
= _copyXmlExpr(from
);
3972 retval
= _copyNullIfExpr(from
);
3975 retval
= _copyNullTest(from
);
3978 retval
= _copyBooleanTest(from
);
3980 case T_CoerceToDomain
:
3981 retval
= _copyCoerceToDomain(from
);
3983 case T_CoerceToDomainValue
:
3984 retval
= _copyCoerceToDomainValue(from
);
3986 case T_SetToDefault
:
3987 retval
= _copySetToDefault(from
);
3989 case T_CurrentOfExpr
:
3990 retval
= _copyCurrentOfExpr(from
);
3993 retval
= _copyTargetEntry(from
);
3996 retval
= _copyRangeTblRef(from
);
3999 retval
= _copyJoinExpr(from
);
4002 retval
= _copyFromExpr(from
);
4009 retval
= _copyPathKey(from
);
4011 case T_RestrictInfo
:
4012 retval
= _copyRestrictInfo(from
);
4014 case T_PlaceHolderVar
:
4015 retval
= _copyPlaceHolderVar(from
);
4017 case T_SpecialJoinInfo
:
4018 retval
= _copySpecialJoinInfo(from
);
4020 case T_AppendRelInfo
:
4021 retval
= _copyAppendRelInfo(from
);
4023 case T_PlaceHolderInfo
:
4024 retval
= _copyPlaceHolderInfo(from
);
4026 case T_MinMaxAggInfo
:
4027 retval
= _copyMinMaxAggInfo(from
);
4038 retval
= _copyValue(from
);
4045 retval
= _copyList(from
);
4049 * Lists of integers and OIDs don't need to be deep-copied, so we
4050 * perform a shallow copy via list_copy()
4054 retval
= list_copy(from
);
4061 retval
= _copyQuery(from
);
4064 retval
= _copyInsertStmt(from
);
4067 retval
= _copyDeleteStmt(from
);
4070 retval
= _copyUpdateStmt(from
);
4073 retval
= _copySelectStmt(from
);
4075 case T_SetOperationStmt
:
4076 retval
= _copySetOperationStmt(from
);
4078 case T_AlterTableStmt
:
4079 retval
= _copyAlterTableStmt(from
);
4081 case T_AlterTableCmd
:
4082 retval
= _copyAlterTableCmd(from
);
4084 case T_AlterDomainStmt
:
4085 retval
= _copyAlterDomainStmt(from
);
4088 retval
= _copyGrantStmt(from
);
4090 case T_GrantRoleStmt
:
4091 retval
= _copyGrantRoleStmt(from
);
4093 case T_AlterDefaultPrivilegesStmt
:
4094 retval
= _copyAlterDefaultPrivilegesStmt(from
);
4096 case T_DeclareCursorStmt
:
4097 retval
= _copyDeclareCursorStmt(from
);
4099 case T_ClosePortalStmt
:
4100 retval
= _copyClosePortalStmt(from
);
4103 retval
= _copyClusterStmt(from
);
4106 retval
= _copyCopyStmt(from
);
4109 retval
= _copyCreateStmt(from
);
4112 retval
= _copyInhRelation(from
);
4115 retval
= _copyDefineStmt(from
);
4118 retval
= _copyDropStmt(from
);
4120 case T_TruncateStmt
:
4121 retval
= _copyTruncateStmt(from
);
4124 retval
= _copyCommentStmt(from
);
4126 case T_SecLabelStmt
:
4127 retval
= _copySecLabelStmt(from
);
4130 retval
= _copyFetchStmt(from
);
4133 retval
= _copyIndexStmt(from
);
4135 case T_CreateFunctionStmt
:
4136 retval
= _copyCreateFunctionStmt(from
);
4138 case T_FunctionParameter
:
4139 retval
= _copyFunctionParameter(from
);
4141 case T_AlterFunctionStmt
:
4142 retval
= _copyAlterFunctionStmt(from
);
4144 case T_RemoveFuncStmt
:
4145 retval
= _copyRemoveFuncStmt(from
);
4148 retval
= _copyDoStmt(from
);
4150 case T_RemoveOpClassStmt
:
4151 retval
= _copyRemoveOpClassStmt(from
);
4153 case T_RemoveOpFamilyStmt
:
4154 retval
= _copyRemoveOpFamilyStmt(from
);
4157 retval
= _copyRenameStmt(from
);
4159 case T_AlterObjectSchemaStmt
:
4160 retval
= _copyAlterObjectSchemaStmt(from
);
4162 case T_AlterOwnerStmt
:
4163 retval
= _copyAlterOwnerStmt(from
);
4166 retval
= _copyRuleStmt(from
);
4169 retval
= _copyNotifyStmt(from
);
4172 retval
= _copyListenStmt(from
);
4174 case T_UnlistenStmt
:
4175 retval
= _copyUnlistenStmt(from
);
4177 case T_TransactionStmt
:
4178 retval
= _copyTransactionStmt(from
);
4180 case T_CompositeTypeStmt
:
4181 retval
= _copyCompositeTypeStmt(from
);
4183 case T_CreateEnumStmt
:
4184 retval
= _copyCreateEnumStmt(from
);
4186 case T_AlterEnumStmt
:
4187 retval
= _copyAlterEnumStmt(from
);
4190 retval
= _copyViewStmt(from
);
4193 retval
= _copyLoadStmt(from
);
4195 case T_CreateDomainStmt
:
4196 retval
= _copyCreateDomainStmt(from
);
4198 case T_CreateOpClassStmt
:
4199 retval
= _copyCreateOpClassStmt(from
);
4201 case T_CreateOpClassItem
:
4202 retval
= _copyCreateOpClassItem(from
);
4204 case T_CreateOpFamilyStmt
:
4205 retval
= _copyCreateOpFamilyStmt(from
);
4207 case T_AlterOpFamilyStmt
:
4208 retval
= _copyAlterOpFamilyStmt(from
);
4210 case T_CreatedbStmt
:
4211 retval
= _copyCreatedbStmt(from
);
4213 case T_AlterDatabaseStmt
:
4214 retval
= _copyAlterDatabaseStmt(from
);
4216 case T_AlterDatabaseSetStmt
:
4217 retval
= _copyAlterDatabaseSetStmt(from
);
4220 retval
= _copyDropdbStmt(from
);
4223 retval
= _copyVacuumStmt(from
);
4226 retval
= _copyExplainStmt(from
);
4228 case T_CreateSeqStmt
:
4229 retval
= _copyCreateSeqStmt(from
);
4231 case T_AlterSeqStmt
:
4232 retval
= _copyAlterSeqStmt(from
);
4234 case T_VariableSetStmt
:
4235 retval
= _copyVariableSetStmt(from
);
4237 case T_VariableShowStmt
:
4238 retval
= _copyVariableShowStmt(from
);
4241 retval
= _copyDiscardStmt(from
);
4243 case T_CreateTableSpaceStmt
:
4244 retval
= _copyCreateTableSpaceStmt(from
);
4246 case T_DropTableSpaceStmt
:
4247 retval
= _copyDropTableSpaceStmt(from
);
4249 case T_AlterTableSpaceOptionsStmt
:
4250 retval
= _copyAlterTableSpaceOptionsStmt(from
);
4252 case T_CreateExtensionStmt
:
4253 retval
= _copyCreateExtensionStmt(from
);
4255 case T_CreateFdwStmt
:
4256 retval
= _copyCreateFdwStmt(from
);
4258 case T_AlterFdwStmt
:
4259 retval
= _copyAlterFdwStmt(from
);
4262 retval
= _copyDropFdwStmt(from
);
4264 case T_CreateForeignServerStmt
:
4265 retval
= _copyCreateForeignServerStmt(from
);
4267 case T_AlterForeignServerStmt
:
4268 retval
= _copyAlterForeignServerStmt(from
);
4270 case T_DropForeignServerStmt
:
4271 retval
= _copyDropForeignServerStmt(from
);
4273 case T_CreateUserMappingStmt
:
4274 retval
= _copyCreateUserMappingStmt(from
);
4276 case T_AlterUserMappingStmt
:
4277 retval
= _copyAlterUserMappingStmt(from
);
4279 case T_DropUserMappingStmt
:
4280 retval
= _copyDropUserMappingStmt(from
);
4282 case T_CreateForeignTableStmt
:
4283 retval
= _copyCreateForeignTableStmt(from
);
4285 case T_CreateTrigStmt
:
4286 retval
= _copyCreateTrigStmt(from
);
4288 case T_DropPropertyStmt
:
4289 retval
= _copyDropPropertyStmt(from
);
4291 case T_CreatePLangStmt
:
4292 retval
= _copyCreatePLangStmt(from
);
4294 case T_DropPLangStmt
:
4295 retval
= _copyDropPLangStmt(from
);
4297 case T_CreateRoleStmt
:
4298 retval
= _copyCreateRoleStmt(from
);
4300 case T_AlterRoleStmt
:
4301 retval
= _copyAlterRoleStmt(from
);
4303 case T_AlterRoleSetStmt
:
4304 retval
= _copyAlterRoleSetStmt(from
);
4306 case T_DropRoleStmt
:
4307 retval
= _copyDropRoleStmt(from
);
4310 retval
= _copyLockStmt(from
);
4312 case T_ConstraintsSetStmt
:
4313 retval
= _copyConstraintsSetStmt(from
);
4316 retval
= _copyReindexStmt(from
);
4318 case T_CheckPointStmt
:
4319 retval
= (void *) makeNode(CheckPointStmt
);
4321 case T_CreateSchemaStmt
:
4322 retval
= _copyCreateSchemaStmt(from
);
4324 case T_CreateConversionStmt
:
4325 retval
= _copyCreateConversionStmt(from
);
4327 case T_CreateCastStmt
:
4328 retval
= _copyCreateCastStmt(from
);
4330 case T_DropCastStmt
:
4331 retval
= _copyDropCastStmt(from
);
4334 retval
= _copyPrepareStmt(from
);
4337 retval
= _copyExecuteStmt(from
);
4339 case T_DeallocateStmt
:
4340 retval
= _copyDeallocateStmt(from
);
4342 case T_DropOwnedStmt
:
4343 retval
= _copyDropOwnedStmt(from
);
4345 case T_ReassignOwnedStmt
:
4346 retval
= _copyReassignOwnedStmt(from
);
4348 case T_AlterTSDictionaryStmt
:
4349 retval
= _copyAlterTSDictionaryStmt(from
);
4351 case T_AlterTSConfigurationStmt
:
4352 retval
= _copyAlterTSConfigurationStmt(from
);
4356 retval
= _copyAExpr(from
);
4359 retval
= _copyColumnRef(from
);
4362 retval
= _copyParamRef(from
);
4365 retval
= _copyAConst(from
);
4368 retval
= _copyFuncCall(from
);
4371 retval
= _copyAStar(from
);
4374 retval
= _copyAIndices(from
);
4376 case T_A_Indirection
:
4377 retval
= _copyA_Indirection(from
);
4380 retval
= _copyA_ArrayExpr(from
);
4383 retval
= _copyResTarget(from
);
4386 retval
= _copyTypeCast(from
);
4388 case T_CollateClause
:
4389 retval
= _copyCollateClause(from
);
4392 retval
= _copySortBy(from
);
4395 retval
= _copyWindowDef(from
);
4397 case T_RangeSubselect
:
4398 retval
= _copyRangeSubselect(from
);
4400 case T_RangeFunction
:
4401 retval
= _copyRangeFunction(from
);
4404 retval
= _copyTypeName(from
);
4407 retval
= _copyIndexElem(from
);
4410 retval
= _copyColumnDef(from
);
4413 retval
= _copyConstraint(from
);
4416 retval
= _copyDefElem(from
);
4418 case T_LockingClause
:
4419 retval
= _copyLockingClause(from
);
4421 case T_RangeTblEntry
:
4422 retval
= _copyRangeTblEntry(from
);
4424 case T_SortGroupClause
:
4425 retval
= _copySortGroupClause(from
);
4427 case T_WindowClause
:
4428 retval
= _copyWindowClause(from
);
4430 case T_RowMarkClause
:
4431 retval
= _copyRowMarkClause(from
);
4434 retval
= _copyWithClause(from
);
4436 case T_CommonTableExpr
:
4437 retval
= _copyCommonTableExpr(from
);
4440 retval
= _copyPrivGrantee(from
);
4442 case T_FuncWithArgs
:
4443 retval
= _copyFuncWithArgs(from
);
4446 retval
= _copyAccessPriv(from
);
4448 case T_XmlSerialize
:
4449 retval
= _copyXmlSerialize(from
);
4453 elog(ERROR
, "unrecognized node type: %d", (int) nodeTag(from
));
4454 retval
= from
; /* keep compiler quiet */