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