OSDN Git Service

Fix typo in sslmode documentation
[pg-rex/syncrep.git] / src / backend / nodes / copyfuncs.c
1 /*-------------------------------------------------------------------------
2  *
3  * copyfuncs.c
4  *        Copy functions for Postgres tree nodes.
5  *
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.
12  *
13  *
14  * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
15  * Portions Copyright (c) 1994, Regents of the University of California
16  *
17  * IDENTIFICATION
18  *        src/backend/nodes/copyfuncs.c
19  *
20  *-------------------------------------------------------------------------
21  */
22
23 #include "postgres.h"
24
25 #include "miscadmin.h"
26 #include "foreign/fdwapi.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
30
31
32 /*
33  * Macros to simplify copying of different kinds of fields.  Use these
34  * wherever possible to reduce the chance for silly typos.      Note that these
35  * hard-wire the convention that the local variables in a Copy routine are
36  * named 'newnode' and 'from'.
37  */
38
39 /* Copy a simple scalar field (int, float, bool, enum, etc) */
40 #define COPY_SCALAR_FIELD(fldname) \
41         (newnode->fldname = from->fldname)
42
43 /* Copy a field that is a pointer to some kind of Node or Node tree */
44 #define COPY_NODE_FIELD(fldname) \
45         (newnode->fldname = copyObject(from->fldname))
46
47 /* Copy a field that is a pointer to a Bitmapset */
48 #define COPY_BITMAPSET_FIELD(fldname) \
49         (newnode->fldname = bms_copy(from->fldname))
50
51 /* Copy a field that is a pointer to a C string, or perhaps NULL */
52 #define COPY_STRING_FIELD(fldname) \
53         (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
54
55 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
56 #define COPY_POINTER_FIELD(fldname, sz) \
57         do { \
58                 Size    _size = (sz); \
59                 newnode->fldname = palloc(_size); \
60                 memcpy(newnode->fldname, from->fldname, _size); \
61         } while (0)
62
63 /* Copy a parse location field (for Copy, this is same as scalar case) */
64 #define COPY_LOCATION_FIELD(fldname) \
65         (newnode->fldname = from->fldname)
66
67
68 /* ****************************************************************
69  *                                       plannodes.h copy functions
70  * ****************************************************************
71  */
72
73 /*
74  * _copyPlannedStmt
75  */
76 static PlannedStmt *
77 _copyPlannedStmt(PlannedStmt *from)
78 {
79         PlannedStmt *newnode = makeNode(PlannedStmt);
80
81         COPY_SCALAR_FIELD(commandType);
82         COPY_SCALAR_FIELD(hasReturning);
83         COPY_SCALAR_FIELD(hasModifyingCTE);
84         COPY_SCALAR_FIELD(canSetTag);
85         COPY_SCALAR_FIELD(transientPlan);
86         COPY_NODE_FIELD(planTree);
87         COPY_NODE_FIELD(rtable);
88         COPY_NODE_FIELD(resultRelations);
89         COPY_NODE_FIELD(utilityStmt);
90         COPY_NODE_FIELD(intoClause);
91         COPY_NODE_FIELD(subplans);
92         COPY_BITMAPSET_FIELD(rewindPlanIDs);
93         COPY_NODE_FIELD(rowMarks);
94         COPY_NODE_FIELD(relationOids);
95         COPY_NODE_FIELD(invalItems);
96         COPY_SCALAR_FIELD(nParamExec);
97
98         return newnode;
99 }
100
101 /*
102  * CopyPlanFields
103  *
104  *              This function copies the fields of the Plan node.  It is used by
105  *              all the copy functions for classes which inherit from Plan.
106  */
107 static void
108 CopyPlanFields(Plan *from, Plan *newnode)
109 {
110         COPY_SCALAR_FIELD(startup_cost);
111         COPY_SCALAR_FIELD(total_cost);
112         COPY_SCALAR_FIELD(plan_rows);
113         COPY_SCALAR_FIELD(plan_width);
114         COPY_NODE_FIELD(targetlist);
115         COPY_NODE_FIELD(qual);
116         COPY_NODE_FIELD(lefttree);
117         COPY_NODE_FIELD(righttree);
118         COPY_NODE_FIELD(initPlan);
119         COPY_BITMAPSET_FIELD(extParam);
120         COPY_BITMAPSET_FIELD(allParam);
121 }
122
123 /*
124  * _copyPlan
125  */
126 static Plan *
127 _copyPlan(Plan *from)
128 {
129         Plan       *newnode = makeNode(Plan);
130
131         /*
132          * copy node superclass fields
133          */
134         CopyPlanFields(from, newnode);
135
136         return newnode;
137 }
138
139
140 /*
141  * _copyResult
142  */
143 static Result *
144 _copyResult(Result *from)
145 {
146         Result     *newnode = makeNode(Result);
147
148         /*
149          * copy node superclass fields
150          */
151         CopyPlanFields((Plan *) from, (Plan *) newnode);
152
153         /*
154          * copy remainder of node
155          */
156         COPY_NODE_FIELD(resconstantqual);
157
158         return newnode;
159 }
160
161 /*
162  * _copyModifyTable
163  */
164 static ModifyTable *
165 _copyModifyTable(ModifyTable *from)
166 {
167         ModifyTable *newnode = makeNode(ModifyTable);
168
169         /*
170          * copy node superclass fields
171          */
172         CopyPlanFields((Plan *) from, (Plan *) newnode);
173
174         /*
175          * copy remainder of node
176          */
177         COPY_SCALAR_FIELD(operation);
178         COPY_SCALAR_FIELD(canSetTag);
179         COPY_NODE_FIELD(resultRelations);
180         COPY_SCALAR_FIELD(resultRelIndex);
181         COPY_NODE_FIELD(plans);
182         COPY_NODE_FIELD(returningLists);
183         COPY_NODE_FIELD(rowMarks);
184         COPY_SCALAR_FIELD(epqParam);
185
186         return newnode;
187 }
188
189 /*
190  * _copyAppend
191  */
192 static Append *
193 _copyAppend(Append *from)
194 {
195         Append     *newnode = makeNode(Append);
196
197         /*
198          * copy node superclass fields
199          */
200         CopyPlanFields((Plan *) from, (Plan *) newnode);
201
202         /*
203          * copy remainder of node
204          */
205         COPY_NODE_FIELD(appendplans);
206
207         return newnode;
208 }
209
210 /*
211  * _copyMergeAppend
212  */
213 static MergeAppend *
214 _copyMergeAppend(MergeAppend *from)
215 {
216         MergeAppend *newnode = makeNode(MergeAppend);
217
218         /*
219          * copy node superclass fields
220          */
221         CopyPlanFields((Plan *) from, (Plan *) newnode);
222
223         /*
224          * copy remainder of node
225          */
226         COPY_NODE_FIELD(mergeplans);
227         COPY_SCALAR_FIELD(numCols);
228         COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
229         COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
230         COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
231         COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
232
233         return newnode;
234 }
235
236 /*
237  * _copyRecursiveUnion
238  */
239 static RecursiveUnion *
240 _copyRecursiveUnion(RecursiveUnion *from)
241 {
242         RecursiveUnion *newnode = makeNode(RecursiveUnion);
243
244         /*
245          * copy node superclass fields
246          */
247         CopyPlanFields((Plan *) from, (Plan *) newnode);
248
249         /*
250          * copy remainder of node
251          */
252         COPY_SCALAR_FIELD(wtParam);
253         COPY_SCALAR_FIELD(numCols);
254         if (from->numCols > 0)
255         {
256                 COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
257                 COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
258         }
259         COPY_SCALAR_FIELD(numGroups);
260
261         return newnode;
262 }
263
264 /*
265  * _copyBitmapAnd
266  */
267 static BitmapAnd *
268 _copyBitmapAnd(BitmapAnd *from)
269 {
270         BitmapAnd  *newnode = makeNode(BitmapAnd);
271
272         /*
273          * copy node superclass fields
274          */
275         CopyPlanFields((Plan *) from, (Plan *) newnode);
276
277         /*
278          * copy remainder of node
279          */
280         COPY_NODE_FIELD(bitmapplans);
281
282         return newnode;
283 }
284
285 /*
286  * _copyBitmapOr
287  */
288 static BitmapOr *
289 _copyBitmapOr(BitmapOr *from)
290 {
291         BitmapOr   *newnode = makeNode(BitmapOr);
292
293         /*
294          * copy node superclass fields
295          */
296         CopyPlanFields((Plan *) from, (Plan *) newnode);
297
298         /*
299          * copy remainder of node
300          */
301         COPY_NODE_FIELD(bitmapplans);
302
303         return newnode;
304 }
305
306
307 /*
308  * CopyScanFields
309  *
310  *              This function copies the fields of the Scan node.  It is used by
311  *              all the copy functions for classes which inherit from Scan.
312  */
313 static void
314 CopyScanFields(Scan *from, Scan *newnode)
315 {
316         CopyPlanFields((Plan *) from, (Plan *) newnode);
317
318         COPY_SCALAR_FIELD(scanrelid);
319 }
320
321 /*
322  * _copyScan
323  */
324 static Scan *
325 _copyScan(Scan *from)
326 {
327         Scan       *newnode = makeNode(Scan);
328
329         /*
330          * copy node superclass fields
331          */
332         CopyScanFields((Scan *) from, (Scan *) newnode);
333
334         return newnode;
335 }
336
337 /*
338  * _copySeqScan
339  */
340 static SeqScan *
341 _copySeqScan(SeqScan *from)
342 {
343         SeqScan    *newnode = makeNode(SeqScan);
344
345         /*
346          * copy node superclass fields
347          */
348         CopyScanFields((Scan *) from, (Scan *) newnode);
349
350         return newnode;
351 }
352
353 /*
354  * _copyIndexScan
355  */
356 static IndexScan *
357 _copyIndexScan(IndexScan *from)
358 {
359         IndexScan  *newnode = makeNode(IndexScan);
360
361         /*
362          * copy node superclass fields
363          */
364         CopyScanFields((Scan *) from, (Scan *) newnode);
365
366         /*
367          * copy remainder of node
368          */
369         COPY_SCALAR_FIELD(indexid);
370         COPY_NODE_FIELD(indexqual);
371         COPY_NODE_FIELD(indexqualorig);
372         COPY_NODE_FIELD(indexorderby);
373         COPY_NODE_FIELD(indexorderbyorig);
374         COPY_SCALAR_FIELD(indexorderdir);
375
376         return newnode;
377 }
378
379 /*
380  * _copyBitmapIndexScan
381  */
382 static BitmapIndexScan *
383 _copyBitmapIndexScan(BitmapIndexScan *from)
384 {
385         BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
386
387         /*
388          * copy node superclass fields
389          */
390         CopyScanFields((Scan *) from, (Scan *) newnode);
391
392         /*
393          * copy remainder of node
394          */
395         COPY_SCALAR_FIELD(indexid);
396         COPY_NODE_FIELD(indexqual);
397         COPY_NODE_FIELD(indexqualorig);
398
399         return newnode;
400 }
401
402 /*
403  * _copyBitmapHeapScan
404  */
405 static BitmapHeapScan *
406 _copyBitmapHeapScan(BitmapHeapScan *from)
407 {
408         BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
409
410         /*
411          * copy node superclass fields
412          */
413         CopyScanFields((Scan *) from, (Scan *) newnode);
414
415         /*
416          * copy remainder of node
417          */
418         COPY_NODE_FIELD(bitmapqualorig);
419
420         return newnode;
421 }
422
423 /*
424  * _copyTidScan
425  */
426 static TidScan *
427 _copyTidScan(TidScan *from)
428 {
429         TidScan    *newnode = makeNode(TidScan);
430
431         /*
432          * copy node superclass fields
433          */
434         CopyScanFields((Scan *) from, (Scan *) newnode);
435
436         /*
437          * copy remainder of node
438          */
439         COPY_NODE_FIELD(tidquals);
440
441         return newnode;
442 }
443
444 /*
445  * _copySubqueryScan
446  */
447 static SubqueryScan *
448 _copySubqueryScan(SubqueryScan *from)
449 {
450         SubqueryScan *newnode = makeNode(SubqueryScan);
451
452         /*
453          * copy node superclass fields
454          */
455         CopyScanFields((Scan *) from, (Scan *) newnode);
456
457         /*
458          * copy remainder of node
459          */
460         COPY_NODE_FIELD(subplan);
461         COPY_NODE_FIELD(subrtable);
462         COPY_NODE_FIELD(subrowmark);
463
464         return newnode;
465 }
466
467 /*
468  * _copyFunctionScan
469  */
470 static FunctionScan *
471 _copyFunctionScan(FunctionScan *from)
472 {
473         FunctionScan *newnode = makeNode(FunctionScan);
474
475         /*
476          * copy node superclass fields
477          */
478         CopyScanFields((Scan *) from, (Scan *) newnode);
479
480         /*
481          * copy remainder of node
482          */
483         COPY_NODE_FIELD(funcexpr);
484         COPY_NODE_FIELD(funccolnames);
485         COPY_NODE_FIELD(funccoltypes);
486         COPY_NODE_FIELD(funccoltypmods);
487         COPY_NODE_FIELD(funccolcollations);
488
489         return newnode;
490 }
491
492 /*
493  * _copyValuesScan
494  */
495 static ValuesScan *
496 _copyValuesScan(ValuesScan *from)
497 {
498         ValuesScan *newnode = makeNode(ValuesScan);
499
500         /*
501          * copy node superclass fields
502          */
503         CopyScanFields((Scan *) from, (Scan *) newnode);
504
505         /*
506          * copy remainder of node
507          */
508         COPY_NODE_FIELD(values_lists);
509
510         return newnode;
511 }
512
513 /*
514  * _copyCteScan
515  */
516 static CteScan *
517 _copyCteScan(CteScan *from)
518 {
519         CteScan    *newnode = makeNode(CteScan);
520
521         /*
522          * copy node superclass fields
523          */
524         CopyScanFields((Scan *) from, (Scan *) newnode);
525
526         /*
527          * copy remainder of node
528          */
529         COPY_SCALAR_FIELD(ctePlanId);
530         COPY_SCALAR_FIELD(cteParam);
531
532         return newnode;
533 }
534
535 /*
536  * _copyWorkTableScan
537  */
538 static WorkTableScan *
539 _copyWorkTableScan(WorkTableScan *from)
540 {
541         WorkTableScan *newnode = makeNode(WorkTableScan);
542
543         /*
544          * copy node superclass fields
545          */
546         CopyScanFields((Scan *) from, (Scan *) newnode);
547
548         /*
549          * copy remainder of node
550          */
551         COPY_SCALAR_FIELD(wtParam);
552
553         return newnode;
554 }
555
556 /*
557  * _copyForeignScan
558  */
559 static ForeignScan *
560 _copyForeignScan(ForeignScan *from)
561 {
562         ForeignScan *newnode = makeNode(ForeignScan);
563
564         /*
565          * copy node superclass fields
566          */
567         CopyScanFields((Scan *) from, (Scan *) newnode);
568
569         /*
570          * copy remainder of node
571          */
572         COPY_SCALAR_FIELD(fsSystemCol);
573         COPY_NODE_FIELD(fdwplan);
574
575         return newnode;
576 }
577
578 /*
579  * _copyFdwPlan
580  */
581 static FdwPlan *
582 _copyFdwPlan(FdwPlan *from)
583 {
584         FdwPlan    *newnode = makeNode(FdwPlan);
585
586         COPY_SCALAR_FIELD(startup_cost);
587         COPY_SCALAR_FIELD(total_cost);
588         COPY_NODE_FIELD(fdw_private);
589
590         return newnode;
591 }
592
593 /*
594  * CopyJoinFields
595  *
596  *              This function copies the fields of the Join node.  It is used by
597  *              all the copy functions for classes which inherit from Join.
598  */
599 static void
600 CopyJoinFields(Join *from, Join *newnode)
601 {
602         CopyPlanFields((Plan *) from, (Plan *) newnode);
603
604         COPY_SCALAR_FIELD(jointype);
605         COPY_NODE_FIELD(joinqual);
606 }
607
608
609 /*
610  * _copyJoin
611  */
612 static Join *
613 _copyJoin(Join *from)
614 {
615         Join       *newnode = makeNode(Join);
616
617         /*
618          * copy node superclass fields
619          */
620         CopyJoinFields(from, newnode);
621
622         return newnode;
623 }
624
625
626 /*
627  * _copyNestLoop
628  */
629 static NestLoop *
630 _copyNestLoop(NestLoop *from)
631 {
632         NestLoop   *newnode = makeNode(NestLoop);
633
634         /*
635          * copy node superclass fields
636          */
637         CopyJoinFields((Join *) from, (Join *) newnode);
638
639         /*
640          * copy remainder of node
641          */
642         COPY_NODE_FIELD(nestParams);
643
644         return newnode;
645 }
646
647
648 /*
649  * _copyMergeJoin
650  */
651 static MergeJoin *
652 _copyMergeJoin(MergeJoin *from)
653 {
654         MergeJoin  *newnode = makeNode(MergeJoin);
655         int                     numCols;
656
657         /*
658          * copy node superclass fields
659          */
660         CopyJoinFields((Join *) from, (Join *) newnode);
661
662         /*
663          * copy remainder of node
664          */
665         COPY_NODE_FIELD(mergeclauses);
666         numCols = list_length(from->mergeclauses);
667         COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
668         COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
669         COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
670         COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
671
672         return newnode;
673 }
674
675 /*
676  * _copyHashJoin
677  */
678 static HashJoin *
679 _copyHashJoin(HashJoin *from)
680 {
681         HashJoin   *newnode = makeNode(HashJoin);
682
683         /*
684          * copy node superclass fields
685          */
686         CopyJoinFields((Join *) from, (Join *) newnode);
687
688         /*
689          * copy remainder of node
690          */
691         COPY_NODE_FIELD(hashclauses);
692
693         return newnode;
694 }
695
696
697 /*
698  * _copyMaterial
699  */
700 static Material *
701 _copyMaterial(Material *from)
702 {
703         Material   *newnode = makeNode(Material);
704
705         /*
706          * copy node superclass fields
707          */
708         CopyPlanFields((Plan *) from, (Plan *) newnode);
709
710         return newnode;
711 }
712
713
714 /*
715  * _copySort
716  */
717 static Sort *
718 _copySort(Sort *from)
719 {
720         Sort       *newnode = makeNode(Sort);
721
722         /*
723          * copy node superclass fields
724          */
725         CopyPlanFields((Plan *) from, (Plan *) newnode);
726
727         COPY_SCALAR_FIELD(numCols);
728         COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
729         COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
730         COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
731         COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
732
733         return newnode;
734 }
735
736
737 /*
738  * _copyGroup
739  */
740 static Group *
741 _copyGroup(Group *from)
742 {
743         Group      *newnode = makeNode(Group);
744
745         CopyPlanFields((Plan *) from, (Plan *) newnode);
746
747         COPY_SCALAR_FIELD(numCols);
748         COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
749         COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
750
751         return newnode;
752 }
753
754 /*
755  * _copyAgg
756  */
757 static Agg *
758 _copyAgg(Agg *from)
759 {
760         Agg                *newnode = makeNode(Agg);
761
762         CopyPlanFields((Plan *) from, (Plan *) newnode);
763
764         COPY_SCALAR_FIELD(aggstrategy);
765         COPY_SCALAR_FIELD(numCols);
766         if (from->numCols > 0)
767         {
768                 COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
769                 COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
770         }
771         COPY_SCALAR_FIELD(numGroups);
772
773         return newnode;
774 }
775
776 /*
777  * _copyWindowAgg
778  */
779 static WindowAgg *
780 _copyWindowAgg(WindowAgg *from)
781 {
782         WindowAgg  *newnode = makeNode(WindowAgg);
783
784         CopyPlanFields((Plan *) from, (Plan *) newnode);
785
786         COPY_SCALAR_FIELD(winref);
787         COPY_SCALAR_FIELD(partNumCols);
788         if (from->partNumCols > 0)
789         {
790                 COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
791                 COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
792         }
793         COPY_SCALAR_FIELD(ordNumCols);
794         if (from->ordNumCols > 0)
795         {
796                 COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
797                 COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
798         }
799         COPY_SCALAR_FIELD(frameOptions);
800         COPY_NODE_FIELD(startOffset);
801         COPY_NODE_FIELD(endOffset);
802
803         return newnode;
804 }
805
806 /*
807  * _copyUnique
808  */
809 static Unique *
810 _copyUnique(Unique *from)
811 {
812         Unique     *newnode = makeNode(Unique);
813
814         /*
815          * copy node superclass fields
816          */
817         CopyPlanFields((Plan *) from, (Plan *) newnode);
818
819         /*
820          * copy remainder of node
821          */
822         COPY_SCALAR_FIELD(numCols);
823         COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
824         COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
825
826         return newnode;
827 }
828
829 /*
830  * _copyHash
831  */
832 static Hash *
833 _copyHash(Hash *from)
834 {
835         Hash       *newnode = makeNode(Hash);
836
837         /*
838          * copy node superclass fields
839          */
840         CopyPlanFields((Plan *) from, (Plan *) newnode);
841
842         /*
843          * copy remainder of node
844          */
845         COPY_SCALAR_FIELD(skewTable);
846         COPY_SCALAR_FIELD(skewColumn);
847         COPY_SCALAR_FIELD(skewInherit);
848         COPY_SCALAR_FIELD(skewColType);
849         COPY_SCALAR_FIELD(skewColTypmod);
850
851         return newnode;
852 }
853
854 /*
855  * _copySetOp
856  */
857 static SetOp *
858 _copySetOp(SetOp *from)
859 {
860         SetOp      *newnode = makeNode(SetOp);
861
862         /*
863          * copy node superclass fields
864          */
865         CopyPlanFields((Plan *) from, (Plan *) newnode);
866
867         /*
868          * copy remainder of node
869          */
870         COPY_SCALAR_FIELD(cmd);
871         COPY_SCALAR_FIELD(strategy);
872         COPY_SCALAR_FIELD(numCols);
873         COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
874         COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
875         COPY_SCALAR_FIELD(flagColIdx);
876         COPY_SCALAR_FIELD(firstFlag);
877         COPY_SCALAR_FIELD(numGroups);
878
879         return newnode;
880 }
881
882 /*
883  * _copyLockRows
884  */
885 static LockRows *
886 _copyLockRows(LockRows *from)
887 {
888         LockRows   *newnode = makeNode(LockRows);
889
890         /*
891          * copy node superclass fields
892          */
893         CopyPlanFields((Plan *) from, (Plan *) newnode);
894
895         /*
896          * copy remainder of node
897          */
898         COPY_NODE_FIELD(rowMarks);
899         COPY_SCALAR_FIELD(epqParam);
900
901         return newnode;
902 }
903
904 /*
905  * _copyLimit
906  */
907 static Limit *
908 _copyLimit(Limit *from)
909 {
910         Limit      *newnode = makeNode(Limit);
911
912         /*
913          * copy node superclass fields
914          */
915         CopyPlanFields((Plan *) from, (Plan *) newnode);
916
917         /*
918          * copy remainder of node
919          */
920         COPY_NODE_FIELD(limitOffset);
921         COPY_NODE_FIELD(limitCount);
922
923         return newnode;
924 }
925
926 /*
927  * _copyNestLoopParam
928  */
929 static NestLoopParam *
930 _copyNestLoopParam(NestLoopParam *from)
931 {
932         NestLoopParam *newnode = makeNode(NestLoopParam);
933
934         COPY_SCALAR_FIELD(paramno);
935         COPY_NODE_FIELD(paramval);
936
937         return newnode;
938 }
939
940 /*
941  * _copyPlanRowMark
942  */
943 static PlanRowMark *
944 _copyPlanRowMark(PlanRowMark *from)
945 {
946         PlanRowMark *newnode = makeNode(PlanRowMark);
947
948         COPY_SCALAR_FIELD(rti);
949         COPY_SCALAR_FIELD(prti);
950         COPY_SCALAR_FIELD(rowmarkId);
951         COPY_SCALAR_FIELD(markType);
952         COPY_SCALAR_FIELD(noWait);
953         COPY_SCALAR_FIELD(isParent);
954
955         return newnode;
956 }
957
958 /*
959  * _copyPlanInvalItem
960  */
961 static PlanInvalItem *
962 _copyPlanInvalItem(PlanInvalItem *from)
963 {
964         PlanInvalItem *newnode = makeNode(PlanInvalItem);
965
966         COPY_SCALAR_FIELD(cacheId);
967         /* tupleId isn't really a "scalar", but this works anyway */
968         COPY_SCALAR_FIELD(tupleId);
969
970         return newnode;
971 }
972
973 /* ****************************************************************
974  *                                         primnodes.h copy functions
975  * ****************************************************************
976  */
977
978 /*
979  * _copyAlias
980  */
981 static Alias *
982 _copyAlias(Alias *from)
983 {
984         Alias      *newnode = makeNode(Alias);
985
986         COPY_STRING_FIELD(aliasname);
987         COPY_NODE_FIELD(colnames);
988
989         return newnode;
990 }
991
992 /*
993  * _copyRangeVar
994  */
995 static RangeVar *
996 _copyRangeVar(RangeVar *from)
997 {
998         RangeVar   *newnode = makeNode(RangeVar);
999
1000         COPY_STRING_FIELD(catalogname);
1001         COPY_STRING_FIELD(schemaname);
1002         COPY_STRING_FIELD(relname);
1003         COPY_SCALAR_FIELD(inhOpt);
1004         COPY_SCALAR_FIELD(relpersistence);
1005         COPY_NODE_FIELD(alias);
1006         COPY_LOCATION_FIELD(location);
1007
1008         return newnode;
1009 }
1010
1011 /*
1012  * _copyIntoClause
1013  */
1014 static IntoClause *
1015 _copyIntoClause(IntoClause *from)
1016 {
1017         IntoClause *newnode = makeNode(IntoClause);
1018
1019         COPY_NODE_FIELD(rel);
1020         COPY_NODE_FIELD(colNames);
1021         COPY_NODE_FIELD(options);
1022         COPY_SCALAR_FIELD(onCommit);
1023         COPY_STRING_FIELD(tableSpaceName);
1024
1025         return newnode;
1026 }
1027
1028 /*
1029  * We don't need a _copyExpr because Expr is an abstract supertype which
1030  * should never actually get instantiated.      Also, since it has no common
1031  * fields except NodeTag, there's no need for a helper routine to factor
1032  * out copying the common fields...
1033  */
1034
1035 /*
1036  * _copyVar
1037  */
1038 static Var *
1039 _copyVar(Var *from)
1040 {
1041         Var                *newnode = makeNode(Var);
1042
1043         COPY_SCALAR_FIELD(varno);
1044         COPY_SCALAR_FIELD(varattno);
1045         COPY_SCALAR_FIELD(vartype);
1046         COPY_SCALAR_FIELD(vartypmod);
1047         COPY_SCALAR_FIELD(varcollid);
1048         COPY_SCALAR_FIELD(varlevelsup);
1049         COPY_SCALAR_FIELD(varnoold);
1050         COPY_SCALAR_FIELD(varoattno);
1051         COPY_LOCATION_FIELD(location);
1052
1053         return newnode;
1054 }
1055
1056 /*
1057  * _copyConst
1058  */
1059 static Const *
1060 _copyConst(Const *from)
1061 {
1062         Const      *newnode = makeNode(Const);
1063
1064         COPY_SCALAR_FIELD(consttype);
1065         COPY_SCALAR_FIELD(consttypmod);
1066         COPY_SCALAR_FIELD(constcollid);
1067         COPY_SCALAR_FIELD(constlen);
1068
1069         if (from->constbyval || from->constisnull)
1070         {
1071                 /*
1072                  * passed by value so just copy the datum. Also, don't try to copy
1073                  * struct when value is null!
1074                  */
1075                 newnode->constvalue = from->constvalue;
1076         }
1077         else
1078         {
1079                 /*
1080                  * passed by reference.  We need a palloc'd copy.
1081                  */
1082                 newnode->constvalue = datumCopy(from->constvalue,
1083                                                                                 from->constbyval,
1084                                                                                 from->constlen);
1085         }
1086
1087         COPY_SCALAR_FIELD(constisnull);
1088         COPY_SCALAR_FIELD(constbyval);
1089         COPY_LOCATION_FIELD(location);
1090
1091         return newnode;
1092 }
1093
1094 /*
1095  * _copyParam
1096  */
1097 static Param *
1098 _copyParam(Param *from)
1099 {
1100         Param      *newnode = makeNode(Param);
1101
1102         COPY_SCALAR_FIELD(paramkind);
1103         COPY_SCALAR_FIELD(paramid);
1104         COPY_SCALAR_FIELD(paramtype);
1105         COPY_SCALAR_FIELD(paramtypmod);
1106         COPY_SCALAR_FIELD(paramcollid);
1107         COPY_LOCATION_FIELD(location);
1108
1109         return newnode;
1110 }
1111
1112 /*
1113  * _copyAggref
1114  */
1115 static Aggref *
1116 _copyAggref(Aggref *from)
1117 {
1118         Aggref     *newnode = makeNode(Aggref);
1119
1120         COPY_SCALAR_FIELD(aggfnoid);
1121         COPY_SCALAR_FIELD(aggtype);
1122         COPY_SCALAR_FIELD(aggcollid);
1123         COPY_SCALAR_FIELD(inputcollid);
1124         COPY_NODE_FIELD(args);
1125         COPY_NODE_FIELD(aggorder);
1126         COPY_NODE_FIELD(aggdistinct);
1127         COPY_SCALAR_FIELD(aggstar);
1128         COPY_SCALAR_FIELD(agglevelsup);
1129         COPY_LOCATION_FIELD(location);
1130
1131         return newnode;
1132 }
1133
1134 /*
1135  * _copyWindowFunc
1136  */
1137 static WindowFunc *
1138 _copyWindowFunc(WindowFunc *from)
1139 {
1140         WindowFunc *newnode = makeNode(WindowFunc);
1141
1142         COPY_SCALAR_FIELD(winfnoid);
1143         COPY_SCALAR_FIELD(wintype);
1144         COPY_SCALAR_FIELD(wincollid);
1145         COPY_SCALAR_FIELD(inputcollid);
1146         COPY_NODE_FIELD(args);
1147         COPY_SCALAR_FIELD(winref);
1148         COPY_SCALAR_FIELD(winstar);
1149         COPY_SCALAR_FIELD(winagg);
1150         COPY_LOCATION_FIELD(location);
1151
1152         return newnode;
1153 }
1154
1155 /*
1156  * _copyArrayRef
1157  */
1158 static ArrayRef *
1159 _copyArrayRef(ArrayRef *from)
1160 {
1161         ArrayRef   *newnode = makeNode(ArrayRef);
1162
1163         COPY_SCALAR_FIELD(refarraytype);
1164         COPY_SCALAR_FIELD(refelemtype);
1165         COPY_SCALAR_FIELD(reftypmod);
1166         COPY_SCALAR_FIELD(refcollid);
1167         COPY_NODE_FIELD(refupperindexpr);
1168         COPY_NODE_FIELD(reflowerindexpr);
1169         COPY_NODE_FIELD(refexpr);
1170         COPY_NODE_FIELD(refassgnexpr);
1171
1172         return newnode;
1173 }
1174
1175 /*
1176  * _copyFuncExpr
1177  */
1178 static FuncExpr *
1179 _copyFuncExpr(FuncExpr *from)
1180 {
1181         FuncExpr   *newnode = makeNode(FuncExpr);
1182
1183         COPY_SCALAR_FIELD(funcid);
1184         COPY_SCALAR_FIELD(funcresulttype);
1185         COPY_SCALAR_FIELD(funcretset);
1186         COPY_SCALAR_FIELD(funcformat);
1187         COPY_SCALAR_FIELD(funccollid);
1188         COPY_SCALAR_FIELD(inputcollid);
1189         COPY_NODE_FIELD(args);
1190         COPY_LOCATION_FIELD(location);
1191
1192         return newnode;
1193 }
1194
1195 /*
1196  * _copyNamedArgExpr *
1197  */
1198 static NamedArgExpr *
1199 _copyNamedArgExpr(NamedArgExpr *from)
1200 {
1201         NamedArgExpr *newnode = makeNode(NamedArgExpr);
1202
1203         COPY_NODE_FIELD(arg);
1204         COPY_STRING_FIELD(name);
1205         COPY_SCALAR_FIELD(argnumber);
1206         COPY_LOCATION_FIELD(location);
1207
1208         return newnode;
1209 }
1210
1211 /*
1212  * _copyOpExpr
1213  */
1214 static OpExpr *
1215 _copyOpExpr(OpExpr *from)
1216 {
1217         OpExpr     *newnode = makeNode(OpExpr);
1218
1219         COPY_SCALAR_FIELD(opno);
1220         COPY_SCALAR_FIELD(opfuncid);
1221         COPY_SCALAR_FIELD(opresulttype);
1222         COPY_SCALAR_FIELD(opretset);
1223         COPY_SCALAR_FIELD(opcollid);
1224         COPY_SCALAR_FIELD(inputcollid);
1225         COPY_NODE_FIELD(args);
1226         COPY_LOCATION_FIELD(location);
1227
1228         return newnode;
1229 }
1230
1231 /*
1232  * _copyDistinctExpr (same as OpExpr)
1233  */
1234 static DistinctExpr *
1235 _copyDistinctExpr(DistinctExpr *from)
1236 {
1237         DistinctExpr *newnode = makeNode(DistinctExpr);
1238
1239         COPY_SCALAR_FIELD(opno);
1240         COPY_SCALAR_FIELD(opfuncid);
1241         COPY_SCALAR_FIELD(opresulttype);
1242         COPY_SCALAR_FIELD(opretset);
1243         COPY_SCALAR_FIELD(opcollid);
1244         COPY_SCALAR_FIELD(inputcollid);
1245         COPY_NODE_FIELD(args);
1246         COPY_LOCATION_FIELD(location);
1247
1248         return newnode;
1249 }
1250
1251 /*
1252  * _copyNullIfExpr (same as OpExpr)
1253  */
1254 static NullIfExpr *
1255 _copyNullIfExpr(NullIfExpr *from)
1256 {
1257         NullIfExpr *newnode = makeNode(NullIfExpr);
1258
1259         COPY_SCALAR_FIELD(opno);
1260         COPY_SCALAR_FIELD(opfuncid);
1261         COPY_SCALAR_FIELD(opresulttype);
1262         COPY_SCALAR_FIELD(opretset);
1263         COPY_SCALAR_FIELD(opcollid);
1264         COPY_SCALAR_FIELD(inputcollid);
1265         COPY_NODE_FIELD(args);
1266         COPY_LOCATION_FIELD(location);
1267
1268         return newnode;
1269 }
1270
1271 /*
1272  * _copyScalarArrayOpExpr
1273  */
1274 static ScalarArrayOpExpr *
1275 _copyScalarArrayOpExpr(ScalarArrayOpExpr *from)
1276 {
1277         ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
1278
1279         COPY_SCALAR_FIELD(opno);
1280         COPY_SCALAR_FIELD(opfuncid);
1281         COPY_SCALAR_FIELD(useOr);
1282         COPY_SCALAR_FIELD(inputcollid);
1283         COPY_NODE_FIELD(args);
1284         COPY_LOCATION_FIELD(location);
1285
1286         return newnode;
1287 }
1288
1289 /*
1290  * _copyBoolExpr
1291  */
1292 static BoolExpr *
1293 _copyBoolExpr(BoolExpr *from)
1294 {
1295         BoolExpr   *newnode = makeNode(BoolExpr);
1296
1297         COPY_SCALAR_FIELD(boolop);
1298         COPY_NODE_FIELD(args);
1299         COPY_LOCATION_FIELD(location);
1300
1301         return newnode;
1302 }
1303
1304 /*
1305  * _copySubLink
1306  */
1307 static SubLink *
1308 _copySubLink(SubLink *from)
1309 {
1310         SubLink    *newnode = makeNode(SubLink);
1311
1312         COPY_SCALAR_FIELD(subLinkType);
1313         COPY_NODE_FIELD(testexpr);
1314         COPY_NODE_FIELD(operName);
1315         COPY_NODE_FIELD(subselect);
1316         COPY_LOCATION_FIELD(location);
1317
1318         return newnode;
1319 }
1320
1321 /*
1322  * _copySubPlan
1323  */
1324 static SubPlan *
1325 _copySubPlan(SubPlan *from)
1326 {
1327         SubPlan    *newnode = makeNode(SubPlan);
1328
1329         COPY_SCALAR_FIELD(subLinkType);
1330         COPY_NODE_FIELD(testexpr);
1331         COPY_NODE_FIELD(paramIds);
1332         COPY_SCALAR_FIELD(plan_id);
1333         COPY_STRING_FIELD(plan_name);
1334         COPY_SCALAR_FIELD(firstColType);
1335         COPY_SCALAR_FIELD(firstColTypmod);
1336         COPY_SCALAR_FIELD(firstColCollation);
1337         COPY_SCALAR_FIELD(useHashTable);
1338         COPY_SCALAR_FIELD(unknownEqFalse);
1339         COPY_NODE_FIELD(setParam);
1340         COPY_NODE_FIELD(parParam);
1341         COPY_NODE_FIELD(args);
1342         COPY_SCALAR_FIELD(startup_cost);
1343         COPY_SCALAR_FIELD(per_call_cost);
1344
1345         return newnode;
1346 }
1347
1348 /*
1349  * _copyAlternativeSubPlan
1350  */
1351 static AlternativeSubPlan *
1352 _copyAlternativeSubPlan(AlternativeSubPlan *from)
1353 {
1354         AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
1355
1356         COPY_NODE_FIELD(subplans);
1357
1358         return newnode;
1359 }
1360
1361 /*
1362  * _copyFieldSelect
1363  */
1364 static FieldSelect *
1365 _copyFieldSelect(FieldSelect *from)
1366 {
1367         FieldSelect *newnode = makeNode(FieldSelect);
1368
1369         COPY_NODE_FIELD(arg);
1370         COPY_SCALAR_FIELD(fieldnum);
1371         COPY_SCALAR_FIELD(resulttype);
1372         COPY_SCALAR_FIELD(resulttypmod);
1373         COPY_SCALAR_FIELD(resultcollid);
1374
1375         return newnode;
1376 }
1377
1378 /*
1379  * _copyFieldStore
1380  */
1381 static FieldStore *
1382 _copyFieldStore(FieldStore *from)
1383 {
1384         FieldStore *newnode = makeNode(FieldStore);
1385
1386         COPY_NODE_FIELD(arg);
1387         COPY_NODE_FIELD(newvals);
1388         COPY_NODE_FIELD(fieldnums);
1389         COPY_SCALAR_FIELD(resulttype);
1390
1391         return newnode;
1392 }
1393
1394 /*
1395  * _copyRelabelType
1396  */
1397 static RelabelType *
1398 _copyRelabelType(RelabelType *from)
1399 {
1400         RelabelType *newnode = makeNode(RelabelType);
1401
1402         COPY_NODE_FIELD(arg);
1403         COPY_SCALAR_FIELD(resulttype);
1404         COPY_SCALAR_FIELD(resulttypmod);
1405         COPY_SCALAR_FIELD(resultcollid);
1406         COPY_SCALAR_FIELD(relabelformat);
1407         COPY_LOCATION_FIELD(location);
1408
1409         return newnode;
1410 }
1411
1412 /*
1413  * _copyCoerceViaIO
1414  */
1415 static CoerceViaIO *
1416 _copyCoerceViaIO(CoerceViaIO *from)
1417 {
1418         CoerceViaIO *newnode = makeNode(CoerceViaIO);
1419
1420         COPY_NODE_FIELD(arg);
1421         COPY_SCALAR_FIELD(resulttype);
1422         COPY_SCALAR_FIELD(resultcollid);
1423         COPY_SCALAR_FIELD(coerceformat);
1424         COPY_LOCATION_FIELD(location);
1425
1426         return newnode;
1427 }
1428
1429 /*
1430  * _copyArrayCoerceExpr
1431  */
1432 static ArrayCoerceExpr *
1433 _copyArrayCoerceExpr(ArrayCoerceExpr *from)
1434 {
1435         ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
1436
1437         COPY_NODE_FIELD(arg);
1438         COPY_SCALAR_FIELD(elemfuncid);
1439         COPY_SCALAR_FIELD(resulttype);
1440         COPY_SCALAR_FIELD(resulttypmod);
1441         COPY_SCALAR_FIELD(resultcollid);
1442         COPY_SCALAR_FIELD(isExplicit);
1443         COPY_SCALAR_FIELD(coerceformat);
1444         COPY_LOCATION_FIELD(location);
1445
1446         return newnode;
1447 }
1448
1449 /*
1450  * _copyConvertRowtypeExpr
1451  */
1452 static ConvertRowtypeExpr *
1453 _copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
1454 {
1455         ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
1456
1457         COPY_NODE_FIELD(arg);
1458         COPY_SCALAR_FIELD(resulttype);
1459         COPY_SCALAR_FIELD(convertformat);
1460         COPY_LOCATION_FIELD(location);
1461
1462         return newnode;
1463 }
1464
1465 /*
1466  * _copyCollateExpr
1467  */
1468 static CollateExpr *
1469 _copyCollateExpr(CollateExpr *from)
1470 {
1471         CollateExpr *newnode = makeNode(CollateExpr);
1472
1473         COPY_NODE_FIELD(arg);
1474         COPY_SCALAR_FIELD(collOid);
1475         COPY_LOCATION_FIELD(location);
1476
1477         return newnode;
1478 }
1479
1480 /*
1481  * _copyCaseExpr
1482  */
1483 static CaseExpr *
1484 _copyCaseExpr(CaseExpr *from)
1485 {
1486         CaseExpr   *newnode = makeNode(CaseExpr);
1487
1488         COPY_SCALAR_FIELD(casetype);
1489         COPY_SCALAR_FIELD(casecollid);
1490         COPY_NODE_FIELD(arg);
1491         COPY_NODE_FIELD(args);
1492         COPY_NODE_FIELD(defresult);
1493         COPY_LOCATION_FIELD(location);
1494
1495         return newnode;
1496 }
1497
1498 /*
1499  * _copyCaseWhen
1500  */
1501 static CaseWhen *
1502 _copyCaseWhen(CaseWhen *from)
1503 {
1504         CaseWhen   *newnode = makeNode(CaseWhen);
1505
1506         COPY_NODE_FIELD(expr);
1507         COPY_NODE_FIELD(result);
1508         COPY_LOCATION_FIELD(location);
1509
1510         return newnode;
1511 }
1512
1513 /*
1514  * _copyCaseTestExpr
1515  */
1516 static CaseTestExpr *
1517 _copyCaseTestExpr(CaseTestExpr *from)
1518 {
1519         CaseTestExpr *newnode = makeNode(CaseTestExpr);
1520
1521         COPY_SCALAR_FIELD(typeId);
1522         COPY_SCALAR_FIELD(typeMod);
1523         COPY_SCALAR_FIELD(collation);
1524
1525         return newnode;
1526 }
1527
1528 /*
1529  * _copyArrayExpr
1530  */
1531 static ArrayExpr *
1532 _copyArrayExpr(ArrayExpr *from)
1533 {
1534         ArrayExpr  *newnode = makeNode(ArrayExpr);
1535
1536         COPY_SCALAR_FIELD(array_typeid);
1537         COPY_SCALAR_FIELD(array_collid);
1538         COPY_SCALAR_FIELD(element_typeid);
1539         COPY_NODE_FIELD(elements);
1540         COPY_SCALAR_FIELD(multidims);
1541         COPY_LOCATION_FIELD(location);
1542
1543         return newnode;
1544 }
1545
1546 /*
1547  * _copyRowExpr
1548  */
1549 static RowExpr *
1550 _copyRowExpr(RowExpr *from)
1551 {
1552         RowExpr    *newnode = makeNode(RowExpr);
1553
1554         COPY_NODE_FIELD(args);
1555         COPY_SCALAR_FIELD(row_typeid);
1556         COPY_SCALAR_FIELD(row_format);
1557         COPY_NODE_FIELD(colnames);
1558         COPY_LOCATION_FIELD(location);
1559
1560         return newnode;
1561 }
1562
1563 /*
1564  * _copyRowCompareExpr
1565  */
1566 static RowCompareExpr *
1567 _copyRowCompareExpr(RowCompareExpr *from)
1568 {
1569         RowCompareExpr *newnode = makeNode(RowCompareExpr);
1570
1571         COPY_SCALAR_FIELD(rctype);
1572         COPY_NODE_FIELD(opnos);
1573         COPY_NODE_FIELD(opfamilies);
1574         COPY_NODE_FIELD(inputcollids);
1575         COPY_NODE_FIELD(largs);
1576         COPY_NODE_FIELD(rargs);
1577
1578         return newnode;
1579 }
1580
1581 /*
1582  * _copyCoalesceExpr
1583  */
1584 static CoalesceExpr *
1585 _copyCoalesceExpr(CoalesceExpr *from)
1586 {
1587         CoalesceExpr *newnode = makeNode(CoalesceExpr);
1588
1589         COPY_SCALAR_FIELD(coalescetype);
1590         COPY_SCALAR_FIELD(coalescecollid);
1591         COPY_NODE_FIELD(args);
1592         COPY_LOCATION_FIELD(location);
1593
1594         return newnode;
1595 }
1596
1597 /*
1598  * _copyMinMaxExpr
1599  */
1600 static MinMaxExpr *
1601 _copyMinMaxExpr(MinMaxExpr *from)
1602 {
1603         MinMaxExpr *newnode = makeNode(MinMaxExpr);
1604
1605         COPY_SCALAR_FIELD(minmaxtype);
1606         COPY_SCALAR_FIELD(minmaxcollid);
1607         COPY_SCALAR_FIELD(inputcollid);
1608         COPY_SCALAR_FIELD(op);
1609         COPY_NODE_FIELD(args);
1610         COPY_LOCATION_FIELD(location);
1611
1612         return newnode;
1613 }
1614
1615 /*
1616  * _copyXmlExpr
1617  */
1618 static XmlExpr *
1619 _copyXmlExpr(XmlExpr *from)
1620 {
1621         XmlExpr    *newnode = makeNode(XmlExpr);
1622
1623         COPY_SCALAR_FIELD(op);
1624         COPY_STRING_FIELD(name);
1625         COPY_NODE_FIELD(named_args);
1626         COPY_NODE_FIELD(arg_names);
1627         COPY_NODE_FIELD(args);
1628         COPY_SCALAR_FIELD(xmloption);
1629         COPY_SCALAR_FIELD(type);
1630         COPY_SCALAR_FIELD(typmod);
1631         COPY_LOCATION_FIELD(location);
1632
1633         return newnode;
1634 }
1635
1636 /*
1637  * _copyNullTest
1638  */
1639 static NullTest *
1640 _copyNullTest(NullTest *from)
1641 {
1642         NullTest   *newnode = makeNode(NullTest);
1643
1644         COPY_NODE_FIELD(arg);
1645         COPY_SCALAR_FIELD(nulltesttype);
1646         COPY_SCALAR_FIELD(argisrow);
1647
1648         return newnode;
1649 }
1650
1651 /*
1652  * _copyBooleanTest
1653  */
1654 static BooleanTest *
1655 _copyBooleanTest(BooleanTest *from)
1656 {
1657         BooleanTest *newnode = makeNode(BooleanTest);
1658
1659         COPY_NODE_FIELD(arg);
1660         COPY_SCALAR_FIELD(booltesttype);
1661
1662         return newnode;
1663 }
1664
1665 /*
1666  * _copyCoerceToDomain
1667  */
1668 static CoerceToDomain *
1669 _copyCoerceToDomain(CoerceToDomain *from)
1670 {
1671         CoerceToDomain *newnode = makeNode(CoerceToDomain);
1672
1673         COPY_NODE_FIELD(arg);
1674         COPY_SCALAR_FIELD(resulttype);
1675         COPY_SCALAR_FIELD(resulttypmod);
1676         COPY_SCALAR_FIELD(resultcollid);
1677         COPY_SCALAR_FIELD(coercionformat);
1678         COPY_LOCATION_FIELD(location);
1679
1680         return newnode;
1681 }
1682
1683 /*
1684  * _copyCoerceToDomainValue
1685  */
1686 static CoerceToDomainValue *
1687 _copyCoerceToDomainValue(CoerceToDomainValue *from)
1688 {
1689         CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
1690
1691         COPY_SCALAR_FIELD(typeId);
1692         COPY_SCALAR_FIELD(typeMod);
1693         COPY_SCALAR_FIELD(collation);
1694         COPY_LOCATION_FIELD(location);
1695
1696         return newnode;
1697 }
1698
1699 /*
1700  * _copySetToDefault
1701  */
1702 static SetToDefault *
1703 _copySetToDefault(SetToDefault *from)
1704 {
1705         SetToDefault *newnode = makeNode(SetToDefault);
1706
1707         COPY_SCALAR_FIELD(typeId);
1708         COPY_SCALAR_FIELD(typeMod);
1709         COPY_SCALAR_FIELD(collation);
1710         COPY_LOCATION_FIELD(location);
1711
1712         return newnode;
1713 }
1714
1715 /*
1716  * _copyCurrentOfExpr
1717  */
1718 static CurrentOfExpr *
1719 _copyCurrentOfExpr(CurrentOfExpr *from)
1720 {
1721         CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1722
1723         COPY_SCALAR_FIELD(cvarno);
1724         COPY_STRING_FIELD(cursor_name);
1725         COPY_SCALAR_FIELD(cursor_param);
1726
1727         return newnode;
1728 }
1729
1730 /*
1731  * _copyTargetEntry
1732  */
1733 static TargetEntry *
1734 _copyTargetEntry(TargetEntry *from)
1735 {
1736         TargetEntry *newnode = makeNode(TargetEntry);
1737
1738         COPY_NODE_FIELD(expr);
1739         COPY_SCALAR_FIELD(resno);
1740         COPY_STRING_FIELD(resname);
1741         COPY_SCALAR_FIELD(ressortgroupref);
1742         COPY_SCALAR_FIELD(resorigtbl);
1743         COPY_SCALAR_FIELD(resorigcol);
1744         COPY_SCALAR_FIELD(resjunk);
1745
1746         return newnode;
1747 }
1748
1749 /*
1750  * _copyRangeTblRef
1751  */
1752 static RangeTblRef *
1753 _copyRangeTblRef(RangeTblRef *from)
1754 {
1755         RangeTblRef *newnode = makeNode(RangeTblRef);
1756
1757         COPY_SCALAR_FIELD(rtindex);
1758
1759         return newnode;
1760 }
1761
1762 /*
1763  * _copyJoinExpr
1764  */
1765 static JoinExpr *
1766 _copyJoinExpr(JoinExpr *from)
1767 {
1768         JoinExpr   *newnode = makeNode(JoinExpr);
1769
1770         COPY_SCALAR_FIELD(jointype);
1771         COPY_SCALAR_FIELD(isNatural);
1772         COPY_NODE_FIELD(larg);
1773         COPY_NODE_FIELD(rarg);
1774         COPY_NODE_FIELD(usingClause);
1775         COPY_NODE_FIELD(quals);
1776         COPY_NODE_FIELD(alias);
1777         COPY_SCALAR_FIELD(rtindex);
1778
1779         return newnode;
1780 }
1781
1782 /*
1783  * _copyFromExpr
1784  */
1785 static FromExpr *
1786 _copyFromExpr(FromExpr *from)
1787 {
1788         FromExpr   *newnode = makeNode(FromExpr);
1789
1790         COPY_NODE_FIELD(fromlist);
1791         COPY_NODE_FIELD(quals);
1792
1793         return newnode;
1794 }
1795
1796 /* ****************************************************************
1797  *                                              relation.h copy functions
1798  *
1799  * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
1800  * There are some subsidiary structs that are useful to copy, though.
1801  * ****************************************************************
1802  */
1803
1804 /*
1805  * _copyPathKey
1806  */
1807 static PathKey *
1808 _copyPathKey(PathKey *from)
1809 {
1810         PathKey    *newnode = makeNode(PathKey);
1811
1812         /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
1813         COPY_SCALAR_FIELD(pk_eclass);
1814         COPY_SCALAR_FIELD(pk_opfamily);
1815         COPY_SCALAR_FIELD(pk_strategy);
1816         COPY_SCALAR_FIELD(pk_nulls_first);
1817
1818         return newnode;
1819 }
1820
1821 /*
1822  * _copyRestrictInfo
1823  */
1824 static RestrictInfo *
1825 _copyRestrictInfo(RestrictInfo *from)
1826 {
1827         RestrictInfo *newnode = makeNode(RestrictInfo);
1828
1829         COPY_NODE_FIELD(clause);
1830         COPY_SCALAR_FIELD(is_pushed_down);
1831         COPY_SCALAR_FIELD(outerjoin_delayed);
1832         COPY_SCALAR_FIELD(can_join);
1833         COPY_SCALAR_FIELD(pseudoconstant);
1834         COPY_BITMAPSET_FIELD(clause_relids);
1835         COPY_BITMAPSET_FIELD(required_relids);
1836         COPY_BITMAPSET_FIELD(nullable_relids);
1837         COPY_BITMAPSET_FIELD(left_relids);
1838         COPY_BITMAPSET_FIELD(right_relids);
1839         COPY_NODE_FIELD(orclause);
1840         /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1841         COPY_SCALAR_FIELD(parent_ec);
1842         COPY_SCALAR_FIELD(eval_cost);
1843         COPY_SCALAR_FIELD(norm_selec);
1844         COPY_SCALAR_FIELD(outer_selec);
1845         COPY_NODE_FIELD(mergeopfamilies);
1846         /* EquivalenceClasses are never copied, so shallow-copy the pointers */
1847         COPY_SCALAR_FIELD(left_ec);
1848         COPY_SCALAR_FIELD(right_ec);
1849         COPY_SCALAR_FIELD(left_em);
1850         COPY_SCALAR_FIELD(right_em);
1851         /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
1852         newnode->scansel_cache = NIL;
1853         COPY_SCALAR_FIELD(outer_is_left);
1854         COPY_SCALAR_FIELD(hashjoinoperator);
1855         COPY_SCALAR_FIELD(left_bucketsize);
1856         COPY_SCALAR_FIELD(right_bucketsize);
1857
1858         return newnode;
1859 }
1860
1861 /*
1862  * _copyPlaceHolderVar
1863  */
1864 static PlaceHolderVar *
1865 _copyPlaceHolderVar(PlaceHolderVar *from)
1866 {
1867         PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
1868
1869         COPY_NODE_FIELD(phexpr);
1870         COPY_BITMAPSET_FIELD(phrels);
1871         COPY_SCALAR_FIELD(phid);
1872         COPY_SCALAR_FIELD(phlevelsup);
1873
1874         return newnode;
1875 }
1876
1877 /*
1878  * _copySpecialJoinInfo
1879  */
1880 static SpecialJoinInfo *
1881 _copySpecialJoinInfo(SpecialJoinInfo *from)
1882 {
1883         SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
1884
1885         COPY_BITMAPSET_FIELD(min_lefthand);
1886         COPY_BITMAPSET_FIELD(min_righthand);
1887         COPY_BITMAPSET_FIELD(syn_lefthand);
1888         COPY_BITMAPSET_FIELD(syn_righthand);
1889         COPY_SCALAR_FIELD(jointype);
1890         COPY_SCALAR_FIELD(lhs_strict);
1891         COPY_SCALAR_FIELD(delay_upper_joins);
1892         COPY_NODE_FIELD(join_quals);
1893
1894         return newnode;
1895 }
1896
1897 /*
1898  * _copyAppendRelInfo
1899  */
1900 static AppendRelInfo *
1901 _copyAppendRelInfo(AppendRelInfo *from)
1902 {
1903         AppendRelInfo *newnode = makeNode(AppendRelInfo);
1904
1905         COPY_SCALAR_FIELD(parent_relid);
1906         COPY_SCALAR_FIELD(child_relid);
1907         COPY_SCALAR_FIELD(parent_reltype);
1908         COPY_SCALAR_FIELD(child_reltype);
1909         COPY_NODE_FIELD(translated_vars);
1910         COPY_SCALAR_FIELD(parent_reloid);
1911
1912         return newnode;
1913 }
1914
1915 /*
1916  * _copyPlaceHolderInfo
1917  */
1918 static PlaceHolderInfo *
1919 _copyPlaceHolderInfo(PlaceHolderInfo *from)
1920 {
1921         PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
1922
1923         COPY_SCALAR_FIELD(phid);
1924         COPY_NODE_FIELD(ph_var);
1925         COPY_BITMAPSET_FIELD(ph_eval_at);
1926         COPY_BITMAPSET_FIELD(ph_needed);
1927         COPY_BITMAPSET_FIELD(ph_may_need);
1928         COPY_SCALAR_FIELD(ph_width);
1929
1930         return newnode;
1931 }
1932
1933 /* ****************************************************************
1934  *                                      parsenodes.h copy functions
1935  * ****************************************************************
1936  */
1937
1938 static RangeTblEntry *
1939 _copyRangeTblEntry(RangeTblEntry *from)
1940 {
1941         RangeTblEntry *newnode = makeNode(RangeTblEntry);
1942
1943         COPY_SCALAR_FIELD(rtekind);
1944         COPY_SCALAR_FIELD(relid);
1945         COPY_SCALAR_FIELD(relkind);
1946         COPY_NODE_FIELD(subquery);
1947         COPY_SCALAR_FIELD(jointype);
1948         COPY_NODE_FIELD(joinaliasvars);
1949         COPY_NODE_FIELD(funcexpr);
1950         COPY_NODE_FIELD(funccoltypes);
1951         COPY_NODE_FIELD(funccoltypmods);
1952         COPY_NODE_FIELD(funccolcollations);
1953         COPY_NODE_FIELD(values_lists);
1954         COPY_NODE_FIELD(values_collations);
1955         COPY_STRING_FIELD(ctename);
1956         COPY_SCALAR_FIELD(ctelevelsup);
1957         COPY_SCALAR_FIELD(self_reference);
1958         COPY_NODE_FIELD(ctecoltypes);
1959         COPY_NODE_FIELD(ctecoltypmods);
1960         COPY_NODE_FIELD(ctecolcollations);
1961         COPY_NODE_FIELD(alias);
1962         COPY_NODE_FIELD(eref);
1963         COPY_SCALAR_FIELD(inh);
1964         COPY_SCALAR_FIELD(inFromCl);
1965         COPY_SCALAR_FIELD(requiredPerms);
1966         COPY_SCALAR_FIELD(checkAsUser);
1967         COPY_BITMAPSET_FIELD(selectedCols);
1968         COPY_BITMAPSET_FIELD(modifiedCols);
1969
1970         return newnode;
1971 }
1972
1973 static SortGroupClause *
1974 _copySortGroupClause(SortGroupClause *from)
1975 {
1976         SortGroupClause *newnode = makeNode(SortGroupClause);
1977
1978         COPY_SCALAR_FIELD(tleSortGroupRef);
1979         COPY_SCALAR_FIELD(eqop);
1980         COPY_SCALAR_FIELD(sortop);
1981         COPY_SCALAR_FIELD(nulls_first);
1982         COPY_SCALAR_FIELD(hashable);
1983
1984         return newnode;
1985 }
1986
1987 static WindowClause *
1988 _copyWindowClause(WindowClause *from)
1989 {
1990         WindowClause *newnode = makeNode(WindowClause);
1991
1992         COPY_STRING_FIELD(name);
1993         COPY_STRING_FIELD(refname);
1994         COPY_NODE_FIELD(partitionClause);
1995         COPY_NODE_FIELD(orderClause);
1996         COPY_SCALAR_FIELD(frameOptions);
1997         COPY_NODE_FIELD(startOffset);
1998         COPY_NODE_FIELD(endOffset);
1999         COPY_SCALAR_FIELD(winref);
2000         COPY_SCALAR_FIELD(copiedOrder);
2001
2002         return newnode;
2003 }
2004
2005 static RowMarkClause *
2006 _copyRowMarkClause(RowMarkClause *from)
2007 {
2008         RowMarkClause *newnode = makeNode(RowMarkClause);
2009
2010         COPY_SCALAR_FIELD(rti);
2011         COPY_SCALAR_FIELD(forUpdate);
2012         COPY_SCALAR_FIELD(noWait);
2013         COPY_SCALAR_FIELD(pushedDown);
2014
2015         return newnode;
2016 }
2017
2018 static WithClause *
2019 _copyWithClause(WithClause *from)
2020 {
2021         WithClause *newnode = makeNode(WithClause);
2022
2023         COPY_NODE_FIELD(ctes);
2024         COPY_SCALAR_FIELD(recursive);
2025         COPY_LOCATION_FIELD(location);
2026
2027         return newnode;
2028 }
2029
2030 static CommonTableExpr *
2031 _copyCommonTableExpr(CommonTableExpr *from)
2032 {
2033         CommonTableExpr *newnode = makeNode(CommonTableExpr);
2034
2035         COPY_STRING_FIELD(ctename);
2036         COPY_NODE_FIELD(aliascolnames);
2037         COPY_NODE_FIELD(ctequery);
2038         COPY_LOCATION_FIELD(location);
2039         COPY_SCALAR_FIELD(cterecursive);
2040         COPY_SCALAR_FIELD(cterefcount);
2041         COPY_NODE_FIELD(ctecolnames);
2042         COPY_NODE_FIELD(ctecoltypes);
2043         COPY_NODE_FIELD(ctecoltypmods);
2044         COPY_NODE_FIELD(ctecolcollations);
2045
2046         return newnode;
2047 }
2048
2049 static A_Expr *
2050 _copyAExpr(A_Expr *from)
2051 {
2052         A_Expr     *newnode = makeNode(A_Expr);
2053
2054         COPY_SCALAR_FIELD(kind);
2055         COPY_NODE_FIELD(name);
2056         COPY_NODE_FIELD(lexpr);
2057         COPY_NODE_FIELD(rexpr);
2058         COPY_LOCATION_FIELD(location);
2059
2060         return newnode;
2061 }
2062
2063 static ColumnRef *
2064 _copyColumnRef(ColumnRef *from)
2065 {
2066         ColumnRef  *newnode = makeNode(ColumnRef);
2067
2068         COPY_NODE_FIELD(fields);
2069         COPY_LOCATION_FIELD(location);
2070
2071         return newnode;
2072 }
2073
2074 static ParamRef *
2075 _copyParamRef(ParamRef *from)
2076 {
2077         ParamRef   *newnode = makeNode(ParamRef);
2078
2079         COPY_SCALAR_FIELD(number);
2080         COPY_LOCATION_FIELD(location);
2081
2082         return newnode;
2083 }
2084
2085 static A_Const *
2086 _copyAConst(A_Const *from)
2087 {
2088         A_Const    *newnode = makeNode(A_Const);
2089
2090         /* This part must duplicate _copyValue */
2091         COPY_SCALAR_FIELD(val.type);
2092         switch (from->val.type)
2093         {
2094                 case T_Integer:
2095                         COPY_SCALAR_FIELD(val.val.ival);
2096                         break;
2097                 case T_Float:
2098                 case T_String:
2099                 case T_BitString:
2100                         COPY_STRING_FIELD(val.val.str);
2101                         break;
2102                 case T_Null:
2103                         /* nothing to do */
2104                         break;
2105                 default:
2106                         elog(ERROR, "unrecognized node type: %d",
2107                                  (int) from->val.type);
2108                         break;
2109         }
2110
2111         COPY_LOCATION_FIELD(location);
2112
2113         return newnode;
2114 }
2115
2116 static FuncCall *
2117 _copyFuncCall(FuncCall *from)
2118 {
2119         FuncCall   *newnode = makeNode(FuncCall);
2120
2121         COPY_NODE_FIELD(funcname);
2122         COPY_NODE_FIELD(args);
2123         COPY_NODE_FIELD(agg_order);
2124         COPY_SCALAR_FIELD(agg_star);
2125         COPY_SCALAR_FIELD(agg_distinct);
2126         COPY_SCALAR_FIELD(func_variadic);
2127         COPY_NODE_FIELD(over);
2128         COPY_LOCATION_FIELD(location);
2129
2130         return newnode;
2131 }
2132
2133 static A_Star *
2134 _copyAStar(A_Star *from)
2135 {
2136         A_Star     *newnode = makeNode(A_Star);
2137
2138         return newnode;
2139 }
2140
2141 static A_Indices *
2142 _copyAIndices(A_Indices *from)
2143 {
2144         A_Indices  *newnode = makeNode(A_Indices);
2145
2146         COPY_NODE_FIELD(lidx);
2147         COPY_NODE_FIELD(uidx);
2148
2149         return newnode;
2150 }
2151
2152 static A_Indirection *
2153 _copyA_Indirection(A_Indirection *from)
2154 {
2155         A_Indirection *newnode = makeNode(A_Indirection);
2156
2157         COPY_NODE_FIELD(arg);
2158         COPY_NODE_FIELD(indirection);
2159
2160         return newnode;
2161 }
2162
2163 static A_ArrayExpr *
2164 _copyA_ArrayExpr(A_ArrayExpr *from)
2165 {
2166         A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2167
2168         COPY_NODE_FIELD(elements);
2169         COPY_LOCATION_FIELD(location);
2170
2171         return newnode;
2172 }
2173
2174 static ResTarget *
2175 _copyResTarget(ResTarget *from)
2176 {
2177         ResTarget  *newnode = makeNode(ResTarget);
2178
2179         COPY_STRING_FIELD(name);
2180         COPY_NODE_FIELD(indirection);
2181         COPY_NODE_FIELD(val);
2182         COPY_LOCATION_FIELD(location);
2183
2184         return newnode;
2185 }
2186
2187 static TypeName *
2188 _copyTypeName(TypeName *from)
2189 {
2190         TypeName   *newnode = makeNode(TypeName);
2191
2192         COPY_NODE_FIELD(names);
2193         COPY_SCALAR_FIELD(typeOid);
2194         COPY_SCALAR_FIELD(setof);
2195         COPY_SCALAR_FIELD(pct_type);
2196         COPY_NODE_FIELD(typmods);
2197         COPY_SCALAR_FIELD(typemod);
2198         COPY_NODE_FIELD(arrayBounds);
2199         COPY_LOCATION_FIELD(location);
2200
2201         return newnode;
2202 }
2203
2204 static SortBy *
2205 _copySortBy(SortBy *from)
2206 {
2207         SortBy     *newnode = makeNode(SortBy);
2208
2209         COPY_NODE_FIELD(node);
2210         COPY_SCALAR_FIELD(sortby_dir);
2211         COPY_SCALAR_FIELD(sortby_nulls);
2212         COPY_NODE_FIELD(useOp);
2213         COPY_LOCATION_FIELD(location);
2214
2215         return newnode;
2216 }
2217
2218 static WindowDef *
2219 _copyWindowDef(WindowDef *from)
2220 {
2221         WindowDef  *newnode = makeNode(WindowDef);
2222
2223         COPY_STRING_FIELD(name);
2224         COPY_STRING_FIELD(refname);
2225         COPY_NODE_FIELD(partitionClause);
2226         COPY_NODE_FIELD(orderClause);
2227         COPY_SCALAR_FIELD(frameOptions);
2228         COPY_NODE_FIELD(startOffset);
2229         COPY_NODE_FIELD(endOffset);
2230         COPY_LOCATION_FIELD(location);
2231
2232         return newnode;
2233 }
2234
2235 static RangeSubselect *
2236 _copyRangeSubselect(RangeSubselect *from)
2237 {
2238         RangeSubselect *newnode = makeNode(RangeSubselect);
2239
2240         COPY_NODE_FIELD(subquery);
2241         COPY_NODE_FIELD(alias);
2242
2243         return newnode;
2244 }
2245
2246 static RangeFunction *
2247 _copyRangeFunction(RangeFunction *from)
2248 {
2249         RangeFunction *newnode = makeNode(RangeFunction);
2250
2251         COPY_NODE_FIELD(funccallnode);
2252         COPY_NODE_FIELD(alias);
2253         COPY_NODE_FIELD(coldeflist);
2254
2255         return newnode;
2256 }
2257
2258 static TypeCast *
2259 _copyTypeCast(TypeCast *from)
2260 {
2261         TypeCast   *newnode = makeNode(TypeCast);
2262
2263         COPY_NODE_FIELD(arg);
2264         COPY_NODE_FIELD(typeName);
2265         COPY_LOCATION_FIELD(location);
2266
2267         return newnode;
2268 }
2269
2270 static CollateClause *
2271 _copyCollateClause(CollateClause *from)
2272 {
2273         CollateClause *newnode = makeNode(CollateClause);
2274
2275         COPY_NODE_FIELD(arg);
2276         COPY_NODE_FIELD(collname);
2277         COPY_LOCATION_FIELD(location);
2278
2279         return newnode;
2280 }
2281
2282 static IndexElem *
2283 _copyIndexElem(IndexElem *from)
2284 {
2285         IndexElem  *newnode = makeNode(IndexElem);
2286
2287         COPY_STRING_FIELD(name);
2288         COPY_NODE_FIELD(expr);
2289         COPY_STRING_FIELD(indexcolname);
2290         COPY_NODE_FIELD(collation);
2291         COPY_NODE_FIELD(opclass);
2292         COPY_SCALAR_FIELD(ordering);
2293         COPY_SCALAR_FIELD(nulls_ordering);
2294
2295         return newnode;
2296 }
2297
2298 static ColumnDef *
2299 _copyColumnDef(ColumnDef *from)
2300 {
2301         ColumnDef  *newnode = makeNode(ColumnDef);
2302
2303         COPY_STRING_FIELD(colname);
2304         COPY_NODE_FIELD(typeName);
2305         COPY_SCALAR_FIELD(inhcount);
2306         COPY_SCALAR_FIELD(is_local);
2307         COPY_SCALAR_FIELD(is_not_null);
2308         COPY_SCALAR_FIELD(is_from_type);
2309         COPY_SCALAR_FIELD(storage);
2310         COPY_NODE_FIELD(raw_default);
2311         COPY_NODE_FIELD(cooked_default);
2312         COPY_NODE_FIELD(collClause);
2313         COPY_SCALAR_FIELD(collOid);
2314         COPY_NODE_FIELD(constraints);
2315
2316         return newnode;
2317 }
2318
2319 static Constraint *
2320 _copyConstraint(Constraint *from)
2321 {
2322         Constraint *newnode = makeNode(Constraint);
2323
2324         COPY_SCALAR_FIELD(contype);
2325         COPY_STRING_FIELD(conname);
2326         COPY_SCALAR_FIELD(deferrable);
2327         COPY_SCALAR_FIELD(initdeferred);
2328         COPY_LOCATION_FIELD(location);
2329         COPY_NODE_FIELD(raw_expr);
2330         COPY_STRING_FIELD(cooked_expr);
2331         COPY_NODE_FIELD(keys);
2332         COPY_NODE_FIELD(exclusions);
2333         COPY_NODE_FIELD(options);
2334         COPY_STRING_FIELD(indexname);
2335         COPY_STRING_FIELD(indexspace);
2336         COPY_STRING_FIELD(access_method);
2337         COPY_NODE_FIELD(where_clause);
2338         COPY_NODE_FIELD(pktable);
2339         COPY_NODE_FIELD(fk_attrs);
2340         COPY_NODE_FIELD(pk_attrs);
2341         COPY_SCALAR_FIELD(fk_matchtype);
2342         COPY_SCALAR_FIELD(fk_upd_action);
2343         COPY_SCALAR_FIELD(fk_del_action);
2344         COPY_SCALAR_FIELD(skip_validation);
2345         COPY_SCALAR_FIELD(initially_valid);
2346
2347         return newnode;
2348 }
2349
2350 static DefElem *
2351 _copyDefElem(DefElem *from)
2352 {
2353         DefElem    *newnode = makeNode(DefElem);
2354
2355         COPY_STRING_FIELD(defnamespace);
2356         COPY_STRING_FIELD(defname);
2357         COPY_NODE_FIELD(arg);
2358         COPY_SCALAR_FIELD(defaction);
2359
2360         return newnode;
2361 }
2362
2363 static LockingClause *
2364 _copyLockingClause(LockingClause *from)
2365 {
2366         LockingClause *newnode = makeNode(LockingClause);
2367
2368         COPY_NODE_FIELD(lockedRels);
2369         COPY_SCALAR_FIELD(forUpdate);
2370         COPY_SCALAR_FIELD(noWait);
2371
2372         return newnode;
2373 }
2374
2375 static XmlSerialize *
2376 _copyXmlSerialize(XmlSerialize *from)
2377 {
2378         XmlSerialize *newnode = makeNode(XmlSerialize);
2379
2380         COPY_SCALAR_FIELD(xmloption);
2381         COPY_NODE_FIELD(expr);
2382         COPY_NODE_FIELD(typeName);
2383         COPY_LOCATION_FIELD(location);
2384
2385         return newnode;
2386 }
2387
2388 static Query *
2389 _copyQuery(Query *from)
2390 {
2391         Query      *newnode = makeNode(Query);
2392
2393         COPY_SCALAR_FIELD(commandType);
2394         COPY_SCALAR_FIELD(querySource);
2395         COPY_SCALAR_FIELD(canSetTag);
2396         COPY_NODE_FIELD(utilityStmt);
2397         COPY_SCALAR_FIELD(resultRelation);
2398         COPY_NODE_FIELD(intoClause);
2399         COPY_SCALAR_FIELD(hasAggs);
2400         COPY_SCALAR_FIELD(hasWindowFuncs);
2401         COPY_SCALAR_FIELD(hasSubLinks);
2402         COPY_SCALAR_FIELD(hasDistinctOn);
2403         COPY_SCALAR_FIELD(hasRecursive);
2404         COPY_SCALAR_FIELD(hasModifyingCTE);
2405         COPY_SCALAR_FIELD(hasForUpdate);
2406         COPY_NODE_FIELD(cteList);
2407         COPY_NODE_FIELD(rtable);
2408         COPY_NODE_FIELD(jointree);
2409         COPY_NODE_FIELD(targetList);
2410         COPY_NODE_FIELD(returningList);
2411         COPY_NODE_FIELD(groupClause);
2412         COPY_NODE_FIELD(havingQual);
2413         COPY_NODE_FIELD(windowClause);
2414         COPY_NODE_FIELD(distinctClause);
2415         COPY_NODE_FIELD(sortClause);
2416         COPY_NODE_FIELD(limitOffset);
2417         COPY_NODE_FIELD(limitCount);
2418         COPY_NODE_FIELD(rowMarks);
2419         COPY_NODE_FIELD(setOperations);
2420         COPY_NODE_FIELD(constraintDeps);
2421
2422         return newnode;
2423 }
2424
2425 static InsertStmt *
2426 _copyInsertStmt(InsertStmt *from)
2427 {
2428         InsertStmt *newnode = makeNode(InsertStmt);
2429
2430         COPY_NODE_FIELD(relation);
2431         COPY_NODE_FIELD(cols);
2432         COPY_NODE_FIELD(selectStmt);
2433         COPY_NODE_FIELD(returningList);
2434         COPY_NODE_FIELD(withClause);
2435
2436         return newnode;
2437 }
2438
2439 static DeleteStmt *
2440 _copyDeleteStmt(DeleteStmt *from)
2441 {
2442         DeleteStmt *newnode = makeNode(DeleteStmt);
2443
2444         COPY_NODE_FIELD(relation);
2445         COPY_NODE_FIELD(usingClause);
2446         COPY_NODE_FIELD(whereClause);
2447         COPY_NODE_FIELD(returningList);
2448         COPY_NODE_FIELD(withClause);
2449
2450         return newnode;
2451 }
2452
2453 static UpdateStmt *
2454 _copyUpdateStmt(UpdateStmt *from)
2455 {
2456         UpdateStmt *newnode = makeNode(UpdateStmt);
2457
2458         COPY_NODE_FIELD(relation);
2459         COPY_NODE_FIELD(targetList);
2460         COPY_NODE_FIELD(whereClause);
2461         COPY_NODE_FIELD(fromClause);
2462         COPY_NODE_FIELD(returningList);
2463         COPY_NODE_FIELD(withClause);
2464
2465         return newnode;
2466 }
2467
2468 static SelectStmt *
2469 _copySelectStmt(SelectStmt *from)
2470 {
2471         SelectStmt *newnode = makeNode(SelectStmt);
2472
2473         COPY_NODE_FIELD(distinctClause);
2474         COPY_NODE_FIELD(intoClause);
2475         COPY_NODE_FIELD(targetList);
2476         COPY_NODE_FIELD(fromClause);
2477         COPY_NODE_FIELD(whereClause);
2478         COPY_NODE_FIELD(groupClause);
2479         COPY_NODE_FIELD(havingClause);
2480         COPY_NODE_FIELD(windowClause);
2481         COPY_NODE_FIELD(withClause);
2482         COPY_NODE_FIELD(valuesLists);
2483         COPY_NODE_FIELD(sortClause);
2484         COPY_NODE_FIELD(limitOffset);
2485         COPY_NODE_FIELD(limitCount);
2486         COPY_NODE_FIELD(lockingClause);
2487         COPY_SCALAR_FIELD(op);
2488         COPY_SCALAR_FIELD(all);
2489         COPY_NODE_FIELD(larg);
2490         COPY_NODE_FIELD(rarg);
2491
2492         return newnode;
2493 }
2494
2495 static SetOperationStmt *
2496 _copySetOperationStmt(SetOperationStmt *from)
2497 {
2498         SetOperationStmt *newnode = makeNode(SetOperationStmt);
2499
2500         COPY_SCALAR_FIELD(op);
2501         COPY_SCALAR_FIELD(all);
2502         COPY_NODE_FIELD(larg);
2503         COPY_NODE_FIELD(rarg);
2504         COPY_NODE_FIELD(colTypes);
2505         COPY_NODE_FIELD(colTypmods);
2506         COPY_NODE_FIELD(colCollations);
2507         COPY_NODE_FIELD(groupClauses);
2508
2509         return newnode;
2510 }
2511
2512 static AlterTableStmt *
2513 _copyAlterTableStmt(AlterTableStmt *from)
2514 {
2515         AlterTableStmt *newnode = makeNode(AlterTableStmt);
2516
2517         COPY_NODE_FIELD(relation);
2518         COPY_NODE_FIELD(cmds);
2519         COPY_SCALAR_FIELD(relkind);
2520
2521         return newnode;
2522 }
2523
2524 static AlterTableCmd *
2525 _copyAlterTableCmd(AlterTableCmd *from)
2526 {
2527         AlterTableCmd *newnode = makeNode(AlterTableCmd);
2528
2529         COPY_SCALAR_FIELD(subtype);
2530         COPY_STRING_FIELD(name);
2531         COPY_NODE_FIELD(def);
2532         COPY_SCALAR_FIELD(behavior);
2533         COPY_SCALAR_FIELD(missing_ok);
2534
2535         return newnode;
2536 }
2537
2538 static AlterDomainStmt *
2539 _copyAlterDomainStmt(AlterDomainStmt *from)
2540 {
2541         AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
2542
2543         COPY_SCALAR_FIELD(subtype);
2544         COPY_NODE_FIELD(typeName);
2545         COPY_STRING_FIELD(name);
2546         COPY_NODE_FIELD(def);
2547         COPY_SCALAR_FIELD(behavior);
2548
2549         return newnode;
2550 }
2551
2552 static GrantStmt *
2553 _copyGrantStmt(GrantStmt *from)
2554 {
2555         GrantStmt  *newnode = makeNode(GrantStmt);
2556
2557         COPY_SCALAR_FIELD(is_grant);
2558         COPY_SCALAR_FIELD(targtype);
2559         COPY_SCALAR_FIELD(objtype);
2560         COPY_NODE_FIELD(objects);
2561         COPY_NODE_FIELD(privileges);
2562         COPY_NODE_FIELD(grantees);
2563         COPY_SCALAR_FIELD(grant_option);
2564         COPY_SCALAR_FIELD(behavior);
2565
2566         return newnode;
2567 }
2568
2569 static PrivGrantee *
2570 _copyPrivGrantee(PrivGrantee *from)
2571 {
2572         PrivGrantee *newnode = makeNode(PrivGrantee);
2573
2574         COPY_STRING_FIELD(rolname);
2575
2576         return newnode;
2577 }
2578
2579 static FuncWithArgs *
2580 _copyFuncWithArgs(FuncWithArgs *from)
2581 {
2582         FuncWithArgs *newnode = makeNode(FuncWithArgs);
2583
2584         COPY_NODE_FIELD(funcname);
2585         COPY_NODE_FIELD(funcargs);
2586
2587         return newnode;
2588 }
2589
2590 static AccessPriv *
2591 _copyAccessPriv(AccessPriv *from)
2592 {
2593         AccessPriv *newnode = makeNode(AccessPriv);
2594
2595         COPY_STRING_FIELD(priv_name);
2596         COPY_NODE_FIELD(cols);
2597
2598         return newnode;
2599 }
2600
2601 static GrantRoleStmt *
2602 _copyGrantRoleStmt(GrantRoleStmt *from)
2603 {
2604         GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
2605
2606         COPY_NODE_FIELD(granted_roles);
2607         COPY_NODE_FIELD(grantee_roles);
2608         COPY_SCALAR_FIELD(is_grant);
2609         COPY_SCALAR_FIELD(admin_opt);
2610         COPY_STRING_FIELD(grantor);
2611         COPY_SCALAR_FIELD(behavior);
2612
2613         return newnode;
2614 }
2615
2616 static AlterDefaultPrivilegesStmt *
2617 _copyAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *from)
2618 {
2619         AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
2620
2621         COPY_NODE_FIELD(options);
2622         COPY_NODE_FIELD(action);
2623
2624         return newnode;
2625 }
2626
2627 static DeclareCursorStmt *
2628 _copyDeclareCursorStmt(DeclareCursorStmt *from)
2629 {
2630         DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
2631
2632         COPY_STRING_FIELD(portalname);
2633         COPY_SCALAR_FIELD(options);
2634         COPY_NODE_FIELD(query);
2635
2636         return newnode;
2637 }
2638
2639 static ClosePortalStmt *
2640 _copyClosePortalStmt(ClosePortalStmt *from)
2641 {
2642         ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
2643
2644         COPY_STRING_FIELD(portalname);
2645
2646         return newnode;
2647 }
2648
2649 static ClusterStmt *
2650 _copyClusterStmt(ClusterStmt *from)
2651 {
2652         ClusterStmt *newnode = makeNode(ClusterStmt);
2653
2654         COPY_NODE_FIELD(relation);
2655         COPY_STRING_FIELD(indexname);
2656         COPY_SCALAR_FIELD(verbose);
2657
2658         return newnode;
2659 }
2660
2661 static CopyStmt *
2662 _copyCopyStmt(CopyStmt *from)
2663 {
2664         CopyStmt   *newnode = makeNode(CopyStmt);
2665
2666         COPY_NODE_FIELD(relation);
2667         COPY_NODE_FIELD(query);
2668         COPY_NODE_FIELD(attlist);
2669         COPY_SCALAR_FIELD(is_from);
2670         COPY_STRING_FIELD(filename);
2671         COPY_NODE_FIELD(options);
2672
2673         return newnode;
2674 }
2675
2676 /*
2677  * CopyCreateStmtFields
2678  *
2679  *              This function copies the fields of the CreateStmt node.  It is used by
2680  *              copy functions for classes which inherit from CreateStmt.
2681  */
2682 static void
2683 CopyCreateStmtFields(CreateStmt *from, CreateStmt *newnode)
2684 {
2685         COPY_NODE_FIELD(relation);
2686         COPY_NODE_FIELD(tableElts);
2687         COPY_NODE_FIELD(inhRelations);
2688         COPY_NODE_FIELD(ofTypename);
2689         COPY_NODE_FIELD(constraints);
2690         COPY_NODE_FIELD(options);
2691         COPY_SCALAR_FIELD(oncommit);
2692         COPY_STRING_FIELD(tablespacename);
2693         COPY_SCALAR_FIELD(if_not_exists);
2694 }
2695
2696 static CreateStmt *
2697 _copyCreateStmt(CreateStmt *from)
2698 {
2699         CreateStmt *newnode = makeNode(CreateStmt);
2700
2701         CopyCreateStmtFields(from, newnode);
2702
2703         return newnode;
2704 }
2705
2706 static InhRelation *
2707 _copyInhRelation(InhRelation *from)
2708 {
2709         InhRelation *newnode = makeNode(InhRelation);
2710
2711         COPY_NODE_FIELD(relation);
2712         COPY_SCALAR_FIELD(options);
2713
2714         return newnode;
2715 }
2716
2717 static DefineStmt *
2718 _copyDefineStmt(DefineStmt *from)
2719 {
2720         DefineStmt *newnode = makeNode(DefineStmt);
2721
2722         COPY_SCALAR_FIELD(kind);
2723         COPY_SCALAR_FIELD(oldstyle);
2724         COPY_NODE_FIELD(defnames);
2725         COPY_NODE_FIELD(args);
2726         COPY_NODE_FIELD(definition);
2727
2728         return newnode;
2729 }
2730
2731 static DropStmt *
2732 _copyDropStmt(DropStmt *from)
2733 {
2734         DropStmt   *newnode = makeNode(DropStmt);
2735
2736         COPY_NODE_FIELD(objects);
2737         COPY_SCALAR_FIELD(removeType);
2738         COPY_SCALAR_FIELD(behavior);
2739         COPY_SCALAR_FIELD(missing_ok);
2740
2741         return newnode;
2742 }
2743
2744 static TruncateStmt *
2745 _copyTruncateStmt(TruncateStmt *from)
2746 {
2747         TruncateStmt *newnode = makeNode(TruncateStmt);
2748
2749         COPY_NODE_FIELD(relations);
2750         COPY_SCALAR_FIELD(restart_seqs);
2751         COPY_SCALAR_FIELD(behavior);
2752
2753         return newnode;
2754 }
2755
2756 static CommentStmt *
2757 _copyCommentStmt(CommentStmt *from)
2758 {
2759         CommentStmt *newnode = makeNode(CommentStmt);
2760
2761         COPY_SCALAR_FIELD(objtype);
2762         COPY_NODE_FIELD(objname);
2763         COPY_NODE_FIELD(objargs);
2764         COPY_STRING_FIELD(comment);
2765
2766         return newnode;
2767 }
2768
2769 static SecLabelStmt *
2770 _copySecLabelStmt(SecLabelStmt *from)
2771 {
2772         SecLabelStmt *newnode = makeNode(SecLabelStmt);
2773
2774         COPY_SCALAR_FIELD(objtype);
2775         COPY_NODE_FIELD(objname);
2776         COPY_NODE_FIELD(objargs);
2777         COPY_STRING_FIELD(provider);
2778         COPY_STRING_FIELD(label);
2779
2780         return newnode;
2781 }
2782
2783 static FetchStmt *
2784 _copyFetchStmt(FetchStmt *from)
2785 {
2786         FetchStmt  *newnode = makeNode(FetchStmt);
2787
2788         COPY_SCALAR_FIELD(direction);
2789         COPY_SCALAR_FIELD(howMany);
2790         COPY_STRING_FIELD(portalname);
2791         COPY_SCALAR_FIELD(ismove);
2792
2793         return newnode;
2794 }
2795
2796 static IndexStmt *
2797 _copyIndexStmt(IndexStmt *from)
2798 {
2799         IndexStmt  *newnode = makeNode(IndexStmt);
2800
2801         COPY_STRING_FIELD(idxname);
2802         COPY_NODE_FIELD(relation);
2803         COPY_STRING_FIELD(accessMethod);
2804         COPY_STRING_FIELD(tableSpace);
2805         COPY_NODE_FIELD(indexParams);
2806         COPY_NODE_FIELD(options);
2807         COPY_NODE_FIELD(whereClause);
2808         COPY_NODE_FIELD(excludeOpNames);
2809         COPY_SCALAR_FIELD(indexOid);
2810         COPY_SCALAR_FIELD(unique);
2811         COPY_SCALAR_FIELD(primary);
2812         COPY_SCALAR_FIELD(isconstraint);
2813         COPY_SCALAR_FIELD(deferrable);
2814         COPY_SCALAR_FIELD(initdeferred);
2815         COPY_SCALAR_FIELD(concurrent);
2816
2817         return newnode;
2818 }
2819
2820 static CreateFunctionStmt *
2821 _copyCreateFunctionStmt(CreateFunctionStmt *from)
2822 {
2823         CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
2824
2825         COPY_SCALAR_FIELD(replace);
2826         COPY_NODE_FIELD(funcname);
2827         COPY_NODE_FIELD(parameters);
2828         COPY_NODE_FIELD(returnType);
2829         COPY_NODE_FIELD(options);
2830         COPY_NODE_FIELD(withClause);
2831
2832         return newnode;
2833 }
2834
2835 static FunctionParameter *
2836 _copyFunctionParameter(FunctionParameter *from)
2837 {
2838         FunctionParameter *newnode = makeNode(FunctionParameter);
2839
2840         COPY_STRING_FIELD(name);
2841         COPY_NODE_FIELD(argType);
2842         COPY_SCALAR_FIELD(mode);
2843         COPY_NODE_FIELD(defexpr);
2844
2845         return newnode;
2846 }
2847
2848 static AlterFunctionStmt *
2849 _copyAlterFunctionStmt(AlterFunctionStmt *from)
2850 {
2851         AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
2852
2853         COPY_NODE_FIELD(func);
2854         COPY_NODE_FIELD(actions);
2855
2856         return newnode;
2857 }
2858
2859 static RemoveFuncStmt *
2860 _copyRemoveFuncStmt(RemoveFuncStmt *from)
2861 {
2862         RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
2863
2864         COPY_SCALAR_FIELD(kind);
2865         COPY_NODE_FIELD(name);
2866         COPY_NODE_FIELD(args);
2867         COPY_SCALAR_FIELD(behavior);
2868         COPY_SCALAR_FIELD(missing_ok);
2869
2870         return newnode;
2871 }
2872
2873 static DoStmt *
2874 _copyDoStmt(DoStmt *from)
2875 {
2876         DoStmt     *newnode = makeNode(DoStmt);
2877
2878         COPY_NODE_FIELD(args);
2879
2880         return newnode;
2881 }
2882
2883 static RemoveOpClassStmt *
2884 _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
2885 {
2886         RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
2887
2888         COPY_NODE_FIELD(opclassname);
2889         COPY_STRING_FIELD(amname);
2890         COPY_SCALAR_FIELD(behavior);
2891         COPY_SCALAR_FIELD(missing_ok);
2892
2893         return newnode;
2894 }
2895
2896 static RemoveOpFamilyStmt *
2897 _copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
2898 {
2899         RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
2900
2901         COPY_NODE_FIELD(opfamilyname);
2902         COPY_STRING_FIELD(amname);
2903         COPY_SCALAR_FIELD(behavior);
2904         COPY_SCALAR_FIELD(missing_ok);
2905
2906         return newnode;
2907 }
2908
2909 static RenameStmt *
2910 _copyRenameStmt(RenameStmt *from)
2911 {
2912         RenameStmt *newnode = makeNode(RenameStmt);
2913
2914         COPY_SCALAR_FIELD(renameType);
2915         COPY_NODE_FIELD(relation);
2916         COPY_NODE_FIELD(object);
2917         COPY_NODE_FIELD(objarg);
2918         COPY_STRING_FIELD(subname);
2919         COPY_STRING_FIELD(newname);
2920         COPY_SCALAR_FIELD(behavior);
2921
2922         return newnode;
2923 }
2924
2925 static AlterObjectSchemaStmt *
2926 _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
2927 {
2928         AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
2929
2930         COPY_SCALAR_FIELD(objectType);
2931         COPY_NODE_FIELD(relation);
2932         COPY_NODE_FIELD(object);
2933         COPY_NODE_FIELD(objarg);
2934         COPY_STRING_FIELD(addname);
2935         COPY_STRING_FIELD(newschema);
2936
2937         return newnode;
2938 }
2939
2940 static AlterOwnerStmt *
2941 _copyAlterOwnerStmt(AlterOwnerStmt *from)
2942 {
2943         AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
2944
2945         COPY_SCALAR_FIELD(objectType);
2946         COPY_NODE_FIELD(relation);
2947         COPY_NODE_FIELD(object);
2948         COPY_NODE_FIELD(objarg);
2949         COPY_STRING_FIELD(addname);
2950         COPY_STRING_FIELD(newowner);
2951
2952         return newnode;
2953 }
2954
2955 static RuleStmt *
2956 _copyRuleStmt(RuleStmt *from)
2957 {
2958         RuleStmt   *newnode = makeNode(RuleStmt);
2959
2960         COPY_NODE_FIELD(relation);
2961         COPY_STRING_FIELD(rulename);
2962         COPY_NODE_FIELD(whereClause);
2963         COPY_SCALAR_FIELD(event);
2964         COPY_SCALAR_FIELD(instead);
2965         COPY_NODE_FIELD(actions);
2966         COPY_SCALAR_FIELD(replace);
2967
2968         return newnode;
2969 }
2970
2971 static NotifyStmt *
2972 _copyNotifyStmt(NotifyStmt *from)
2973 {
2974         NotifyStmt *newnode = makeNode(NotifyStmt);
2975
2976         COPY_STRING_FIELD(conditionname);
2977         COPY_STRING_FIELD(payload);
2978
2979         return newnode;
2980 }
2981
2982 static ListenStmt *
2983 _copyListenStmt(ListenStmt *from)
2984 {
2985         ListenStmt *newnode = makeNode(ListenStmt);
2986
2987         COPY_STRING_FIELD(conditionname);
2988
2989         return newnode;
2990 }
2991
2992 static UnlistenStmt *
2993 _copyUnlistenStmt(UnlistenStmt *from)
2994 {
2995         UnlistenStmt *newnode = makeNode(UnlistenStmt);
2996
2997         COPY_STRING_FIELD(conditionname);
2998
2999         return newnode;
3000 }
3001
3002 static TransactionStmt *
3003 _copyTransactionStmt(TransactionStmt *from)
3004 {
3005         TransactionStmt *newnode = makeNode(TransactionStmt);
3006
3007         COPY_SCALAR_FIELD(kind);
3008         COPY_NODE_FIELD(options);
3009         COPY_STRING_FIELD(gid);
3010
3011         return newnode;
3012 }
3013
3014 static CompositeTypeStmt *
3015 _copyCompositeTypeStmt(CompositeTypeStmt *from)
3016 {
3017         CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
3018
3019         COPY_NODE_FIELD(typevar);
3020         COPY_NODE_FIELD(coldeflist);
3021
3022         return newnode;
3023 }
3024
3025 static CreateEnumStmt *
3026 _copyCreateEnumStmt(CreateEnumStmt *from)
3027 {
3028         CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
3029
3030         COPY_NODE_FIELD(typeName);
3031         COPY_NODE_FIELD(vals);
3032
3033         return newnode;
3034 }
3035
3036 static AlterEnumStmt *
3037 _copyAlterEnumStmt(AlterEnumStmt *from)
3038 {
3039         AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3040
3041         COPY_NODE_FIELD(typeName);
3042         COPY_STRING_FIELD(newVal);
3043         COPY_STRING_FIELD(newValNeighbor);
3044         COPY_SCALAR_FIELD(newValIsAfter);
3045
3046         return newnode;
3047 }
3048
3049 static ViewStmt *
3050 _copyViewStmt(ViewStmt *from)
3051 {
3052         ViewStmt   *newnode = makeNode(ViewStmt);
3053
3054         COPY_NODE_FIELD(view);
3055         COPY_NODE_FIELD(aliases);
3056         COPY_NODE_FIELD(query);
3057         COPY_SCALAR_FIELD(replace);
3058
3059         return newnode;
3060 }
3061
3062 static LoadStmt *
3063 _copyLoadStmt(LoadStmt *from)
3064 {
3065         LoadStmt   *newnode = makeNode(LoadStmt);
3066
3067         COPY_STRING_FIELD(filename);
3068
3069         return newnode;
3070 }
3071
3072 static CreateDomainStmt *
3073 _copyCreateDomainStmt(CreateDomainStmt *from)
3074 {
3075         CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
3076
3077         COPY_NODE_FIELD(domainname);
3078         COPY_NODE_FIELD(typeName);
3079         COPY_NODE_FIELD(collClause);
3080         COPY_NODE_FIELD(constraints);
3081
3082         return newnode;
3083 }
3084
3085 static CreateOpClassStmt *
3086 _copyCreateOpClassStmt(CreateOpClassStmt *from)
3087 {
3088         CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
3089
3090         COPY_NODE_FIELD(opclassname);
3091         COPY_NODE_FIELD(opfamilyname);
3092         COPY_STRING_FIELD(amname);
3093         COPY_NODE_FIELD(datatype);
3094         COPY_NODE_FIELD(items);
3095         COPY_SCALAR_FIELD(isDefault);
3096
3097         return newnode;
3098 }
3099
3100 static CreateOpClassItem *
3101 _copyCreateOpClassItem(CreateOpClassItem *from)
3102 {
3103         CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
3104
3105         COPY_SCALAR_FIELD(itemtype);
3106         COPY_NODE_FIELD(name);
3107         COPY_NODE_FIELD(args);
3108         COPY_SCALAR_FIELD(number);
3109         COPY_NODE_FIELD(order_family);
3110         COPY_NODE_FIELD(class_args);
3111         COPY_NODE_FIELD(storedtype);
3112
3113         return newnode;
3114 }
3115
3116 static CreateOpFamilyStmt *
3117 _copyCreateOpFamilyStmt(CreateOpFamilyStmt *from)
3118 {
3119         CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
3120
3121         COPY_NODE_FIELD(opfamilyname);
3122         COPY_STRING_FIELD(amname);
3123
3124         return newnode;
3125 }
3126
3127 static AlterOpFamilyStmt *
3128 _copyAlterOpFamilyStmt(AlterOpFamilyStmt *from)
3129 {
3130         AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
3131
3132         COPY_NODE_FIELD(opfamilyname);
3133         COPY_STRING_FIELD(amname);
3134         COPY_SCALAR_FIELD(isDrop);
3135         COPY_NODE_FIELD(items);
3136
3137         return newnode;
3138 }
3139
3140 static CreatedbStmt *
3141 _copyCreatedbStmt(CreatedbStmt *from)
3142 {
3143         CreatedbStmt *newnode = makeNode(CreatedbStmt);
3144
3145         COPY_STRING_FIELD(dbname);
3146         COPY_NODE_FIELD(options);
3147
3148         return newnode;
3149 }
3150
3151 static AlterDatabaseStmt *
3152 _copyAlterDatabaseStmt(AlterDatabaseStmt *from)
3153 {
3154         AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
3155
3156         COPY_STRING_FIELD(dbname);
3157         COPY_NODE_FIELD(options);
3158
3159         return newnode;
3160 }
3161
3162 static AlterDatabaseSetStmt *
3163 _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
3164 {
3165         AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
3166
3167         COPY_STRING_FIELD(dbname);
3168         COPY_NODE_FIELD(setstmt);
3169
3170         return newnode;
3171 }
3172
3173 static DropdbStmt *
3174 _copyDropdbStmt(DropdbStmt *from)
3175 {
3176         DropdbStmt *newnode = makeNode(DropdbStmt);
3177
3178         COPY_STRING_FIELD(dbname);
3179         COPY_SCALAR_FIELD(missing_ok);
3180
3181         return newnode;
3182 }
3183
3184 static VacuumStmt *
3185 _copyVacuumStmt(VacuumStmt *from)
3186 {
3187         VacuumStmt *newnode = makeNode(VacuumStmt);
3188
3189         COPY_SCALAR_FIELD(options);
3190         COPY_SCALAR_FIELD(freeze_min_age);
3191         COPY_SCALAR_FIELD(freeze_table_age);
3192         COPY_NODE_FIELD(relation);
3193         COPY_NODE_FIELD(va_cols);
3194
3195         return newnode;
3196 }
3197
3198 static ExplainStmt *
3199 _copyExplainStmt(ExplainStmt *from)
3200 {
3201         ExplainStmt *newnode = makeNode(ExplainStmt);
3202
3203         COPY_NODE_FIELD(query);
3204         COPY_NODE_FIELD(options);
3205
3206         return newnode;
3207 }
3208
3209 static CreateSeqStmt *
3210 _copyCreateSeqStmt(CreateSeqStmt *from)
3211 {
3212         CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3213
3214         COPY_NODE_FIELD(sequence);
3215         COPY_NODE_FIELD(options);
3216         COPY_SCALAR_FIELD(ownerId);
3217
3218         return newnode;
3219 }
3220
3221 static AlterSeqStmt *
3222 _copyAlterSeqStmt(AlterSeqStmt *from)
3223 {
3224         AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3225
3226         COPY_NODE_FIELD(sequence);
3227         COPY_NODE_FIELD(options);
3228
3229         return newnode;
3230 }
3231
3232 static VariableSetStmt *
3233 _copyVariableSetStmt(VariableSetStmt *from)
3234 {
3235         VariableSetStmt *newnode = makeNode(VariableSetStmt);
3236
3237         COPY_SCALAR_FIELD(kind);
3238         COPY_STRING_FIELD(name);
3239         COPY_NODE_FIELD(args);
3240         COPY_SCALAR_FIELD(is_local);
3241
3242         return newnode;
3243 }
3244
3245 static VariableShowStmt *
3246 _copyVariableShowStmt(VariableShowStmt *from)
3247 {
3248         VariableShowStmt *newnode = makeNode(VariableShowStmt);
3249
3250         COPY_STRING_FIELD(name);
3251
3252         return newnode;
3253 }
3254
3255 static DiscardStmt *
3256 _copyDiscardStmt(DiscardStmt *from)
3257 {
3258         DiscardStmt *newnode = makeNode(DiscardStmt);
3259
3260         COPY_SCALAR_FIELD(target);
3261
3262         return newnode;
3263 }
3264
3265 static CreateTableSpaceStmt *
3266 _copyCreateTableSpaceStmt(CreateTableSpaceStmt *from)
3267 {
3268         CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
3269
3270         COPY_STRING_FIELD(tablespacename);
3271         COPY_STRING_FIELD(owner);
3272         COPY_STRING_FIELD(location);
3273
3274         return newnode;
3275 }
3276
3277 static DropTableSpaceStmt *
3278 _copyDropTableSpaceStmt(DropTableSpaceStmt *from)
3279 {
3280         DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
3281
3282         COPY_STRING_FIELD(tablespacename);
3283         COPY_SCALAR_FIELD(missing_ok);
3284
3285         return newnode;
3286 }
3287
3288 static AlterTableSpaceOptionsStmt *
3289 _copyAlterTableSpaceOptionsStmt(AlterTableSpaceOptionsStmt *from)
3290 {
3291         AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
3292
3293         COPY_STRING_FIELD(tablespacename);
3294         COPY_NODE_FIELD(options);
3295         COPY_SCALAR_FIELD(isReset);
3296
3297         return newnode;
3298 }
3299
3300 static CreateExtensionStmt *
3301 _copyCreateExtensionStmt(CreateExtensionStmt *from)
3302 {
3303         CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
3304
3305         COPY_STRING_FIELD(extname);
3306         COPY_SCALAR_FIELD(if_not_exists);
3307         COPY_NODE_FIELD(options);
3308
3309         return newnode;
3310 }
3311
3312 static AlterExtensionStmt *
3313 _copyAlterExtensionStmt(AlterExtensionStmt *from)
3314 {
3315         AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
3316
3317         COPY_STRING_FIELD(extname);
3318         COPY_NODE_FIELD(options);
3319
3320         return newnode;
3321 }
3322
3323 static AlterExtensionContentsStmt *
3324 _copyAlterExtensionContentsStmt(AlterExtensionContentsStmt *from)
3325 {
3326         AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
3327
3328         COPY_STRING_FIELD(extname);
3329         COPY_SCALAR_FIELD(action);
3330         COPY_SCALAR_FIELD(objtype);
3331         COPY_NODE_FIELD(objname);
3332         COPY_NODE_FIELD(objargs);
3333
3334         return newnode;
3335 }
3336
3337 static CreateFdwStmt *
3338 _copyCreateFdwStmt(CreateFdwStmt *from)
3339 {
3340         CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3341
3342         COPY_STRING_FIELD(fdwname);
3343         COPY_NODE_FIELD(func_options);
3344         COPY_NODE_FIELD(options);
3345
3346         return newnode;
3347 }
3348
3349 static AlterFdwStmt *
3350 _copyAlterFdwStmt(AlterFdwStmt *from)
3351 {
3352         AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3353
3354         COPY_STRING_FIELD(fdwname);
3355         COPY_NODE_FIELD(func_options);
3356         COPY_NODE_FIELD(options);
3357
3358         return newnode;
3359 }
3360
3361 static DropFdwStmt *
3362 _copyDropFdwStmt(DropFdwStmt *from)
3363 {
3364         DropFdwStmt *newnode = makeNode(DropFdwStmt);
3365
3366         COPY_STRING_FIELD(fdwname);
3367         COPY_SCALAR_FIELD(missing_ok);
3368         COPY_SCALAR_FIELD(behavior);
3369
3370         return newnode;
3371 }
3372
3373 static CreateForeignServerStmt *
3374 _copyCreateForeignServerStmt(CreateForeignServerStmt *from)
3375 {
3376         CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
3377
3378         COPY_STRING_FIELD(servername);
3379         COPY_STRING_FIELD(servertype);
3380         COPY_STRING_FIELD(version);
3381         COPY_STRING_FIELD(fdwname);
3382         COPY_NODE_FIELD(options);
3383
3384         return newnode;
3385 }
3386
3387 static AlterForeignServerStmt *
3388 _copyAlterForeignServerStmt(AlterForeignServerStmt *from)
3389 {
3390         AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
3391
3392         COPY_STRING_FIELD(servername);
3393         COPY_STRING_FIELD(version);
3394         COPY_NODE_FIELD(options);
3395         COPY_SCALAR_FIELD(has_version);
3396
3397         return newnode;
3398 }
3399
3400 static DropForeignServerStmt *
3401 _copyDropForeignServerStmt(DropForeignServerStmt *from)
3402 {
3403         DropForeignServerStmt *newnode = makeNode(DropForeignServerStmt);
3404
3405         COPY_STRING_FIELD(servername);
3406         COPY_SCALAR_FIELD(missing_ok);
3407         COPY_SCALAR_FIELD(behavior);
3408
3409         return newnode;
3410 }
3411
3412 static CreateUserMappingStmt *
3413 _copyCreateUserMappingStmt(CreateUserMappingStmt *from)
3414 {
3415         CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
3416
3417         COPY_STRING_FIELD(username);
3418         COPY_STRING_FIELD(servername);
3419         COPY_NODE_FIELD(options);
3420
3421         return newnode;
3422 }
3423
3424 static AlterUserMappingStmt *
3425 _copyAlterUserMappingStmt(AlterUserMappingStmt *from)
3426 {
3427         AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
3428
3429         COPY_STRING_FIELD(username);
3430         COPY_STRING_FIELD(servername);
3431         COPY_NODE_FIELD(options);
3432
3433         return newnode;
3434 }
3435
3436 static DropUserMappingStmt *
3437 _copyDropUserMappingStmt(DropUserMappingStmt *from)
3438 {
3439         DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
3440
3441         COPY_STRING_FIELD(username);
3442         COPY_STRING_FIELD(servername);
3443         COPY_SCALAR_FIELD(missing_ok);
3444
3445         return newnode;
3446 }
3447
3448 static CreateForeignTableStmt *
3449 _copyCreateForeignTableStmt(CreateForeignTableStmt *from)
3450 {
3451         CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
3452
3453         CopyCreateStmtFields((CreateStmt *) from, (CreateStmt *) newnode);
3454
3455         COPY_STRING_FIELD(servername);
3456         COPY_NODE_FIELD(options);
3457
3458         return newnode;
3459 }
3460
3461 static CreateTrigStmt *
3462 _copyCreateTrigStmt(CreateTrigStmt *from)
3463 {
3464         CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
3465
3466         COPY_STRING_FIELD(trigname);
3467         COPY_NODE_FIELD(relation);
3468         COPY_NODE_FIELD(funcname);
3469         COPY_NODE_FIELD(args);
3470         COPY_SCALAR_FIELD(row);
3471         COPY_SCALAR_FIELD(timing);
3472         COPY_SCALAR_FIELD(events);
3473         COPY_NODE_FIELD(columns);
3474         COPY_NODE_FIELD(whenClause);
3475         COPY_SCALAR_FIELD(isconstraint);
3476         COPY_SCALAR_FIELD(deferrable);
3477         COPY_SCALAR_FIELD(initdeferred);
3478         COPY_NODE_FIELD(constrrel);
3479
3480         return newnode;
3481 }
3482
3483 static DropPropertyStmt *
3484 _copyDropPropertyStmt(DropPropertyStmt *from)
3485 {
3486         DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
3487
3488         COPY_NODE_FIELD(relation);
3489         COPY_STRING_FIELD(property);
3490         COPY_SCALAR_FIELD(removeType);
3491         COPY_SCALAR_FIELD(behavior);
3492         COPY_SCALAR_FIELD(missing_ok);
3493
3494         return newnode;
3495 }
3496
3497 static CreatePLangStmt *
3498 _copyCreatePLangStmt(CreatePLangStmt *from)
3499 {
3500         CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
3501
3502         COPY_SCALAR_FIELD(replace);
3503         COPY_STRING_FIELD(plname);
3504         COPY_NODE_FIELD(plhandler);
3505         COPY_NODE_FIELD(plinline);
3506         COPY_NODE_FIELD(plvalidator);
3507         COPY_SCALAR_FIELD(pltrusted);
3508
3509         return newnode;
3510 }
3511
3512 static DropPLangStmt *
3513 _copyDropPLangStmt(DropPLangStmt *from)
3514 {
3515         DropPLangStmt *newnode = makeNode(DropPLangStmt);
3516
3517         COPY_STRING_FIELD(plname);
3518         COPY_SCALAR_FIELD(behavior);
3519         COPY_SCALAR_FIELD(missing_ok);
3520
3521         return newnode;
3522 }
3523
3524 static CreateRoleStmt *
3525 _copyCreateRoleStmt(CreateRoleStmt *from)
3526 {
3527         CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
3528
3529         COPY_SCALAR_FIELD(stmt_type);
3530         COPY_STRING_FIELD(role);
3531         COPY_NODE_FIELD(options);
3532
3533         return newnode;
3534 }
3535
3536 static AlterRoleStmt *
3537 _copyAlterRoleStmt(AlterRoleStmt *from)
3538 {
3539         AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
3540
3541         COPY_STRING_FIELD(role);
3542         COPY_NODE_FIELD(options);
3543         COPY_SCALAR_FIELD(action);
3544
3545         return newnode;
3546 }
3547
3548 static AlterRoleSetStmt *
3549 _copyAlterRoleSetStmt(AlterRoleSetStmt *from)
3550 {
3551         AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
3552
3553         COPY_STRING_FIELD(role);
3554         COPY_STRING_FIELD(database);
3555         COPY_NODE_FIELD(setstmt);
3556
3557         return newnode;
3558 }
3559
3560 static DropRoleStmt *
3561 _copyDropRoleStmt(DropRoleStmt *from)
3562 {
3563         DropRoleStmt *newnode = makeNode(DropRoleStmt);
3564
3565         COPY_NODE_FIELD(roles);
3566         COPY_SCALAR_FIELD(missing_ok);
3567
3568         return newnode;
3569 }
3570
3571 static LockStmt *
3572 _copyLockStmt(LockStmt *from)
3573 {
3574         LockStmt   *newnode = makeNode(LockStmt);
3575
3576         COPY_NODE_FIELD(relations);
3577         COPY_SCALAR_FIELD(mode);
3578         COPY_SCALAR_FIELD(nowait);
3579
3580         return newnode;
3581 }
3582
3583 static ConstraintsSetStmt *
3584 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
3585 {
3586         ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
3587
3588         COPY_NODE_FIELD(constraints);
3589         COPY_SCALAR_FIELD(deferred);
3590
3591         return newnode;
3592 }
3593
3594 static ReindexStmt *
3595 _copyReindexStmt(ReindexStmt *from)
3596 {
3597         ReindexStmt *newnode = makeNode(ReindexStmt);
3598
3599         COPY_SCALAR_FIELD(kind);
3600         COPY_NODE_FIELD(relation);
3601         COPY_STRING_FIELD(name);
3602         COPY_SCALAR_FIELD(do_system);
3603         COPY_SCALAR_FIELD(do_user);
3604
3605         return newnode;
3606 }
3607
3608 static CreateSchemaStmt *
3609 _copyCreateSchemaStmt(CreateSchemaStmt *from)
3610 {
3611         CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
3612
3613         COPY_STRING_FIELD(schemaname);
3614         COPY_STRING_FIELD(authid);
3615         COPY_NODE_FIELD(schemaElts);
3616
3617         return newnode;
3618 }
3619
3620 static CreateConversionStmt *
3621 _copyCreateConversionStmt(CreateConversionStmt *from)
3622 {
3623         CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
3624
3625         COPY_NODE_FIELD(conversion_name);
3626         COPY_STRING_FIELD(for_encoding_name);
3627         COPY_STRING_FIELD(to_encoding_name);
3628         COPY_NODE_FIELD(func_name);
3629         COPY_SCALAR_FIELD(def);
3630
3631         return newnode;
3632 }
3633
3634 static CreateCastStmt *
3635 _copyCreateCastStmt(CreateCastStmt *from)
3636 {
3637         CreateCastStmt *newnode = makeNode(CreateCastStmt);
3638
3639         COPY_NODE_FIELD(sourcetype);
3640         COPY_NODE_FIELD(targettype);
3641         COPY_NODE_FIELD(func);
3642         COPY_SCALAR_FIELD(context);
3643         COPY_SCALAR_FIELD(inout);
3644
3645         return newnode;
3646 }
3647
3648 static DropCastStmt *
3649 _copyDropCastStmt(DropCastStmt *from)
3650 {
3651         DropCastStmt *newnode = makeNode(DropCastStmt);
3652
3653         COPY_NODE_FIELD(sourcetype);
3654         COPY_NODE_FIELD(targettype);
3655         COPY_SCALAR_FIELD(behavior);
3656         COPY_SCALAR_FIELD(missing_ok);
3657
3658         return newnode;
3659 }
3660
3661 static PrepareStmt *
3662 _copyPrepareStmt(PrepareStmt *from)
3663 {
3664         PrepareStmt *newnode = makeNode(PrepareStmt);
3665
3666         COPY_STRING_FIELD(name);
3667         COPY_NODE_FIELD(argtypes);
3668         COPY_NODE_FIELD(query);
3669
3670         return newnode;
3671 }
3672
3673 static ExecuteStmt *
3674 _copyExecuteStmt(ExecuteStmt *from)
3675 {
3676         ExecuteStmt *newnode = makeNode(ExecuteStmt);
3677
3678         COPY_STRING_FIELD(name);
3679         COPY_NODE_FIELD(into);
3680         COPY_NODE_FIELD(params);
3681
3682         return newnode;
3683 }
3684
3685 static DeallocateStmt *
3686 _copyDeallocateStmt(DeallocateStmt *from)
3687 {
3688         DeallocateStmt *newnode = makeNode(DeallocateStmt);
3689
3690         COPY_STRING_FIELD(name);
3691
3692         return newnode;
3693 }
3694
3695 static DropOwnedStmt *
3696 _copyDropOwnedStmt(DropOwnedStmt *from)
3697 {
3698         DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
3699
3700         COPY_NODE_FIELD(roles);
3701         COPY_SCALAR_FIELD(behavior);
3702
3703         return newnode;
3704 }
3705
3706 static ReassignOwnedStmt *
3707 _copyReassignOwnedStmt(ReassignOwnedStmt *from)
3708 {
3709         ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
3710
3711         COPY_NODE_FIELD(roles);
3712         COPY_SCALAR_FIELD(newrole);
3713
3714         return newnode;
3715 }
3716
3717 static AlterTSDictionaryStmt *
3718 _copyAlterTSDictionaryStmt(AlterTSDictionaryStmt *from)
3719 {
3720         AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
3721
3722         COPY_NODE_FIELD(dictname);
3723         COPY_NODE_FIELD(options);
3724
3725         return newnode;
3726 }
3727
3728 static AlterTSConfigurationStmt *
3729 _copyAlterTSConfigurationStmt(AlterTSConfigurationStmt *from)
3730 {
3731         AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
3732
3733         COPY_NODE_FIELD(cfgname);
3734         COPY_NODE_FIELD(tokentype);
3735         COPY_NODE_FIELD(dicts);
3736         COPY_SCALAR_FIELD(override);
3737         COPY_SCALAR_FIELD(replace);
3738         COPY_SCALAR_FIELD(missing_ok);
3739
3740         return newnode;
3741 }
3742
3743 /* ****************************************************************
3744  *                                      pg_list.h copy functions
3745  * ****************************************************************
3746  */
3747
3748 /*
3749  * Perform a deep copy of the specified list, using copyObject(). The
3750  * list MUST be of type T_List; T_IntList and T_OidList nodes don't
3751  * need deep copies, so they should be copied via list_copy()
3752  */
3753 #define COPY_NODE_CELL(new, old)                                        \
3754         (new) = (ListCell *) palloc(sizeof(ListCell));  \
3755         lfirst(new) = copyObject(lfirst(old));
3756
3757 static List *
3758 _copyList(List *from)
3759 {
3760         List       *new;
3761         ListCell   *curr_old;
3762         ListCell   *prev_new;
3763
3764         Assert(list_length(from) >= 1);
3765
3766         new = makeNode(List);
3767         new->length = from->length;
3768
3769         COPY_NODE_CELL(new->head, from->head);
3770         prev_new = new->head;
3771         curr_old = lnext(from->head);
3772
3773         while (curr_old)
3774         {
3775                 COPY_NODE_CELL(prev_new->next, curr_old);
3776                 prev_new = prev_new->next;
3777                 curr_old = curr_old->next;
3778         }
3779         prev_new->next = NULL;
3780         new->tail = prev_new;
3781
3782         return new;
3783 }
3784
3785 /* ****************************************************************
3786  *                                      value.h copy functions
3787  * ****************************************************************
3788  */
3789 static Value *
3790 _copyValue(Value *from)
3791 {
3792         Value      *newnode = makeNode(Value);
3793
3794         /* See also _copyAConst when changing this code! */
3795
3796         COPY_SCALAR_FIELD(type);
3797         switch (from->type)
3798         {
3799                 case T_Integer:
3800                         COPY_SCALAR_FIELD(val.ival);
3801                         break;
3802                 case T_Float:
3803                 case T_String:
3804                 case T_BitString:
3805                         COPY_STRING_FIELD(val.str);
3806                         break;
3807                 case T_Null:
3808                         /* nothing to do */
3809                         break;
3810                 default:
3811                         elog(ERROR, "unrecognized node type: %d",
3812                                  (int) from->type);
3813                         break;
3814         }
3815         return newnode;
3816 }
3817
3818 /*
3819  * copyObject
3820  *
3821  * Create a copy of a Node tree or list.  This is a "deep" copy: all
3822  * substructure is copied too, recursively.
3823  */
3824 void *
3825 copyObject(void *from)
3826 {
3827         void       *retval;
3828
3829         if (from == NULL)
3830                 return NULL;
3831
3832         /* Guard against stack overflow due to overly complex expressions */
3833         check_stack_depth();
3834
3835         switch (nodeTag(from))
3836         {
3837                         /*
3838                          * PLAN NODES
3839                          */
3840                 case T_PlannedStmt:
3841                         retval = _copyPlannedStmt(from);
3842                         break;
3843                 case T_Plan:
3844                         retval = _copyPlan(from);
3845                         break;
3846                 case T_Result:
3847                         retval = _copyResult(from);
3848                         break;
3849                 case T_ModifyTable:
3850                         retval = _copyModifyTable(from);
3851                         break;
3852                 case T_Append:
3853                         retval = _copyAppend(from);
3854                         break;
3855                 case T_MergeAppend:
3856                         retval = _copyMergeAppend(from);
3857                         break;
3858                 case T_RecursiveUnion:
3859                         retval = _copyRecursiveUnion(from);
3860                         break;
3861                 case T_BitmapAnd:
3862                         retval = _copyBitmapAnd(from);
3863                         break;
3864                 case T_BitmapOr:
3865                         retval = _copyBitmapOr(from);
3866                         break;
3867                 case T_Scan:
3868                         retval = _copyScan(from);
3869                         break;
3870                 case T_SeqScan:
3871                         retval = _copySeqScan(from);
3872                         break;
3873                 case T_IndexScan:
3874                         retval = _copyIndexScan(from);
3875                         break;
3876                 case T_BitmapIndexScan:
3877                         retval = _copyBitmapIndexScan(from);
3878                         break;
3879                 case T_BitmapHeapScan:
3880                         retval = _copyBitmapHeapScan(from);
3881                         break;
3882                 case T_TidScan:
3883                         retval = _copyTidScan(from);
3884                         break;
3885                 case T_SubqueryScan:
3886                         retval = _copySubqueryScan(from);
3887                         break;
3888                 case T_FunctionScan:
3889                         retval = _copyFunctionScan(from);
3890                         break;
3891                 case T_ValuesScan:
3892                         retval = _copyValuesScan(from);
3893                         break;
3894                 case T_CteScan:
3895                         retval = _copyCteScan(from);
3896                         break;
3897                 case T_WorkTableScan:
3898                         retval = _copyWorkTableScan(from);
3899                         break;
3900                 case T_ForeignScan:
3901                         retval = _copyForeignScan(from);
3902                         break;
3903                 case T_FdwPlan:
3904                         retval = _copyFdwPlan(from);
3905                         break;
3906                 case T_Join:
3907                         retval = _copyJoin(from);
3908                         break;
3909                 case T_NestLoop:
3910                         retval = _copyNestLoop(from);
3911                         break;
3912                 case T_MergeJoin:
3913                         retval = _copyMergeJoin(from);
3914                         break;
3915                 case T_HashJoin:
3916                         retval = _copyHashJoin(from);
3917                         break;
3918                 case T_Material:
3919                         retval = _copyMaterial(from);
3920                         break;
3921                 case T_Sort:
3922                         retval = _copySort(from);
3923                         break;
3924                 case T_Group:
3925                         retval = _copyGroup(from);
3926                         break;
3927                 case T_Agg:
3928                         retval = _copyAgg(from);
3929                         break;
3930                 case T_WindowAgg:
3931                         retval = _copyWindowAgg(from);
3932                         break;
3933                 case T_Unique:
3934                         retval = _copyUnique(from);
3935                         break;
3936                 case T_Hash:
3937                         retval = _copyHash(from);
3938                         break;
3939                 case T_SetOp:
3940                         retval = _copySetOp(from);
3941                         break;
3942                 case T_LockRows:
3943                         retval = _copyLockRows(from);
3944                         break;
3945                 case T_Limit:
3946                         retval = _copyLimit(from);
3947                         break;
3948                 case T_NestLoopParam:
3949                         retval = _copyNestLoopParam(from);
3950                         break;
3951                 case T_PlanRowMark:
3952                         retval = _copyPlanRowMark(from);
3953                         break;
3954                 case T_PlanInvalItem:
3955                         retval = _copyPlanInvalItem(from);
3956                         break;
3957
3958                         /*
3959                          * PRIMITIVE NODES
3960                          */
3961                 case T_Alias:
3962                         retval = _copyAlias(from);
3963                         break;
3964                 case T_RangeVar:
3965                         retval = _copyRangeVar(from);
3966                         break;
3967                 case T_IntoClause:
3968                         retval = _copyIntoClause(from);
3969                         break;
3970                 case T_Var:
3971                         retval = _copyVar(from);
3972                         break;
3973                 case T_Const:
3974                         retval = _copyConst(from);
3975                         break;
3976                 case T_Param:
3977                         retval = _copyParam(from);
3978                         break;
3979                 case T_Aggref:
3980                         retval = _copyAggref(from);
3981                         break;
3982                 case T_WindowFunc:
3983                         retval = _copyWindowFunc(from);
3984                         break;
3985                 case T_ArrayRef:
3986                         retval = _copyArrayRef(from);
3987                         break;
3988                 case T_FuncExpr:
3989                         retval = _copyFuncExpr(from);
3990                         break;
3991                 case T_NamedArgExpr:
3992                         retval = _copyNamedArgExpr(from);
3993                         break;
3994                 case T_OpExpr:
3995                         retval = _copyOpExpr(from);
3996                         break;
3997                 case T_DistinctExpr:
3998                         retval = _copyDistinctExpr(from);
3999                         break;
4000                 case T_NullIfExpr:
4001                         retval = _copyNullIfExpr(from);
4002                         break;
4003                 case T_ScalarArrayOpExpr:
4004                         retval = _copyScalarArrayOpExpr(from);
4005                         break;
4006                 case T_BoolExpr:
4007                         retval = _copyBoolExpr(from);
4008                         break;
4009                 case T_SubLink:
4010                         retval = _copySubLink(from);
4011                         break;
4012                 case T_SubPlan:
4013                         retval = _copySubPlan(from);
4014                         break;
4015                 case T_AlternativeSubPlan:
4016                         retval = _copyAlternativeSubPlan(from);
4017                         break;
4018                 case T_FieldSelect:
4019                         retval = _copyFieldSelect(from);
4020                         break;
4021                 case T_FieldStore:
4022                         retval = _copyFieldStore(from);
4023                         break;
4024                 case T_RelabelType:
4025                         retval = _copyRelabelType(from);
4026                         break;
4027                 case T_CoerceViaIO:
4028                         retval = _copyCoerceViaIO(from);
4029                         break;
4030                 case T_ArrayCoerceExpr:
4031                         retval = _copyArrayCoerceExpr(from);
4032                         break;
4033                 case T_ConvertRowtypeExpr:
4034                         retval = _copyConvertRowtypeExpr(from);
4035                         break;
4036                 case T_CollateExpr:
4037                         retval = _copyCollateExpr(from);
4038                         break;
4039                 case T_CaseExpr:
4040                         retval = _copyCaseExpr(from);
4041                         break;
4042                 case T_CaseWhen:
4043                         retval = _copyCaseWhen(from);
4044                         break;
4045                 case T_CaseTestExpr:
4046                         retval = _copyCaseTestExpr(from);
4047                         break;
4048                 case T_ArrayExpr:
4049                         retval = _copyArrayExpr(from);
4050                         break;
4051                 case T_RowExpr:
4052                         retval = _copyRowExpr(from);
4053                         break;
4054                 case T_RowCompareExpr:
4055                         retval = _copyRowCompareExpr(from);
4056                         break;
4057                 case T_CoalesceExpr:
4058                         retval = _copyCoalesceExpr(from);
4059                         break;
4060                 case T_MinMaxExpr:
4061                         retval = _copyMinMaxExpr(from);
4062                         break;
4063                 case T_XmlExpr:
4064                         retval = _copyXmlExpr(from);
4065                         break;
4066                 case T_NullTest:
4067                         retval = _copyNullTest(from);
4068                         break;
4069                 case T_BooleanTest:
4070                         retval = _copyBooleanTest(from);
4071                         break;
4072                 case T_CoerceToDomain:
4073                         retval = _copyCoerceToDomain(from);
4074                         break;
4075                 case T_CoerceToDomainValue:
4076                         retval = _copyCoerceToDomainValue(from);
4077                         break;
4078                 case T_SetToDefault:
4079                         retval = _copySetToDefault(from);
4080                         break;
4081                 case T_CurrentOfExpr:
4082                         retval = _copyCurrentOfExpr(from);
4083                         break;
4084                 case T_TargetEntry:
4085                         retval = _copyTargetEntry(from);
4086                         break;
4087                 case T_RangeTblRef:
4088                         retval = _copyRangeTblRef(from);
4089                         break;
4090                 case T_JoinExpr:
4091                         retval = _copyJoinExpr(from);
4092                         break;
4093                 case T_FromExpr:
4094                         retval = _copyFromExpr(from);
4095                         break;
4096
4097                         /*
4098                          * RELATION NODES
4099                          */
4100                 case T_PathKey:
4101                         retval = _copyPathKey(from);
4102                         break;
4103                 case T_RestrictInfo:
4104                         retval = _copyRestrictInfo(from);
4105                         break;
4106                 case T_PlaceHolderVar:
4107                         retval = _copyPlaceHolderVar(from);
4108                         break;
4109                 case T_SpecialJoinInfo:
4110                         retval = _copySpecialJoinInfo(from);
4111                         break;
4112                 case T_AppendRelInfo:
4113                         retval = _copyAppendRelInfo(from);
4114                         break;
4115                 case T_PlaceHolderInfo:
4116                         retval = _copyPlaceHolderInfo(from);
4117                         break;
4118
4119                         /*
4120                          * VALUE NODES
4121                          */
4122                 case T_Integer:
4123                 case T_Float:
4124                 case T_String:
4125                 case T_BitString:
4126                 case T_Null:
4127                         retval = _copyValue(from);
4128                         break;
4129
4130                         /*
4131                          * LIST NODES
4132                          */
4133                 case T_List:
4134                         retval = _copyList(from);
4135                         break;
4136
4137                         /*
4138                          * Lists of integers and OIDs don't need to be deep-copied, so we
4139                          * perform a shallow copy via list_copy()
4140                          */
4141                 case T_IntList:
4142                 case T_OidList:
4143                         retval = list_copy(from);
4144                         break;
4145
4146                         /*
4147                          * PARSE NODES
4148                          */
4149                 case T_Query:
4150                         retval = _copyQuery(from);
4151                         break;
4152                 case T_InsertStmt:
4153                         retval = _copyInsertStmt(from);
4154                         break;
4155                 case T_DeleteStmt:
4156                         retval = _copyDeleteStmt(from);
4157                         break;
4158                 case T_UpdateStmt:
4159                         retval = _copyUpdateStmt(from);
4160                         break;
4161                 case T_SelectStmt:
4162                         retval = _copySelectStmt(from);
4163                         break;
4164                 case T_SetOperationStmt:
4165                         retval = _copySetOperationStmt(from);
4166                         break;
4167                 case T_AlterTableStmt:
4168                         retval = _copyAlterTableStmt(from);
4169                         break;
4170                 case T_AlterTableCmd:
4171                         retval = _copyAlterTableCmd(from);
4172                         break;
4173                 case T_AlterDomainStmt:
4174                         retval = _copyAlterDomainStmt(from);
4175                         break;
4176                 case T_GrantStmt:
4177                         retval = _copyGrantStmt(from);
4178                         break;
4179                 case T_GrantRoleStmt:
4180                         retval = _copyGrantRoleStmt(from);
4181                         break;
4182                 case T_AlterDefaultPrivilegesStmt:
4183                         retval = _copyAlterDefaultPrivilegesStmt(from);
4184                         break;
4185                 case T_DeclareCursorStmt:
4186                         retval = _copyDeclareCursorStmt(from);
4187                         break;
4188                 case T_ClosePortalStmt:
4189                         retval = _copyClosePortalStmt(from);
4190                         break;
4191                 case T_ClusterStmt:
4192                         retval = _copyClusterStmt(from);
4193                         break;
4194                 case T_CopyStmt:
4195                         retval = _copyCopyStmt(from);
4196                         break;
4197                 case T_CreateStmt:
4198                         retval = _copyCreateStmt(from);
4199                         break;
4200                 case T_InhRelation:
4201                         retval = _copyInhRelation(from);
4202                         break;
4203                 case T_DefineStmt:
4204                         retval = _copyDefineStmt(from);
4205                         break;
4206                 case T_DropStmt:
4207                         retval = _copyDropStmt(from);
4208                         break;
4209                 case T_TruncateStmt:
4210                         retval = _copyTruncateStmt(from);
4211                         break;
4212                 case T_CommentStmt:
4213                         retval = _copyCommentStmt(from);
4214                         break;
4215                 case T_SecLabelStmt:
4216                         retval = _copySecLabelStmt(from);
4217                         break;
4218                 case T_FetchStmt:
4219                         retval = _copyFetchStmt(from);
4220                         break;
4221                 case T_IndexStmt:
4222                         retval = _copyIndexStmt(from);
4223                         break;
4224                 case T_CreateFunctionStmt:
4225                         retval = _copyCreateFunctionStmt(from);
4226                         break;
4227                 case T_FunctionParameter:
4228                         retval = _copyFunctionParameter(from);
4229                         break;
4230                 case T_AlterFunctionStmt:
4231                         retval = _copyAlterFunctionStmt(from);
4232                         break;
4233                 case T_RemoveFuncStmt:
4234                         retval = _copyRemoveFuncStmt(from);
4235                         break;
4236                 case T_DoStmt:
4237                         retval = _copyDoStmt(from);
4238                         break;
4239                 case T_RemoveOpClassStmt:
4240                         retval = _copyRemoveOpClassStmt(from);
4241                         break;
4242                 case T_RemoveOpFamilyStmt:
4243                         retval = _copyRemoveOpFamilyStmt(from);
4244                         break;
4245                 case T_RenameStmt:
4246                         retval = _copyRenameStmt(from);
4247                         break;
4248                 case T_AlterObjectSchemaStmt:
4249                         retval = _copyAlterObjectSchemaStmt(from);
4250                         break;
4251                 case T_AlterOwnerStmt:
4252                         retval = _copyAlterOwnerStmt(from);
4253                         break;
4254                 case T_RuleStmt:
4255                         retval = _copyRuleStmt(from);
4256                         break;
4257                 case T_NotifyStmt:
4258                         retval = _copyNotifyStmt(from);
4259                         break;
4260                 case T_ListenStmt:
4261                         retval = _copyListenStmt(from);
4262                         break;
4263                 case T_UnlistenStmt:
4264                         retval = _copyUnlistenStmt(from);
4265                         break;
4266                 case T_TransactionStmt:
4267                         retval = _copyTransactionStmt(from);
4268                         break;
4269                 case T_CompositeTypeStmt:
4270                         retval = _copyCompositeTypeStmt(from);
4271                         break;
4272                 case T_CreateEnumStmt:
4273                         retval = _copyCreateEnumStmt(from);
4274                         break;
4275                 case T_AlterEnumStmt:
4276                         retval = _copyAlterEnumStmt(from);
4277                         break;
4278                 case T_ViewStmt:
4279                         retval = _copyViewStmt(from);
4280                         break;
4281                 case T_LoadStmt:
4282                         retval = _copyLoadStmt(from);
4283                         break;
4284                 case T_CreateDomainStmt:
4285                         retval = _copyCreateDomainStmt(from);
4286                         break;
4287                 case T_CreateOpClassStmt:
4288                         retval = _copyCreateOpClassStmt(from);
4289                         break;
4290                 case T_CreateOpClassItem:
4291                         retval = _copyCreateOpClassItem(from);
4292                         break;
4293                 case T_CreateOpFamilyStmt:
4294                         retval = _copyCreateOpFamilyStmt(from);
4295                         break;
4296                 case T_AlterOpFamilyStmt:
4297                         retval = _copyAlterOpFamilyStmt(from);
4298                         break;
4299                 case T_CreatedbStmt:
4300                         retval = _copyCreatedbStmt(from);
4301                         break;
4302                 case T_AlterDatabaseStmt:
4303                         retval = _copyAlterDatabaseStmt(from);
4304                         break;
4305                 case T_AlterDatabaseSetStmt:
4306                         retval = _copyAlterDatabaseSetStmt(from);
4307                         break;
4308                 case T_DropdbStmt:
4309                         retval = _copyDropdbStmt(from);
4310                         break;
4311                 case T_VacuumStmt:
4312                         retval = _copyVacuumStmt(from);
4313                         break;
4314                 case T_ExplainStmt:
4315                         retval = _copyExplainStmt(from);
4316                         break;
4317                 case T_CreateSeqStmt:
4318                         retval = _copyCreateSeqStmt(from);
4319                         break;
4320                 case T_AlterSeqStmt:
4321                         retval = _copyAlterSeqStmt(from);
4322                         break;
4323                 case T_VariableSetStmt:
4324                         retval = _copyVariableSetStmt(from);
4325                         break;
4326                 case T_VariableShowStmt:
4327                         retval = _copyVariableShowStmt(from);
4328                         break;
4329                 case T_DiscardStmt:
4330                         retval = _copyDiscardStmt(from);
4331                         break;
4332                 case T_CreateTableSpaceStmt:
4333                         retval = _copyCreateTableSpaceStmt(from);
4334                         break;
4335                 case T_DropTableSpaceStmt:
4336                         retval = _copyDropTableSpaceStmt(from);
4337                         break;
4338                 case T_AlterTableSpaceOptionsStmt:
4339                         retval = _copyAlterTableSpaceOptionsStmt(from);
4340                         break;
4341                 case T_CreateExtensionStmt:
4342                         retval = _copyCreateExtensionStmt(from);
4343                         break;
4344                 case T_AlterExtensionStmt:
4345                         retval = _copyAlterExtensionStmt(from);
4346                         break;
4347                 case T_AlterExtensionContentsStmt:
4348                         retval = _copyAlterExtensionContentsStmt(from);
4349                         break;
4350                 case T_CreateFdwStmt:
4351                         retval = _copyCreateFdwStmt(from);
4352                         break;
4353                 case T_AlterFdwStmt:
4354                         retval = _copyAlterFdwStmt(from);
4355                         break;
4356                 case T_DropFdwStmt:
4357                         retval = _copyDropFdwStmt(from);
4358                         break;
4359                 case T_CreateForeignServerStmt:
4360                         retval = _copyCreateForeignServerStmt(from);
4361                         break;
4362                 case T_AlterForeignServerStmt:
4363                         retval = _copyAlterForeignServerStmt(from);
4364                         break;
4365                 case T_DropForeignServerStmt:
4366                         retval = _copyDropForeignServerStmt(from);
4367                         break;
4368                 case T_CreateUserMappingStmt:
4369                         retval = _copyCreateUserMappingStmt(from);
4370                         break;
4371                 case T_AlterUserMappingStmt:
4372                         retval = _copyAlterUserMappingStmt(from);
4373                         break;
4374                 case T_DropUserMappingStmt:
4375                         retval = _copyDropUserMappingStmt(from);
4376                         break;
4377                 case T_CreateForeignTableStmt:
4378                         retval = _copyCreateForeignTableStmt(from);
4379                         break;
4380                 case T_CreateTrigStmt:
4381                         retval = _copyCreateTrigStmt(from);
4382                         break;
4383                 case T_DropPropertyStmt:
4384                         retval = _copyDropPropertyStmt(from);
4385                         break;
4386                 case T_CreatePLangStmt:
4387                         retval = _copyCreatePLangStmt(from);
4388                         break;
4389                 case T_DropPLangStmt:
4390                         retval = _copyDropPLangStmt(from);
4391                         break;
4392                 case T_CreateRoleStmt:
4393                         retval = _copyCreateRoleStmt(from);
4394                         break;
4395                 case T_AlterRoleStmt:
4396                         retval = _copyAlterRoleStmt(from);
4397                         break;
4398                 case T_AlterRoleSetStmt:
4399                         retval = _copyAlterRoleSetStmt(from);
4400                         break;
4401                 case T_DropRoleStmt:
4402                         retval = _copyDropRoleStmt(from);
4403                         break;
4404                 case T_LockStmt:
4405                         retval = _copyLockStmt(from);
4406                         break;
4407                 case T_ConstraintsSetStmt:
4408                         retval = _copyConstraintsSetStmt(from);
4409                         break;
4410                 case T_ReindexStmt:
4411                         retval = _copyReindexStmt(from);
4412                         break;
4413                 case T_CheckPointStmt:
4414                         retval = (void *) makeNode(CheckPointStmt);
4415                         break;
4416                 case T_CreateSchemaStmt:
4417                         retval = _copyCreateSchemaStmt(from);
4418                         break;
4419                 case T_CreateConversionStmt:
4420                         retval = _copyCreateConversionStmt(from);
4421                         break;
4422                 case T_CreateCastStmt:
4423                         retval = _copyCreateCastStmt(from);
4424                         break;
4425                 case T_DropCastStmt:
4426                         retval = _copyDropCastStmt(from);
4427                         break;
4428                 case T_PrepareStmt:
4429                         retval = _copyPrepareStmt(from);
4430                         break;
4431                 case T_ExecuteStmt:
4432                         retval = _copyExecuteStmt(from);
4433                         break;
4434                 case T_DeallocateStmt:
4435                         retval = _copyDeallocateStmt(from);
4436                         break;
4437                 case T_DropOwnedStmt:
4438                         retval = _copyDropOwnedStmt(from);
4439                         break;
4440                 case T_ReassignOwnedStmt:
4441                         retval = _copyReassignOwnedStmt(from);
4442                         break;
4443                 case T_AlterTSDictionaryStmt:
4444                         retval = _copyAlterTSDictionaryStmt(from);
4445                         break;
4446                 case T_AlterTSConfigurationStmt:
4447                         retval = _copyAlterTSConfigurationStmt(from);
4448                         break;
4449
4450                 case T_A_Expr:
4451                         retval = _copyAExpr(from);
4452                         break;
4453                 case T_ColumnRef:
4454                         retval = _copyColumnRef(from);
4455                         break;
4456                 case T_ParamRef:
4457                         retval = _copyParamRef(from);
4458                         break;
4459                 case T_A_Const:
4460                         retval = _copyAConst(from);
4461                         break;
4462                 case T_FuncCall:
4463                         retval = _copyFuncCall(from);
4464                         break;
4465                 case T_A_Star:
4466                         retval = _copyAStar(from);
4467                         break;
4468                 case T_A_Indices:
4469                         retval = _copyAIndices(from);
4470                         break;
4471                 case T_A_Indirection:
4472                         retval = _copyA_Indirection(from);
4473                         break;
4474                 case T_A_ArrayExpr:
4475                         retval = _copyA_ArrayExpr(from);
4476                         break;
4477                 case T_ResTarget:
4478                         retval = _copyResTarget(from);
4479                         break;
4480                 case T_TypeCast:
4481                         retval = _copyTypeCast(from);
4482                         break;
4483                 case T_CollateClause:
4484                         retval = _copyCollateClause(from);
4485                         break;
4486                 case T_SortBy:
4487                         retval = _copySortBy(from);
4488                         break;
4489                 case T_WindowDef:
4490                         retval = _copyWindowDef(from);
4491                         break;
4492                 case T_RangeSubselect:
4493                         retval = _copyRangeSubselect(from);
4494                         break;
4495                 case T_RangeFunction:
4496                         retval = _copyRangeFunction(from);
4497                         break;
4498                 case T_TypeName:
4499                         retval = _copyTypeName(from);
4500                         break;
4501                 case T_IndexElem:
4502                         retval = _copyIndexElem(from);
4503                         break;
4504                 case T_ColumnDef:
4505                         retval = _copyColumnDef(from);
4506                         break;
4507                 case T_Constraint:
4508                         retval = _copyConstraint(from);
4509                         break;
4510                 case T_DefElem:
4511                         retval = _copyDefElem(from);
4512                         break;
4513                 case T_LockingClause:
4514                         retval = _copyLockingClause(from);
4515                         break;
4516                 case T_RangeTblEntry:
4517                         retval = _copyRangeTblEntry(from);
4518                         break;
4519                 case T_SortGroupClause:
4520                         retval = _copySortGroupClause(from);
4521                         break;
4522                 case T_WindowClause:
4523                         retval = _copyWindowClause(from);
4524                         break;
4525                 case T_RowMarkClause:
4526                         retval = _copyRowMarkClause(from);
4527                         break;
4528                 case T_WithClause:
4529                         retval = _copyWithClause(from);
4530                         break;
4531                 case T_CommonTableExpr:
4532                         retval = _copyCommonTableExpr(from);
4533                         break;
4534                 case T_PrivGrantee:
4535                         retval = _copyPrivGrantee(from);
4536                         break;
4537                 case T_FuncWithArgs:
4538                         retval = _copyFuncWithArgs(from);
4539                         break;
4540                 case T_AccessPriv:
4541                         retval = _copyAccessPriv(from);
4542                         break;
4543                 case T_XmlSerialize:
4544                         retval = _copyXmlSerialize(from);
4545                         break;
4546
4547                 default:
4548                         elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
4549                         retval = from;          /* keep compiler quiet */
4550                         break;
4551         }
4552
4553         return retval;
4554 }