Add support for user-defined I/O conversion casts.
[PostgreSQL.git] / src / backend / nodes / copyfuncs.c
blob4273ef18a53449e2215cb269f262364c752ac7ff
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-2008, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
17 * IDENTIFICATION
18 * $PostgreSQL$
20 *-------------------------------------------------------------------------
23 #include "postgres.h"
25 #include "nodes/plannodes.h"
26 #include "nodes/relation.h"
27 #include "utils/datum.h"
31 * Macros to simplify copying of different kinds of fields. Use these
32 * wherever possible to reduce the chance for silly typos. Note that these
33 * hard-wire the convention that the local variables in a Copy routine are
34 * named 'newnode' and 'from'.
37 /* Copy a simple scalar field (int, float, bool, enum, etc) */
38 #define COPY_SCALAR_FIELD(fldname) \
39 (newnode->fldname = from->fldname)
41 /* Copy a field that is a pointer to some kind of Node or Node tree */
42 #define COPY_NODE_FIELD(fldname) \
43 (newnode->fldname = copyObject(from->fldname))
45 /* Copy a field that is a pointer to a Bitmapset */
46 #define COPY_BITMAPSET_FIELD(fldname) \
47 (newnode->fldname = bms_copy(from->fldname))
49 /* Copy a field that is a pointer to a C string, or perhaps NULL */
50 #define COPY_STRING_FIELD(fldname) \
51 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
53 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
54 #define COPY_POINTER_FIELD(fldname, sz) \
55 do { \
56 Size _size = (sz); \
57 newnode->fldname = palloc(_size); \
58 memcpy(newnode->fldname, from->fldname, _size); \
59 } while (0)
61 /* Copy a parse location field (for Copy, this is same as scalar case) */
62 #define COPY_LOCATION_FIELD(fldname) \
63 (newnode->fldname = from->fldname)
66 /* ****************************************************************
67 * plannodes.h copy functions
68 * ****************************************************************
72 * _copyPlannedStmt
74 static PlannedStmt *
75 _copyPlannedStmt(PlannedStmt *from)
77 PlannedStmt *newnode = makeNode(PlannedStmt);
79 COPY_SCALAR_FIELD(commandType);
80 COPY_SCALAR_FIELD(canSetTag);
81 COPY_NODE_FIELD(planTree);
82 COPY_NODE_FIELD(rtable);
83 COPY_NODE_FIELD(resultRelations);
84 COPY_NODE_FIELD(utilityStmt);
85 COPY_NODE_FIELD(intoClause);
86 COPY_NODE_FIELD(subplans);
87 COPY_BITMAPSET_FIELD(rewindPlanIDs);
88 COPY_NODE_FIELD(returningLists);
89 COPY_NODE_FIELD(rowMarks);
90 COPY_NODE_FIELD(relationOids);
91 COPY_NODE_FIELD(invalItems);
92 COPY_SCALAR_FIELD(nParamExec);
94 return newnode;
98 * CopyPlanFields
100 * This function copies the fields of the Plan node. It is used by
101 * all the copy functions for classes which inherit from Plan.
103 static void
104 CopyPlanFields(Plan *from, Plan *newnode)
106 COPY_SCALAR_FIELD(startup_cost);
107 COPY_SCALAR_FIELD(total_cost);
108 COPY_SCALAR_FIELD(plan_rows);
109 COPY_SCALAR_FIELD(plan_width);
110 COPY_NODE_FIELD(targetlist);
111 COPY_NODE_FIELD(qual);
112 COPY_NODE_FIELD(lefttree);
113 COPY_NODE_FIELD(righttree);
114 COPY_NODE_FIELD(initPlan);
115 COPY_BITMAPSET_FIELD(extParam);
116 COPY_BITMAPSET_FIELD(allParam);
120 * _copyPlan
122 static Plan *
123 _copyPlan(Plan *from)
125 Plan *newnode = makeNode(Plan);
128 * copy node superclass fields
130 CopyPlanFields(from, newnode);
132 return newnode;
137 * _copyResult
139 static Result *
140 _copyResult(Result *from)
142 Result *newnode = makeNode(Result);
145 * copy node superclass fields
147 CopyPlanFields((Plan *) from, (Plan *) newnode);
150 * copy remainder of node
152 COPY_NODE_FIELD(resconstantqual);
154 return newnode;
158 * _copyAppend
160 static Append *
161 _copyAppend(Append *from)
163 Append *newnode = makeNode(Append);
166 * copy node superclass fields
168 CopyPlanFields((Plan *) from, (Plan *) newnode);
171 * copy remainder of node
173 COPY_NODE_FIELD(appendplans);
174 COPY_SCALAR_FIELD(isTarget);
176 return newnode;
180 * _copyRecursiveUnion
182 static RecursiveUnion *
183 _copyRecursiveUnion(RecursiveUnion *from)
185 RecursiveUnion *newnode = makeNode(RecursiveUnion);
188 * copy node superclass fields
190 CopyPlanFields((Plan *) from, (Plan *) newnode);
193 * copy remainder of node
195 COPY_SCALAR_FIELD(wtParam);
196 COPY_SCALAR_FIELD(numCols);
197 if (from->numCols > 0)
199 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
200 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
202 COPY_SCALAR_FIELD(numGroups);
204 return newnode;
208 * _copyBitmapAnd
210 static BitmapAnd *
211 _copyBitmapAnd(BitmapAnd *from)
213 BitmapAnd *newnode = makeNode(BitmapAnd);
216 * copy node superclass fields
218 CopyPlanFields((Plan *) from, (Plan *) newnode);
221 * copy remainder of node
223 COPY_NODE_FIELD(bitmapplans);
225 return newnode;
229 * _copyBitmapOr
231 static BitmapOr *
232 _copyBitmapOr(BitmapOr *from)
234 BitmapOr *newnode = makeNode(BitmapOr);
237 * copy node superclass fields
239 CopyPlanFields((Plan *) from, (Plan *) newnode);
242 * copy remainder of node
244 COPY_NODE_FIELD(bitmapplans);
246 return newnode;
251 * CopyScanFields
253 * This function copies the fields of the Scan node. It is used by
254 * all the copy functions for classes which inherit from Scan.
256 static void
257 CopyScanFields(Scan *from, Scan *newnode)
259 CopyPlanFields((Plan *) from, (Plan *) newnode);
261 COPY_SCALAR_FIELD(scanrelid);
265 * _copyScan
267 static Scan *
268 _copyScan(Scan *from)
270 Scan *newnode = makeNode(Scan);
273 * copy node superclass fields
275 CopyScanFields((Scan *) from, (Scan *) newnode);
277 return newnode;
281 * _copySeqScan
283 static SeqScan *
284 _copySeqScan(SeqScan *from)
286 SeqScan *newnode = makeNode(SeqScan);
289 * copy node superclass fields
291 CopyScanFields((Scan *) from, (Scan *) newnode);
293 return newnode;
297 * _copyIndexScan
299 static IndexScan *
300 _copyIndexScan(IndexScan *from)
302 IndexScan *newnode = makeNode(IndexScan);
305 * copy node superclass fields
307 CopyScanFields((Scan *) from, (Scan *) newnode);
310 * copy remainder of node
312 COPY_SCALAR_FIELD(indexid);
313 COPY_NODE_FIELD(indexqual);
314 COPY_NODE_FIELD(indexqualorig);
315 COPY_SCALAR_FIELD(indexorderdir);
317 return newnode;
321 * _copyBitmapIndexScan
323 static BitmapIndexScan *
324 _copyBitmapIndexScan(BitmapIndexScan *from)
326 BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
329 * copy node superclass fields
331 CopyScanFields((Scan *) from, (Scan *) newnode);
334 * copy remainder of node
336 COPY_SCALAR_FIELD(indexid);
337 COPY_NODE_FIELD(indexqual);
338 COPY_NODE_FIELD(indexqualorig);
340 return newnode;
344 * _copyBitmapHeapScan
346 static BitmapHeapScan *
347 _copyBitmapHeapScan(BitmapHeapScan *from)
349 BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
352 * copy node superclass fields
354 CopyScanFields((Scan *) from, (Scan *) newnode);
357 * copy remainder of node
359 COPY_NODE_FIELD(bitmapqualorig);
361 return newnode;
365 * _copyTidScan
367 static TidScan *
368 _copyTidScan(TidScan *from)
370 TidScan *newnode = makeNode(TidScan);
373 * copy node superclass fields
375 CopyScanFields((Scan *) from, (Scan *) newnode);
378 * copy remainder of node
380 COPY_NODE_FIELD(tidquals);
382 return newnode;
386 * _copySubqueryScan
388 static SubqueryScan *
389 _copySubqueryScan(SubqueryScan *from)
391 SubqueryScan *newnode = makeNode(SubqueryScan);
394 * copy node superclass fields
396 CopyScanFields((Scan *) from, (Scan *) newnode);
399 * copy remainder of node
401 COPY_NODE_FIELD(subplan);
402 COPY_NODE_FIELD(subrtable);
404 return newnode;
408 * _copyFunctionScan
410 static FunctionScan *
411 _copyFunctionScan(FunctionScan *from)
413 FunctionScan *newnode = makeNode(FunctionScan);
416 * copy node superclass fields
418 CopyScanFields((Scan *) from, (Scan *) newnode);
421 * copy remainder of node
423 COPY_NODE_FIELD(funcexpr);
424 COPY_NODE_FIELD(funccolnames);
425 COPY_NODE_FIELD(funccoltypes);
426 COPY_NODE_FIELD(funccoltypmods);
428 return newnode;
432 * _copyValuesScan
434 static ValuesScan *
435 _copyValuesScan(ValuesScan *from)
437 ValuesScan *newnode = makeNode(ValuesScan);
440 * copy node superclass fields
442 CopyScanFields((Scan *) from, (Scan *) newnode);
445 * copy remainder of node
447 COPY_NODE_FIELD(values_lists);
449 return newnode;
453 * _copyCteScan
455 static CteScan *
456 _copyCteScan(CteScan *from)
458 CteScan *newnode = makeNode(CteScan);
461 * copy node superclass fields
463 CopyScanFields((Scan *) from, (Scan *) newnode);
466 * copy remainder of node
468 COPY_SCALAR_FIELD(ctePlanId);
469 COPY_SCALAR_FIELD(cteParam);
471 return newnode;
475 * _copyWorkTableScan
477 static WorkTableScan *
478 _copyWorkTableScan(WorkTableScan *from)
480 WorkTableScan *newnode = makeNode(WorkTableScan);
483 * copy node superclass fields
485 CopyScanFields((Scan *) from, (Scan *) newnode);
488 * copy remainder of node
490 COPY_SCALAR_FIELD(wtParam);
492 return newnode;
496 * CopyJoinFields
498 * This function copies the fields of the Join node. It is used by
499 * all the copy functions for classes which inherit from Join.
501 static void
502 CopyJoinFields(Join *from, Join *newnode)
504 CopyPlanFields((Plan *) from, (Plan *) newnode);
506 COPY_SCALAR_FIELD(jointype);
507 COPY_NODE_FIELD(joinqual);
512 * _copyJoin
514 static Join *
515 _copyJoin(Join *from)
517 Join *newnode = makeNode(Join);
520 * copy node superclass fields
522 CopyJoinFields(from, newnode);
524 return newnode;
529 * _copyNestLoop
531 static NestLoop *
532 _copyNestLoop(NestLoop *from)
534 NestLoop *newnode = makeNode(NestLoop);
537 * copy node superclass fields
539 CopyJoinFields((Join *) from, (Join *) newnode);
541 return newnode;
546 * _copyMergeJoin
548 static MergeJoin *
549 _copyMergeJoin(MergeJoin *from)
551 MergeJoin *newnode = makeNode(MergeJoin);
552 int numCols;
555 * copy node superclass fields
557 CopyJoinFields((Join *) from, (Join *) newnode);
560 * copy remainder of node
562 COPY_NODE_FIELD(mergeclauses);
563 numCols = list_length(from->mergeclauses);
564 COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
565 COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
566 COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
568 return newnode;
572 * _copyHashJoin
574 static HashJoin *
575 _copyHashJoin(HashJoin *from)
577 HashJoin *newnode = makeNode(HashJoin);
580 * copy node superclass fields
582 CopyJoinFields((Join *) from, (Join *) newnode);
585 * copy remainder of node
587 COPY_NODE_FIELD(hashclauses);
589 return newnode;
594 * _copyMaterial
596 static Material *
597 _copyMaterial(Material *from)
599 Material *newnode = makeNode(Material);
602 * copy node superclass fields
604 CopyPlanFields((Plan *) from, (Plan *) newnode);
606 return newnode;
611 * _copySort
613 static Sort *
614 _copySort(Sort *from)
616 Sort *newnode = makeNode(Sort);
619 * copy node superclass fields
621 CopyPlanFields((Plan *) from, (Plan *) newnode);
623 COPY_SCALAR_FIELD(numCols);
624 COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
625 COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
626 COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
628 return newnode;
633 * _copyGroup
635 static Group *
636 _copyGroup(Group *from)
638 Group *newnode = makeNode(Group);
640 CopyPlanFields((Plan *) from, (Plan *) newnode);
642 COPY_SCALAR_FIELD(numCols);
643 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
644 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
646 return newnode;
650 * _copyAgg
652 static Agg *
653 _copyAgg(Agg *from)
655 Agg *newnode = makeNode(Agg);
657 CopyPlanFields((Plan *) from, (Plan *) newnode);
659 COPY_SCALAR_FIELD(aggstrategy);
660 COPY_SCALAR_FIELD(numCols);
661 if (from->numCols > 0)
663 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
664 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
666 COPY_SCALAR_FIELD(numGroups);
668 return newnode;
672 * _copyUnique
674 static Unique *
675 _copyUnique(Unique *from)
677 Unique *newnode = makeNode(Unique);
680 * copy node superclass fields
682 CopyPlanFields((Plan *) from, (Plan *) newnode);
685 * copy remainder of node
687 COPY_SCALAR_FIELD(numCols);
688 COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
689 COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
691 return newnode;
695 * _copyHash
697 static Hash *
698 _copyHash(Hash *from)
700 Hash *newnode = makeNode(Hash);
703 * copy node superclass fields
705 CopyPlanFields((Plan *) from, (Plan *) newnode);
708 * copy remainder of node
711 return newnode;
715 * _copySetOp
717 static SetOp *
718 _copySetOp(SetOp *from)
720 SetOp *newnode = makeNode(SetOp);
723 * copy node superclass fields
725 CopyPlanFields((Plan *) from, (Plan *) newnode);
728 * copy remainder of node
730 COPY_SCALAR_FIELD(cmd);
731 COPY_SCALAR_FIELD(strategy);
732 COPY_SCALAR_FIELD(numCols);
733 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
734 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
735 COPY_SCALAR_FIELD(flagColIdx);
736 COPY_SCALAR_FIELD(firstFlag);
737 COPY_SCALAR_FIELD(numGroups);
739 return newnode;
743 * _copyLimit
745 static Limit *
746 _copyLimit(Limit *from)
748 Limit *newnode = makeNode(Limit);
751 * copy node superclass fields
753 CopyPlanFields((Plan *) from, (Plan *) newnode);
756 * copy remainder of node
758 COPY_NODE_FIELD(limitOffset);
759 COPY_NODE_FIELD(limitCount);
761 return newnode;
765 * _copyPlanInvalItem
767 static PlanInvalItem *
768 _copyPlanInvalItem(PlanInvalItem *from)
770 PlanInvalItem *newnode = makeNode(PlanInvalItem);
772 COPY_SCALAR_FIELD(cacheId);
773 /* tupleId isn't really a "scalar", but this works anyway */
774 COPY_SCALAR_FIELD(tupleId);
776 return newnode;
779 /* ****************************************************************
780 * primnodes.h copy functions
781 * ****************************************************************
785 * _copyAlias
787 static Alias *
788 _copyAlias(Alias *from)
790 Alias *newnode = makeNode(Alias);
792 COPY_STRING_FIELD(aliasname);
793 COPY_NODE_FIELD(colnames);
795 return newnode;
799 * _copyRangeVar
801 static RangeVar *
802 _copyRangeVar(RangeVar *from)
804 RangeVar *newnode = makeNode(RangeVar);
806 COPY_STRING_FIELD(catalogname);
807 COPY_STRING_FIELD(schemaname);
808 COPY_STRING_FIELD(relname);
809 COPY_SCALAR_FIELD(inhOpt);
810 COPY_SCALAR_FIELD(istemp);
811 COPY_NODE_FIELD(alias);
812 COPY_LOCATION_FIELD(location);
814 return newnode;
818 * _copyIntoClause
820 static IntoClause *
821 _copyIntoClause(IntoClause *from)
823 IntoClause *newnode = makeNode(IntoClause);
825 COPY_NODE_FIELD(rel);
826 COPY_NODE_FIELD(colNames);
827 COPY_NODE_FIELD(options);
828 COPY_SCALAR_FIELD(onCommit);
829 COPY_STRING_FIELD(tableSpaceName);
831 return newnode;
835 * We don't need a _copyExpr because Expr is an abstract supertype which
836 * should never actually get instantiated. Also, since it has no common
837 * fields except NodeTag, there's no need for a helper routine to factor
838 * out copying the common fields...
842 * _copyVar
844 static Var *
845 _copyVar(Var *from)
847 Var *newnode = makeNode(Var);
849 COPY_SCALAR_FIELD(varno);
850 COPY_SCALAR_FIELD(varattno);
851 COPY_SCALAR_FIELD(vartype);
852 COPY_SCALAR_FIELD(vartypmod);
853 COPY_SCALAR_FIELD(varlevelsup);
854 COPY_SCALAR_FIELD(varnoold);
855 COPY_SCALAR_FIELD(varoattno);
856 COPY_LOCATION_FIELD(location);
858 return newnode;
862 * _copyConst
864 static Const *
865 _copyConst(Const *from)
867 Const *newnode = makeNode(Const);
869 COPY_SCALAR_FIELD(consttype);
870 COPY_SCALAR_FIELD(consttypmod);
871 COPY_SCALAR_FIELD(constlen);
873 if (from->constbyval || from->constisnull)
876 * passed by value so just copy the datum. Also, don't try to copy
877 * struct when value is null!
879 newnode->constvalue = from->constvalue;
881 else
884 * passed by reference. We need a palloc'd copy.
886 newnode->constvalue = datumCopy(from->constvalue,
887 from->constbyval,
888 from->constlen);
891 COPY_SCALAR_FIELD(constisnull);
892 COPY_SCALAR_FIELD(constbyval);
893 COPY_LOCATION_FIELD(location);
895 return newnode;
899 * _copyParam
901 static Param *
902 _copyParam(Param *from)
904 Param *newnode = makeNode(Param);
906 COPY_SCALAR_FIELD(paramkind);
907 COPY_SCALAR_FIELD(paramid);
908 COPY_SCALAR_FIELD(paramtype);
909 COPY_SCALAR_FIELD(paramtypmod);
910 COPY_LOCATION_FIELD(location);
912 return newnode;
916 * _copyAggref
918 static Aggref *
919 _copyAggref(Aggref *from)
921 Aggref *newnode = makeNode(Aggref);
923 COPY_SCALAR_FIELD(aggfnoid);
924 COPY_SCALAR_FIELD(aggtype);
925 COPY_NODE_FIELD(args);
926 COPY_SCALAR_FIELD(agglevelsup);
927 COPY_SCALAR_FIELD(aggstar);
928 COPY_SCALAR_FIELD(aggdistinct);
929 COPY_LOCATION_FIELD(location);
931 return newnode;
935 * _copyArrayRef
937 static ArrayRef *
938 _copyArrayRef(ArrayRef *from)
940 ArrayRef *newnode = makeNode(ArrayRef);
942 COPY_SCALAR_FIELD(refarraytype);
943 COPY_SCALAR_FIELD(refelemtype);
944 COPY_SCALAR_FIELD(reftypmod);
945 COPY_NODE_FIELD(refupperindexpr);
946 COPY_NODE_FIELD(reflowerindexpr);
947 COPY_NODE_FIELD(refexpr);
948 COPY_NODE_FIELD(refassgnexpr);
950 return newnode;
954 * _copyFuncExpr
956 static FuncExpr *
957 _copyFuncExpr(FuncExpr *from)
959 FuncExpr *newnode = makeNode(FuncExpr);
961 COPY_SCALAR_FIELD(funcid);
962 COPY_SCALAR_FIELD(funcresulttype);
963 COPY_SCALAR_FIELD(funcretset);
964 COPY_SCALAR_FIELD(funcformat);
965 COPY_NODE_FIELD(args);
966 COPY_LOCATION_FIELD(location);
968 return newnode;
972 * _copyOpExpr
974 static OpExpr *
975 _copyOpExpr(OpExpr *from)
977 OpExpr *newnode = makeNode(OpExpr);
979 COPY_SCALAR_FIELD(opno);
980 COPY_SCALAR_FIELD(opfuncid);
981 COPY_SCALAR_FIELD(opresulttype);
982 COPY_SCALAR_FIELD(opretset);
983 COPY_NODE_FIELD(args);
984 COPY_LOCATION_FIELD(location);
986 return newnode;
990 * _copyDistinctExpr (same as OpExpr)
992 static DistinctExpr *
993 _copyDistinctExpr(DistinctExpr *from)
995 DistinctExpr *newnode = makeNode(DistinctExpr);
997 COPY_SCALAR_FIELD(opno);
998 COPY_SCALAR_FIELD(opfuncid);
999 COPY_SCALAR_FIELD(opresulttype);
1000 COPY_SCALAR_FIELD(opretset);
1001 COPY_NODE_FIELD(args);
1002 COPY_LOCATION_FIELD(location);
1004 return newnode;
1008 * _copyScalarArrayOpExpr
1010 static ScalarArrayOpExpr *
1011 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
1013 ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1015 COPY_SCALAR_FIELD(opno);
1016 COPY_SCALAR_FIELD(opfuncid);
1017 COPY_SCALAR_FIELD(useOr);
1018 COPY_NODE_FIELD(args);
1019 COPY_LOCATION_FIELD(location);
1021 return newnode;
1025 * _copyBoolExpr
1027 static BoolExpr *
1028 _copyBoolExpr(BoolExpr *from)
1030 BoolExpr *newnode = makeNode(BoolExpr);
1032 COPY_SCALAR_FIELD(boolop);
1033 COPY_NODE_FIELD(args);
1034 COPY_LOCATION_FIELD(location);
1036 return newnode;
1040 * _copySubLink
1042 static SubLink *
1043 _copySubLink(SubLink *from)
1045 SubLink *newnode = makeNode(SubLink);
1047 COPY_SCALAR_FIELD(subLinkType);
1048 COPY_NODE_FIELD(testexpr);
1049 COPY_NODE_FIELD(operName);
1050 COPY_NODE_FIELD(subselect);
1051 COPY_LOCATION_FIELD(location);
1053 return newnode;
1057 * _copySubPlan
1059 static SubPlan *
1060 _copySubPlan(SubPlan *from)
1062 SubPlan *newnode = makeNode(SubPlan);
1064 COPY_SCALAR_FIELD(subLinkType);
1065 COPY_NODE_FIELD(testexpr);
1066 COPY_NODE_FIELD(paramIds);
1067 COPY_SCALAR_FIELD(plan_id);
1068 COPY_SCALAR_FIELD(firstColType);
1069 COPY_SCALAR_FIELD(useHashTable);
1070 COPY_SCALAR_FIELD(unknownEqFalse);
1071 COPY_NODE_FIELD(setParam);
1072 COPY_NODE_FIELD(parParam);
1073 COPY_NODE_FIELD(args);
1074 COPY_SCALAR_FIELD(startup_cost);
1075 COPY_SCALAR_FIELD(per_call_cost);
1077 return newnode;
1081 * _copyAlternativeSubPlan
1083 static AlternativeSubPlan *
1084 _copyAlternativeSubPlan(AlternativeSubPlan *from)
1086 AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1088 COPY_NODE_FIELD(subplans);
1090 return newnode;
1094 * _copyFieldSelect
1096 static FieldSelect *
1097 _copyFieldSelect(FieldSelect *from)
1099 FieldSelect *newnode = makeNode(FieldSelect);
1101 COPY_NODE_FIELD(arg);
1102 COPY_SCALAR_FIELD(fieldnum);
1103 COPY_SCALAR_FIELD(resulttype);
1104 COPY_SCALAR_FIELD(resulttypmod);
1106 return newnode;
1110 * _copyFieldStore
1112 static FieldStore *
1113 _copyFieldStore(FieldStore *from)
1115 FieldStore *newnode = makeNode(FieldStore);
1117 COPY_NODE_FIELD(arg);
1118 COPY_NODE_FIELD(newvals);
1119 COPY_NODE_FIELD(fieldnums);
1120 COPY_SCALAR_FIELD(resulttype);
1122 return newnode;
1126 * _copyRelabelType
1128 static RelabelType *
1129 _copyRelabelType(RelabelType *from)
1131 RelabelType *newnode = makeNode(RelabelType);
1133 COPY_NODE_FIELD(arg);
1134 COPY_SCALAR_FIELD(resulttype);
1135 COPY_SCALAR_FIELD(resulttypmod);
1136 COPY_SCALAR_FIELD(relabelformat);
1137 COPY_LOCATION_FIELD(location);
1139 return newnode;
1143 * _copyCoerceViaIO
1145 static CoerceViaIO *
1146 _copyCoerceViaIO(CoerceViaIO *from)
1148 CoerceViaIO *newnode = makeNode(CoerceViaIO);
1150 COPY_NODE_FIELD(arg);
1151 COPY_SCALAR_FIELD(resulttype);
1152 COPY_SCALAR_FIELD(coerceformat);
1153 COPY_LOCATION_FIELD(location);
1155 return newnode;
1159 * _copyArrayCoerceExpr
1161 static ArrayCoerceExpr *
1162 _copyArrayCoerceExpr(ArrayCoerceExpr *from)
1164 ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1166 COPY_NODE_FIELD(arg);
1167 COPY_SCALAR_FIELD(elemfuncid);
1168 COPY_SCALAR_FIELD(resulttype);
1169 COPY_SCALAR_FIELD(resulttypmod);
1170 COPY_SCALAR_FIELD(isExplicit);
1171 COPY_SCALAR_FIELD(coerceformat);
1172 COPY_LOCATION_FIELD(location);
1174 return newnode;
1178 * _copyConvertRowtypeExpr
1180 static ConvertRowtypeExpr *
1181 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
1183 ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1185 COPY_NODE_FIELD(arg);
1186 COPY_SCALAR_FIELD(resulttype);
1187 COPY_SCALAR_FIELD(convertformat);
1188 COPY_LOCATION_FIELD(location);
1190 return newnode;
1194 * _copyCaseExpr
1196 static CaseExpr *
1197 _copyCaseExpr(CaseExpr *from)
1199 CaseExpr *newnode = makeNode(CaseExpr);
1201 COPY_SCALAR_FIELD(casetype);
1202 COPY_NODE_FIELD(arg);
1203 COPY_NODE_FIELD(args);
1204 COPY_NODE_FIELD(defresult);
1205 COPY_LOCATION_FIELD(location);
1207 return newnode;
1211 * _copyCaseWhen
1213 static CaseWhen *
1214 _copyCaseWhen(CaseWhen *from)
1216 CaseWhen *newnode = makeNode(CaseWhen);
1218 COPY_NODE_FIELD(expr);
1219 COPY_NODE_FIELD(result);
1220 COPY_LOCATION_FIELD(location);
1222 return newnode;
1226 * _copyCaseTestExpr
1228 static CaseTestExpr *
1229 _copyCaseTestExpr(CaseTestExpr *from)
1231 CaseTestExpr *newnode = makeNode(CaseTestExpr);
1233 COPY_SCALAR_FIELD(typeId);
1234 COPY_SCALAR_FIELD(typeMod);
1236 return newnode;
1240 * _copyArrayExpr
1242 static ArrayExpr *
1243 _copyArrayExpr(ArrayExpr *from)
1245 ArrayExpr *newnode = makeNode(ArrayExpr);
1247 COPY_SCALAR_FIELD(array_typeid);
1248 COPY_SCALAR_FIELD(element_typeid);
1249 COPY_NODE_FIELD(elements);
1250 COPY_SCALAR_FIELD(multidims);
1251 COPY_LOCATION_FIELD(location);
1253 return newnode;
1257 * _copyRowExpr
1259 static RowExpr *
1260 _copyRowExpr(RowExpr *from)
1262 RowExpr *newnode = makeNode(RowExpr);
1264 COPY_NODE_FIELD(args);
1265 COPY_SCALAR_FIELD(row_typeid);
1266 COPY_SCALAR_FIELD(row_format);
1267 COPY_NODE_FIELD(colnames);
1268 COPY_LOCATION_FIELD(location);
1270 return newnode;
1274 * _copyRowCompareExpr
1276 static RowCompareExpr *
1277 _copyRowCompareExpr(RowCompareExpr *from)
1279 RowCompareExpr *newnode = makeNode(RowCompareExpr);
1281 COPY_SCALAR_FIELD(rctype);
1282 COPY_NODE_FIELD(opnos);
1283 COPY_NODE_FIELD(opfamilies);
1284 COPY_NODE_FIELD(largs);
1285 COPY_NODE_FIELD(rargs);
1287 return newnode;
1291 * _copyCoalesceExpr
1293 static CoalesceExpr *
1294 _copyCoalesceExpr(CoalesceExpr *from)
1296 CoalesceExpr *newnode = makeNode(CoalesceExpr);
1298 COPY_SCALAR_FIELD(coalescetype);
1299 COPY_NODE_FIELD(args);
1300 COPY_LOCATION_FIELD(location);
1302 return newnode;
1306 * _copyMinMaxExpr
1308 static MinMaxExpr *
1309 _copyMinMaxExpr(MinMaxExpr *from)
1311 MinMaxExpr *newnode = makeNode(MinMaxExpr);
1313 COPY_SCALAR_FIELD(minmaxtype);
1314 COPY_SCALAR_FIELD(op);
1315 COPY_NODE_FIELD(args);
1316 COPY_LOCATION_FIELD(location);
1318 return newnode;
1322 * _copyXmlExpr
1324 static XmlExpr *
1325 _copyXmlExpr(XmlExpr *from)
1327 XmlExpr *newnode = makeNode(XmlExpr);
1329 COPY_SCALAR_FIELD(op);
1330 COPY_STRING_FIELD(name);
1331 COPY_NODE_FIELD(named_args);
1332 COPY_NODE_FIELD(arg_names);
1333 COPY_NODE_FIELD(args);
1334 COPY_SCALAR_FIELD(xmloption);
1335 COPY_SCALAR_FIELD(type);
1336 COPY_SCALAR_FIELD(typmod);
1337 COPY_LOCATION_FIELD(location);
1339 return newnode;
1343 * _copyNullIfExpr (same as OpExpr)
1345 static NullIfExpr *
1346 _copyNullIfExpr(NullIfExpr *from)
1348 NullIfExpr *newnode = makeNode(NullIfExpr);
1350 COPY_SCALAR_FIELD(opno);
1351 COPY_SCALAR_FIELD(opfuncid);
1352 COPY_SCALAR_FIELD(opresulttype);
1353 COPY_SCALAR_FIELD(opretset);
1354 COPY_NODE_FIELD(args);
1355 COPY_LOCATION_FIELD(location);
1357 return newnode;
1361 * _copyNullTest
1363 static NullTest *
1364 _copyNullTest(NullTest *from)
1366 NullTest *newnode = makeNode(NullTest);
1368 COPY_NODE_FIELD(arg);
1369 COPY_SCALAR_FIELD(nulltesttype);
1371 return newnode;
1375 * _copyBooleanTest
1377 static BooleanTest *
1378 _copyBooleanTest(BooleanTest *from)
1380 BooleanTest *newnode = makeNode(BooleanTest);
1382 COPY_NODE_FIELD(arg);
1383 COPY_SCALAR_FIELD(booltesttype);
1385 return newnode;
1389 * _copyCoerceToDomain
1391 static CoerceToDomain *
1392 _copyCoerceToDomain(CoerceToDomain *from)
1394 CoerceToDomain *newnode = makeNode(CoerceToDomain);
1396 COPY_NODE_FIELD(arg);
1397 COPY_SCALAR_FIELD(resulttype);
1398 COPY_SCALAR_FIELD(resulttypmod);
1399 COPY_SCALAR_FIELD(coercionformat);
1400 COPY_LOCATION_FIELD(location);
1402 return newnode;
1406 * _copyCoerceToDomainValue
1408 static CoerceToDomainValue *
1409 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1411 CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1413 COPY_SCALAR_FIELD(typeId);
1414 COPY_SCALAR_FIELD(typeMod);
1415 COPY_LOCATION_FIELD(location);
1417 return newnode;
1421 * _copySetToDefault
1423 static SetToDefault *
1424 _copySetToDefault(SetToDefault *from)
1426 SetToDefault *newnode = makeNode(SetToDefault);
1428 COPY_SCALAR_FIELD(typeId);
1429 COPY_SCALAR_FIELD(typeMod);
1430 COPY_LOCATION_FIELD(location);
1432 return newnode;
1436 * _copyCurrentOfExpr
1438 static CurrentOfExpr *
1439 _copyCurrentOfExpr(CurrentOfExpr *from)
1441 CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1443 COPY_SCALAR_FIELD(cvarno);
1444 COPY_STRING_FIELD(cursor_name);
1445 COPY_SCALAR_FIELD(cursor_param);
1447 return newnode;
1451 * _copyTargetEntry
1453 static TargetEntry *
1454 _copyTargetEntry(TargetEntry *from)
1456 TargetEntry *newnode = makeNode(TargetEntry);
1458 COPY_NODE_FIELD(expr);
1459 COPY_SCALAR_FIELD(resno);
1460 COPY_STRING_FIELD(resname);
1461 COPY_SCALAR_FIELD(ressortgroupref);
1462 COPY_SCALAR_FIELD(resorigtbl);
1463 COPY_SCALAR_FIELD(resorigcol);
1464 COPY_SCALAR_FIELD(resjunk);
1466 return newnode;
1470 * _copyRangeTblRef
1472 static RangeTblRef *
1473 _copyRangeTblRef(RangeTblRef *from)
1475 RangeTblRef *newnode = makeNode(RangeTblRef);
1477 COPY_SCALAR_FIELD(rtindex);
1479 return newnode;
1483 * _copyJoinExpr
1485 static JoinExpr *
1486 _copyJoinExpr(JoinExpr *from)
1488 JoinExpr *newnode = makeNode(JoinExpr);
1490 COPY_SCALAR_FIELD(jointype);
1491 COPY_SCALAR_FIELD(isNatural);
1492 COPY_NODE_FIELD(larg);
1493 COPY_NODE_FIELD(rarg);
1494 COPY_NODE_FIELD(using);
1495 COPY_NODE_FIELD(quals);
1496 COPY_NODE_FIELD(alias);
1497 COPY_SCALAR_FIELD(rtindex);
1499 return newnode;
1503 * _copyFromExpr
1505 static FromExpr *
1506 _copyFromExpr(FromExpr *from)
1508 FromExpr *newnode = makeNode(FromExpr);
1510 COPY_NODE_FIELD(fromlist);
1511 COPY_NODE_FIELD(quals);
1513 return newnode;
1516 /* ****************************************************************
1517 * relation.h copy functions
1519 * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1520 * There are some subsidiary structs that are useful to copy, though.
1521 * ****************************************************************
1525 * _copyPathKey
1527 static PathKey *
1528 _copyPathKey(PathKey *from)
1530 PathKey *newnode = makeNode(PathKey);
1532 /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1533 COPY_SCALAR_FIELD(pk_eclass);
1534 COPY_SCALAR_FIELD(pk_opfamily);
1535 COPY_SCALAR_FIELD(pk_strategy);
1536 COPY_SCALAR_FIELD(pk_nulls_first);
1538 return newnode;
1542 * _copyRestrictInfo
1544 static RestrictInfo *
1545 _copyRestrictInfo(RestrictInfo *from)
1547 RestrictInfo *newnode = makeNode(RestrictInfo);
1549 COPY_NODE_FIELD(clause);
1550 COPY_SCALAR_FIELD(is_pushed_down);
1551 COPY_SCALAR_FIELD(outerjoin_delayed);
1552 COPY_SCALAR_FIELD(can_join);
1553 COPY_SCALAR_FIELD(pseudoconstant);
1554 COPY_BITMAPSET_FIELD(clause_relids);
1555 COPY_BITMAPSET_FIELD(required_relids);
1556 COPY_BITMAPSET_FIELD(left_relids);
1557 COPY_BITMAPSET_FIELD(right_relids);
1558 COPY_NODE_FIELD(orclause);
1559 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1560 COPY_SCALAR_FIELD(parent_ec);
1561 COPY_SCALAR_FIELD(eval_cost);
1562 COPY_SCALAR_FIELD(this_selec);
1563 COPY_NODE_FIELD(mergeopfamilies);
1564 /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1565 COPY_SCALAR_FIELD(left_ec);
1566 COPY_SCALAR_FIELD(right_ec);
1567 COPY_SCALAR_FIELD(left_em);
1568 COPY_SCALAR_FIELD(right_em);
1569 /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1570 newnode->scansel_cache = NIL;
1571 COPY_SCALAR_FIELD(outer_is_left);
1572 COPY_SCALAR_FIELD(hashjoinoperator);
1573 COPY_SCALAR_FIELD(left_bucketsize);
1574 COPY_SCALAR_FIELD(right_bucketsize);
1576 return newnode;
1580 * _copyFlattenedSubLink
1582 static FlattenedSubLink *
1583 _copyFlattenedSubLink(FlattenedSubLink *from)
1585 FlattenedSubLink *newnode = makeNode(FlattenedSubLink);
1587 COPY_SCALAR_FIELD(jointype);
1588 COPY_BITMAPSET_FIELD(lefthand);
1589 COPY_BITMAPSET_FIELD(righthand);
1590 COPY_NODE_FIELD(quals);
1592 return newnode;
1596 * _copyPlaceHolderVar
1598 static PlaceHolderVar *
1599 _copyPlaceHolderVar(PlaceHolderVar *from)
1601 PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
1603 COPY_NODE_FIELD(phexpr);
1604 COPY_BITMAPSET_FIELD(phrels);
1605 COPY_SCALAR_FIELD(phid);
1606 COPY_SCALAR_FIELD(phlevelsup);
1608 return newnode;
1612 * _copySpecialJoinInfo
1614 static SpecialJoinInfo *
1615 _copySpecialJoinInfo(SpecialJoinInfo *from)
1617 SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
1619 COPY_BITMAPSET_FIELD(min_lefthand);
1620 COPY_BITMAPSET_FIELD(min_righthand);
1621 COPY_BITMAPSET_FIELD(syn_lefthand);
1622 COPY_BITMAPSET_FIELD(syn_righthand);
1623 COPY_SCALAR_FIELD(jointype);
1624 COPY_SCALAR_FIELD(lhs_strict);
1625 COPY_SCALAR_FIELD(delay_upper_joins);
1626 COPY_NODE_FIELD(join_quals);
1628 return newnode;
1632 * _copyAppendRelInfo
1634 static AppendRelInfo *
1635 _copyAppendRelInfo(AppendRelInfo *from)
1637 AppendRelInfo *newnode = makeNode(AppendRelInfo);
1639 COPY_SCALAR_FIELD(parent_relid);
1640 COPY_SCALAR_FIELD(child_relid);
1641 COPY_SCALAR_FIELD(parent_reltype);
1642 COPY_SCALAR_FIELD(child_reltype);
1643 COPY_NODE_FIELD(col_mappings);
1644 COPY_NODE_FIELD(translated_vars);
1645 COPY_SCALAR_FIELD(parent_reloid);
1647 return newnode;
1651 * _copyPlaceHolderInfo
1653 static PlaceHolderInfo *
1654 _copyPlaceHolderInfo(PlaceHolderInfo *from)
1656 PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
1658 COPY_SCALAR_FIELD(phid);
1659 COPY_NODE_FIELD(ph_var);
1660 COPY_BITMAPSET_FIELD(ph_eval_at);
1661 COPY_BITMAPSET_FIELD(ph_needed);
1662 COPY_SCALAR_FIELD(ph_width);
1664 return newnode;
1667 /* ****************************************************************
1668 * parsenodes.h copy functions
1669 * ****************************************************************
1672 static RangeTblEntry *
1673 _copyRangeTblEntry(RangeTblEntry *from)
1675 RangeTblEntry *newnode = makeNode(RangeTblEntry);
1677 COPY_SCALAR_FIELD(rtekind);
1678 COPY_SCALAR_FIELD(relid);
1679 COPY_NODE_FIELD(subquery);
1680 COPY_SCALAR_FIELD(jointype);
1681 COPY_NODE_FIELD(joinaliasvars);
1682 COPY_NODE_FIELD(funcexpr);
1683 COPY_NODE_FIELD(funccoltypes);
1684 COPY_NODE_FIELD(funccoltypmods);
1685 COPY_NODE_FIELD(values_lists);
1686 COPY_STRING_FIELD(ctename);
1687 COPY_SCALAR_FIELD(ctelevelsup);
1688 COPY_SCALAR_FIELD(self_reference);
1689 COPY_NODE_FIELD(ctecoltypes);
1690 COPY_NODE_FIELD(ctecoltypmods);
1691 COPY_NODE_FIELD(alias);
1692 COPY_NODE_FIELD(eref);
1693 COPY_SCALAR_FIELD(inh);
1694 COPY_SCALAR_FIELD(inFromCl);
1695 COPY_SCALAR_FIELD(requiredPerms);
1696 COPY_SCALAR_FIELD(checkAsUser);
1698 return newnode;
1701 static FkConstraint *
1702 _copyFkConstraint(FkConstraint *from)
1704 FkConstraint *newnode = makeNode(FkConstraint);
1706 COPY_STRING_FIELD(constr_name);
1707 COPY_NODE_FIELD(pktable);
1708 COPY_NODE_FIELD(fk_attrs);
1709 COPY_NODE_FIELD(pk_attrs);
1710 COPY_SCALAR_FIELD(fk_matchtype);
1711 COPY_SCALAR_FIELD(fk_upd_action);
1712 COPY_SCALAR_FIELD(fk_del_action);
1713 COPY_SCALAR_FIELD(deferrable);
1714 COPY_SCALAR_FIELD(initdeferred);
1715 COPY_SCALAR_FIELD(skip_validation);
1717 return newnode;
1720 static SortGroupClause *
1721 _copySortGroupClause(SortGroupClause *from)
1723 SortGroupClause *newnode = makeNode(SortGroupClause);
1725 COPY_SCALAR_FIELD(tleSortGroupRef);
1726 COPY_SCALAR_FIELD(eqop);
1727 COPY_SCALAR_FIELD(sortop);
1728 COPY_SCALAR_FIELD(nulls_first);
1730 return newnode;
1733 static RowMarkClause *
1734 _copyRowMarkClause(RowMarkClause *from)
1736 RowMarkClause *newnode = makeNode(RowMarkClause);
1738 COPY_SCALAR_FIELD(rti);
1739 COPY_SCALAR_FIELD(forUpdate);
1740 COPY_SCALAR_FIELD(noWait);
1742 return newnode;
1745 static WithClause *
1746 _copyWithClause(WithClause *from)
1748 WithClause *newnode = makeNode(WithClause);
1750 COPY_NODE_FIELD(ctes);
1751 COPY_SCALAR_FIELD(recursive);
1752 COPY_LOCATION_FIELD(location);
1754 return newnode;
1757 static CommonTableExpr *
1758 _copyCommonTableExpr(CommonTableExpr *from)
1760 CommonTableExpr *newnode = makeNode(CommonTableExpr);
1762 COPY_STRING_FIELD(ctename);
1763 COPY_NODE_FIELD(aliascolnames);
1764 COPY_NODE_FIELD(ctequery);
1765 COPY_LOCATION_FIELD(location);
1766 COPY_SCALAR_FIELD(cterecursive);
1767 COPY_SCALAR_FIELD(cterefcount);
1768 COPY_NODE_FIELD(ctecolnames);
1769 COPY_NODE_FIELD(ctecoltypes);
1770 COPY_NODE_FIELD(ctecoltypmods);
1772 return newnode;
1775 static A_Expr *
1776 _copyAExpr(A_Expr *from)
1778 A_Expr *newnode = makeNode(A_Expr);
1780 COPY_SCALAR_FIELD(kind);
1781 COPY_NODE_FIELD(name);
1782 COPY_NODE_FIELD(lexpr);
1783 COPY_NODE_FIELD(rexpr);
1784 COPY_LOCATION_FIELD(location);
1786 return newnode;
1789 static ColumnRef *
1790 _copyColumnRef(ColumnRef *from)
1792 ColumnRef *newnode = makeNode(ColumnRef);
1794 COPY_NODE_FIELD(fields);
1795 COPY_LOCATION_FIELD(location);
1797 return newnode;
1800 static ParamRef *
1801 _copyParamRef(ParamRef *from)
1803 ParamRef *newnode = makeNode(ParamRef);
1805 COPY_SCALAR_FIELD(number);
1806 COPY_LOCATION_FIELD(location);
1808 return newnode;
1811 static A_Const *
1812 _copyAConst(A_Const *from)
1814 A_Const *newnode = makeNode(A_Const);
1816 /* This part must duplicate _copyValue */
1817 COPY_SCALAR_FIELD(val.type);
1818 switch (from->val.type)
1820 case T_Integer:
1821 COPY_SCALAR_FIELD(val.val.ival);
1822 break;
1823 case T_Float:
1824 case T_String:
1825 case T_BitString:
1826 COPY_STRING_FIELD(val.val.str);
1827 break;
1828 case T_Null:
1829 /* nothing to do */
1830 break;
1831 default:
1832 elog(ERROR, "unrecognized node type: %d",
1833 (int) from->val.type);
1834 break;
1837 COPY_LOCATION_FIELD(location);
1839 return newnode;
1842 static FuncCall *
1843 _copyFuncCall(FuncCall *from)
1845 FuncCall *newnode = makeNode(FuncCall);
1847 COPY_NODE_FIELD(funcname);
1848 COPY_NODE_FIELD(args);
1849 COPY_SCALAR_FIELD(agg_star);
1850 COPY_SCALAR_FIELD(agg_distinct);
1851 COPY_SCALAR_FIELD(func_variadic);
1852 COPY_LOCATION_FIELD(location);
1854 return newnode;
1857 static A_Star *
1858 _copyAStar(A_Star *from)
1860 A_Star *newnode = makeNode(A_Star);
1862 return newnode;
1865 static A_Indices *
1866 _copyAIndices(A_Indices *from)
1868 A_Indices *newnode = makeNode(A_Indices);
1870 COPY_NODE_FIELD(lidx);
1871 COPY_NODE_FIELD(uidx);
1873 return newnode;
1876 static A_Indirection *
1877 _copyA_Indirection(A_Indirection *from)
1879 A_Indirection *newnode = makeNode(A_Indirection);
1881 COPY_NODE_FIELD(arg);
1882 COPY_NODE_FIELD(indirection);
1884 return newnode;
1887 static A_ArrayExpr *
1888 _copyA_ArrayExpr(A_ArrayExpr *from)
1890 A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
1892 COPY_NODE_FIELD(elements);
1893 COPY_LOCATION_FIELD(location);
1895 return newnode;
1898 static ResTarget *
1899 _copyResTarget(ResTarget *from)
1901 ResTarget *newnode = makeNode(ResTarget);
1903 COPY_STRING_FIELD(name);
1904 COPY_NODE_FIELD(indirection);
1905 COPY_NODE_FIELD(val);
1906 COPY_LOCATION_FIELD(location);
1908 return newnode;
1911 static TypeName *
1912 _copyTypeName(TypeName *from)
1914 TypeName *newnode = makeNode(TypeName);
1916 COPY_NODE_FIELD(names);
1917 COPY_SCALAR_FIELD(typeid);
1918 COPY_SCALAR_FIELD(setof);
1919 COPY_SCALAR_FIELD(pct_type);
1920 COPY_NODE_FIELD(typmods);
1921 COPY_SCALAR_FIELD(typemod);
1922 COPY_NODE_FIELD(arrayBounds);
1923 COPY_LOCATION_FIELD(location);
1925 return newnode;
1928 static SortBy *
1929 _copySortBy(SortBy *from)
1931 SortBy *newnode = makeNode(SortBy);
1933 COPY_NODE_FIELD(node);
1934 COPY_SCALAR_FIELD(sortby_dir);
1935 COPY_SCALAR_FIELD(sortby_nulls);
1936 COPY_NODE_FIELD(useOp);
1937 COPY_LOCATION_FIELD(location);
1939 return newnode;
1942 static RangeSubselect *
1943 _copyRangeSubselect(RangeSubselect *from)
1945 RangeSubselect *newnode = makeNode(RangeSubselect);
1947 COPY_NODE_FIELD(subquery);
1948 COPY_NODE_FIELD(alias);
1950 return newnode;
1953 static RangeFunction *
1954 _copyRangeFunction(RangeFunction *from)
1956 RangeFunction *newnode = makeNode(RangeFunction);
1958 COPY_NODE_FIELD(funccallnode);
1959 COPY_NODE_FIELD(alias);
1960 COPY_NODE_FIELD(coldeflist);
1962 return newnode;
1965 static TypeCast *
1966 _copyTypeCast(TypeCast *from)
1968 TypeCast *newnode = makeNode(TypeCast);
1970 COPY_NODE_FIELD(arg);
1971 COPY_NODE_FIELD(typename);
1972 COPY_LOCATION_FIELD(location);
1974 return newnode;
1977 static IndexElem *
1978 _copyIndexElem(IndexElem *from)
1980 IndexElem *newnode = makeNode(IndexElem);
1982 COPY_STRING_FIELD(name);
1983 COPY_NODE_FIELD(expr);
1984 COPY_NODE_FIELD(opclass);
1985 COPY_SCALAR_FIELD(ordering);
1986 COPY_SCALAR_FIELD(nulls_ordering);
1988 return newnode;
1991 static ColumnDef *
1992 _copyColumnDef(ColumnDef *from)
1994 ColumnDef *newnode = makeNode(ColumnDef);
1996 COPY_STRING_FIELD(colname);
1997 COPY_NODE_FIELD(typename);
1998 COPY_SCALAR_FIELD(inhcount);
1999 COPY_SCALAR_FIELD(is_local);
2000 COPY_SCALAR_FIELD(is_not_null);
2001 COPY_NODE_FIELD(raw_default);
2002 COPY_STRING_FIELD(cooked_default);
2003 COPY_NODE_FIELD(constraints);
2005 return newnode;
2008 static Constraint *
2009 _copyConstraint(Constraint *from)
2011 Constraint *newnode = makeNode(Constraint);
2013 COPY_SCALAR_FIELD(contype);
2014 COPY_STRING_FIELD(name);
2015 COPY_NODE_FIELD(raw_expr);
2016 COPY_STRING_FIELD(cooked_expr);
2017 COPY_NODE_FIELD(keys);
2018 COPY_NODE_FIELD(options);
2019 COPY_STRING_FIELD(indexspace);
2021 return newnode;
2024 static DefElem *
2025 _copyDefElem(DefElem *from)
2027 DefElem *newnode = makeNode(DefElem);
2029 COPY_STRING_FIELD(defname);
2030 COPY_NODE_FIELD(arg);
2032 return newnode;
2035 static LockingClause *
2036 _copyLockingClause(LockingClause *from)
2038 LockingClause *newnode = makeNode(LockingClause);
2040 COPY_NODE_FIELD(lockedRels);
2041 COPY_SCALAR_FIELD(forUpdate);
2042 COPY_SCALAR_FIELD(noWait);
2044 return newnode;
2047 static XmlSerialize *
2048 _copyXmlSerialize(XmlSerialize *from)
2050 XmlSerialize *newnode = makeNode(XmlSerialize);
2052 COPY_SCALAR_FIELD(xmloption);
2053 COPY_NODE_FIELD(expr);
2054 COPY_NODE_FIELD(typename);
2055 COPY_LOCATION_FIELD(location);
2057 return newnode;
2060 static Query *
2061 _copyQuery(Query *from)
2063 Query *newnode = makeNode(Query);
2065 COPY_SCALAR_FIELD(commandType);
2066 COPY_SCALAR_FIELD(querySource);
2067 COPY_SCALAR_FIELD(canSetTag);
2068 COPY_NODE_FIELD(utilityStmt);
2069 COPY_SCALAR_FIELD(resultRelation);
2070 COPY_NODE_FIELD(intoClause);
2071 COPY_SCALAR_FIELD(hasAggs);
2072 COPY_SCALAR_FIELD(hasSubLinks);
2073 COPY_SCALAR_FIELD(hasDistinctOn);
2074 COPY_SCALAR_FIELD(hasRecursive);
2075 COPY_NODE_FIELD(cteList);
2076 COPY_NODE_FIELD(rtable);
2077 COPY_NODE_FIELD(jointree);
2078 COPY_NODE_FIELD(targetList);
2079 COPY_NODE_FIELD(returningList);
2080 COPY_NODE_FIELD(groupClause);
2081 COPY_NODE_FIELD(havingQual);
2082 COPY_NODE_FIELD(distinctClause);
2083 COPY_NODE_FIELD(sortClause);
2084 COPY_NODE_FIELD(limitOffset);
2085 COPY_NODE_FIELD(limitCount);
2086 COPY_NODE_FIELD(rowMarks);
2087 COPY_NODE_FIELD(setOperations);
2089 return newnode;
2092 static InsertStmt *
2093 _copyInsertStmt(InsertStmt *from)
2095 InsertStmt *newnode = makeNode(InsertStmt);
2097 COPY_NODE_FIELD(relation);
2098 COPY_NODE_FIELD(cols);
2099 COPY_NODE_FIELD(selectStmt);
2100 COPY_NODE_FIELD(returningList);
2102 return newnode;
2105 static DeleteStmt *
2106 _copyDeleteStmt(DeleteStmt *from)
2108 DeleteStmt *newnode = makeNode(DeleteStmt);
2110 COPY_NODE_FIELD(relation);
2111 COPY_NODE_FIELD(usingClause);
2112 COPY_NODE_FIELD(whereClause);
2113 COPY_NODE_FIELD(returningList);
2115 return newnode;
2118 static UpdateStmt *
2119 _copyUpdateStmt(UpdateStmt *from)
2121 UpdateStmt *newnode = makeNode(UpdateStmt);
2123 COPY_NODE_FIELD(relation);
2124 COPY_NODE_FIELD(targetList);
2125 COPY_NODE_FIELD(whereClause);
2126 COPY_NODE_FIELD(fromClause);
2127 COPY_NODE_FIELD(returningList);
2129 return newnode;
2132 static SelectStmt *
2133 _copySelectStmt(SelectStmt *from)
2135 SelectStmt *newnode = makeNode(SelectStmt);
2137 COPY_NODE_FIELD(distinctClause);
2138 COPY_NODE_FIELD(intoClause);
2139 COPY_NODE_FIELD(targetList);
2140 COPY_NODE_FIELD(fromClause);
2141 COPY_NODE_FIELD(whereClause);
2142 COPY_NODE_FIELD(groupClause);
2143 COPY_NODE_FIELD(havingClause);
2144 COPY_NODE_FIELD(withClause);
2145 COPY_NODE_FIELD(valuesLists);
2146 COPY_NODE_FIELD(sortClause);
2147 COPY_NODE_FIELD(limitOffset);
2148 COPY_NODE_FIELD(limitCount);
2149 COPY_NODE_FIELD(lockingClause);
2150 COPY_SCALAR_FIELD(op);
2151 COPY_SCALAR_FIELD(all);
2152 COPY_NODE_FIELD(larg);
2153 COPY_NODE_FIELD(rarg);
2155 return newnode;
2158 static SetOperationStmt *
2159 _copySetOperationStmt(SetOperationStmt *from)
2161 SetOperationStmt *newnode = makeNode(SetOperationStmt);
2163 COPY_SCALAR_FIELD(op);
2164 COPY_SCALAR_FIELD(all);
2165 COPY_NODE_FIELD(larg);
2166 COPY_NODE_FIELD(rarg);
2167 COPY_NODE_FIELD(colTypes);
2168 COPY_NODE_FIELD(colTypmods);
2169 COPY_NODE_FIELD(groupClauses);
2171 return newnode;
2174 static AlterTableStmt *
2175 _copyAlterTableStmt(AlterTableStmt *from)
2177 AlterTableStmt *newnode = makeNode(AlterTableStmt);
2179 COPY_NODE_FIELD(relation);
2180 COPY_NODE_FIELD(cmds);
2181 COPY_SCALAR_FIELD(relkind);
2183 return newnode;
2186 static AlterTableCmd *
2187 _copyAlterTableCmd(AlterTableCmd *from)
2189 AlterTableCmd *newnode = makeNode(AlterTableCmd);
2191 COPY_SCALAR_FIELD(subtype);
2192 COPY_STRING_FIELD(name);
2193 COPY_NODE_FIELD(def);
2194 COPY_NODE_FIELD(transform);
2195 COPY_SCALAR_FIELD(behavior);
2197 return newnode;
2200 static AlterDomainStmt *
2201 _copyAlterDomainStmt(AlterDomainStmt *from)
2203 AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2205 COPY_SCALAR_FIELD(subtype);
2206 COPY_NODE_FIELD(typename);
2207 COPY_STRING_FIELD(name);
2208 COPY_NODE_FIELD(def);
2209 COPY_SCALAR_FIELD(behavior);
2211 return newnode;
2214 static GrantStmt *
2215 _copyGrantStmt(GrantStmt *from)
2217 GrantStmt *newnode = makeNode(GrantStmt);
2219 COPY_SCALAR_FIELD(is_grant);
2220 COPY_SCALAR_FIELD(objtype);
2221 COPY_NODE_FIELD(objects);
2222 COPY_NODE_FIELD(privileges);
2223 COPY_NODE_FIELD(grantees);
2224 COPY_SCALAR_FIELD(grant_option);
2225 COPY_SCALAR_FIELD(behavior);
2227 return newnode;
2230 static PrivGrantee *
2231 _copyPrivGrantee(PrivGrantee *from)
2233 PrivGrantee *newnode = makeNode(PrivGrantee);
2235 COPY_STRING_FIELD(rolname);
2237 return newnode;
2240 static FuncWithArgs *
2241 _copyFuncWithArgs(FuncWithArgs *from)
2243 FuncWithArgs *newnode = makeNode(FuncWithArgs);
2245 COPY_NODE_FIELD(funcname);
2246 COPY_NODE_FIELD(funcargs);
2248 return newnode;
2251 static GrantRoleStmt *
2252 _copyGrantRoleStmt(GrantRoleStmt *from)
2254 GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2256 COPY_NODE_FIELD(granted_roles);
2257 COPY_NODE_FIELD(grantee_roles);
2258 COPY_SCALAR_FIELD(is_grant);
2259 COPY_SCALAR_FIELD(admin_opt);
2260 COPY_STRING_FIELD(grantor);
2261 COPY_SCALAR_FIELD(behavior);
2263 return newnode;
2266 static DeclareCursorStmt *
2267 _copyDeclareCursorStmt(DeclareCursorStmt *from)
2269 DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2271 COPY_STRING_FIELD(portalname);
2272 COPY_SCALAR_FIELD(options);
2273 COPY_NODE_FIELD(query);
2275 return newnode;
2278 static ClosePortalStmt *
2279 _copyClosePortalStmt(ClosePortalStmt *from)
2281 ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2283 COPY_STRING_FIELD(portalname);
2285 return newnode;
2288 static ClusterStmt *
2289 _copyClusterStmt(ClusterStmt *from)
2291 ClusterStmt *newnode = makeNode(ClusterStmt);
2293 COPY_NODE_FIELD(relation);
2294 COPY_STRING_FIELD(indexname);
2296 return newnode;
2299 static CopyStmt *
2300 _copyCopyStmt(CopyStmt *from)
2302 CopyStmt *newnode = makeNode(CopyStmt);
2304 COPY_NODE_FIELD(relation);
2305 COPY_NODE_FIELD(query);
2306 COPY_NODE_FIELD(attlist);
2307 COPY_SCALAR_FIELD(is_from);
2308 COPY_STRING_FIELD(filename);
2309 COPY_NODE_FIELD(options);
2311 return newnode;
2314 static CreateStmt *
2315 _copyCreateStmt(CreateStmt *from)
2317 CreateStmt *newnode = makeNode(CreateStmt);
2319 COPY_NODE_FIELD(relation);
2320 COPY_NODE_FIELD(tableElts);
2321 COPY_NODE_FIELD(inhRelations);
2322 COPY_NODE_FIELD(constraints);
2323 COPY_NODE_FIELD(options);
2324 COPY_SCALAR_FIELD(oncommit);
2325 COPY_STRING_FIELD(tablespacename);
2327 return newnode;
2330 static InhRelation *
2331 _copyInhRelation(InhRelation *from)
2333 InhRelation *newnode = makeNode(InhRelation);
2335 COPY_NODE_FIELD(relation);
2336 COPY_NODE_FIELD(options);
2338 return newnode;
2341 static DefineStmt *
2342 _copyDefineStmt(DefineStmt *from)
2344 DefineStmt *newnode = makeNode(DefineStmt);
2346 COPY_SCALAR_FIELD(kind);
2347 COPY_SCALAR_FIELD(oldstyle);
2348 COPY_NODE_FIELD(defnames);
2349 COPY_NODE_FIELD(args);
2350 COPY_NODE_FIELD(definition);
2352 return newnode;
2355 static DropStmt *
2356 _copyDropStmt(DropStmt *from)
2358 DropStmt *newnode = makeNode(DropStmt);
2360 COPY_NODE_FIELD(objects);
2361 COPY_SCALAR_FIELD(removeType);
2362 COPY_SCALAR_FIELD(behavior);
2363 COPY_SCALAR_FIELD(missing_ok);
2365 return newnode;
2368 static TruncateStmt *
2369 _copyTruncateStmt(TruncateStmt *from)
2371 TruncateStmt *newnode = makeNode(TruncateStmt);
2373 COPY_NODE_FIELD(relations);
2374 COPY_SCALAR_FIELD(restart_seqs);
2375 COPY_SCALAR_FIELD(behavior);
2377 return newnode;
2380 static CommentStmt *
2381 _copyCommentStmt(CommentStmt *from)
2383 CommentStmt *newnode = makeNode(CommentStmt);
2385 COPY_SCALAR_FIELD(objtype);
2386 COPY_NODE_FIELD(objname);
2387 COPY_NODE_FIELD(objargs);
2388 COPY_STRING_FIELD(comment);
2390 return newnode;
2393 static FetchStmt *
2394 _copyFetchStmt(FetchStmt *from)
2396 FetchStmt *newnode = makeNode(FetchStmt);
2398 COPY_SCALAR_FIELD(direction);
2399 COPY_SCALAR_FIELD(howMany);
2400 COPY_STRING_FIELD(portalname);
2401 COPY_SCALAR_FIELD(ismove);
2403 return newnode;
2406 static IndexStmt *
2407 _copyIndexStmt(IndexStmt *from)
2409 IndexStmt *newnode = makeNode(IndexStmt);
2411 COPY_STRING_FIELD(idxname);
2412 COPY_NODE_FIELD(relation);
2413 COPY_STRING_FIELD(accessMethod);
2414 COPY_STRING_FIELD(tableSpace);
2415 COPY_NODE_FIELD(indexParams);
2416 COPY_NODE_FIELD(options);
2417 COPY_NODE_FIELD(whereClause);
2418 COPY_SCALAR_FIELD(unique);
2419 COPY_SCALAR_FIELD(primary);
2420 COPY_SCALAR_FIELD(isconstraint);
2421 COPY_SCALAR_FIELD(concurrent);
2423 return newnode;
2426 static CreateFunctionStmt *
2427 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2429 CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2431 COPY_SCALAR_FIELD(replace);
2432 COPY_NODE_FIELD(funcname);
2433 COPY_NODE_FIELD(parameters);
2434 COPY_NODE_FIELD(returnType);
2435 COPY_NODE_FIELD(options);
2436 COPY_NODE_FIELD(withClause);
2438 return newnode;
2441 static FunctionParameter *
2442 _copyFunctionParameter(FunctionParameter *from)
2444 FunctionParameter *newnode = makeNode(FunctionParameter);
2446 COPY_STRING_FIELD(name);
2447 COPY_NODE_FIELD(argType);
2448 COPY_SCALAR_FIELD(mode);
2450 return newnode;
2453 static AlterFunctionStmt *
2454 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2456 AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2458 COPY_NODE_FIELD(func);
2459 COPY_NODE_FIELD(actions);
2461 return newnode;
2464 static RemoveFuncStmt *
2465 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2467 RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2469 COPY_SCALAR_FIELD(kind);
2470 COPY_NODE_FIELD(name);
2471 COPY_NODE_FIELD(args);
2472 COPY_SCALAR_FIELD(behavior);
2473 COPY_SCALAR_FIELD(missing_ok);
2475 return newnode;
2478 static RemoveOpClassStmt *
2479 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2481 RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2483 COPY_NODE_FIELD(opclassname);
2484 COPY_STRING_FIELD(amname);
2485 COPY_SCALAR_FIELD(behavior);
2486 COPY_SCALAR_FIELD(missing_ok);
2488 return newnode;
2491 static RemoveOpFamilyStmt *
2492 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2494 RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2496 COPY_NODE_FIELD(opfamilyname);
2497 COPY_STRING_FIELD(amname);
2498 COPY_SCALAR_FIELD(behavior);
2499 COPY_SCALAR_FIELD(missing_ok);
2501 return newnode;
2504 static RenameStmt *
2505 _copyRenameStmt(RenameStmt *from)
2507 RenameStmt *newnode = makeNode(RenameStmt);
2509 COPY_SCALAR_FIELD(renameType);
2510 COPY_NODE_FIELD(relation);
2511 COPY_NODE_FIELD(object);
2512 COPY_NODE_FIELD(objarg);
2513 COPY_STRING_FIELD(subname);
2514 COPY_STRING_FIELD(newname);
2516 return newnode;
2519 static AlterObjectSchemaStmt *
2520 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2522 AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2524 COPY_SCALAR_FIELD(objectType);
2525 COPY_NODE_FIELD(relation);
2526 COPY_NODE_FIELD(object);
2527 COPY_NODE_FIELD(objarg);
2528 COPY_STRING_FIELD(addname);
2529 COPY_STRING_FIELD(newschema);
2531 return newnode;
2534 static AlterOwnerStmt *
2535 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2537 AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2539 COPY_SCALAR_FIELD(objectType);
2540 COPY_NODE_FIELD(relation);
2541 COPY_NODE_FIELD(object);
2542 COPY_NODE_FIELD(objarg);
2543 COPY_STRING_FIELD(addname);
2544 COPY_STRING_FIELD(newowner);
2546 return newnode;
2549 static RuleStmt *
2550 _copyRuleStmt(RuleStmt *from)
2552 RuleStmt *newnode = makeNode(RuleStmt);
2554 COPY_NODE_FIELD(relation);
2555 COPY_STRING_FIELD(rulename);
2556 COPY_NODE_FIELD(whereClause);
2557 COPY_SCALAR_FIELD(event);
2558 COPY_SCALAR_FIELD(instead);
2559 COPY_NODE_FIELD(actions);
2560 COPY_SCALAR_FIELD(replace);
2562 return newnode;
2565 static NotifyStmt *
2566 _copyNotifyStmt(NotifyStmt *from)
2568 NotifyStmt *newnode = makeNode(NotifyStmt);
2570 COPY_STRING_FIELD(conditionname);
2572 return newnode;
2575 static ListenStmt *
2576 _copyListenStmt(ListenStmt *from)
2578 ListenStmt *newnode = makeNode(ListenStmt);
2580 COPY_STRING_FIELD(conditionname);
2582 return newnode;
2585 static UnlistenStmt *
2586 _copyUnlistenStmt(UnlistenStmt *from)
2588 UnlistenStmt *newnode = makeNode(UnlistenStmt);
2590 COPY_STRING_FIELD(conditionname);
2592 return newnode;
2595 static TransactionStmt *
2596 _copyTransactionStmt(TransactionStmt *from)
2598 TransactionStmt *newnode = makeNode(TransactionStmt);
2600 COPY_SCALAR_FIELD(kind);
2601 COPY_NODE_FIELD(options);
2602 COPY_STRING_FIELD(gid);
2604 return newnode;
2607 static CompositeTypeStmt *
2608 _copyCompositeTypeStmt(CompositeTypeStmt *from)
2610 CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
2612 COPY_NODE_FIELD(typevar);
2613 COPY_NODE_FIELD(coldeflist);
2615 return newnode;
2618 static CreateEnumStmt *
2619 _copyCreateEnumStmt(CreateEnumStmt *from)
2621 CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
2623 COPY_NODE_FIELD(typename);
2624 COPY_NODE_FIELD(vals);
2626 return newnode;
2629 static ViewStmt *
2630 _copyViewStmt(ViewStmt *from)
2632 ViewStmt *newnode = makeNode(ViewStmt);
2634 COPY_NODE_FIELD(view);
2635 COPY_NODE_FIELD(aliases);
2636 COPY_NODE_FIELD(query);
2637 COPY_SCALAR_FIELD(replace);
2639 return newnode;
2642 static LoadStmt *
2643 _copyLoadStmt(LoadStmt *from)
2645 LoadStmt *newnode = makeNode(LoadStmt);
2647 COPY_STRING_FIELD(filename);
2649 return newnode;
2652 static CreateDomainStmt *
2653 _copyCreateDomainStmt(CreateDomainStmt *from)
2655 CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
2657 COPY_NODE_FIELD(domainname);
2658 COPY_NODE_FIELD(typename);
2659 COPY_NODE_FIELD(constraints);
2661 return newnode;
2664 static CreateOpClassStmt *
2665 _copyCreateOpClassStmt(CreateOpClassStmt *from)
2667 CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
2669 COPY_NODE_FIELD(opclassname);
2670 COPY_NODE_FIELD(opfamilyname);
2671 COPY_STRING_FIELD(amname);
2672 COPY_NODE_FIELD(datatype);
2673 COPY_NODE_FIELD(items);
2674 COPY_SCALAR_FIELD(isDefault);
2676 return newnode;
2679 static CreateOpClassItem *
2680 _copyCreateOpClassItem(CreateOpClassItem *from)
2682 CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
2684 COPY_SCALAR_FIELD(itemtype);
2685 COPY_NODE_FIELD(name);
2686 COPY_NODE_FIELD(args);
2687 COPY_SCALAR_FIELD(number);
2688 COPY_NODE_FIELD(class_args);
2689 COPY_NODE_FIELD(storedtype);
2691 return newnode;
2694 static CreateOpFamilyStmt *
2695 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
2697 CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
2699 COPY_NODE_FIELD(opfamilyname);
2700 COPY_STRING_FIELD(amname);
2702 return newnode;
2705 static AlterOpFamilyStmt *
2706 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
2708 AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
2710 COPY_NODE_FIELD(opfamilyname);
2711 COPY_STRING_FIELD(amname);
2712 COPY_SCALAR_FIELD(isDrop);
2713 COPY_NODE_FIELD(items);
2715 return newnode;
2718 static CreatedbStmt *
2719 _copyCreatedbStmt(CreatedbStmt *from)
2721 CreatedbStmt *newnode = makeNode(CreatedbStmt);
2723 COPY_STRING_FIELD(dbname);
2724 COPY_NODE_FIELD(options);
2726 return newnode;
2729 static AlterDatabaseStmt *
2730 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
2732 AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
2734 COPY_STRING_FIELD(dbname);
2735 COPY_NODE_FIELD(options);
2737 return newnode;
2740 static AlterDatabaseSetStmt *
2741 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
2743 AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
2745 COPY_STRING_FIELD(dbname);
2746 COPY_NODE_FIELD(setstmt);
2748 return newnode;
2751 static DropdbStmt *
2752 _copyDropdbStmt(DropdbStmt *from)
2754 DropdbStmt *newnode = makeNode(DropdbStmt);
2756 COPY_STRING_FIELD(dbname);
2757 COPY_SCALAR_FIELD(missing_ok);
2759 return newnode;
2762 static VacuumStmt *
2763 _copyVacuumStmt(VacuumStmt *from)
2765 VacuumStmt *newnode = makeNode(VacuumStmt);
2767 COPY_SCALAR_FIELD(vacuum);
2768 COPY_SCALAR_FIELD(full);
2769 COPY_SCALAR_FIELD(analyze);
2770 COPY_SCALAR_FIELD(verbose);
2771 COPY_SCALAR_FIELD(freeze_min_age);
2772 COPY_NODE_FIELD(relation);
2773 COPY_NODE_FIELD(va_cols);
2775 return newnode;
2778 static ExplainStmt *
2779 _copyExplainStmt(ExplainStmt *from)
2781 ExplainStmt *newnode = makeNode(ExplainStmt);
2783 COPY_NODE_FIELD(query);
2784 COPY_SCALAR_FIELD(verbose);
2785 COPY_SCALAR_FIELD(analyze);
2787 return newnode;
2790 static CreateSeqStmt *
2791 _copyCreateSeqStmt(CreateSeqStmt *from)
2793 CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
2795 COPY_NODE_FIELD(sequence);
2796 COPY_NODE_FIELD(options);
2798 return newnode;
2801 static AlterSeqStmt *
2802 _copyAlterSeqStmt(AlterSeqStmt *from)
2804 AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
2806 COPY_NODE_FIELD(sequence);
2807 COPY_NODE_FIELD(options);
2809 return newnode;
2812 static VariableSetStmt *
2813 _copyVariableSetStmt(VariableSetStmt *from)
2815 VariableSetStmt *newnode = makeNode(VariableSetStmt);
2817 COPY_SCALAR_FIELD(kind);
2818 COPY_STRING_FIELD(name);
2819 COPY_NODE_FIELD(args);
2820 COPY_SCALAR_FIELD(is_local);
2822 return newnode;
2825 static VariableShowStmt *
2826 _copyVariableShowStmt(VariableShowStmt *from)
2828 VariableShowStmt *newnode = makeNode(VariableShowStmt);
2830 COPY_STRING_FIELD(name);
2832 return newnode;
2835 static DiscardStmt *
2836 _copyDiscardStmt(DiscardStmt *from)
2838 DiscardStmt *newnode = makeNode(DiscardStmt);
2840 COPY_SCALAR_FIELD(target);
2842 return newnode;
2845 static CreateTableSpaceStmt *
2846 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
2848 CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
2850 COPY_STRING_FIELD(tablespacename);
2851 COPY_STRING_FIELD(owner);
2852 COPY_STRING_FIELD(location);
2854 return newnode;
2857 static DropTableSpaceStmt *
2858 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
2860 DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
2862 COPY_STRING_FIELD(tablespacename);
2863 COPY_SCALAR_FIELD(missing_ok);
2865 return newnode;
2868 static CreateTrigStmt *
2869 _copyCreateTrigStmt(CreateTrigStmt *from)
2871 CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
2873 COPY_STRING_FIELD(trigname);
2874 COPY_NODE_FIELD(relation);
2875 COPY_NODE_FIELD(funcname);
2876 COPY_NODE_FIELD(args);
2877 COPY_SCALAR_FIELD(before);
2878 COPY_SCALAR_FIELD(row);
2879 strcpy(newnode->actions, from->actions); /* in-line string field */
2880 COPY_SCALAR_FIELD(isconstraint);
2881 COPY_SCALAR_FIELD(deferrable);
2882 COPY_SCALAR_FIELD(initdeferred);
2883 COPY_NODE_FIELD(constrrel);
2885 return newnode;
2888 static DropPropertyStmt *
2889 _copyDropPropertyStmt(DropPropertyStmt *from)
2891 DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
2893 COPY_NODE_FIELD(relation);
2894 COPY_STRING_FIELD(property);
2895 COPY_SCALAR_FIELD(removeType);
2896 COPY_SCALAR_FIELD(behavior);
2897 COPY_SCALAR_FIELD(missing_ok);
2899 return newnode;
2902 static CreatePLangStmt *
2903 _copyCreatePLangStmt(CreatePLangStmt *from)
2905 CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
2907 COPY_STRING_FIELD(plname);
2908 COPY_NODE_FIELD(plhandler);
2909 COPY_NODE_FIELD(plvalidator);
2910 COPY_SCALAR_FIELD(pltrusted);
2912 return newnode;
2915 static DropPLangStmt *
2916 _copyDropPLangStmt(DropPLangStmt *from)
2918 DropPLangStmt *newnode = makeNode(DropPLangStmt);
2920 COPY_STRING_FIELD(plname);
2921 COPY_SCALAR_FIELD(behavior);
2922 COPY_SCALAR_FIELD(missing_ok);
2924 return newnode;
2927 static CreateRoleStmt *
2928 _copyCreateRoleStmt(CreateRoleStmt *from)
2930 CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
2932 COPY_SCALAR_FIELD(stmt_type);
2933 COPY_STRING_FIELD(role);
2934 COPY_NODE_FIELD(options);
2936 return newnode;
2939 static AlterRoleStmt *
2940 _copyAlterRoleStmt(AlterRoleStmt *from)
2942 AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
2944 COPY_STRING_FIELD(role);
2945 COPY_NODE_FIELD(options);
2946 COPY_SCALAR_FIELD(action);
2948 return newnode;
2951 static AlterRoleSetStmt *
2952 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
2954 AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
2956 COPY_STRING_FIELD(role);
2957 COPY_NODE_FIELD(setstmt);
2959 return newnode;
2962 static DropRoleStmt *
2963 _copyDropRoleStmt(DropRoleStmt *from)
2965 DropRoleStmt *newnode = makeNode(DropRoleStmt);
2967 COPY_NODE_FIELD(roles);
2968 COPY_SCALAR_FIELD(missing_ok);
2970 return newnode;
2973 static LockStmt *
2974 _copyLockStmt(LockStmt *from)
2976 LockStmt *newnode = makeNode(LockStmt);
2978 COPY_NODE_FIELD(relations);
2979 COPY_SCALAR_FIELD(mode);
2980 COPY_SCALAR_FIELD(nowait);
2982 return newnode;
2985 static ConstraintsSetStmt *
2986 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
2988 ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
2990 COPY_NODE_FIELD(constraints);
2991 COPY_SCALAR_FIELD(deferred);
2993 return newnode;
2996 static ReindexStmt *
2997 _copyReindexStmt(ReindexStmt *from)
2999 ReindexStmt *newnode = makeNode(ReindexStmt);
3001 COPY_SCALAR_FIELD(kind);
3002 COPY_NODE_FIELD(relation);
3003 COPY_STRING_FIELD(name);
3004 COPY_SCALAR_FIELD(do_system);
3005 COPY_SCALAR_FIELD(do_user);
3007 return newnode;
3010 static CreateSchemaStmt *
3011 _copyCreateSchemaStmt(CreateSchemaStmt *from)
3013 CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3015 COPY_STRING_FIELD(schemaname);
3016 COPY_STRING_FIELD(authid);
3017 COPY_NODE_FIELD(schemaElts);
3019 return newnode;
3022 static CreateConversionStmt *
3023 _copyCreateConversionStmt(CreateConversionStmt *from)
3025 CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3027 COPY_NODE_FIELD(conversion_name);
3028 COPY_STRING_FIELD(for_encoding_name);
3029 COPY_STRING_FIELD(to_encoding_name);
3030 COPY_NODE_FIELD(func_name);
3031 COPY_SCALAR_FIELD(def);
3033 return newnode;
3036 static CreateCastStmt *
3037 _copyCreateCastStmt(CreateCastStmt *from)
3039 CreateCastStmt *newnode = makeNode(CreateCastStmt);
3041 COPY_NODE_FIELD(sourcetype);
3042 COPY_NODE_FIELD(targettype);
3043 COPY_NODE_FIELD(func);
3044 COPY_SCALAR_FIELD(context);
3045 COPY_SCALAR_FIELD(inout);
3047 return newnode;
3050 static DropCastStmt *
3051 _copyDropCastStmt(DropCastStmt *from)
3053 DropCastStmt *newnode = makeNode(DropCastStmt);
3055 COPY_NODE_FIELD(sourcetype);
3056 COPY_NODE_FIELD(targettype);
3057 COPY_SCALAR_FIELD(behavior);
3058 COPY_SCALAR_FIELD(missing_ok);
3060 return newnode;
3063 static PrepareStmt *
3064 _copyPrepareStmt(PrepareStmt *from)
3066 PrepareStmt *newnode = makeNode(PrepareStmt);
3068 COPY_STRING_FIELD(name);
3069 COPY_NODE_FIELD(argtypes);
3070 COPY_NODE_FIELD(query);
3072 return newnode;
3075 static ExecuteStmt *
3076 _copyExecuteStmt(ExecuteStmt *from)
3078 ExecuteStmt *newnode = makeNode(ExecuteStmt);
3080 COPY_STRING_FIELD(name);
3081 COPY_NODE_FIELD(into);
3082 COPY_NODE_FIELD(params);
3084 return newnode;
3087 static DeallocateStmt *
3088 _copyDeallocateStmt(DeallocateStmt *from)
3090 DeallocateStmt *newnode = makeNode(DeallocateStmt);
3092 COPY_STRING_FIELD(name);
3094 return newnode;
3097 static DropOwnedStmt *
3098 _copyDropOwnedStmt(DropOwnedStmt *from)
3100 DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3102 COPY_NODE_FIELD(roles);
3103 COPY_SCALAR_FIELD(behavior);
3105 return newnode;
3108 static ReassignOwnedStmt *
3109 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
3111 ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3113 COPY_NODE_FIELD(roles);
3114 COPY_SCALAR_FIELD(newrole);
3116 return newnode;
3119 static AlterTSDictionaryStmt *
3120 _copyAlterTSDictionaryStmt(AlterTSDictionaryStmt *from)
3122 AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3124 COPY_NODE_FIELD(dictname);
3125 COPY_NODE_FIELD(options);
3127 return newnode;
3130 static AlterTSConfigurationStmt *
3131 _copyAlterTSConfigurationStmt(AlterTSConfigurationStmt *from)
3133 AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3135 COPY_NODE_FIELD(cfgname);
3136 COPY_NODE_FIELD(tokentype);
3137 COPY_NODE_FIELD(dicts);
3138 COPY_SCALAR_FIELD(override);
3139 COPY_SCALAR_FIELD(replace);
3140 COPY_SCALAR_FIELD(missing_ok);
3142 return newnode;
3145 /* ****************************************************************
3146 * pg_list.h copy functions
3147 * ****************************************************************
3151 * Perform a deep copy of the specified list, using copyObject(). The
3152 * list MUST be of type T_List; T_IntList and T_OidList nodes don't
3153 * need deep copies, so they should be copied via list_copy()
3155 #define COPY_NODE_CELL(new, old) \
3156 (new) = (ListCell *) palloc(sizeof(ListCell)); \
3157 lfirst(new) = copyObject(lfirst(old));
3159 static List *
3160 _copyList(List *from)
3162 List *new;
3163 ListCell *curr_old;
3164 ListCell *prev_new;
3166 Assert(list_length(from) >= 1);
3168 new = makeNode(List);
3169 new->length = from->length;
3171 COPY_NODE_CELL(new->head, from->head);
3172 prev_new = new->head;
3173 curr_old = lnext(from->head);
3175 while (curr_old)
3177 COPY_NODE_CELL(prev_new->next, curr_old);
3178 prev_new = prev_new->next;
3179 curr_old = curr_old->next;
3181 prev_new->next = NULL;
3182 new->tail = prev_new;
3184 return new;
3187 /* ****************************************************************
3188 * value.h copy functions
3189 * ****************************************************************
3191 static Value *
3192 _copyValue(Value *from)
3194 Value *newnode = makeNode(Value);
3196 /* See also _copyAConst when changing this code! */
3198 COPY_SCALAR_FIELD(type);
3199 switch (from->type)
3201 case T_Integer:
3202 COPY_SCALAR_FIELD(val.ival);
3203 break;
3204 case T_Float:
3205 case T_String:
3206 case T_BitString:
3207 COPY_STRING_FIELD(val.str);
3208 break;
3209 case T_Null:
3210 /* nothing to do */
3211 break;
3212 default:
3213 elog(ERROR, "unrecognized node type: %d",
3214 (int) from->type);
3215 break;
3217 return newnode;
3221 * copyObject
3223 * Create a copy of a Node tree or list. This is a "deep" copy: all
3224 * substructure is copied too, recursively.
3226 void *
3227 copyObject(void *from)
3229 void *retval;
3231 if (from == NULL)
3232 return NULL;
3234 switch (nodeTag(from))
3237 * PLAN NODES
3239 case T_PlannedStmt:
3240 retval = _copyPlannedStmt(from);
3241 break;
3242 case T_Plan:
3243 retval = _copyPlan(from);
3244 break;
3245 case T_Result:
3246 retval = _copyResult(from);
3247 break;
3248 case T_Append:
3249 retval = _copyAppend(from);
3250 break;
3251 case T_RecursiveUnion:
3252 retval = _copyRecursiveUnion(from);
3253 break;
3254 case T_BitmapAnd:
3255 retval = _copyBitmapAnd(from);
3256 break;
3257 case T_BitmapOr:
3258 retval = _copyBitmapOr(from);
3259 break;
3260 case T_Scan:
3261 retval = _copyScan(from);
3262 break;
3263 case T_SeqScan:
3264 retval = _copySeqScan(from);
3265 break;
3266 case T_IndexScan:
3267 retval = _copyIndexScan(from);
3268 break;
3269 case T_BitmapIndexScan:
3270 retval = _copyBitmapIndexScan(from);
3271 break;
3272 case T_BitmapHeapScan:
3273 retval = _copyBitmapHeapScan(from);
3274 break;
3275 case T_TidScan:
3276 retval = _copyTidScan(from);
3277 break;
3278 case T_SubqueryScan:
3279 retval = _copySubqueryScan(from);
3280 break;
3281 case T_FunctionScan:
3282 retval = _copyFunctionScan(from);
3283 break;
3284 case T_ValuesScan:
3285 retval = _copyValuesScan(from);
3286 break;
3287 case T_CteScan:
3288 retval = _copyCteScan(from);
3289 break;
3290 case T_WorkTableScan:
3291 retval = _copyWorkTableScan(from);
3292 break;
3293 case T_Join:
3294 retval = _copyJoin(from);
3295 break;
3296 case T_NestLoop:
3297 retval = _copyNestLoop(from);
3298 break;
3299 case T_MergeJoin:
3300 retval = _copyMergeJoin(from);
3301 break;
3302 case T_HashJoin:
3303 retval = _copyHashJoin(from);
3304 break;
3305 case T_Material:
3306 retval = _copyMaterial(from);
3307 break;
3308 case T_Sort:
3309 retval = _copySort(from);
3310 break;
3311 case T_Group:
3312 retval = _copyGroup(from);
3313 break;
3314 case T_Agg:
3315 retval = _copyAgg(from);
3316 break;
3317 case T_Unique:
3318 retval = _copyUnique(from);
3319 break;
3320 case T_Hash:
3321 retval = _copyHash(from);
3322 break;
3323 case T_SetOp:
3324 retval = _copySetOp(from);
3325 break;
3326 case T_Limit:
3327 retval = _copyLimit(from);
3328 break;
3329 case T_PlanInvalItem:
3330 retval = _copyPlanInvalItem(from);
3331 break;
3334 * PRIMITIVE NODES
3336 case T_Alias:
3337 retval = _copyAlias(from);
3338 break;
3339 case T_RangeVar:
3340 retval = _copyRangeVar(from);
3341 break;
3342 case T_IntoClause:
3343 retval = _copyIntoClause(from);
3344 break;
3345 case T_Var:
3346 retval = _copyVar(from);
3347 break;
3348 case T_Const:
3349 retval = _copyConst(from);
3350 break;
3351 case T_Param:
3352 retval = _copyParam(from);
3353 break;
3354 case T_Aggref:
3355 retval = _copyAggref(from);
3356 break;
3357 case T_ArrayRef:
3358 retval = _copyArrayRef(from);
3359 break;
3360 case T_FuncExpr:
3361 retval = _copyFuncExpr(from);
3362 break;
3363 case T_OpExpr:
3364 retval = _copyOpExpr(from);
3365 break;
3366 case T_DistinctExpr:
3367 retval = _copyDistinctExpr(from);
3368 break;
3369 case T_ScalarArrayOpExpr:
3370 retval = _copyScalarArrayOpExpr(from);
3371 break;
3372 case T_BoolExpr:
3373 retval = _copyBoolExpr(from);
3374 break;
3375 case T_SubLink:
3376 retval = _copySubLink(from);
3377 break;
3378 case T_SubPlan:
3379 retval = _copySubPlan(from);
3380 break;
3381 case T_AlternativeSubPlan:
3382 retval = _copyAlternativeSubPlan(from);
3383 break;
3384 case T_FieldSelect:
3385 retval = _copyFieldSelect(from);
3386 break;
3387 case T_FieldStore:
3388 retval = _copyFieldStore(from);
3389 break;
3390 case T_RelabelType:
3391 retval = _copyRelabelType(from);
3392 break;
3393 case T_CoerceViaIO:
3394 retval = _copyCoerceViaIO(from);
3395 break;
3396 case T_ArrayCoerceExpr:
3397 retval = _copyArrayCoerceExpr(from);
3398 break;
3399 case T_ConvertRowtypeExpr:
3400 retval = _copyConvertRowtypeExpr(from);
3401 break;
3402 case T_CaseExpr:
3403 retval = _copyCaseExpr(from);
3404 break;
3405 case T_CaseWhen:
3406 retval = _copyCaseWhen(from);
3407 break;
3408 case T_CaseTestExpr:
3409 retval = _copyCaseTestExpr(from);
3410 break;
3411 case T_ArrayExpr:
3412 retval = _copyArrayExpr(from);
3413 break;
3414 case T_RowExpr:
3415 retval = _copyRowExpr(from);
3416 break;
3417 case T_RowCompareExpr:
3418 retval = _copyRowCompareExpr(from);
3419 break;
3420 case T_CoalesceExpr:
3421 retval = _copyCoalesceExpr(from);
3422 break;
3423 case T_MinMaxExpr:
3424 retval = _copyMinMaxExpr(from);
3425 break;
3426 case T_XmlExpr:
3427 retval = _copyXmlExpr(from);
3428 break;
3429 case T_NullIfExpr:
3430 retval = _copyNullIfExpr(from);
3431 break;
3432 case T_NullTest:
3433 retval = _copyNullTest(from);
3434 break;
3435 case T_BooleanTest:
3436 retval = _copyBooleanTest(from);
3437 break;
3438 case T_CoerceToDomain:
3439 retval = _copyCoerceToDomain(from);
3440 break;
3441 case T_CoerceToDomainValue:
3442 retval = _copyCoerceToDomainValue(from);
3443 break;
3444 case T_SetToDefault:
3445 retval = _copySetToDefault(from);
3446 break;
3447 case T_CurrentOfExpr:
3448 retval = _copyCurrentOfExpr(from);
3449 break;
3450 case T_TargetEntry:
3451 retval = _copyTargetEntry(from);
3452 break;
3453 case T_RangeTblRef:
3454 retval = _copyRangeTblRef(from);
3455 break;
3456 case T_JoinExpr:
3457 retval = _copyJoinExpr(from);
3458 break;
3459 case T_FromExpr:
3460 retval = _copyFromExpr(from);
3461 break;
3464 * RELATION NODES
3466 case T_PathKey:
3467 retval = _copyPathKey(from);
3468 break;
3469 case T_RestrictInfo:
3470 retval = _copyRestrictInfo(from);
3471 break;
3472 case T_FlattenedSubLink:
3473 retval = _copyFlattenedSubLink(from);
3474 break;
3475 case T_PlaceHolderVar:
3476 retval = _copyPlaceHolderVar(from);
3477 break;
3478 case T_SpecialJoinInfo:
3479 retval = _copySpecialJoinInfo(from);
3480 break;
3481 case T_AppendRelInfo:
3482 retval = _copyAppendRelInfo(from);
3483 break;
3484 case T_PlaceHolderInfo:
3485 retval = _copyPlaceHolderInfo(from);
3486 break;
3489 * VALUE NODES
3491 case T_Integer:
3492 case T_Float:
3493 case T_String:
3494 case T_BitString:
3495 case T_Null:
3496 retval = _copyValue(from);
3497 break;
3500 * LIST NODES
3502 case T_List:
3503 retval = _copyList(from);
3504 break;
3507 * Lists of integers and OIDs don't need to be deep-copied, so we
3508 * perform a shallow copy via list_copy()
3510 case T_IntList:
3511 case T_OidList:
3512 retval = list_copy(from);
3513 break;
3516 * PARSE NODES
3518 case T_Query:
3519 retval = _copyQuery(from);
3520 break;
3521 case T_InsertStmt:
3522 retval = _copyInsertStmt(from);
3523 break;
3524 case T_DeleteStmt:
3525 retval = _copyDeleteStmt(from);
3526 break;
3527 case T_UpdateStmt:
3528 retval = _copyUpdateStmt(from);
3529 break;
3530 case T_SelectStmt:
3531 retval = _copySelectStmt(from);
3532 break;
3533 case T_SetOperationStmt:
3534 retval = _copySetOperationStmt(from);
3535 break;
3536 case T_AlterTableStmt:
3537 retval = _copyAlterTableStmt(from);
3538 break;
3539 case T_AlterTableCmd:
3540 retval = _copyAlterTableCmd(from);
3541 break;
3542 case T_AlterDomainStmt:
3543 retval = _copyAlterDomainStmt(from);
3544 break;
3545 case T_GrantStmt:
3546 retval = _copyGrantStmt(from);
3547 break;
3548 case T_GrantRoleStmt:
3549 retval = _copyGrantRoleStmt(from);
3550 break;
3551 case T_DeclareCursorStmt:
3552 retval = _copyDeclareCursorStmt(from);
3553 break;
3554 case T_ClosePortalStmt:
3555 retval = _copyClosePortalStmt(from);
3556 break;
3557 case T_ClusterStmt:
3558 retval = _copyClusterStmt(from);
3559 break;
3560 case T_CopyStmt:
3561 retval = _copyCopyStmt(from);
3562 break;
3563 case T_CreateStmt:
3564 retval = _copyCreateStmt(from);
3565 break;
3566 case T_InhRelation:
3567 retval = _copyInhRelation(from);
3568 break;
3569 case T_DefineStmt:
3570 retval = _copyDefineStmt(from);
3571 break;
3572 case T_DropStmt:
3573 retval = _copyDropStmt(from);
3574 break;
3575 case T_TruncateStmt:
3576 retval = _copyTruncateStmt(from);
3577 break;
3578 case T_CommentStmt:
3579 retval = _copyCommentStmt(from);
3580 break;
3581 case T_FetchStmt:
3582 retval = _copyFetchStmt(from);
3583 break;
3584 case T_IndexStmt:
3585 retval = _copyIndexStmt(from);
3586 break;
3587 case T_CreateFunctionStmt:
3588 retval = _copyCreateFunctionStmt(from);
3589 break;
3590 case T_FunctionParameter:
3591 retval = _copyFunctionParameter(from);
3592 break;
3593 case T_AlterFunctionStmt:
3594 retval = _copyAlterFunctionStmt(from);
3595 break;
3596 case T_RemoveFuncStmt:
3597 retval = _copyRemoveFuncStmt(from);
3598 break;
3599 case T_RemoveOpClassStmt:
3600 retval = _copyRemoveOpClassStmt(from);
3601 break;
3602 case T_RemoveOpFamilyStmt:
3603 retval = _copyRemoveOpFamilyStmt(from);
3604 break;
3605 case T_RenameStmt:
3606 retval = _copyRenameStmt(from);
3607 break;
3608 case T_AlterObjectSchemaStmt:
3609 retval = _copyAlterObjectSchemaStmt(from);
3610 break;
3611 case T_AlterOwnerStmt:
3612 retval = _copyAlterOwnerStmt(from);
3613 break;
3614 case T_RuleStmt:
3615 retval = _copyRuleStmt(from);
3616 break;
3617 case T_NotifyStmt:
3618 retval = _copyNotifyStmt(from);
3619 break;
3620 case T_ListenStmt:
3621 retval = _copyListenStmt(from);
3622 break;
3623 case T_UnlistenStmt:
3624 retval = _copyUnlistenStmt(from);
3625 break;
3626 case T_TransactionStmt:
3627 retval = _copyTransactionStmt(from);
3628 break;
3629 case T_CompositeTypeStmt:
3630 retval = _copyCompositeTypeStmt(from);
3631 break;
3632 case T_CreateEnumStmt:
3633 retval = _copyCreateEnumStmt(from);
3634 break;
3635 case T_ViewStmt:
3636 retval = _copyViewStmt(from);
3637 break;
3638 case T_LoadStmt:
3639 retval = _copyLoadStmt(from);
3640 break;
3641 case T_CreateDomainStmt:
3642 retval = _copyCreateDomainStmt(from);
3643 break;
3644 case T_CreateOpClassStmt:
3645 retval = _copyCreateOpClassStmt(from);
3646 break;
3647 case T_CreateOpClassItem:
3648 retval = _copyCreateOpClassItem(from);
3649 break;
3650 case T_CreateOpFamilyStmt:
3651 retval = _copyCreateOpFamilyStmt(from);
3652 break;
3653 case T_AlterOpFamilyStmt:
3654 retval = _copyAlterOpFamilyStmt(from);
3655 break;
3656 case T_CreatedbStmt:
3657 retval = _copyCreatedbStmt(from);
3658 break;
3659 case T_AlterDatabaseStmt:
3660 retval = _copyAlterDatabaseStmt(from);
3661 break;
3662 case T_AlterDatabaseSetStmt:
3663 retval = _copyAlterDatabaseSetStmt(from);
3664 break;
3665 case T_DropdbStmt:
3666 retval = _copyDropdbStmt(from);
3667 break;
3668 case T_VacuumStmt:
3669 retval = _copyVacuumStmt(from);
3670 break;
3671 case T_ExplainStmt:
3672 retval = _copyExplainStmt(from);
3673 break;
3674 case T_CreateSeqStmt:
3675 retval = _copyCreateSeqStmt(from);
3676 break;
3677 case T_AlterSeqStmt:
3678 retval = _copyAlterSeqStmt(from);
3679 break;
3680 case T_VariableSetStmt:
3681 retval = _copyVariableSetStmt(from);
3682 break;
3683 case T_VariableShowStmt:
3684 retval = _copyVariableShowStmt(from);
3685 break;
3686 case T_DiscardStmt:
3687 retval = _copyDiscardStmt(from);
3688 break;
3689 case T_CreateTableSpaceStmt:
3690 retval = _copyCreateTableSpaceStmt(from);
3691 break;
3692 case T_DropTableSpaceStmt:
3693 retval = _copyDropTableSpaceStmt(from);
3694 break;
3695 case T_CreateTrigStmt:
3696 retval = _copyCreateTrigStmt(from);
3697 break;
3698 case T_DropPropertyStmt:
3699 retval = _copyDropPropertyStmt(from);
3700 break;
3701 case T_CreatePLangStmt:
3702 retval = _copyCreatePLangStmt(from);
3703 break;
3704 case T_DropPLangStmt:
3705 retval = _copyDropPLangStmt(from);
3706 break;
3707 case T_CreateRoleStmt:
3708 retval = _copyCreateRoleStmt(from);
3709 break;
3710 case T_AlterRoleStmt:
3711 retval = _copyAlterRoleStmt(from);
3712 break;
3713 case T_AlterRoleSetStmt:
3714 retval = _copyAlterRoleSetStmt(from);
3715 break;
3716 case T_DropRoleStmt:
3717 retval = _copyDropRoleStmt(from);
3718 break;
3719 case T_LockStmt:
3720 retval = _copyLockStmt(from);
3721 break;
3722 case T_ConstraintsSetStmt:
3723 retval = _copyConstraintsSetStmt(from);
3724 break;
3725 case T_ReindexStmt:
3726 retval = _copyReindexStmt(from);
3727 break;
3728 case T_CheckPointStmt:
3729 retval = (void *) makeNode(CheckPointStmt);
3730 break;
3731 case T_CreateSchemaStmt:
3732 retval = _copyCreateSchemaStmt(from);
3733 break;
3734 case T_CreateConversionStmt:
3735 retval = _copyCreateConversionStmt(from);
3736 break;
3737 case T_CreateCastStmt:
3738 retval = _copyCreateCastStmt(from);
3739 break;
3740 case T_DropCastStmt:
3741 retval = _copyDropCastStmt(from);
3742 break;
3743 case T_PrepareStmt:
3744 retval = _copyPrepareStmt(from);
3745 break;
3746 case T_ExecuteStmt:
3747 retval = _copyExecuteStmt(from);
3748 break;
3749 case T_DeallocateStmt:
3750 retval = _copyDeallocateStmt(from);
3751 break;
3752 case T_DropOwnedStmt:
3753 retval = _copyDropOwnedStmt(from);
3754 break;
3755 case T_ReassignOwnedStmt:
3756 retval = _copyReassignOwnedStmt(from);
3757 break;
3758 case T_AlterTSDictionaryStmt:
3759 retval = _copyAlterTSDictionaryStmt(from);
3760 break;
3761 case T_AlterTSConfigurationStmt:
3762 retval = _copyAlterTSConfigurationStmt(from);
3763 break;
3765 case T_A_Expr:
3766 retval = _copyAExpr(from);
3767 break;
3768 case T_ColumnRef:
3769 retval = _copyColumnRef(from);
3770 break;
3771 case T_ParamRef:
3772 retval = _copyParamRef(from);
3773 break;
3774 case T_A_Const:
3775 retval = _copyAConst(from);
3776 break;
3777 case T_FuncCall:
3778 retval = _copyFuncCall(from);
3779 break;
3780 case T_A_Star:
3781 retval = _copyAStar(from);
3782 break;
3783 case T_A_Indices:
3784 retval = _copyAIndices(from);
3785 break;
3786 case T_A_Indirection:
3787 retval = _copyA_Indirection(from);
3788 break;
3789 case T_A_ArrayExpr:
3790 retval = _copyA_ArrayExpr(from);
3791 break;
3792 case T_ResTarget:
3793 retval = _copyResTarget(from);
3794 break;
3795 case T_TypeCast:
3796 retval = _copyTypeCast(from);
3797 break;
3798 case T_SortBy:
3799 retval = _copySortBy(from);
3800 break;
3801 case T_RangeSubselect:
3802 retval = _copyRangeSubselect(from);
3803 break;
3804 case T_RangeFunction:
3805 retval = _copyRangeFunction(from);
3806 break;
3807 case T_TypeName:
3808 retval = _copyTypeName(from);
3809 break;
3810 case T_IndexElem:
3811 retval = _copyIndexElem(from);
3812 break;
3813 case T_ColumnDef:
3814 retval = _copyColumnDef(from);
3815 break;
3816 case T_Constraint:
3817 retval = _copyConstraint(from);
3818 break;
3819 case T_DefElem:
3820 retval = _copyDefElem(from);
3821 break;
3822 case T_LockingClause:
3823 retval = _copyLockingClause(from);
3824 break;
3825 case T_RangeTblEntry:
3826 retval = _copyRangeTblEntry(from);
3827 break;
3828 case T_SortGroupClause:
3829 retval = _copySortGroupClause(from);
3830 break;
3831 case T_RowMarkClause:
3832 retval = _copyRowMarkClause(from);
3833 break;
3834 case T_WithClause:
3835 retval = _copyWithClause(from);
3836 break;
3837 case T_CommonTableExpr:
3838 retval = _copyCommonTableExpr(from);
3839 break;
3840 case T_FkConstraint:
3841 retval = _copyFkConstraint(from);
3842 break;
3843 case T_PrivGrantee:
3844 retval = _copyPrivGrantee(from);
3845 break;
3846 case T_FuncWithArgs:
3847 retval = _copyFuncWithArgs(from);
3848 break;
3849 case T_XmlSerialize:
3850 retval = _copyXmlSerialize(from);
3851 break;
3853 default:
3854 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
3855 retval = from; /* keep compiler quiet */
3856 break;
3859 return retval;