PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
copyfuncs.c
Go to the documentation of this file.
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-2017, 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/extensible.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
30 #include "utils/rel.h"
31 
32 
33 /*
34  * Macros to simplify copying of different kinds of fields. Use these
35  * wherever possible to reduce the chance for silly typos. Note that these
36  * hard-wire the convention that the local variables in a Copy routine are
37  * named 'newnode' and 'from'.
38  */
39 
40 /* Copy a simple scalar field (int, float, bool, enum, etc) */
41 #define COPY_SCALAR_FIELD(fldname) \
42  (newnode->fldname = from->fldname)
43 
44 /* Copy a field that is a pointer to some kind of Node or Node tree */
45 #define COPY_NODE_FIELD(fldname) \
46  (newnode->fldname = copyObject(from->fldname))
47 
48 /* Copy a field that is a pointer to a Bitmapset */
49 #define COPY_BITMAPSET_FIELD(fldname) \
50  (newnode->fldname = bms_copy(from->fldname))
51 
52 /* Copy a field that is a pointer to a C string, or perhaps NULL */
53 #define COPY_STRING_FIELD(fldname) \
54  (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
55 
56 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
57 #define COPY_POINTER_FIELD(fldname, sz) \
58  do { \
59  Size _size = (sz); \
60  newnode->fldname = palloc(_size); \
61  memcpy(newnode->fldname, from->fldname, _size); \
62  } while (0)
63 
64 /* Copy a parse location field (for Copy, this is same as scalar case) */
65 #define COPY_LOCATION_FIELD(fldname) \
66  (newnode->fldname = from->fldname)
67 
68 
69 /* ****************************************************************
70  * plannodes.h copy functions
71  * ****************************************************************
72  */
73 
74 /*
75  * _copyPlannedStmt
76  */
77 static PlannedStmt *
79 {
80  PlannedStmt *newnode = makeNode(PlannedStmt);
81 
82  COPY_SCALAR_FIELD(commandType);
83  COPY_SCALAR_FIELD(queryId);
84  COPY_SCALAR_FIELD(hasReturning);
85  COPY_SCALAR_FIELD(hasModifyingCTE);
86  COPY_SCALAR_FIELD(canSetTag);
87  COPY_SCALAR_FIELD(transientPlan);
88  COPY_SCALAR_FIELD(dependsOnRole);
89  COPY_SCALAR_FIELD(parallelModeNeeded);
90  COPY_NODE_FIELD(planTree);
91  COPY_NODE_FIELD(rtable);
92  COPY_NODE_FIELD(resultRelations);
93  COPY_NODE_FIELD(nonleafResultRelations);
94  COPY_NODE_FIELD(subplans);
95  COPY_BITMAPSET_FIELD(rewindPlanIDs);
96  COPY_NODE_FIELD(rowMarks);
97  COPY_NODE_FIELD(relationOids);
98  COPY_NODE_FIELD(invalItems);
99  COPY_SCALAR_FIELD(nParamExec);
100  COPY_NODE_FIELD(utilityStmt);
101  COPY_LOCATION_FIELD(stmt_location);
102  COPY_LOCATION_FIELD(stmt_len);
103 
104  return newnode;
105 }
106 
107 /*
108  * CopyPlanFields
109  *
110  * This function copies the fields of the Plan node. It is used by
111  * all the copy functions for classes which inherit from Plan.
112  */
113 static void
114 CopyPlanFields(const Plan *from, Plan *newnode)
115 {
116  COPY_SCALAR_FIELD(startup_cost);
117  COPY_SCALAR_FIELD(total_cost);
118  COPY_SCALAR_FIELD(plan_rows);
119  COPY_SCALAR_FIELD(plan_width);
120  COPY_SCALAR_FIELD(parallel_aware);
121  COPY_SCALAR_FIELD(plan_node_id);
122  COPY_NODE_FIELD(targetlist);
123  COPY_NODE_FIELD(qual);
124  COPY_NODE_FIELD(lefttree);
125  COPY_NODE_FIELD(righttree);
126  COPY_NODE_FIELD(initPlan);
127  COPY_BITMAPSET_FIELD(extParam);
128  COPY_BITMAPSET_FIELD(allParam);
129 }
130 
131 /*
132  * _copyPlan
133  */
134 static Plan *
135 _copyPlan(const Plan *from)
136 {
137  Plan *newnode = makeNode(Plan);
138 
139  /*
140  * copy node superclass fields
141  */
142  CopyPlanFields(from, newnode);
143 
144  return newnode;
145 }
146 
147 
148 /*
149  * _copyResult
150  */
151 static Result *
152 _copyResult(const Result *from)
153 {
154  Result *newnode = makeNode(Result);
155 
156  /*
157  * copy node superclass fields
158  */
159  CopyPlanFields((const Plan *) from, (Plan *) newnode);
160 
161  /*
162  * copy remainder of node
163  */
164  COPY_NODE_FIELD(resconstantqual);
165 
166  return newnode;
167 }
168 
169 /*
170  * _copyProjectSet
171  */
172 static ProjectSet *
174 {
175  ProjectSet *newnode = makeNode(ProjectSet);
176 
177  /*
178  * copy node superclass fields
179  */
180  CopyPlanFields((const Plan *) from, (Plan *) newnode);
181 
182  return newnode;
183 }
184 
185 /*
186  * _copyModifyTable
187  */
188 static ModifyTable *
190 {
191  ModifyTable *newnode = makeNode(ModifyTable);
192 
193  /*
194  * copy node superclass fields
195  */
196  CopyPlanFields((const Plan *) from, (Plan *) newnode);
197 
198  /*
199  * copy remainder of node
200  */
201  COPY_SCALAR_FIELD(operation);
202  COPY_SCALAR_FIELD(canSetTag);
203  COPY_SCALAR_FIELD(nominalRelation);
204  COPY_NODE_FIELD(partitioned_rels);
205  COPY_NODE_FIELD(resultRelations);
206  COPY_SCALAR_FIELD(resultRelIndex);
207  COPY_NODE_FIELD(plans);
208  COPY_NODE_FIELD(withCheckOptionLists);
209  COPY_NODE_FIELD(returningLists);
210  COPY_NODE_FIELD(fdwPrivLists);
211  COPY_BITMAPSET_FIELD(fdwDirectModifyPlans);
212  COPY_NODE_FIELD(rowMarks);
213  COPY_SCALAR_FIELD(epqParam);
214  COPY_SCALAR_FIELD(onConflictAction);
215  COPY_NODE_FIELD(arbiterIndexes);
216  COPY_NODE_FIELD(onConflictSet);
217  COPY_NODE_FIELD(onConflictWhere);
218  COPY_SCALAR_FIELD(exclRelRTI);
219  COPY_NODE_FIELD(exclRelTlist);
220 
221  return newnode;
222 }
223 
224 /*
225  * _copyAppend
226  */
227 static Append *
228 _copyAppend(const Append *from)
229 {
230  Append *newnode = makeNode(Append);
231 
232  /*
233  * copy node superclass fields
234  */
235  CopyPlanFields((const Plan *) from, (Plan *) newnode);
236 
237  /*
238  * copy remainder of node
239  */
240  COPY_NODE_FIELD(partitioned_rels);
241  COPY_NODE_FIELD(appendplans);
242 
243  return newnode;
244 }
245 
246 /*
247  * _copyMergeAppend
248  */
249 static MergeAppend *
251 {
252  MergeAppend *newnode = makeNode(MergeAppend);
253 
254  /*
255  * copy node superclass fields
256  */
257  CopyPlanFields((const Plan *) from, (Plan *) newnode);
258 
259  /*
260  * copy remainder of node
261  */
262  COPY_NODE_FIELD(partitioned_rels);
263  COPY_NODE_FIELD(mergeplans);
264  COPY_SCALAR_FIELD(numCols);
265  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
266  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
267  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
268  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
269 
270  return newnode;
271 }
272 
273 /*
274  * _copyRecursiveUnion
275  */
276 static RecursiveUnion *
278 {
280 
281  /*
282  * copy node superclass fields
283  */
284  CopyPlanFields((const Plan *) from, (Plan *) newnode);
285 
286  /*
287  * copy remainder of node
288  */
289  COPY_SCALAR_FIELD(wtParam);
290  COPY_SCALAR_FIELD(numCols);
291  if (from->numCols > 0)
292  {
293  COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
294  COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
295  }
296  COPY_SCALAR_FIELD(numGroups);
297 
298  return newnode;
299 }
300 
301 /*
302  * _copyBitmapAnd
303  */
304 static BitmapAnd *
306 {
307  BitmapAnd *newnode = makeNode(BitmapAnd);
308 
309  /*
310  * copy node superclass fields
311  */
312  CopyPlanFields((const Plan *) from, (Plan *) newnode);
313 
314  /*
315  * copy remainder of node
316  */
317  COPY_NODE_FIELD(bitmapplans);
318 
319  return newnode;
320 }
321 
322 /*
323  * _copyBitmapOr
324  */
325 static BitmapOr *
327 {
328  BitmapOr *newnode = makeNode(BitmapOr);
329 
330  /*
331  * copy node superclass fields
332  */
333  CopyPlanFields((const Plan *) from, (Plan *) newnode);
334 
335  /*
336  * copy remainder of node
337  */
338  COPY_SCALAR_FIELD(isshared);
339  COPY_NODE_FIELD(bitmapplans);
340 
341  return newnode;
342 }
343 
344 /*
345  * _copyGather
346  */
347 static Gather *
348 _copyGather(const Gather *from)
349 {
350  Gather *newnode = makeNode(Gather);
351 
352  /*
353  * copy node superclass fields
354  */
355  CopyPlanFields((const Plan *) from, (Plan *) newnode);
356 
357  /*
358  * copy remainder of node
359  */
360  COPY_SCALAR_FIELD(num_workers);
361  COPY_SCALAR_FIELD(single_copy);
362  COPY_SCALAR_FIELD(invisible);
363 
364  return newnode;
365 }
366 
367 /*
368  * _copyGatherMerge
369  */
370 static GatherMerge *
372 {
373  GatherMerge *newnode = makeNode(GatherMerge);
374 
375  /*
376  * copy node superclass fields
377  */
378  CopyPlanFields((const Plan *) from, (Plan *) newnode);
379 
380  /*
381  * copy remainder of node
382  */
383  COPY_SCALAR_FIELD(num_workers);
384  COPY_SCALAR_FIELD(numCols);
385  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
386  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
387  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
388  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
389 
390  return newnode;
391 }
392 
393 /*
394  * CopyScanFields
395  *
396  * This function copies the fields of the Scan node. It is used by
397  * all the copy functions for classes which inherit from Scan.
398  */
399 static void
400 CopyScanFields(const Scan *from, Scan *newnode)
401 {
402  CopyPlanFields((const Plan *) from, (Plan *) newnode);
403 
404  COPY_SCALAR_FIELD(scanrelid);
405 }
406 
407 /*
408  * _copyScan
409  */
410 static Scan *
411 _copyScan(const Scan *from)
412 {
413  Scan *newnode = makeNode(Scan);
414 
415  /*
416  * copy node superclass fields
417  */
418  CopyScanFields((const Scan *) from, (Scan *) newnode);
419 
420  return newnode;
421 }
422 
423 /*
424  * _copySeqScan
425  */
426 static SeqScan *
427 _copySeqScan(const SeqScan *from)
428 {
429  SeqScan *newnode = makeNode(SeqScan);
430 
431  /*
432  * copy node superclass fields
433  */
434  CopyScanFields((const Scan *) from, (Scan *) newnode);
435 
436  return newnode;
437 }
438 
439 /*
440  * _copySampleScan
441  */
442 static SampleScan *
444 {
445  SampleScan *newnode = makeNode(SampleScan);
446 
447  /*
448  * copy node superclass fields
449  */
450  CopyScanFields((const Scan *) from, (Scan *) newnode);
451 
452  /*
453  * copy remainder of node
454  */
455  COPY_NODE_FIELD(tablesample);
456 
457  return newnode;
458 }
459 
460 /*
461  * _copyIndexScan
462  */
463 static IndexScan *
465 {
466  IndexScan *newnode = makeNode(IndexScan);
467 
468  /*
469  * copy node superclass fields
470  */
471  CopyScanFields((const Scan *) from, (Scan *) newnode);
472 
473  /*
474  * copy remainder of node
475  */
476  COPY_SCALAR_FIELD(indexid);
477  COPY_NODE_FIELD(indexqual);
478  COPY_NODE_FIELD(indexqualorig);
479  COPY_NODE_FIELD(indexorderby);
480  COPY_NODE_FIELD(indexorderbyorig);
481  COPY_NODE_FIELD(indexorderbyops);
482  COPY_SCALAR_FIELD(indexorderdir);
483 
484  return newnode;
485 }
486 
487 /*
488  * _copyIndexOnlyScan
489  */
490 static IndexOnlyScan *
492 {
494 
495  /*
496  * copy node superclass fields
497  */
498  CopyScanFields((const Scan *) from, (Scan *) newnode);
499 
500  /*
501  * copy remainder of node
502  */
503  COPY_SCALAR_FIELD(indexid);
504  COPY_NODE_FIELD(indexqual);
505  COPY_NODE_FIELD(indexorderby);
506  COPY_NODE_FIELD(indextlist);
507  COPY_SCALAR_FIELD(indexorderdir);
508 
509  return newnode;
510 }
511 
512 /*
513  * _copyBitmapIndexScan
514  */
515 static BitmapIndexScan *
517 {
519 
520  /*
521  * copy node superclass fields
522  */
523  CopyScanFields((const Scan *) from, (Scan *) newnode);
524 
525  /*
526  * copy remainder of node
527  */
528  COPY_SCALAR_FIELD(indexid);
529  COPY_SCALAR_FIELD(isshared);
530  COPY_NODE_FIELD(indexqual);
531  COPY_NODE_FIELD(indexqualorig);
532 
533  return newnode;
534 }
535 
536 /*
537  * _copyBitmapHeapScan
538  */
539 static BitmapHeapScan *
541 {
543 
544  /*
545  * copy node superclass fields
546  */
547  CopyScanFields((const Scan *) from, (Scan *) newnode);
548 
549  /*
550  * copy remainder of node
551  */
552  COPY_NODE_FIELD(bitmapqualorig);
553 
554  return newnode;
555 }
556 
557 /*
558  * _copyTidScan
559  */
560 static TidScan *
561 _copyTidScan(const TidScan *from)
562 {
563  TidScan *newnode = makeNode(TidScan);
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_NODE_FIELD(tidquals);
574 
575  return newnode;
576 }
577 
578 /*
579  * _copySubqueryScan
580  */
581 static SubqueryScan *
583 {
584  SubqueryScan *newnode = makeNode(SubqueryScan);
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(subplan);
595 
596  return newnode;
597 }
598 
599 /*
600  * _copyFunctionScan
601  */
602 static FunctionScan *
604 {
605  FunctionScan *newnode = makeNode(FunctionScan);
606 
607  /*
608  * copy node superclass fields
609  */
610  CopyScanFields((const Scan *) from, (Scan *) newnode);
611 
612  /*
613  * copy remainder of node
614  */
616  COPY_SCALAR_FIELD(funcordinality);
617 
618  return newnode;
619 }
620 
621 /*
622  * _copyTableFuncScan
623  */
624 static TableFuncScan *
626 {
628 
629  /*
630  * copy node superclass fields
631  */
632  CopyScanFields((const Scan *) from, (Scan *) newnode);
633 
634  /*
635  * copy remainder of node
636  */
637  COPY_NODE_FIELD(tablefunc);
638 
639  return newnode;
640 }
641 
642 /*
643  * _copyValuesScan
644  */
645 static ValuesScan *
647 {
648  ValuesScan *newnode = makeNode(ValuesScan);
649 
650  /*
651  * copy node superclass fields
652  */
653  CopyScanFields((const Scan *) from, (Scan *) newnode);
654 
655  /*
656  * copy remainder of node
657  */
658  COPY_NODE_FIELD(values_lists);
659 
660  return newnode;
661 }
662 
663 /*
664  * _copyCteScan
665  */
666 static CteScan *
667 _copyCteScan(const CteScan *from)
668 {
669  CteScan *newnode = makeNode(CteScan);
670 
671  /*
672  * copy node superclass fields
673  */
674  CopyScanFields((const Scan *) from, (Scan *) newnode);
675 
676  /*
677  * copy remainder of node
678  */
679  COPY_SCALAR_FIELD(ctePlanId);
680  COPY_SCALAR_FIELD(cteParam);
681 
682  return newnode;
683 }
684 
685 /*
686  * _copyWorkTableScan
687  */
688 static WorkTableScan *
690 {
692 
693  /*
694  * copy node superclass fields
695  */
696  CopyScanFields((const Scan *) from, (Scan *) newnode);
697 
698  /*
699  * copy remainder of node
700  */
701  COPY_SCALAR_FIELD(wtParam);
702 
703  return newnode;
704 }
705 
706 /*
707  * _copyForeignScan
708  */
709 static ForeignScan *
711 {
712  ForeignScan *newnode = makeNode(ForeignScan);
713 
714  /*
715  * copy node superclass fields
716  */
717  CopyScanFields((const Scan *) from, (Scan *) newnode);
718 
719  /*
720  * copy remainder of node
721  */
722  COPY_SCALAR_FIELD(operation);
723  COPY_SCALAR_FIELD(fs_server);
724  COPY_NODE_FIELD(fdw_exprs);
725  COPY_NODE_FIELD(fdw_private);
726  COPY_NODE_FIELD(fdw_scan_tlist);
727  COPY_NODE_FIELD(fdw_recheck_quals);
728  COPY_BITMAPSET_FIELD(fs_relids);
729  COPY_SCALAR_FIELD(fsSystemCol);
730 
731  return newnode;
732 }
733 
734 /*
735  * _copyCustomScan
736  */
737 static CustomScan *
739 {
740  CustomScan *newnode = makeNode(CustomScan);
741 
742  /*
743  * copy node superclass fields
744  */
745  CopyScanFields((const Scan *) from, (Scan *) newnode);
746 
747  /*
748  * copy remainder of node
749  */
750  COPY_SCALAR_FIELD(flags);
751  COPY_NODE_FIELD(custom_plans);
752  COPY_NODE_FIELD(custom_exprs);
753  COPY_NODE_FIELD(custom_private);
754  COPY_NODE_FIELD(custom_scan_tlist);
755  COPY_BITMAPSET_FIELD(custom_relids);
756 
757  /*
758  * NOTE: The method field of CustomScan is required to be a pointer to a
759  * static table of callback functions. So we don't copy the table itself,
760  * just reference the original one.
761  */
762  COPY_SCALAR_FIELD(methods);
763 
764  return newnode;
765 }
766 
767 /*
768  * CopyJoinFields
769  *
770  * This function copies the fields of the Join node. It is used by
771  * all the copy functions for classes which inherit from Join.
772  */
773 static void
774 CopyJoinFields(const Join *from, Join *newnode)
775 {
776  CopyPlanFields((const Plan *) from, (Plan *) newnode);
777 
778  COPY_SCALAR_FIELD(jointype);
779  COPY_NODE_FIELD(joinqual);
780 }
781 
782 
783 /*
784  * _copyJoin
785  */
786 static Join *
787 _copyJoin(const Join *from)
788 {
789  Join *newnode = makeNode(Join);
790 
791  /*
792  * copy node superclass fields
793  */
794  CopyJoinFields(from, newnode);
795 
796  return newnode;
797 }
798 
799 
800 /*
801  * _copyNestLoop
802  */
803 static NestLoop *
805 {
806  NestLoop *newnode = makeNode(NestLoop);
807 
808  /*
809  * copy node superclass fields
810  */
811  CopyJoinFields((const Join *) from, (Join *) newnode);
812 
813  /*
814  * copy remainder of node
815  */
816  COPY_NODE_FIELD(nestParams);
817 
818  return newnode;
819 }
820 
821 
822 /*
823  * _copyMergeJoin
824  */
825 static MergeJoin *
827 {
828  MergeJoin *newnode = makeNode(MergeJoin);
829  int numCols;
830 
831  /*
832  * copy node superclass fields
833  */
834  CopyJoinFields((const Join *) from, (Join *) newnode);
835 
836  /*
837  * copy remainder of node
838  */
839  COPY_NODE_FIELD(mergeclauses);
840  numCols = list_length(from->mergeclauses);
841  if (numCols > 0)
842  {
843  COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
844  COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
845  COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
846  COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
847  }
848 
849  return newnode;
850 }
851 
852 /*
853  * _copyHashJoin
854  */
855 static HashJoin *
857 {
858  HashJoin *newnode = makeNode(HashJoin);
859 
860  /*
861  * copy node superclass fields
862  */
863  CopyJoinFields((const Join *) from, (Join *) newnode);
864 
865  /*
866  * copy remainder of node
867  */
868  COPY_NODE_FIELD(hashclauses);
869 
870  return newnode;
871 }
872 
873 
874 /*
875  * _copyMaterial
876  */
877 static Material *
879 {
880  Material *newnode = makeNode(Material);
881 
882  /*
883  * copy node superclass fields
884  */
885  CopyPlanFields((const Plan *) from, (Plan *) newnode);
886 
887  return newnode;
888 }
889 
890 
891 /*
892  * _copySort
893  */
894 static Sort *
895 _copySort(const Sort *from)
896 {
897  Sort *newnode = makeNode(Sort);
898 
899  /*
900  * copy node superclass fields
901  */
902  CopyPlanFields((const Plan *) from, (Plan *) newnode);
903 
904  COPY_SCALAR_FIELD(numCols);
905  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
906  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
907  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
908  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
909 
910  return newnode;
911 }
912 
913 
914 /*
915  * _copyGroup
916  */
917 static Group *
918 _copyGroup(const Group *from)
919 {
920  Group *newnode = makeNode(Group);
921 
922  CopyPlanFields((const Plan *) from, (Plan *) newnode);
923 
924  COPY_SCALAR_FIELD(numCols);
925  COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
926  COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
927 
928  return newnode;
929 }
930 
931 /*
932  * _copyAgg
933  */
934 static Agg *
935 _copyAgg(const Agg *from)
936 {
937  Agg *newnode = makeNode(Agg);
938 
939  CopyPlanFields((const Plan *) from, (Plan *) newnode);
940 
941  COPY_SCALAR_FIELD(aggstrategy);
942  COPY_SCALAR_FIELD(aggsplit);
943  COPY_SCALAR_FIELD(numCols);
944  if (from->numCols > 0)
945  {
946  COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
947  COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
948  }
949  COPY_SCALAR_FIELD(numGroups);
950  COPY_BITMAPSET_FIELD(aggParams);
951  COPY_NODE_FIELD(groupingSets);
952  COPY_NODE_FIELD(chain);
953 
954  return newnode;
955 }
956 
957 /*
958  * _copyWindowAgg
959  */
960 static WindowAgg *
962 {
963  WindowAgg *newnode = makeNode(WindowAgg);
964 
965  CopyPlanFields((const Plan *) from, (Plan *) newnode);
966 
967  COPY_SCALAR_FIELD(winref);
968  COPY_SCALAR_FIELD(partNumCols);
969  if (from->partNumCols > 0)
970  {
971  COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
972  COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
973  }
974  COPY_SCALAR_FIELD(ordNumCols);
975  if (from->ordNumCols > 0)
976  {
977  COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
978  COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
979  }
980  COPY_SCALAR_FIELD(frameOptions);
981  COPY_NODE_FIELD(startOffset);
982  COPY_NODE_FIELD(endOffset);
983 
984  return newnode;
985 }
986 
987 /*
988  * _copyUnique
989  */
990 static Unique *
991 _copyUnique(const Unique *from)
992 {
993  Unique *newnode = makeNode(Unique);
994 
995  /*
996  * copy node superclass fields
997  */
998  CopyPlanFields((const Plan *) from, (Plan *) newnode);
999 
1000  /*
1001  * copy remainder of node
1002  */
1003  COPY_SCALAR_FIELD(numCols);
1004  COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
1005  COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
1006 
1007  return newnode;
1008 }
1009 
1010 /*
1011  * _copyHash
1012  */
1013 static Hash *
1014 _copyHash(const Hash *from)
1015 {
1016  Hash *newnode = makeNode(Hash);
1017 
1018  /*
1019  * copy node superclass fields
1020  */
1021  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1022 
1023  /*
1024  * copy remainder of node
1025  */
1026  COPY_SCALAR_FIELD(skewTable);
1027  COPY_SCALAR_FIELD(skewColumn);
1028  COPY_SCALAR_FIELD(skewInherit);
1029  COPY_SCALAR_FIELD(skewColType);
1030  COPY_SCALAR_FIELD(skewColTypmod);
1031 
1032  return newnode;
1033 }
1034 
1035 /*
1036  * _copySetOp
1037  */
1038 static SetOp *
1039 _copySetOp(const SetOp *from)
1040 {
1041  SetOp *newnode = makeNode(SetOp);
1042 
1043  /*
1044  * copy node superclass fields
1045  */
1046  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1047 
1048  /*
1049  * copy remainder of node
1050  */
1051  COPY_SCALAR_FIELD(cmd);
1052  COPY_SCALAR_FIELD(strategy);
1053  COPY_SCALAR_FIELD(numCols);
1054  COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
1055  COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
1056  COPY_SCALAR_FIELD(flagColIdx);
1057  COPY_SCALAR_FIELD(firstFlag);
1058  COPY_SCALAR_FIELD(numGroups);
1059 
1060  return newnode;
1061 }
1062 
1063 /*
1064  * _copyLockRows
1065  */
1066 static LockRows *
1068 {
1069  LockRows *newnode = makeNode(LockRows);
1070 
1071  /*
1072  * copy node superclass fields
1073  */
1074  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1075 
1076  /*
1077  * copy remainder of node
1078  */
1079  COPY_NODE_FIELD(rowMarks);
1080  COPY_SCALAR_FIELD(epqParam);
1081 
1082  return newnode;
1083 }
1084 
1085 /*
1086  * _copyLimit
1087  */
1088 static Limit *
1089 _copyLimit(const Limit *from)
1090 {
1091  Limit *newnode = makeNode(Limit);
1092 
1093  /*
1094  * copy node superclass fields
1095  */
1096  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1097 
1098  /*
1099  * copy remainder of node
1100  */
1101  COPY_NODE_FIELD(limitOffset);
1102  COPY_NODE_FIELD(limitCount);
1103 
1104  return newnode;
1105 }
1106 
1107 /*
1108  * _copyNestLoopParam
1109  */
1110 static NestLoopParam *
1112 {
1113  NestLoopParam *newnode = makeNode(NestLoopParam);
1114 
1115  COPY_SCALAR_FIELD(paramno);
1116  COPY_NODE_FIELD(paramval);
1117 
1118  return newnode;
1119 }
1120 
1121 /*
1122  * _copyPlanRowMark
1123  */
1124 static PlanRowMark *
1126 {
1127  PlanRowMark *newnode = makeNode(PlanRowMark);
1128 
1129  COPY_SCALAR_FIELD(rti);
1130  COPY_SCALAR_FIELD(prti);
1131  COPY_SCALAR_FIELD(rowmarkId);
1132  COPY_SCALAR_FIELD(markType);
1133  COPY_SCALAR_FIELD(allMarkTypes);
1134  COPY_SCALAR_FIELD(strength);
1135  COPY_SCALAR_FIELD(waitPolicy);
1136  COPY_SCALAR_FIELD(isParent);
1137 
1138  return newnode;
1139 }
1140 
1141 /*
1142  * _copyPlanInvalItem
1143  */
1144 static PlanInvalItem *
1146 {
1147  PlanInvalItem *newnode = makeNode(PlanInvalItem);
1148 
1149  COPY_SCALAR_FIELD(cacheId);
1150  COPY_SCALAR_FIELD(hashValue);
1151 
1152  return newnode;
1153 }
1154 
1155 /* ****************************************************************
1156  * primnodes.h copy functions
1157  * ****************************************************************
1158  */
1159 
1160 /*
1161  * _copyAlias
1162  */
1163 static Alias *
1164 _copyAlias(const Alias *from)
1165 {
1166  Alias *newnode = makeNode(Alias);
1167 
1168  COPY_STRING_FIELD(aliasname);
1169  COPY_NODE_FIELD(colnames);
1170 
1171  return newnode;
1172 }
1173 
1174 /*
1175  * _copyRangeVar
1176  */
1177 static RangeVar *
1179 {
1180  RangeVar *newnode = makeNode(RangeVar);
1181 
1182  COPY_STRING_FIELD(catalogname);
1183  COPY_STRING_FIELD(schemaname);
1184  COPY_STRING_FIELD(relname);
1185  COPY_SCALAR_FIELD(inh);
1186  COPY_SCALAR_FIELD(relpersistence);
1187  COPY_NODE_FIELD(alias);
1188  COPY_LOCATION_FIELD(location);
1189 
1190  return newnode;
1191 }
1192 
1193 /*
1194  * _copyTableFunc
1195  */
1196 static TableFunc *
1198 {
1199  TableFunc *newnode = makeNode(TableFunc);
1200 
1201  COPY_NODE_FIELD(ns_names);
1202  COPY_NODE_FIELD(ns_uris);
1203  COPY_NODE_FIELD(docexpr);
1204  COPY_NODE_FIELD(rowexpr);
1205  COPY_NODE_FIELD(colnames);
1206  COPY_NODE_FIELD(coltypes);
1207  COPY_NODE_FIELD(coltypmods);
1208  COPY_NODE_FIELD(colcollations);
1209  COPY_NODE_FIELD(colexprs);
1210  COPY_NODE_FIELD(coldefexprs);
1211  COPY_BITMAPSET_FIELD(notnulls);
1212  COPY_SCALAR_FIELD(ordinalitycol);
1213  COPY_LOCATION_FIELD(location);
1214 
1215  return newnode;
1216 }
1217 
1218 /*
1219  * _copyIntoClause
1220  */
1221 static IntoClause *
1223 {
1224  IntoClause *newnode = makeNode(IntoClause);
1225 
1226  COPY_NODE_FIELD(rel);
1227  COPY_NODE_FIELD(colNames);
1229  COPY_SCALAR_FIELD(onCommit);
1230  COPY_STRING_FIELD(tableSpaceName);
1231  COPY_NODE_FIELD(viewQuery);
1232  COPY_SCALAR_FIELD(skipData);
1233 
1234  return newnode;
1235 }
1236 
1237 /*
1238  * We don't need a _copyExpr because Expr is an abstract supertype which
1239  * should never actually get instantiated. Also, since it has no common
1240  * fields except NodeTag, there's no need for a helper routine to factor
1241  * out copying the common fields...
1242  */
1243 
1244 /*
1245  * _copyVar
1246  */
1247 static Var *
1248 _copyVar(const Var *from)
1249 {
1250  Var *newnode = makeNode(Var);
1251 
1252  COPY_SCALAR_FIELD(varno);
1253  COPY_SCALAR_FIELD(varattno);
1254  COPY_SCALAR_FIELD(vartype);
1255  COPY_SCALAR_FIELD(vartypmod);
1256  COPY_SCALAR_FIELD(varcollid);
1257  COPY_SCALAR_FIELD(varlevelsup);
1258  COPY_SCALAR_FIELD(varnoold);
1259  COPY_SCALAR_FIELD(varoattno);
1260  COPY_LOCATION_FIELD(location);
1261 
1262  return newnode;
1263 }
1264 
1265 /*
1266  * _copyConst
1267  */
1268 static Const *
1269 _copyConst(const Const *from)
1270 {
1271  Const *newnode = makeNode(Const);
1272 
1273  COPY_SCALAR_FIELD(consttype);
1274  COPY_SCALAR_FIELD(consttypmod);
1275  COPY_SCALAR_FIELD(constcollid);
1276  COPY_SCALAR_FIELD(constlen);
1277 
1278  if (from->constbyval || from->constisnull)
1279  {
1280  /*
1281  * passed by value so just copy the datum. Also, don't try to copy
1282  * struct when value is null!
1283  */
1284  newnode->constvalue = from->constvalue;
1285  }
1286  else
1287  {
1288  /*
1289  * passed by reference. We need a palloc'd copy.
1290  */
1291  newnode->constvalue = datumCopy(from->constvalue,
1292  from->constbyval,
1293  from->constlen);
1294  }
1295 
1296  COPY_SCALAR_FIELD(constisnull);
1297  COPY_SCALAR_FIELD(constbyval);
1298  COPY_LOCATION_FIELD(location);
1299 
1300  return newnode;
1301 }
1302 
1303 /*
1304  * _copyParam
1305  */
1306 static Param *
1307 _copyParam(const Param *from)
1308 {
1309  Param *newnode = makeNode(Param);
1310 
1311  COPY_SCALAR_FIELD(paramkind);
1312  COPY_SCALAR_FIELD(paramid);
1313  COPY_SCALAR_FIELD(paramtype);
1314  COPY_SCALAR_FIELD(paramtypmod);
1315  COPY_SCALAR_FIELD(paramcollid);
1316  COPY_LOCATION_FIELD(location);
1317 
1318  return newnode;
1319 }
1320 
1321 /*
1322  * _copyAggref
1323  */
1324 static Aggref *
1325 _copyAggref(const Aggref *from)
1326 {
1327  Aggref *newnode = makeNode(Aggref);
1328 
1329  COPY_SCALAR_FIELD(aggfnoid);
1330  COPY_SCALAR_FIELD(aggtype);
1331  COPY_SCALAR_FIELD(aggcollid);
1332  COPY_SCALAR_FIELD(inputcollid);
1333  COPY_SCALAR_FIELD(aggtranstype);
1334  COPY_NODE_FIELD(aggargtypes);
1335  COPY_NODE_FIELD(aggdirectargs);
1337  COPY_NODE_FIELD(aggorder);
1338  COPY_NODE_FIELD(aggdistinct);
1339  COPY_NODE_FIELD(aggfilter);
1340  COPY_SCALAR_FIELD(aggstar);
1341  COPY_SCALAR_FIELD(aggvariadic);
1342  COPY_SCALAR_FIELD(aggkind);
1343  COPY_SCALAR_FIELD(agglevelsup);
1344  COPY_SCALAR_FIELD(aggsplit);
1345  COPY_LOCATION_FIELD(location);
1346 
1347  return newnode;
1348 }
1349 
1350 /*
1351  * _copyGroupingFunc
1352  */
1353 static GroupingFunc *
1355 {
1356  GroupingFunc *newnode = makeNode(GroupingFunc);
1357 
1359  COPY_NODE_FIELD(refs);
1360  COPY_NODE_FIELD(cols);
1361  COPY_SCALAR_FIELD(agglevelsup);
1362  COPY_LOCATION_FIELD(location);
1363 
1364  return newnode;
1365 }
1366 
1367 /*
1368  * _copyWindowFunc
1369  */
1370 static WindowFunc *
1372 {
1373  WindowFunc *newnode = makeNode(WindowFunc);
1374 
1375  COPY_SCALAR_FIELD(winfnoid);
1376  COPY_SCALAR_FIELD(wintype);
1377  COPY_SCALAR_FIELD(wincollid);
1378  COPY_SCALAR_FIELD(inputcollid);
1380  COPY_NODE_FIELD(aggfilter);
1381  COPY_SCALAR_FIELD(winref);
1382  COPY_SCALAR_FIELD(winstar);
1383  COPY_SCALAR_FIELD(winagg);
1384  COPY_LOCATION_FIELD(location);
1385 
1386  return newnode;
1387 }
1388 
1389 /*
1390  * _copyArrayRef
1391  */
1392 static ArrayRef *
1394 {
1395  ArrayRef *newnode = makeNode(ArrayRef);
1396 
1397  COPY_SCALAR_FIELD(refarraytype);
1398  COPY_SCALAR_FIELD(refelemtype);
1399  COPY_SCALAR_FIELD(reftypmod);
1400  COPY_SCALAR_FIELD(refcollid);
1401  COPY_NODE_FIELD(refupperindexpr);
1402  COPY_NODE_FIELD(reflowerindexpr);
1403  COPY_NODE_FIELD(refexpr);
1404  COPY_NODE_FIELD(refassgnexpr);
1405 
1406  return newnode;
1407 }
1408 
1409 /*
1410  * _copyFuncExpr
1411  */
1412 static FuncExpr *
1414 {
1415  FuncExpr *newnode = makeNode(FuncExpr);
1416 
1417  COPY_SCALAR_FIELD(funcid);
1418  COPY_SCALAR_FIELD(funcresulttype);
1419  COPY_SCALAR_FIELD(funcretset);
1420  COPY_SCALAR_FIELD(funcvariadic);
1421  COPY_SCALAR_FIELD(funcformat);
1422  COPY_SCALAR_FIELD(funccollid);
1423  COPY_SCALAR_FIELD(inputcollid);
1425  COPY_LOCATION_FIELD(location);
1426 
1427  return newnode;
1428 }
1429 
1430 /*
1431  * _copyNamedArgExpr *
1432  */
1433 static NamedArgExpr *
1435 {
1436  NamedArgExpr *newnode = makeNode(NamedArgExpr);
1437 
1440  COPY_SCALAR_FIELD(argnumber);
1441  COPY_LOCATION_FIELD(location);
1442 
1443  return newnode;
1444 }
1445 
1446 /*
1447  * _copyOpExpr
1448  */
1449 static OpExpr *
1450 _copyOpExpr(const OpExpr *from)
1451 {
1452  OpExpr *newnode = makeNode(OpExpr);
1453 
1454  COPY_SCALAR_FIELD(opno);
1455  COPY_SCALAR_FIELD(opfuncid);
1456  COPY_SCALAR_FIELD(opresulttype);
1457  COPY_SCALAR_FIELD(opretset);
1458  COPY_SCALAR_FIELD(opcollid);
1459  COPY_SCALAR_FIELD(inputcollid);
1461  COPY_LOCATION_FIELD(location);
1462 
1463  return newnode;
1464 }
1465 
1466 /*
1467  * _copyDistinctExpr (same as OpExpr)
1468  */
1469 static DistinctExpr *
1471 {
1472  DistinctExpr *newnode = makeNode(DistinctExpr);
1473 
1474  COPY_SCALAR_FIELD(opno);
1475  COPY_SCALAR_FIELD(opfuncid);
1476  COPY_SCALAR_FIELD(opresulttype);
1477  COPY_SCALAR_FIELD(opretset);
1478  COPY_SCALAR_FIELD(opcollid);
1479  COPY_SCALAR_FIELD(inputcollid);
1481  COPY_LOCATION_FIELD(location);
1482 
1483  return newnode;
1484 }
1485 
1486 /*
1487  * _copyNullIfExpr (same as OpExpr)
1488  */
1489 static NullIfExpr *
1491 {
1492  NullIfExpr *newnode = makeNode(NullIfExpr);
1493 
1494  COPY_SCALAR_FIELD(opno);
1495  COPY_SCALAR_FIELD(opfuncid);
1496  COPY_SCALAR_FIELD(opresulttype);
1497  COPY_SCALAR_FIELD(opretset);
1498  COPY_SCALAR_FIELD(opcollid);
1499  COPY_SCALAR_FIELD(inputcollid);
1501  COPY_LOCATION_FIELD(location);
1502 
1503  return newnode;
1504 }
1505 
1506 /*
1507  * _copyScalarArrayOpExpr
1508  */
1509 static ScalarArrayOpExpr *
1511 {
1513 
1514  COPY_SCALAR_FIELD(opno);
1515  COPY_SCALAR_FIELD(opfuncid);
1516  COPY_SCALAR_FIELD(useOr);
1517  COPY_SCALAR_FIELD(inputcollid);
1519  COPY_LOCATION_FIELD(location);
1520 
1521  return newnode;
1522 }
1523 
1524 /*
1525  * _copyBoolExpr
1526  */
1527 static BoolExpr *
1529 {
1530  BoolExpr *newnode = makeNode(BoolExpr);
1531 
1534  COPY_LOCATION_FIELD(location);
1535 
1536  return newnode;
1537 }
1538 
1539 /*
1540  * _copySubLink
1541  */
1542 static SubLink *
1543 _copySubLink(const SubLink *from)
1544 {
1545  SubLink *newnode = makeNode(SubLink);
1546 
1547  COPY_SCALAR_FIELD(subLinkType);
1548  COPY_SCALAR_FIELD(subLinkId);
1549  COPY_NODE_FIELD(testexpr);
1550  COPY_NODE_FIELD(operName);
1551  COPY_NODE_FIELD(subselect);
1552  COPY_LOCATION_FIELD(location);
1553 
1554  return newnode;
1555 }
1556 
1557 /*
1558  * _copySubPlan
1559  */
1560 static SubPlan *
1561 _copySubPlan(const SubPlan *from)
1562 {
1563  SubPlan *newnode = makeNode(SubPlan);
1564 
1565  COPY_SCALAR_FIELD(subLinkType);
1566  COPY_NODE_FIELD(testexpr);
1567  COPY_NODE_FIELD(paramIds);
1568  COPY_SCALAR_FIELD(plan_id);
1569  COPY_STRING_FIELD(plan_name);
1570  COPY_SCALAR_FIELD(firstColType);
1571  COPY_SCALAR_FIELD(firstColTypmod);
1572  COPY_SCALAR_FIELD(firstColCollation);
1573  COPY_SCALAR_FIELD(useHashTable);
1574  COPY_SCALAR_FIELD(unknownEqFalse);
1575  COPY_SCALAR_FIELD(parallel_safe);
1576  COPY_NODE_FIELD(setParam);
1577  COPY_NODE_FIELD(parParam);
1579  COPY_SCALAR_FIELD(startup_cost);
1580  COPY_SCALAR_FIELD(per_call_cost);
1581 
1582  return newnode;
1583 }
1584 
1585 /*
1586  * _copyAlternativeSubPlan
1587  */
1588 static AlternativeSubPlan *
1590 {
1592 
1593  COPY_NODE_FIELD(subplans);
1594 
1595  return newnode;
1596 }
1597 
1598 /*
1599  * _copyFieldSelect
1600  */
1601 static FieldSelect *
1603 {
1604  FieldSelect *newnode = makeNode(FieldSelect);
1605 
1607  COPY_SCALAR_FIELD(fieldnum);
1608  COPY_SCALAR_FIELD(resulttype);
1609  COPY_SCALAR_FIELD(resulttypmod);
1610  COPY_SCALAR_FIELD(resultcollid);
1611 
1612  return newnode;
1613 }
1614 
1615 /*
1616  * _copyFieldStore
1617  */
1618 static FieldStore *
1620 {
1621  FieldStore *newnode = makeNode(FieldStore);
1622 
1624  COPY_NODE_FIELD(newvals);
1625  COPY_NODE_FIELD(fieldnums);
1626  COPY_SCALAR_FIELD(resulttype);
1627 
1628  return newnode;
1629 }
1630 
1631 /*
1632  * _copyRelabelType
1633  */
1634 static RelabelType *
1636 {
1637  RelabelType *newnode = makeNode(RelabelType);
1638 
1640  COPY_SCALAR_FIELD(resulttype);
1641  COPY_SCALAR_FIELD(resulttypmod);
1642  COPY_SCALAR_FIELD(resultcollid);
1643  COPY_SCALAR_FIELD(relabelformat);
1644  COPY_LOCATION_FIELD(location);
1645 
1646  return newnode;
1647 }
1648 
1649 /*
1650  * _copyCoerceViaIO
1651  */
1652 static CoerceViaIO *
1654 {
1655  CoerceViaIO *newnode = makeNode(CoerceViaIO);
1656 
1658  COPY_SCALAR_FIELD(resulttype);
1659  COPY_SCALAR_FIELD(resultcollid);
1660  COPY_SCALAR_FIELD(coerceformat);
1661  COPY_LOCATION_FIELD(location);
1662 
1663  return newnode;
1664 }
1665 
1666 /*
1667  * _copyArrayCoerceExpr
1668  */
1669 static ArrayCoerceExpr *
1671 {
1673 
1675  COPY_SCALAR_FIELD(elemfuncid);
1676  COPY_SCALAR_FIELD(resulttype);
1677  COPY_SCALAR_FIELD(resulttypmod);
1678  COPY_SCALAR_FIELD(resultcollid);
1679  COPY_SCALAR_FIELD(isExplicit);
1680  COPY_SCALAR_FIELD(coerceformat);
1681  COPY_LOCATION_FIELD(location);
1682 
1683  return newnode;
1684 }
1685 
1686 /*
1687  * _copyConvertRowtypeExpr
1688  */
1689 static ConvertRowtypeExpr *
1691 {
1693 
1695  COPY_SCALAR_FIELD(resulttype);
1696  COPY_SCALAR_FIELD(convertformat);
1697  COPY_LOCATION_FIELD(location);
1698 
1699  return newnode;
1700 }
1701 
1702 /*
1703  * _copyCollateExpr
1704  */
1705 static CollateExpr *
1707 {
1708  CollateExpr *newnode = makeNode(CollateExpr);
1709 
1711  COPY_SCALAR_FIELD(collOid);
1712  COPY_LOCATION_FIELD(location);
1713 
1714  return newnode;
1715 }
1716 
1717 /*
1718  * _copyCaseExpr
1719  */
1720 static CaseExpr *
1722 {
1723  CaseExpr *newnode = makeNode(CaseExpr);
1724 
1725  COPY_SCALAR_FIELD(casetype);
1726  COPY_SCALAR_FIELD(casecollid);
1729  COPY_NODE_FIELD(defresult);
1730  COPY_LOCATION_FIELD(location);
1731 
1732  return newnode;
1733 }
1734 
1735 /*
1736  * _copyCaseWhen
1737  */
1738 static CaseWhen *
1740 {
1741  CaseWhen *newnode = makeNode(CaseWhen);
1742 
1743  COPY_NODE_FIELD(expr);
1745  COPY_LOCATION_FIELD(location);
1746 
1747  return newnode;
1748 }
1749 
1750 /*
1751  * _copyCaseTestExpr
1752  */
1753 static CaseTestExpr *
1755 {
1756  CaseTestExpr *newnode = makeNode(CaseTestExpr);
1757 
1758  COPY_SCALAR_FIELD(typeId);
1759  COPY_SCALAR_FIELD(typeMod);
1760  COPY_SCALAR_FIELD(collation);
1761 
1762  return newnode;
1763 }
1764 
1765 /*
1766  * _copyArrayExpr
1767  */
1768 static ArrayExpr *
1770 {
1771  ArrayExpr *newnode = makeNode(ArrayExpr);
1772 
1773  COPY_SCALAR_FIELD(array_typeid);
1774  COPY_SCALAR_FIELD(array_collid);
1775  COPY_SCALAR_FIELD(element_typeid);
1776  COPY_NODE_FIELD(elements);
1777  COPY_SCALAR_FIELD(multidims);
1778  COPY_LOCATION_FIELD(location);
1779 
1780  return newnode;
1781 }
1782 
1783 /*
1784  * _copyRowExpr
1785  */
1786 static RowExpr *
1787 _copyRowExpr(const RowExpr *from)
1788 {
1789  RowExpr *newnode = makeNode(RowExpr);
1790 
1792  COPY_SCALAR_FIELD(row_typeid);
1793  COPY_SCALAR_FIELD(row_format);
1794  COPY_NODE_FIELD(colnames);
1795  COPY_LOCATION_FIELD(location);
1796 
1797  return newnode;
1798 }
1799 
1800 /*
1801  * _copyRowCompareExpr
1802  */
1803 static RowCompareExpr *
1805 {
1807 
1808  COPY_SCALAR_FIELD(rctype);
1809  COPY_NODE_FIELD(opnos);
1810  COPY_NODE_FIELD(opfamilies);
1811  COPY_NODE_FIELD(inputcollids);
1812  COPY_NODE_FIELD(largs);
1813  COPY_NODE_FIELD(rargs);
1814 
1815  return newnode;
1816 }
1817 
1818 /*
1819  * _copyCoalesceExpr
1820  */
1821 static CoalesceExpr *
1823 {
1824  CoalesceExpr *newnode = makeNode(CoalesceExpr);
1825 
1826  COPY_SCALAR_FIELD(coalescetype);
1827  COPY_SCALAR_FIELD(coalescecollid);
1829  COPY_LOCATION_FIELD(location);
1830 
1831  return newnode;
1832 }
1833 
1834 /*
1835  * _copyMinMaxExpr
1836  */
1837 static MinMaxExpr *
1839 {
1840  MinMaxExpr *newnode = makeNode(MinMaxExpr);
1841 
1842  COPY_SCALAR_FIELD(minmaxtype);
1843  COPY_SCALAR_FIELD(minmaxcollid);
1844  COPY_SCALAR_FIELD(inputcollid);
1845  COPY_SCALAR_FIELD(op);
1847  COPY_LOCATION_FIELD(location);
1848 
1849  return newnode;
1850 }
1851 
1852 /*
1853  * _copySQLValueFunction
1854  */
1855 static SQLValueFunction *
1857 {
1859 
1860  COPY_SCALAR_FIELD(op);
1861  COPY_SCALAR_FIELD(type);
1862  COPY_SCALAR_FIELD(typmod);
1863  COPY_LOCATION_FIELD(location);
1864 
1865  return newnode;
1866 }
1867 
1868 /*
1869  * _copyXmlExpr
1870  */
1871 static XmlExpr *
1872 _copyXmlExpr(const XmlExpr *from)
1873 {
1874  XmlExpr *newnode = makeNode(XmlExpr);
1875 
1876  COPY_SCALAR_FIELD(op);
1878  COPY_NODE_FIELD(named_args);
1879  COPY_NODE_FIELD(arg_names);
1882  COPY_SCALAR_FIELD(type);
1883  COPY_SCALAR_FIELD(typmod);
1884  COPY_LOCATION_FIELD(location);
1885 
1886  return newnode;
1887 }
1888 
1889 /*
1890  * _copyNullTest
1891  */
1892 static NullTest *
1894 {
1895  NullTest *newnode = makeNode(NullTest);
1896 
1898  COPY_SCALAR_FIELD(nulltesttype);
1899  COPY_SCALAR_FIELD(argisrow);
1900  COPY_LOCATION_FIELD(location);
1901 
1902  return newnode;
1903 }
1904 
1905 /*
1906  * _copyBooleanTest
1907  */
1908 static BooleanTest *
1910 {
1911  BooleanTest *newnode = makeNode(BooleanTest);
1912 
1914  COPY_SCALAR_FIELD(booltesttype);
1915  COPY_LOCATION_FIELD(location);
1916 
1917  return newnode;
1918 }
1919 
1920 /*
1921  * _copyCoerceToDomain
1922  */
1923 static CoerceToDomain *
1925 {
1927 
1929  COPY_SCALAR_FIELD(resulttype);
1930  COPY_SCALAR_FIELD(resulttypmod);
1931  COPY_SCALAR_FIELD(resultcollid);
1932  COPY_SCALAR_FIELD(coercionformat);
1933  COPY_LOCATION_FIELD(location);
1934 
1935  return newnode;
1936 }
1937 
1938 /*
1939  * _copyCoerceToDomainValue
1940  */
1941 static CoerceToDomainValue *
1943 {
1945 
1946  COPY_SCALAR_FIELD(typeId);
1947  COPY_SCALAR_FIELD(typeMod);
1948  COPY_SCALAR_FIELD(collation);
1949  COPY_LOCATION_FIELD(location);
1950 
1951  return newnode;
1952 }
1953 
1954 /*
1955  * _copySetToDefault
1956  */
1957 static SetToDefault *
1959 {
1960  SetToDefault *newnode = makeNode(SetToDefault);
1961 
1962  COPY_SCALAR_FIELD(typeId);
1963  COPY_SCALAR_FIELD(typeMod);
1964  COPY_SCALAR_FIELD(collation);
1965  COPY_LOCATION_FIELD(location);
1966 
1967  return newnode;
1968 }
1969 
1970 /*
1971  * _copyCurrentOfExpr
1972  */
1973 static CurrentOfExpr *
1975 {
1976  CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
1977 
1978  COPY_SCALAR_FIELD(cvarno);
1979  COPY_STRING_FIELD(cursor_name);
1980  COPY_SCALAR_FIELD(cursor_param);
1981 
1982  return newnode;
1983 }
1984 
1985 /*
1986  * _copyInferenceElem
1987  */
1988 static InferenceElem *
1990 {
1991  InferenceElem *newnode = makeNode(InferenceElem);
1992 
1993  COPY_NODE_FIELD(expr);
1994  COPY_SCALAR_FIELD(infercollid);
1995  COPY_SCALAR_FIELD(inferopclass);
1996 
1997  return newnode;
1998 }
1999 
2000 /*
2001  * _copyTargetEntry
2002  */
2003 static TargetEntry *
2005 {
2006  TargetEntry *newnode = makeNode(TargetEntry);
2007 
2008  COPY_NODE_FIELD(expr);
2009  COPY_SCALAR_FIELD(resno);
2010  COPY_STRING_FIELD(resname);
2011  COPY_SCALAR_FIELD(ressortgroupref);
2012  COPY_SCALAR_FIELD(resorigtbl);
2013  COPY_SCALAR_FIELD(resorigcol);
2014  COPY_SCALAR_FIELD(resjunk);
2015 
2016  return newnode;
2017 }
2018 
2019 /*
2020  * _copyRangeTblRef
2021  */
2022 static RangeTblRef *
2024 {
2025  RangeTblRef *newnode = makeNode(RangeTblRef);
2026 
2027  COPY_SCALAR_FIELD(rtindex);
2028 
2029  return newnode;
2030 }
2031 
2032 /*
2033  * _copyJoinExpr
2034  */
2035 static JoinExpr *
2037 {
2038  JoinExpr *newnode = makeNode(JoinExpr);
2039 
2040  COPY_SCALAR_FIELD(jointype);
2041  COPY_SCALAR_FIELD(isNatural);
2042  COPY_NODE_FIELD(larg);
2043  COPY_NODE_FIELD(rarg);
2044  COPY_NODE_FIELD(usingClause);
2045  COPY_NODE_FIELD(quals);
2046  COPY_NODE_FIELD(alias);
2047  COPY_SCALAR_FIELD(rtindex);
2048 
2049  return newnode;
2050 }
2051 
2052 /*
2053  * _copyFromExpr
2054  */
2055 static FromExpr *
2057 {
2058  FromExpr *newnode = makeNode(FromExpr);
2059 
2060  COPY_NODE_FIELD(fromlist);
2061  COPY_NODE_FIELD(quals);
2062 
2063  return newnode;
2064 }
2065 
2066 /*
2067  * _copyOnConflictExpr
2068  */
2069 static OnConflictExpr *
2071 {
2073 
2074  COPY_SCALAR_FIELD(action);
2075  COPY_NODE_FIELD(arbiterElems);
2076  COPY_NODE_FIELD(arbiterWhere);
2077  COPY_SCALAR_FIELD(constraint);
2078  COPY_NODE_FIELD(onConflictSet);
2079  COPY_NODE_FIELD(onConflictWhere);
2080  COPY_SCALAR_FIELD(exclRelIndex);
2081  COPY_NODE_FIELD(exclRelTlist);
2082 
2083  return newnode;
2084 }
2085 
2086 /* ****************************************************************
2087  * relation.h copy functions
2088  *
2089  * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
2090  * There are some subsidiary structs that are useful to copy, though.
2091  * ****************************************************************
2092  */
2093 
2094 /*
2095  * _copyPathKey
2096  */
2097 static PathKey *
2098 _copyPathKey(const PathKey *from)
2099 {
2100  PathKey *newnode = makeNode(PathKey);
2101 
2102  /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
2103  COPY_SCALAR_FIELD(pk_eclass);
2104  COPY_SCALAR_FIELD(pk_opfamily);
2105  COPY_SCALAR_FIELD(pk_strategy);
2106  COPY_SCALAR_FIELD(pk_nulls_first);
2107 
2108  return newnode;
2109 }
2110 
2111 /*
2112  * _copyRestrictInfo
2113  */
2114 static RestrictInfo *
2116 {
2117  RestrictInfo *newnode = makeNode(RestrictInfo);
2118 
2119  COPY_NODE_FIELD(clause);
2120  COPY_SCALAR_FIELD(is_pushed_down);
2121  COPY_SCALAR_FIELD(outerjoin_delayed);
2122  COPY_SCALAR_FIELD(can_join);
2123  COPY_SCALAR_FIELD(pseudoconstant);
2124  COPY_SCALAR_FIELD(leakproof);
2125  COPY_SCALAR_FIELD(security_level);
2126  COPY_BITMAPSET_FIELD(clause_relids);
2127  COPY_BITMAPSET_FIELD(required_relids);
2128  COPY_BITMAPSET_FIELD(outer_relids);
2129  COPY_BITMAPSET_FIELD(nullable_relids);
2130  COPY_BITMAPSET_FIELD(left_relids);
2131  COPY_BITMAPSET_FIELD(right_relids);
2132  COPY_NODE_FIELD(orclause);
2133  /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2134  COPY_SCALAR_FIELD(parent_ec);
2135  COPY_SCALAR_FIELD(eval_cost);
2136  COPY_SCALAR_FIELD(norm_selec);
2137  COPY_SCALAR_FIELD(outer_selec);
2138  COPY_NODE_FIELD(mergeopfamilies);
2139  /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2140  COPY_SCALAR_FIELD(left_ec);
2141  COPY_SCALAR_FIELD(right_ec);
2142  COPY_SCALAR_FIELD(left_em);
2143  COPY_SCALAR_FIELD(right_em);
2144  /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
2145  newnode->scansel_cache = NIL;
2146  COPY_SCALAR_FIELD(outer_is_left);
2147  COPY_SCALAR_FIELD(hashjoinoperator);
2148  COPY_SCALAR_FIELD(left_bucketsize);
2149  COPY_SCALAR_FIELD(right_bucketsize);
2150 
2151  return newnode;
2152 }
2153 
2154 /*
2155  * _copyPlaceHolderVar
2156  */
2157 static PlaceHolderVar *
2159 {
2161 
2162  COPY_NODE_FIELD(phexpr);
2163  COPY_BITMAPSET_FIELD(phrels);
2164  COPY_SCALAR_FIELD(phid);
2165  COPY_SCALAR_FIELD(phlevelsup);
2166 
2167  return newnode;
2168 }
2169 
2170 /*
2171  * _copySpecialJoinInfo
2172  */
2173 static SpecialJoinInfo *
2175 {
2177 
2178  COPY_BITMAPSET_FIELD(min_lefthand);
2179  COPY_BITMAPSET_FIELD(min_righthand);
2180  COPY_BITMAPSET_FIELD(syn_lefthand);
2181  COPY_BITMAPSET_FIELD(syn_righthand);
2182  COPY_SCALAR_FIELD(jointype);
2183  COPY_SCALAR_FIELD(lhs_strict);
2184  COPY_SCALAR_FIELD(delay_upper_joins);
2185  COPY_SCALAR_FIELD(semi_can_btree);
2186  COPY_SCALAR_FIELD(semi_can_hash);
2187  COPY_NODE_FIELD(semi_operators);
2188  COPY_NODE_FIELD(semi_rhs_exprs);
2189 
2190  return newnode;
2191 }
2192 
2193 /*
2194  * _copyAppendRelInfo
2195  */
2196 static AppendRelInfo *
2198 {
2199  AppendRelInfo *newnode = makeNode(AppendRelInfo);
2200 
2201  COPY_SCALAR_FIELD(parent_relid);
2202  COPY_SCALAR_FIELD(child_relid);
2203  COPY_SCALAR_FIELD(parent_reltype);
2204  COPY_SCALAR_FIELD(child_reltype);
2205  COPY_NODE_FIELD(translated_vars);
2206  COPY_SCALAR_FIELD(parent_reloid);
2207 
2208  return newnode;
2209 }
2210 
2211 /*
2212  * _copyPartitionedChildRelInfo
2213  */
2214 static PartitionedChildRelInfo *
2216 {
2218 
2219  COPY_SCALAR_FIELD(parent_relid);
2220  COPY_NODE_FIELD(child_rels);
2221 
2222  return newnode;
2223 }
2224 
2225 /*
2226  * _copyPlaceHolderInfo
2227  */
2228 static PlaceHolderInfo *
2230 {
2232 
2233  COPY_SCALAR_FIELD(phid);
2234  COPY_NODE_FIELD(ph_var);
2235  COPY_BITMAPSET_FIELD(ph_eval_at);
2236  COPY_BITMAPSET_FIELD(ph_lateral);
2237  COPY_BITMAPSET_FIELD(ph_needed);
2238  COPY_SCALAR_FIELD(ph_width);
2239 
2240  return newnode;
2241 }
2242 
2243 /* ****************************************************************
2244  * parsenodes.h copy functions
2245  * ****************************************************************
2246  */
2247 
2248 static RangeTblEntry *
2250 {
2251  RangeTblEntry *newnode = makeNode(RangeTblEntry);
2252 
2253  COPY_SCALAR_FIELD(rtekind);
2254  COPY_SCALAR_FIELD(relid);
2255  COPY_SCALAR_FIELD(relkind);
2256  COPY_NODE_FIELD(tablesample);
2257  COPY_NODE_FIELD(subquery);
2258  COPY_SCALAR_FIELD(security_barrier);
2259  COPY_SCALAR_FIELD(jointype);
2260  COPY_NODE_FIELD(joinaliasvars);
2262  COPY_SCALAR_FIELD(funcordinality);
2263  COPY_NODE_FIELD(tablefunc);
2264  COPY_NODE_FIELD(values_lists);
2265  COPY_STRING_FIELD(ctename);
2266  COPY_SCALAR_FIELD(ctelevelsup);
2267  COPY_SCALAR_FIELD(self_reference);
2268  COPY_NODE_FIELD(coltypes);
2269  COPY_NODE_FIELD(coltypmods);
2270  COPY_NODE_FIELD(colcollations);
2271  COPY_NODE_FIELD(alias);
2272  COPY_NODE_FIELD(eref);
2273  COPY_SCALAR_FIELD(lateral);
2274  COPY_SCALAR_FIELD(inh);
2275  COPY_SCALAR_FIELD(inFromCl);
2276  COPY_SCALAR_FIELD(requiredPerms);
2277  COPY_SCALAR_FIELD(checkAsUser);
2278  COPY_BITMAPSET_FIELD(selectedCols);
2279  COPY_BITMAPSET_FIELD(insertedCols);
2280  COPY_BITMAPSET_FIELD(updatedCols);
2281  COPY_NODE_FIELD(securityQuals);
2282 
2283  return newnode;
2284 }
2285 
2286 static RangeTblFunction *
2288 {
2290 
2291  COPY_NODE_FIELD(funcexpr);
2292  COPY_SCALAR_FIELD(funccolcount);
2293  COPY_NODE_FIELD(funccolnames);
2294  COPY_NODE_FIELD(funccoltypes);
2295  COPY_NODE_FIELD(funccoltypmods);
2296  COPY_NODE_FIELD(funccolcollations);
2297  COPY_BITMAPSET_FIELD(funcparams);
2298 
2299  return newnode;
2300 }
2301 
2302 static TableSampleClause *
2304 {
2306 
2307  COPY_SCALAR_FIELD(tsmhandler);
2309  COPY_NODE_FIELD(repeatable);
2310 
2311  return newnode;
2312 }
2313 
2314 static WithCheckOption *
2316 {
2318 
2319  COPY_SCALAR_FIELD(kind);
2320  COPY_STRING_FIELD(relname);
2321  COPY_STRING_FIELD(polname);
2322  COPY_NODE_FIELD(qual);
2323  COPY_SCALAR_FIELD(cascaded);
2324 
2325  return newnode;
2326 }
2327 
2328 static SortGroupClause *
2330 {
2332 
2333  COPY_SCALAR_FIELD(tleSortGroupRef);
2334  COPY_SCALAR_FIELD(eqop);
2335  COPY_SCALAR_FIELD(sortop);
2336  COPY_SCALAR_FIELD(nulls_first);
2337  COPY_SCALAR_FIELD(hashable);
2338 
2339  return newnode;
2340 }
2341 
2342 static GroupingSet *
2344 {
2345  GroupingSet *newnode = makeNode(GroupingSet);
2346 
2347  COPY_SCALAR_FIELD(kind);
2348  COPY_NODE_FIELD(content);
2349  COPY_LOCATION_FIELD(location);
2350 
2351  return newnode;
2352 }
2353 
2354 static WindowClause *
2356 {
2357  WindowClause *newnode = makeNode(WindowClause);
2358 
2360  COPY_STRING_FIELD(refname);
2361  COPY_NODE_FIELD(partitionClause);
2362  COPY_NODE_FIELD(orderClause);
2363  COPY_SCALAR_FIELD(frameOptions);
2364  COPY_NODE_FIELD(startOffset);
2365  COPY_NODE_FIELD(endOffset);
2366  COPY_SCALAR_FIELD(winref);
2367  COPY_SCALAR_FIELD(copiedOrder);
2368 
2369  return newnode;
2370 }
2371 
2372 static RowMarkClause *
2374 {
2375  RowMarkClause *newnode = makeNode(RowMarkClause);
2376 
2377  COPY_SCALAR_FIELD(rti);
2378  COPY_SCALAR_FIELD(strength);
2379  COPY_SCALAR_FIELD(waitPolicy);
2380  COPY_SCALAR_FIELD(pushedDown);
2381 
2382  return newnode;
2383 }
2384 
2385 static WithClause *
2387 {
2388  WithClause *newnode = makeNode(WithClause);
2389 
2390  COPY_NODE_FIELD(ctes);
2391  COPY_SCALAR_FIELD(recursive);
2392  COPY_LOCATION_FIELD(location);
2393 
2394  return newnode;
2395 }
2396 
2397 static InferClause *
2399 {
2400  InferClause *newnode = makeNode(InferClause);
2401 
2402  COPY_NODE_FIELD(indexElems);
2403  COPY_NODE_FIELD(whereClause);
2404  COPY_STRING_FIELD(conname);
2405  COPY_LOCATION_FIELD(location);
2406 
2407  return newnode;
2408 }
2409 
2410 static OnConflictClause *
2412 {
2414 
2415  COPY_SCALAR_FIELD(action);
2416  COPY_NODE_FIELD(infer);
2417  COPY_NODE_FIELD(targetList);
2418  COPY_NODE_FIELD(whereClause);
2419  COPY_LOCATION_FIELD(location);
2420 
2421  return newnode;
2422 }
2423 
2424 static CommonTableExpr *
2426 {
2428 
2429  COPY_STRING_FIELD(ctename);
2430  COPY_NODE_FIELD(aliascolnames);
2431  COPY_NODE_FIELD(ctequery);
2432  COPY_LOCATION_FIELD(location);
2433  COPY_SCALAR_FIELD(cterecursive);
2434  COPY_SCALAR_FIELD(cterefcount);
2435  COPY_NODE_FIELD(ctecolnames);
2436  COPY_NODE_FIELD(ctecoltypes);
2437  COPY_NODE_FIELD(ctecoltypmods);
2438  COPY_NODE_FIELD(ctecolcollations);
2439 
2440  return newnode;
2441 }
2442 
2443 static A_Expr *
2444 _copyAExpr(const A_Expr *from)
2445 {
2446  A_Expr *newnode = makeNode(A_Expr);
2447 
2448  COPY_SCALAR_FIELD(kind);
2450  COPY_NODE_FIELD(lexpr);
2451  COPY_NODE_FIELD(rexpr);
2452  COPY_LOCATION_FIELD(location);
2453 
2454  return newnode;
2455 }
2456 
2457 static ColumnRef *
2459 {
2460  ColumnRef *newnode = makeNode(ColumnRef);
2461 
2462  COPY_NODE_FIELD(fields);
2463  COPY_LOCATION_FIELD(location);
2464 
2465  return newnode;
2466 }
2467 
2468 static ParamRef *
2470 {
2471  ParamRef *newnode = makeNode(ParamRef);
2472 
2473  COPY_SCALAR_FIELD(number);
2474  COPY_LOCATION_FIELD(location);
2475 
2476  return newnode;
2477 }
2478 
2479 static A_Const *
2480 _copyAConst(const A_Const *from)
2481 {
2482  A_Const *newnode = makeNode(A_Const);
2483 
2484  /* This part must duplicate _copyValue */
2485  COPY_SCALAR_FIELD(val.type);
2486  switch (from->val.type)
2487  {
2488  case T_Integer:
2489  COPY_SCALAR_FIELD(val.val.ival);
2490  break;
2491  case T_Float:
2492  case T_String:
2493  case T_BitString:
2494  COPY_STRING_FIELD(val.val.str);
2495  break;
2496  case T_Null:
2497  /* nothing to do */
2498  break;
2499  default:
2500  elog(ERROR, "unrecognized node type: %d",
2501  (int) from->val.type);
2502  break;
2503  }
2504 
2505  COPY_LOCATION_FIELD(location);
2506 
2507  return newnode;
2508 }
2509 
2510 static FuncCall *
2512 {
2513  FuncCall *newnode = makeNode(FuncCall);
2514 
2515  COPY_NODE_FIELD(funcname);
2517  COPY_NODE_FIELD(agg_order);
2518  COPY_NODE_FIELD(agg_filter);
2519  COPY_SCALAR_FIELD(agg_within_group);
2520  COPY_SCALAR_FIELD(agg_star);
2521  COPY_SCALAR_FIELD(agg_distinct);
2522  COPY_SCALAR_FIELD(func_variadic);
2523  COPY_NODE_FIELD(over);
2524  COPY_LOCATION_FIELD(location);
2525 
2526  return newnode;
2527 }
2528 
2529 static A_Star *
2530 _copyAStar(const A_Star *from)
2531 {
2532  A_Star *newnode = makeNode(A_Star);
2533 
2534  return newnode;
2535 }
2536 
2537 static A_Indices *
2539 {
2540  A_Indices *newnode = makeNode(A_Indices);
2541 
2542  COPY_SCALAR_FIELD(is_slice);
2543  COPY_NODE_FIELD(lidx);
2544  COPY_NODE_FIELD(uidx);
2545 
2546  return newnode;
2547 }
2548 
2549 static A_Indirection *
2551 {
2552  A_Indirection *newnode = makeNode(A_Indirection);
2553 
2555  COPY_NODE_FIELD(indirection);
2556 
2557  return newnode;
2558 }
2559 
2560 static A_ArrayExpr *
2562 {
2563  A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2564 
2565  COPY_NODE_FIELD(elements);
2566  COPY_LOCATION_FIELD(location);
2567 
2568  return newnode;
2569 }
2570 
2571 static ResTarget *
2573 {
2574  ResTarget *newnode = makeNode(ResTarget);
2575 
2577  COPY_NODE_FIELD(indirection);
2579  COPY_LOCATION_FIELD(location);
2580 
2581  return newnode;
2582 }
2583 
2584 static MultiAssignRef *
2586 {
2588 
2589  COPY_NODE_FIELD(source);
2590  COPY_SCALAR_FIELD(colno);
2591  COPY_SCALAR_FIELD(ncolumns);
2592 
2593  return newnode;
2594 }
2595 
2596 static TypeName *
2598 {
2599  TypeName *newnode = makeNode(TypeName);
2600 
2601  COPY_NODE_FIELD(names);
2602  COPY_SCALAR_FIELD(typeOid);
2603  COPY_SCALAR_FIELD(setof);
2604  COPY_SCALAR_FIELD(pct_type);
2605  COPY_NODE_FIELD(typmods);
2606  COPY_SCALAR_FIELD(typemod);
2607  COPY_NODE_FIELD(arrayBounds);
2608  COPY_LOCATION_FIELD(location);
2609 
2610  return newnode;
2611 }
2612 
2613 static SortBy *
2614 _copySortBy(const SortBy *from)
2615 {
2616  SortBy *newnode = makeNode(SortBy);
2617 
2618  COPY_NODE_FIELD(node);
2619  COPY_SCALAR_FIELD(sortby_dir);
2620  COPY_SCALAR_FIELD(sortby_nulls);
2621  COPY_NODE_FIELD(useOp);
2622  COPY_LOCATION_FIELD(location);
2623 
2624  return newnode;
2625 }
2626 
2627 static WindowDef *
2629 {
2630  WindowDef *newnode = makeNode(WindowDef);
2631 
2633  COPY_STRING_FIELD(refname);
2634  COPY_NODE_FIELD(partitionClause);
2635  COPY_NODE_FIELD(orderClause);
2636  COPY_SCALAR_FIELD(frameOptions);
2637  COPY_NODE_FIELD(startOffset);
2638  COPY_NODE_FIELD(endOffset);
2639  COPY_LOCATION_FIELD(location);
2640 
2641  return newnode;
2642 }
2643 
2644 static RangeSubselect *
2646 {
2648 
2649  COPY_SCALAR_FIELD(lateral);
2650  COPY_NODE_FIELD(subquery);
2651  COPY_NODE_FIELD(alias);
2652 
2653  return newnode;
2654 }
2655 
2656 static RangeFunction *
2658 {
2659  RangeFunction *newnode = makeNode(RangeFunction);
2660 
2661  COPY_SCALAR_FIELD(lateral);
2662  COPY_SCALAR_FIELD(ordinality);
2663  COPY_SCALAR_FIELD(is_rowsfrom);
2665  COPY_NODE_FIELD(alias);
2666  COPY_NODE_FIELD(coldeflist);
2667 
2668  return newnode;
2669 }
2670 
2671 static RangeTableSample *
2673 {
2675 
2676  COPY_NODE_FIELD(relation);
2677  COPY_NODE_FIELD(method);
2679  COPY_NODE_FIELD(repeatable);
2680  COPY_LOCATION_FIELD(location);
2681 
2682  return newnode;
2683 }
2684 
2685 static RangeTableFunc *
2687 {
2689 
2690  COPY_SCALAR_FIELD(lateral);
2691  COPY_NODE_FIELD(docexpr);
2692  COPY_NODE_FIELD(rowexpr);
2693  COPY_NODE_FIELD(namespaces);
2694  COPY_NODE_FIELD(columns);
2695  COPY_NODE_FIELD(alias);
2696  COPY_LOCATION_FIELD(location);
2697 
2698  return newnode;
2699 }
2700 
2701 static RangeTableFuncCol *
2703 {
2705 
2706  COPY_STRING_FIELD(colname);
2707  COPY_NODE_FIELD(typeName);
2708  COPY_SCALAR_FIELD(for_ordinality);
2709  COPY_SCALAR_FIELD(is_not_null);
2710  COPY_NODE_FIELD(colexpr);
2711  COPY_NODE_FIELD(coldefexpr);
2712  COPY_LOCATION_FIELD(location);
2713 
2714  return newnode;
2715 }
2716 
2717 static TypeCast *
2719 {
2720  TypeCast *newnode = makeNode(TypeCast);
2721 
2723  COPY_NODE_FIELD(typeName);
2724  COPY_LOCATION_FIELD(location);
2725 
2726  return newnode;
2727 }
2728 
2729 static CollateClause *
2731 {
2732  CollateClause *newnode = makeNode(CollateClause);
2733 
2735  COPY_NODE_FIELD(collname);
2736  COPY_LOCATION_FIELD(location);
2737 
2738  return newnode;
2739 }
2740 
2741 static IndexElem *
2743 {
2744  IndexElem *newnode = makeNode(IndexElem);
2745 
2747  COPY_NODE_FIELD(expr);
2748  COPY_STRING_FIELD(indexcolname);
2749  COPY_NODE_FIELD(collation);
2750  COPY_NODE_FIELD(opclass);
2751  COPY_SCALAR_FIELD(ordering);
2752  COPY_SCALAR_FIELD(nulls_ordering);
2753 
2754  return newnode;
2755 }
2756 
2757 static ColumnDef *
2759 {
2760  ColumnDef *newnode = makeNode(ColumnDef);
2761 
2762  COPY_STRING_FIELD(colname);
2763  COPY_NODE_FIELD(typeName);
2764  COPY_SCALAR_FIELD(inhcount);
2765  COPY_SCALAR_FIELD(is_local);
2766  COPY_SCALAR_FIELD(is_not_null);
2767  COPY_SCALAR_FIELD(is_from_type);
2768  COPY_SCALAR_FIELD(storage);
2769  COPY_NODE_FIELD(raw_default);
2770  COPY_NODE_FIELD(cooked_default);
2771  COPY_NODE_FIELD(collClause);
2772  COPY_SCALAR_FIELD(collOid);
2773  COPY_NODE_FIELD(constraints);
2774  COPY_NODE_FIELD(fdwoptions);
2775  COPY_LOCATION_FIELD(location);
2776 
2777  return newnode;
2778 }
2779 
2780 static Constraint *
2782 {
2783  Constraint *newnode = makeNode(Constraint);
2784 
2785  COPY_SCALAR_FIELD(contype);
2786  COPY_STRING_FIELD(conname);
2787  COPY_SCALAR_FIELD(deferrable);
2788  COPY_SCALAR_FIELD(initdeferred);
2789  COPY_LOCATION_FIELD(location);
2790  COPY_SCALAR_FIELD(is_no_inherit);
2791  COPY_NODE_FIELD(raw_expr);
2792  COPY_STRING_FIELD(cooked_expr);
2793  COPY_NODE_FIELD(keys);
2794  COPY_NODE_FIELD(exclusions);
2796  COPY_STRING_FIELD(indexname);
2797  COPY_STRING_FIELD(indexspace);
2798  COPY_STRING_FIELD(access_method);
2799  COPY_NODE_FIELD(where_clause);
2800  COPY_NODE_FIELD(pktable);
2801  COPY_NODE_FIELD(fk_attrs);
2802  COPY_NODE_FIELD(pk_attrs);
2803  COPY_SCALAR_FIELD(fk_matchtype);
2804  COPY_SCALAR_FIELD(fk_upd_action);
2805  COPY_SCALAR_FIELD(fk_del_action);
2806  COPY_NODE_FIELD(old_conpfeqop);
2807  COPY_SCALAR_FIELD(old_pktable_oid);
2808  COPY_SCALAR_FIELD(skip_validation);
2809  COPY_SCALAR_FIELD(initially_valid);
2810 
2811  return newnode;
2812 }
2813 
2814 static DefElem *
2815 _copyDefElem(const DefElem *from)
2816 {
2817  DefElem *newnode = makeNode(DefElem);
2818 
2819  COPY_STRING_FIELD(defnamespace);
2820  COPY_STRING_FIELD(defname);
2822  COPY_SCALAR_FIELD(defaction);
2823  COPY_LOCATION_FIELD(location);
2824 
2825  return newnode;
2826 }
2827 
2828 static LockingClause *
2830 {
2831  LockingClause *newnode = makeNode(LockingClause);
2832 
2833  COPY_NODE_FIELD(lockedRels);
2834  COPY_SCALAR_FIELD(strength);
2835  COPY_SCALAR_FIELD(waitPolicy);
2836 
2837  return newnode;
2838 }
2839 
2840 static XmlSerialize *
2842 {
2843  XmlSerialize *newnode = makeNode(XmlSerialize);
2844 
2846  COPY_NODE_FIELD(expr);
2847  COPY_NODE_FIELD(typeName);
2848  COPY_LOCATION_FIELD(location);
2849 
2850  return newnode;
2851 }
2852 
2853 static RoleSpec *
2855 {
2856  RoleSpec *newnode = makeNode(RoleSpec);
2857 
2858  COPY_SCALAR_FIELD(roletype);
2859  COPY_STRING_FIELD(rolename);
2860  COPY_LOCATION_FIELD(location);
2861 
2862  return newnode;
2863 }
2864 
2865 static TriggerTransition *
2867 {
2869 
2871  COPY_SCALAR_FIELD(isNew);
2872  COPY_SCALAR_FIELD(isTable);
2873 
2874  return newnode;
2875 }
2876 
2877 static Query *
2878 _copyQuery(const Query *from)
2879 {
2880  Query *newnode = makeNode(Query);
2881 
2882  COPY_SCALAR_FIELD(commandType);
2883  COPY_SCALAR_FIELD(querySource);
2884  COPY_SCALAR_FIELD(queryId);
2885  COPY_SCALAR_FIELD(canSetTag);
2886  COPY_NODE_FIELD(utilityStmt);
2887  COPY_SCALAR_FIELD(resultRelation);
2888  COPY_SCALAR_FIELD(hasAggs);
2889  COPY_SCALAR_FIELD(hasWindowFuncs);
2890  COPY_SCALAR_FIELD(hasTargetSRFs);
2891  COPY_SCALAR_FIELD(hasSubLinks);
2892  COPY_SCALAR_FIELD(hasDistinctOn);
2893  COPY_SCALAR_FIELD(hasRecursive);
2894  COPY_SCALAR_FIELD(hasModifyingCTE);
2895  COPY_SCALAR_FIELD(hasForUpdate);
2896  COPY_SCALAR_FIELD(hasRowSecurity);
2897  COPY_NODE_FIELD(cteList);
2898  COPY_NODE_FIELD(rtable);
2899  COPY_NODE_FIELD(jointree);
2900  COPY_NODE_FIELD(targetList);
2901  COPY_NODE_FIELD(onConflict);
2902  COPY_NODE_FIELD(returningList);
2903  COPY_NODE_FIELD(groupClause);
2904  COPY_NODE_FIELD(groupingSets);
2905  COPY_NODE_FIELD(havingQual);
2906  COPY_NODE_FIELD(windowClause);
2907  COPY_NODE_FIELD(distinctClause);
2908  COPY_NODE_FIELD(sortClause);
2909  COPY_NODE_FIELD(limitOffset);
2910  COPY_NODE_FIELD(limitCount);
2911  COPY_NODE_FIELD(rowMarks);
2912  COPY_NODE_FIELD(setOperations);
2913  COPY_NODE_FIELD(constraintDeps);
2914  COPY_NODE_FIELD(withCheckOptions);
2915  COPY_LOCATION_FIELD(stmt_location);
2916  COPY_LOCATION_FIELD(stmt_len);
2917 
2918  return newnode;
2919 }
2920 
2921 static RawStmt *
2922 _copyRawStmt(const RawStmt *from)
2923 {
2924  RawStmt *newnode = makeNode(RawStmt);
2925 
2926  COPY_NODE_FIELD(stmt);
2927  COPY_LOCATION_FIELD(stmt_location);
2928  COPY_LOCATION_FIELD(stmt_len);
2929 
2930  return newnode;
2931 }
2932 
2933 static InsertStmt *
2935 {
2936  InsertStmt *newnode = makeNode(InsertStmt);
2937 
2938  COPY_NODE_FIELD(relation);
2939  COPY_NODE_FIELD(cols);
2940  COPY_NODE_FIELD(selectStmt);
2941  COPY_NODE_FIELD(onConflictClause);
2942  COPY_NODE_FIELD(returningList);
2943  COPY_NODE_FIELD(withClause);
2944 
2945  return newnode;
2946 }
2947 
2948 static DeleteStmt *
2950 {
2951  DeleteStmt *newnode = makeNode(DeleteStmt);
2952 
2953  COPY_NODE_FIELD(relation);
2954  COPY_NODE_FIELD(usingClause);
2955  COPY_NODE_FIELD(whereClause);
2956  COPY_NODE_FIELD(returningList);
2957  COPY_NODE_FIELD(withClause);
2958 
2959  return newnode;
2960 }
2961 
2962 static UpdateStmt *
2964 {
2965  UpdateStmt *newnode = makeNode(UpdateStmt);
2966 
2967  COPY_NODE_FIELD(relation);
2968  COPY_NODE_FIELD(targetList);
2969  COPY_NODE_FIELD(whereClause);
2970  COPY_NODE_FIELD(fromClause);
2971  COPY_NODE_FIELD(returningList);
2972  COPY_NODE_FIELD(withClause);
2973 
2974  return newnode;
2975 }
2976 
2977 static SelectStmt *
2979 {
2980  SelectStmt *newnode = makeNode(SelectStmt);
2981 
2982  COPY_NODE_FIELD(distinctClause);
2983  COPY_NODE_FIELD(intoClause);
2984  COPY_NODE_FIELD(targetList);
2985  COPY_NODE_FIELD(fromClause);
2986  COPY_NODE_FIELD(whereClause);
2987  COPY_NODE_FIELD(groupClause);
2988  COPY_NODE_FIELD(havingClause);
2989  COPY_NODE_FIELD(windowClause);
2990  COPY_NODE_FIELD(valuesLists);
2991  COPY_NODE_FIELD(sortClause);
2992  COPY_NODE_FIELD(limitOffset);
2993  COPY_NODE_FIELD(limitCount);
2994  COPY_NODE_FIELD(lockingClause);
2995  COPY_NODE_FIELD(withClause);
2996  COPY_SCALAR_FIELD(op);
2997  COPY_SCALAR_FIELD(all);
2998  COPY_NODE_FIELD(larg);
2999  COPY_NODE_FIELD(rarg);
3000 
3001  return newnode;
3002 }
3003 
3004 static SetOperationStmt *
3006 {
3008 
3009  COPY_SCALAR_FIELD(op);
3010  COPY_SCALAR_FIELD(all);
3011  COPY_NODE_FIELD(larg);
3012  COPY_NODE_FIELD(rarg);
3013  COPY_NODE_FIELD(colTypes);
3014  COPY_NODE_FIELD(colTypmods);
3015  COPY_NODE_FIELD(colCollations);
3016  COPY_NODE_FIELD(groupClauses);
3017 
3018  return newnode;
3019 }
3020 
3021 static AlterTableStmt *
3023 {
3025 
3026  COPY_NODE_FIELD(relation);
3027  COPY_NODE_FIELD(cmds);
3028  COPY_SCALAR_FIELD(relkind);
3029  COPY_SCALAR_FIELD(missing_ok);
3030 
3031  return newnode;
3032 }
3033 
3034 static AlterTableCmd *
3036 {
3037  AlterTableCmd *newnode = makeNode(AlterTableCmd);
3038 
3039  COPY_SCALAR_FIELD(subtype);
3041  COPY_NODE_FIELD(newowner);
3042  COPY_NODE_FIELD(def);
3043  COPY_SCALAR_FIELD(behavior);
3044  COPY_SCALAR_FIELD(missing_ok);
3045 
3046  return newnode;
3047 }
3048 
3049 static AlterCollationStmt *
3051 {
3053 
3054  COPY_NODE_FIELD(collname);
3055 
3056  return newnode;
3057 }
3058 
3059 static AlterDomainStmt *
3061 {
3063 
3064  COPY_SCALAR_FIELD(subtype);
3065  COPY_NODE_FIELD(typeName);
3067  COPY_NODE_FIELD(def);
3068  COPY_SCALAR_FIELD(behavior);
3069  COPY_SCALAR_FIELD(missing_ok);
3070 
3071  return newnode;
3072 }
3073 
3074 static GrantStmt *
3076 {
3077  GrantStmt *newnode = makeNode(GrantStmt);
3078 
3079  COPY_SCALAR_FIELD(is_grant);
3080  COPY_SCALAR_FIELD(targtype);
3081  COPY_SCALAR_FIELD(objtype);
3082  COPY_NODE_FIELD(objects);
3083  COPY_NODE_FIELD(privileges);
3084  COPY_NODE_FIELD(grantees);
3085  COPY_SCALAR_FIELD(grant_option);
3086  COPY_SCALAR_FIELD(behavior);
3087 
3088  return newnode;
3089 }
3090 
3091 static ObjectWithArgs *
3093 {
3095 
3096  COPY_NODE_FIELD(objname);
3097  COPY_NODE_FIELD(objargs);
3098  COPY_SCALAR_FIELD(args_unspecified);
3099 
3100  return newnode;
3101 }
3102 
3103 static AccessPriv *
3105 {
3106  AccessPriv *newnode = makeNode(AccessPriv);
3107 
3108  COPY_STRING_FIELD(priv_name);
3109  COPY_NODE_FIELD(cols);
3110 
3111  return newnode;
3112 }
3113 
3114 static GrantRoleStmt *
3116 {
3117  GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
3118 
3119  COPY_NODE_FIELD(granted_roles);
3120  COPY_NODE_FIELD(grantee_roles);
3121  COPY_SCALAR_FIELD(is_grant);
3122  COPY_SCALAR_FIELD(admin_opt);
3123  COPY_NODE_FIELD(grantor);
3124  COPY_SCALAR_FIELD(behavior);
3125 
3126  return newnode;
3127 }
3128 
3131 {
3133 
3135  COPY_NODE_FIELD(action);
3136 
3137  return newnode;
3138 }
3139 
3140 static DeclareCursorStmt *
3142 {
3144 
3145  COPY_STRING_FIELD(portalname);
3147  COPY_NODE_FIELD(query);
3148 
3149  return newnode;
3150 }
3151 
3152 static ClosePortalStmt *
3154 {
3156 
3157  COPY_STRING_FIELD(portalname);
3158 
3159  return newnode;
3160 }
3161 
3162 static ClusterStmt *
3164 {
3165  ClusterStmt *newnode = makeNode(ClusterStmt);
3166 
3167  COPY_NODE_FIELD(relation);
3168  COPY_STRING_FIELD(indexname);
3170 
3171  return newnode;
3172 }
3173 
3174 static CopyStmt *
3176 {
3177  CopyStmt *newnode = makeNode(CopyStmt);
3178 
3179  COPY_NODE_FIELD(relation);
3180  COPY_NODE_FIELD(query);
3181  COPY_NODE_FIELD(attlist);
3182  COPY_SCALAR_FIELD(is_from);
3183  COPY_SCALAR_FIELD(is_program);
3186 
3187  return newnode;
3188 }
3189 
3190 /*
3191  * CopyCreateStmtFields
3192  *
3193  * This function copies the fields of the CreateStmt node. It is used by
3194  * copy functions for classes which inherit from CreateStmt.
3195  */
3196 static void
3198 {
3199  COPY_NODE_FIELD(relation);
3200  COPY_NODE_FIELD(tableElts);
3201  COPY_NODE_FIELD(inhRelations);
3202  COPY_NODE_FIELD(partspec);
3203  COPY_NODE_FIELD(partbound);
3204  COPY_NODE_FIELD(ofTypename);
3205  COPY_NODE_FIELD(constraints);
3207  COPY_SCALAR_FIELD(oncommit);
3208  COPY_STRING_FIELD(tablespacename);
3209  COPY_SCALAR_FIELD(if_not_exists);
3210 }
3211 
3212 static CreateStmt *
3214 {
3215  CreateStmt *newnode = makeNode(CreateStmt);
3216 
3217  CopyCreateStmtFields(from, newnode);
3218 
3219  return newnode;
3220 }
3221 
3222 static TableLikeClause *
3224 {
3226 
3227  COPY_NODE_FIELD(relation);
3229 
3230  return newnode;
3231 }
3232 
3233 static DefineStmt *
3235 {
3236  DefineStmt *newnode = makeNode(DefineStmt);
3237 
3238  COPY_SCALAR_FIELD(kind);
3239  COPY_SCALAR_FIELD(oldstyle);
3240  COPY_NODE_FIELD(defnames);
3242  COPY_NODE_FIELD(definition);
3243  COPY_SCALAR_FIELD(if_not_exists);
3244 
3245  return newnode;
3246 }
3247 
3248 static DropStmt *
3250 {
3251  DropStmt *newnode = makeNode(DropStmt);
3252 
3253  COPY_NODE_FIELD(objects);
3254  COPY_SCALAR_FIELD(removeType);
3255  COPY_SCALAR_FIELD(behavior);
3256  COPY_SCALAR_FIELD(missing_ok);
3257  COPY_SCALAR_FIELD(concurrent);
3258 
3259  return newnode;
3260 }
3261 
3262 static TruncateStmt *
3264 {
3265  TruncateStmt *newnode = makeNode(TruncateStmt);
3266 
3267  COPY_NODE_FIELD(relations);
3268  COPY_SCALAR_FIELD(restart_seqs);
3269  COPY_SCALAR_FIELD(behavior);
3270 
3271  return newnode;
3272 }
3273 
3274 static CommentStmt *
3276 {
3277  CommentStmt *newnode = makeNode(CommentStmt);
3278 
3279  COPY_SCALAR_FIELD(objtype);
3280  COPY_NODE_FIELD(object);
3281  COPY_STRING_FIELD(comment);
3282 
3283  return newnode;
3284 }
3285 
3286 static SecLabelStmt *
3288 {
3289  SecLabelStmt *newnode = makeNode(SecLabelStmt);
3290 
3291  COPY_SCALAR_FIELD(objtype);
3292  COPY_NODE_FIELD(object);
3293  COPY_STRING_FIELD(provider);
3295 
3296  return newnode;
3297 }
3298 
3299 static FetchStmt *
3301 {
3302  FetchStmt *newnode = makeNode(FetchStmt);
3303 
3304  COPY_SCALAR_FIELD(direction);
3305  COPY_SCALAR_FIELD(howMany);
3306  COPY_STRING_FIELD(portalname);
3307  COPY_SCALAR_FIELD(ismove);
3308 
3309  return newnode;
3310 }
3311 
3312 static IndexStmt *
3314 {
3315  IndexStmt *newnode = makeNode(IndexStmt);
3316 
3317  COPY_STRING_FIELD(idxname);
3318  COPY_NODE_FIELD(relation);
3319  COPY_STRING_FIELD(accessMethod);
3320  COPY_STRING_FIELD(tableSpace);
3321  COPY_NODE_FIELD(indexParams);
3323  COPY_NODE_FIELD(whereClause);
3324  COPY_NODE_FIELD(excludeOpNames);
3325  COPY_STRING_FIELD(idxcomment);
3326  COPY_SCALAR_FIELD(indexOid);
3327  COPY_SCALAR_FIELD(oldNode);
3328  COPY_SCALAR_FIELD(unique);
3329  COPY_SCALAR_FIELD(primary);
3330  COPY_SCALAR_FIELD(isconstraint);
3331  COPY_SCALAR_FIELD(deferrable);
3332  COPY_SCALAR_FIELD(initdeferred);
3333  COPY_SCALAR_FIELD(transformed);
3334  COPY_SCALAR_FIELD(concurrent);
3335  COPY_SCALAR_FIELD(if_not_exists);
3336 
3337  return newnode;
3338 }
3339 
3340 static CreateStatsStmt *
3342 {
3344 
3345  COPY_NODE_FIELD(defnames);
3346  COPY_NODE_FIELD(relation);
3347  COPY_NODE_FIELD(keys);
3349  COPY_SCALAR_FIELD(if_not_exists);
3350 
3351  return newnode;
3352 }
3353 
3354 static CreateFunctionStmt *
3356 {
3358 
3359  COPY_SCALAR_FIELD(replace);
3360  COPY_NODE_FIELD(funcname);
3361  COPY_NODE_FIELD(parameters);
3362  COPY_NODE_FIELD(returnType);
3364  COPY_NODE_FIELD(withClause);
3365 
3366  return newnode;
3367 }
3368 
3369 static FunctionParameter *
3371 {
3373 
3375  COPY_NODE_FIELD(argType);
3376  COPY_SCALAR_FIELD(mode);
3377  COPY_NODE_FIELD(defexpr);
3378 
3379  return newnode;
3380 }
3381 
3382 static AlterFunctionStmt *
3384 {
3386 
3387  COPY_NODE_FIELD(func);
3388  COPY_NODE_FIELD(actions);
3389 
3390  return newnode;
3391 }
3392 
3393 static DoStmt *
3394 _copyDoStmt(const DoStmt *from)
3395 {
3396  DoStmt *newnode = makeNode(DoStmt);
3397 
3399 
3400  return newnode;
3401 }
3402 
3403 static RenameStmt *
3405 {
3406  RenameStmt *newnode = makeNode(RenameStmt);
3407 
3408  COPY_SCALAR_FIELD(renameType);
3409  COPY_SCALAR_FIELD(relationType);
3410  COPY_NODE_FIELD(relation);
3411  COPY_NODE_FIELD(object);
3412  COPY_STRING_FIELD(subname);
3413  COPY_STRING_FIELD(newname);
3414  COPY_SCALAR_FIELD(behavior);
3415  COPY_SCALAR_FIELD(missing_ok);
3416 
3417  return newnode;
3418 }
3419 
3420 static AlterObjectDependsStmt *
3422 {
3424 
3425  COPY_SCALAR_FIELD(objectType);
3426  COPY_NODE_FIELD(relation);
3427  COPY_NODE_FIELD(object);
3428  COPY_NODE_FIELD(extname);
3429 
3430  return newnode;
3431 }
3432 
3433 static AlterObjectSchemaStmt *
3435 {
3437 
3438  COPY_SCALAR_FIELD(objectType);
3439  COPY_NODE_FIELD(relation);
3440  COPY_NODE_FIELD(object);
3441  COPY_STRING_FIELD(newschema);
3442  COPY_SCALAR_FIELD(missing_ok);
3443 
3444  return newnode;
3445 }
3446 
3447 static AlterOwnerStmt *
3449 {
3451 
3452  COPY_SCALAR_FIELD(objectType);
3453  COPY_NODE_FIELD(relation);
3454  COPY_NODE_FIELD(object);
3455  COPY_NODE_FIELD(newowner);
3456 
3457  return newnode;
3458 }
3459 
3460 static AlterOperatorStmt *
3462 {
3464 
3465  COPY_NODE_FIELD(opername);
3467 
3468  return newnode;
3469 }
3470 
3471 static RuleStmt *
3473 {
3474  RuleStmt *newnode = makeNode(RuleStmt);
3475 
3476  COPY_NODE_FIELD(relation);
3477  COPY_STRING_FIELD(rulename);
3478  COPY_NODE_FIELD(whereClause);
3479  COPY_SCALAR_FIELD(event);
3480  COPY_SCALAR_FIELD(instead);
3481  COPY_NODE_FIELD(actions);
3482  COPY_SCALAR_FIELD(replace);
3483 
3484  return newnode;
3485 }
3486 
3487 static NotifyStmt *
3489 {
3490  NotifyStmt *newnode = makeNode(NotifyStmt);
3491 
3492  COPY_STRING_FIELD(conditionname);
3493  COPY_STRING_FIELD(payload);
3494 
3495  return newnode;
3496 }
3497 
3498 static ListenStmt *
3500 {
3501  ListenStmt *newnode = makeNode(ListenStmt);
3502 
3503  COPY_STRING_FIELD(conditionname);
3504 
3505  return newnode;
3506 }
3507 
3508 static UnlistenStmt *
3510 {
3511  UnlistenStmt *newnode = makeNode(UnlistenStmt);
3512 
3513  COPY_STRING_FIELD(conditionname);
3514 
3515  return newnode;
3516 }
3517 
3518 static TransactionStmt *
3520 {
3522 
3523  COPY_SCALAR_FIELD(kind);
3525  COPY_STRING_FIELD(gid);
3526 
3527  return newnode;
3528 }
3529 
3530 static CompositeTypeStmt *
3532 {
3534 
3535  COPY_NODE_FIELD(typevar);
3536  COPY_NODE_FIELD(coldeflist);
3537 
3538  return newnode;
3539 }
3540 
3541 static CreateEnumStmt *
3543 {
3545 
3546  COPY_NODE_FIELD(typeName);
3547  COPY_NODE_FIELD(vals);
3548 
3549  return newnode;
3550 }
3551 
3552 static CreateRangeStmt *
3554 {
3556 
3557  COPY_NODE_FIELD(typeName);
3558  COPY_NODE_FIELD(params);
3559 
3560  return newnode;
3561 }
3562 
3563 static AlterEnumStmt *
3565 {
3566  AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3567 
3568  COPY_NODE_FIELD(typeName);
3569  COPY_STRING_FIELD(oldVal);
3570  COPY_STRING_FIELD(newVal);
3571  COPY_STRING_FIELD(newValNeighbor);
3572  COPY_SCALAR_FIELD(newValIsAfter);
3573  COPY_SCALAR_FIELD(skipIfNewValExists);
3574 
3575  return newnode;
3576 }
3577 
3578 static ViewStmt *
3580 {
3581  ViewStmt *newnode = makeNode(ViewStmt);
3582 
3583  COPY_NODE_FIELD(view);
3584  COPY_NODE_FIELD(aliases);
3585  COPY_NODE_FIELD(query);
3586  COPY_SCALAR_FIELD(replace);
3588  COPY_SCALAR_FIELD(withCheckOption);
3589 
3590  return newnode;
3591 }
3592 
3593 static LoadStmt *
3595 {
3596  LoadStmt *newnode = makeNode(LoadStmt);
3597 
3599 
3600  return newnode;
3601 }
3602 
3603 static CreateDomainStmt *
3605 {
3607 
3608  COPY_NODE_FIELD(domainname);
3609  COPY_NODE_FIELD(typeName);
3610  COPY_NODE_FIELD(collClause);
3611  COPY_NODE_FIELD(constraints);
3612 
3613  return newnode;
3614 }
3615 
3616 static CreateOpClassStmt *
3618 {
3620 
3621  COPY_NODE_FIELD(opclassname);
3622  COPY_NODE_FIELD(opfamilyname);
3623  COPY_STRING_FIELD(amname);
3624  COPY_NODE_FIELD(datatype);
3625  COPY_NODE_FIELD(items);
3626  COPY_SCALAR_FIELD(isDefault);
3627 
3628  return newnode;
3629 }
3630 
3631 static CreateOpClassItem *
3633 {
3635 
3636  COPY_SCALAR_FIELD(itemtype);
3638  COPY_SCALAR_FIELD(number);
3639  COPY_NODE_FIELD(order_family);
3640  COPY_NODE_FIELD(class_args);
3641  COPY_NODE_FIELD(storedtype);
3642 
3643  return newnode;
3644 }
3645 
3646 static CreateOpFamilyStmt *
3648 {
3650 
3651  COPY_NODE_FIELD(opfamilyname);
3652  COPY_STRING_FIELD(amname);
3653 
3654  return newnode;
3655 }
3656 
3657 static AlterOpFamilyStmt *
3659 {
3661 
3662  COPY_NODE_FIELD(opfamilyname);
3663  COPY_STRING_FIELD(amname);
3664  COPY_SCALAR_FIELD(isDrop);
3665  COPY_NODE_FIELD(items);
3666 
3667  return newnode;
3668 }
3669 
3670 static CreatedbStmt *
3672 {
3673  CreatedbStmt *newnode = makeNode(CreatedbStmt);
3674 
3677 
3678  return newnode;
3679 }
3680 
3681 static AlterDatabaseStmt *
3683 {
3685 
3688 
3689  return newnode;
3690 }
3691 
3692 static AlterDatabaseSetStmt *
3694 {
3696 
3698  COPY_NODE_FIELD(setstmt);
3699 
3700  return newnode;
3701 }
3702 
3703 static DropdbStmt *
3705 {
3706  DropdbStmt *newnode = makeNode(DropdbStmt);
3707 
3709  COPY_SCALAR_FIELD(missing_ok);
3710 
3711  return newnode;
3712 }
3713 
3714 static VacuumStmt *
3716 {
3717  VacuumStmt *newnode = makeNode(VacuumStmt);
3718 
3720  COPY_NODE_FIELD(relation);
3721  COPY_NODE_FIELD(va_cols);
3722 
3723  return newnode;
3724 }
3725 
3726 static ExplainStmt *
3728 {
3729  ExplainStmt *newnode = makeNode(ExplainStmt);
3730 
3731  COPY_NODE_FIELD(query);
3733 
3734  return newnode;
3735 }
3736 
3737 static CreateTableAsStmt *
3739 {
3741 
3742  COPY_NODE_FIELD(query);
3743  COPY_NODE_FIELD(into);
3744  COPY_SCALAR_FIELD(relkind);
3745  COPY_SCALAR_FIELD(is_select_into);
3746  COPY_SCALAR_FIELD(if_not_exists);
3747 
3748  return newnode;
3749 }
3750 
3751 static RefreshMatViewStmt *
3753 {
3755 
3756  COPY_SCALAR_FIELD(concurrent);
3757  COPY_SCALAR_FIELD(skipData);
3758  COPY_NODE_FIELD(relation);
3759 
3760  return newnode;
3761 }
3762 
3763 static ReplicaIdentityStmt *
3765 {
3767 
3768  COPY_SCALAR_FIELD(identity_type);
3770 
3771  return newnode;
3772 }
3773 
3774 static AlterSystemStmt *
3776 {
3778 
3779  COPY_NODE_FIELD(setstmt);
3780 
3781  return newnode;
3782 }
3783 
3784 static CreateSeqStmt *
3786 {
3787  CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3788 
3789  COPY_NODE_FIELD(sequence);
3791  COPY_SCALAR_FIELD(ownerId);
3792  COPY_SCALAR_FIELD(if_not_exists);
3793 
3794  return newnode;
3795 }
3796 
3797 static AlterSeqStmt *
3799 {
3800  AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3801 
3802  COPY_NODE_FIELD(sequence);
3804  COPY_SCALAR_FIELD(missing_ok);
3805 
3806  return newnode;
3807 }
3808 
3809 static VariableSetStmt *
3811 {
3813 
3814  COPY_SCALAR_FIELD(kind);
3817  COPY_SCALAR_FIELD(is_local);
3818 
3819  return newnode;
3820 }
3821 
3822 static VariableShowStmt *
3824 {
3826 
3828 
3829  return newnode;
3830 }
3831 
3832 static DiscardStmt *
3834 {
3835  DiscardStmt *newnode = makeNode(DiscardStmt);
3836 
3837  COPY_SCALAR_FIELD(target);
3838 
3839  return newnode;
3840 }
3841 
3842 static CreateTableSpaceStmt *
3844 {
3846 
3847  COPY_STRING_FIELD(tablespacename);
3848  COPY_NODE_FIELD(owner);
3849  COPY_STRING_FIELD(location);
3851 
3852  return newnode;
3853 }
3854 
3855 static DropTableSpaceStmt *
3857 {
3859 
3860  COPY_STRING_FIELD(tablespacename);
3861  COPY_SCALAR_FIELD(missing_ok);
3862 
3863  return newnode;
3864 }
3865 
3868 {
3870 
3871  COPY_STRING_FIELD(tablespacename);
3873  COPY_SCALAR_FIELD(isReset);
3874 
3875  return newnode;
3876 }
3877 
3878 static AlterTableMoveAllStmt *
3880 {
3882 
3883  COPY_STRING_FIELD(orig_tablespacename);
3884  COPY_SCALAR_FIELD(objtype);
3885  COPY_NODE_FIELD(roles);
3886  COPY_STRING_FIELD(new_tablespacename);
3887  COPY_SCALAR_FIELD(nowait);
3888 
3889  return newnode;
3890 }
3891 
3892 static CreateExtensionStmt *
3894 {
3896 
3897  COPY_STRING_FIELD(extname);
3898  COPY_SCALAR_FIELD(if_not_exists);
3900 
3901  return newnode;
3902 }
3903 
3904 static AlterExtensionStmt *
3906 {
3908 
3909  COPY_STRING_FIELD(extname);
3911 
3912  return newnode;
3913 }
3914 
3917 {
3919 
3920  COPY_STRING_FIELD(extname);
3921  COPY_SCALAR_FIELD(action);
3922  COPY_SCALAR_FIELD(objtype);
3923  COPY_NODE_FIELD(object);
3924 
3925  return newnode;
3926 }
3927 
3928 static CreateFdwStmt *
3930 {
3931  CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3932 
3933  COPY_STRING_FIELD(fdwname);
3934  COPY_NODE_FIELD(func_options);
3936 
3937  return newnode;
3938 }
3939 
3940 static AlterFdwStmt *
3942 {
3943  AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3944 
3945  COPY_STRING_FIELD(fdwname);
3946  COPY_NODE_FIELD(func_options);
3948 
3949  return newnode;
3950 }
3951 
3952 static CreateForeignServerStmt *
3954 {
3956 
3957  COPY_STRING_FIELD(servername);
3958  COPY_STRING_FIELD(servertype);
3959  COPY_STRING_FIELD(version);
3960  COPY_STRING_FIELD(fdwname);
3962  COPY_SCALAR_FIELD(if_not_exists);
3963 
3964  return newnode;
3965 }
3966 
3967 static AlterForeignServerStmt *
3969 {
3971 
3972  COPY_STRING_FIELD(servername);
3973  COPY_STRING_FIELD(version);
3975  COPY_SCALAR_FIELD(has_version);
3976 
3977  return newnode;
3978 }
3979 
3980 static CreateUserMappingStmt *
3982 {
3984 
3986  COPY_STRING_FIELD(servername);
3988  COPY_SCALAR_FIELD(if_not_exists);
3989 
3990  return newnode;
3991 }
3992 
3993 static AlterUserMappingStmt *
3995 {
3997 
3999  COPY_STRING_FIELD(servername);
4001 
4002  return newnode;
4003 }
4004 
4005 static DropUserMappingStmt *
4007 {
4009 
4011  COPY_STRING_FIELD(servername);
4012  COPY_SCALAR_FIELD(missing_ok);
4013 
4014  return newnode;
4015 }
4016 
4017 static CreateForeignTableStmt *
4019 {
4021 
4022  CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
4023 
4024  COPY_STRING_FIELD(servername);
4026 
4027  return newnode;
4028 }
4029 
4030 static ImportForeignSchemaStmt *
4032 {
4034 
4035  COPY_STRING_FIELD(server_name);
4036  COPY_STRING_FIELD(remote_schema);
4037  COPY_STRING_FIELD(local_schema);
4038  COPY_SCALAR_FIELD(list_type);
4039  COPY_NODE_FIELD(table_list);
4041 
4042  return newnode;
4043 }
4044 
4045 static CreateTransformStmt *
4047 {
4049 
4050  COPY_SCALAR_FIELD(replace);
4051  COPY_NODE_FIELD(type_name);
4052  COPY_STRING_FIELD(lang);
4053  COPY_NODE_FIELD(fromsql);
4054  COPY_NODE_FIELD(tosql);
4055 
4056  return newnode;
4057 }
4058 
4059 static CreateAmStmt *
4061 {
4062  CreateAmStmt *newnode = makeNode(CreateAmStmt);
4063 
4064  COPY_STRING_FIELD(amname);
4065  COPY_NODE_FIELD(handler_name);
4066  COPY_SCALAR_FIELD(amtype);
4067 
4068  return newnode;
4069 }
4070 
4071 static CreateTrigStmt *
4073 {
4075 
4076  COPY_STRING_FIELD(trigname);
4077  COPY_NODE_FIELD(relation);
4078  COPY_NODE_FIELD(funcname);
4080  COPY_SCALAR_FIELD(row);
4081  COPY_SCALAR_FIELD(timing);
4082  COPY_SCALAR_FIELD(events);
4083  COPY_NODE_FIELD(columns);
4084  COPY_NODE_FIELD(whenClause);
4085  COPY_SCALAR_FIELD(isconstraint);
4086  COPY_NODE_FIELD(transitionRels);
4087  COPY_SCALAR_FIELD(deferrable);
4088  COPY_SCALAR_FIELD(initdeferred);
4089  COPY_NODE_FIELD(constrrel);
4090 
4091  return newnode;
4092 }
4093 
4094 static CreateEventTrigStmt *
4096 {
4098 
4099  COPY_STRING_FIELD(trigname);
4100  COPY_STRING_FIELD(eventname);
4101  COPY_NODE_FIELD(whenclause);
4102  COPY_NODE_FIELD(funcname);
4103 
4104  return newnode;
4105 }
4106 
4107 static AlterEventTrigStmt *
4109 {
4111 
4112  COPY_STRING_FIELD(trigname);
4113  COPY_SCALAR_FIELD(tgenabled);
4114 
4115  return newnode;
4116 }
4117 
4118 static CreatePLangStmt *
4120 {
4122 
4123  COPY_SCALAR_FIELD(replace);
4124  COPY_STRING_FIELD(plname);
4125  COPY_NODE_FIELD(plhandler);
4126  COPY_NODE_FIELD(plinline);
4127  COPY_NODE_FIELD(plvalidator);
4128  COPY_SCALAR_FIELD(pltrusted);
4129 
4130  return newnode;
4131 }
4132 
4133 static CreateRoleStmt *
4135 {
4137 
4138  COPY_SCALAR_FIELD(stmt_type);
4139  COPY_STRING_FIELD(role);
4141 
4142  return newnode;
4143 }
4144 
4145 static AlterRoleStmt *
4147 {
4148  AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
4149 
4150  COPY_NODE_FIELD(role);
4152  COPY_SCALAR_FIELD(action);
4153 
4154  return newnode;
4155 }
4156 
4157 static AlterRoleSetStmt *
4159 {
4161 
4162  COPY_NODE_FIELD(role);
4163  COPY_STRING_FIELD(database);
4164  COPY_NODE_FIELD(setstmt);
4165 
4166  return newnode;
4167 }
4168 
4169 static DropRoleStmt *
4171 {
4172  DropRoleStmt *newnode = makeNode(DropRoleStmt);
4173 
4174  COPY_NODE_FIELD(roles);
4175  COPY_SCALAR_FIELD(missing_ok);
4176 
4177  return newnode;
4178 }
4179 
4180 static LockStmt *
4182 {
4183  LockStmt *newnode = makeNode(LockStmt);
4184 
4185  COPY_NODE_FIELD(relations);
4186  COPY_SCALAR_FIELD(mode);
4187  COPY_SCALAR_FIELD(nowait);
4188 
4189  return newnode;
4190 }
4191 
4192 static ConstraintsSetStmt *
4194 {
4196 
4197  COPY_NODE_FIELD(constraints);
4198  COPY_SCALAR_FIELD(deferred);
4199 
4200  return newnode;
4201 }
4202 
4203 static ReindexStmt *
4205 {
4206  ReindexStmt *newnode = makeNode(ReindexStmt);
4207 
4208  COPY_SCALAR_FIELD(kind);
4209  COPY_NODE_FIELD(relation);
4212 
4213  return newnode;
4214 }
4215 
4216 static CreateSchemaStmt *
4218 {
4220 
4221  COPY_STRING_FIELD(schemaname);
4222  COPY_NODE_FIELD(authrole);
4223  COPY_NODE_FIELD(schemaElts);
4224  COPY_SCALAR_FIELD(if_not_exists);
4225 
4226  return newnode;
4227 }
4228 
4229 static CreateConversionStmt *
4231 {
4233 
4234  COPY_NODE_FIELD(conversion_name);
4235  COPY_STRING_FIELD(for_encoding_name);
4236  COPY_STRING_FIELD(to_encoding_name);
4237  COPY_NODE_FIELD(func_name);
4238  COPY_SCALAR_FIELD(def);
4239 
4240  return newnode;
4241 }
4242 
4243 static CreateCastStmt *
4245 {
4247 
4248  COPY_NODE_FIELD(sourcetype);
4249  COPY_NODE_FIELD(targettype);
4250  COPY_NODE_FIELD(func);
4251  COPY_SCALAR_FIELD(context);
4252  COPY_SCALAR_FIELD(inout);
4253 
4254  return newnode;
4255 }
4256 
4257 static PrepareStmt *
4259 {
4260  PrepareStmt *newnode = makeNode(PrepareStmt);
4261 
4263  COPY_NODE_FIELD(argtypes);
4264  COPY_NODE_FIELD(query);
4265 
4266  return newnode;
4267 }
4268 
4269 static ExecuteStmt *
4271 {
4272  ExecuteStmt *newnode = makeNode(ExecuteStmt);
4273 
4275  COPY_NODE_FIELD(params);
4276 
4277  return newnode;
4278 }
4279 
4280 static DeallocateStmt *
4282 {
4284 
4286 
4287  return newnode;
4288 }
4289 
4290 static DropOwnedStmt *
4292 {
4293  DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
4294 
4295  COPY_NODE_FIELD(roles);
4296  COPY_SCALAR_FIELD(behavior);
4297 
4298  return newnode;
4299 }
4300 
4301 static ReassignOwnedStmt *
4303 {
4305 
4306  COPY_NODE_FIELD(roles);
4307  COPY_NODE_FIELD(newrole);
4308 
4309  return newnode;
4310 }
4311 
4312 static AlterTSDictionaryStmt *
4314 {
4316 
4317  COPY_NODE_FIELD(dictname);
4319 
4320  return newnode;
4321 }
4322 
4323 static AlterTSConfigurationStmt *
4325 {
4327 
4328  COPY_SCALAR_FIELD(kind);
4329  COPY_NODE_FIELD(cfgname);
4330  COPY_NODE_FIELD(tokentype);
4331  COPY_NODE_FIELD(dicts);
4332  COPY_SCALAR_FIELD(override);
4333  COPY_SCALAR_FIELD(replace);
4334  COPY_SCALAR_FIELD(missing_ok);
4335 
4336  return newnode;
4337 }
4338 
4339 static CreatePolicyStmt *
4341 {
4343 
4344  COPY_STRING_FIELD(policy_name);
4345  COPY_NODE_FIELD(table);
4346  COPY_STRING_FIELD(cmd_name);
4347  COPY_SCALAR_FIELD(permissive);
4348  COPY_NODE_FIELD(roles);
4349  COPY_NODE_FIELD(qual);
4350  COPY_NODE_FIELD(with_check);
4351 
4352  return newnode;
4353 }
4354 
4355 static AlterPolicyStmt *
4357 {
4359 
4360  COPY_STRING_FIELD(policy_name);
4361  COPY_NODE_FIELD(table);
4362  COPY_NODE_FIELD(roles);
4363  COPY_NODE_FIELD(qual);
4364  COPY_NODE_FIELD(with_check);
4365 
4366  return newnode;
4367 }
4368 
4369 static PartitionSpec *
4371 {
4372  PartitionSpec *newnode = makeNode(PartitionSpec);
4373 
4374  COPY_STRING_FIELD(strategy);
4375  COPY_NODE_FIELD(partParams);
4376  COPY_LOCATION_FIELD(location);
4377 
4378  return newnode;
4379 }
4380 
4381 static PartitionElem *
4383 {
4384  PartitionElem *newnode = makeNode(PartitionElem);
4385 
4387  COPY_NODE_FIELD(expr);
4388  COPY_NODE_FIELD(collation);
4389  COPY_NODE_FIELD(opclass);
4390  COPY_LOCATION_FIELD(location);
4391 
4392  return newnode;
4393 }
4394 
4395 static PartitionBoundSpec *
4397 {
4399 
4400  COPY_SCALAR_FIELD(strategy);
4401  COPY_NODE_FIELD(listdatums);
4402  COPY_NODE_FIELD(lowerdatums);
4403  COPY_NODE_FIELD(upperdatums);
4404  COPY_LOCATION_FIELD(location);
4405 
4406  return newnode;
4407 }
4408 
4409 static PartitionRangeDatum *
4411 {
4413 
4414  COPY_SCALAR_FIELD(infinite);
4416  COPY_LOCATION_FIELD(location);
4417 
4418  return newnode;
4419 }
4420 
4421 static PartitionCmd *
4423 {
4424  PartitionCmd *newnode = makeNode(PartitionCmd);
4425 
4427  COPY_NODE_FIELD(bound);
4428 
4429  return newnode;
4430 }
4431 
4432 static CreatePublicationStmt *
4434 {
4436 
4437  COPY_STRING_FIELD(pubname);
4439  COPY_NODE_FIELD(tables);
4440  COPY_SCALAR_FIELD(for_all_tables);
4441 
4442  return newnode;
4443 }
4444 
4445 static AlterPublicationStmt *
4447 {
4449 
4450  COPY_STRING_FIELD(pubname);
4452  COPY_NODE_FIELD(tables);
4453  COPY_SCALAR_FIELD(for_all_tables);
4454  COPY_SCALAR_FIELD(tableAction);
4455 
4456  return newnode;
4457 }
4458 
4459 static CreateSubscriptionStmt *
4461 {
4463 
4464  COPY_STRING_FIELD(subname);
4465  COPY_STRING_FIELD(conninfo);
4466  COPY_NODE_FIELD(publication);
4468 
4469  return newnode;
4470 }
4471 
4472 static AlterSubscriptionStmt *
4474 {
4476 
4477  COPY_SCALAR_FIELD(kind);
4478  COPY_STRING_FIELD(subname);
4479  COPY_STRING_FIELD(conninfo);
4480  COPY_NODE_FIELD(publication);
4482 
4483  return newnode;
4484 }
4485 
4486 static DropSubscriptionStmt *
4488 {
4490 
4491  COPY_STRING_FIELD(subname);
4492  COPY_SCALAR_FIELD(drop_slot);
4493  COPY_SCALAR_FIELD(missing_ok);
4494 
4495  return newnode;
4496 }
4497 
4498 /* ****************************************************************
4499  * pg_list.h copy functions
4500  * ****************************************************************
4501  */
4502 
4503 /*
4504  * Perform a deep copy of the specified list, using copyObject(). The
4505  * list MUST be of type T_List; T_IntList and T_OidList nodes don't
4506  * need deep copies, so they should be copied via list_copy()
4507  */
4508 #define COPY_NODE_CELL(new, old) \
4509  (new) = (ListCell *) palloc(sizeof(ListCell)); \
4510  lfirst(new) = copyObject(lfirst(old));
4511 
4512 static List *
4513 _copyList(const List *from)
4514 {
4515  List *new;
4516  ListCell *curr_old;
4517  ListCell *prev_new;
4518 
4519  Assert(list_length(from) >= 1);
4520 
4521  new = makeNode(List);
4522  new->length = from->length;
4523 
4524  COPY_NODE_CELL(new->head, from->head);
4525  prev_new = new->head;
4526  curr_old = lnext(from->head);
4527 
4528  while (curr_old)
4529  {
4530  COPY_NODE_CELL(prev_new->next, curr_old);
4531  prev_new = prev_new->next;
4532  curr_old = curr_old->next;
4533  }
4534  prev_new->next = NULL;
4535  new->tail = prev_new;
4536 
4537  return new;
4538 }
4539 
4540 /* ****************************************************************
4541  * extensible.h copy functions
4542  * ****************************************************************
4543  */
4544 static ExtensibleNode *
4546 {
4547  ExtensibleNode *newnode;
4548  const ExtensibleNodeMethods *methods;
4549 
4550  methods = GetExtensibleNodeMethods(from->extnodename, false);
4551  newnode = (ExtensibleNode *) newNode(methods->node_size,
4553  COPY_STRING_FIELD(extnodename);
4554 
4555  /* copy the private fields */
4556  methods->nodeCopy(newnode, from);
4557 
4558  return newnode;
4559 }
4560 
4561 /* ****************************************************************
4562  * value.h copy functions
4563  * ****************************************************************
4564  */
4565 static Value *
4566 _copyValue(const Value *from)
4567 {
4568  Value *newnode = makeNode(Value);
4569 
4570  /* See also _copyAConst when changing this code! */
4571 
4572  COPY_SCALAR_FIELD(type);
4573  switch (from->type)
4574  {
4575  case T_Integer:
4576  COPY_SCALAR_FIELD(val.ival);
4577  break;
4578  case T_Float:
4579  case T_String:
4580  case T_BitString:
4581  COPY_STRING_FIELD(val.str);
4582  break;
4583  case T_Null:
4584  /* nothing to do */
4585  break;
4586  default:
4587  elog(ERROR, "unrecognized node type: %d",
4588  (int) from->type);
4589  break;
4590  }
4591  return newnode;
4592 }
4593 
4594 
4595 static ForeignKeyCacheInfo *
4597 {
4599 
4600  COPY_SCALAR_FIELD(conrelid);
4601  COPY_SCALAR_FIELD(confrelid);
4602  COPY_SCALAR_FIELD(nkeys);
4603  /* COPY_SCALAR_FIELD might work for these, but let's not assume that */
4604  memcpy(newnode->conkey, from->conkey, sizeof(newnode->conkey));
4605  memcpy(newnode->confkey, from->confkey, sizeof(newnode->confkey));
4606  memcpy(newnode->conpfeqop, from->conpfeqop, sizeof(newnode->conpfeqop));
4607 
4608  return newnode;
4609 }
4610 
4611 
4612 /*
4613  * copyObject
4614  *
4615  * Create a copy of a Node tree or list. This is a "deep" copy: all
4616  * substructure is copied too, recursively.
4617  */
4618 void *
4619 copyObject(const void *from)
4620 {
4621  void *retval;
4622 
4623  if (from == NULL)
4624  return NULL;
4625 
4626  /* Guard against stack overflow due to overly complex expressions */
4628 
4629  switch (nodeTag(from))
4630  {
4631  /*
4632  * PLAN NODES
4633  */
4634  case T_PlannedStmt:
4635  retval = _copyPlannedStmt(from);
4636  break;
4637  case T_Plan:
4638  retval = _copyPlan(from);
4639  break;
4640  case T_Result:
4641  retval = _copyResult(from);
4642  break;
4643  case T_ProjectSet:
4644  retval = _copyProjectSet(from);
4645  break;
4646  case T_ModifyTable:
4647  retval = _copyModifyTable(from);
4648  break;
4649  case T_Append:
4650  retval = _copyAppend(from);
4651  break;
4652  case T_MergeAppend:
4653  retval = _copyMergeAppend(from);
4654  break;
4655  case T_RecursiveUnion:
4656  retval = _copyRecursiveUnion(from);
4657  break;
4658  case T_BitmapAnd:
4659  retval = _copyBitmapAnd(from);
4660  break;
4661  case T_BitmapOr:
4662  retval = _copyBitmapOr(from);
4663  break;
4664  case T_Scan:
4665  retval = _copyScan(from);
4666  break;
4667  case T_Gather:
4668  retval = _copyGather(from);
4669  break;
4670  case T_GatherMerge:
4671  retval = _copyGatherMerge(from);
4672  break;
4673  case T_SeqScan:
4674  retval = _copySeqScan(from);
4675  break;
4676  case T_SampleScan:
4677  retval = _copySampleScan(from);
4678  break;
4679  case T_IndexScan:
4680  retval = _copyIndexScan(from);
4681  break;
4682  case T_IndexOnlyScan:
4683  retval = _copyIndexOnlyScan(from);
4684  break;
4685  case T_BitmapIndexScan:
4686  retval = _copyBitmapIndexScan(from);
4687  break;
4688  case T_BitmapHeapScan:
4689  retval = _copyBitmapHeapScan(from);
4690  break;
4691  case T_TidScan:
4692  retval = _copyTidScan(from);
4693  break;
4694  case T_SubqueryScan:
4695  retval = _copySubqueryScan(from);
4696  break;
4697  case T_FunctionScan:
4698  retval = _copyFunctionScan(from);
4699  break;
4700  case T_TableFuncScan:
4701  retval = _copyTableFuncScan(from);
4702  break;
4703  case T_ValuesScan:
4704  retval = _copyValuesScan(from);
4705  break;
4706  case T_CteScan:
4707  retval = _copyCteScan(from);
4708  break;
4709  case T_WorkTableScan:
4710  retval = _copyWorkTableScan(from);
4711  break;
4712  case T_ForeignScan:
4713  retval = _copyForeignScan(from);
4714  break;
4715  case T_CustomScan:
4716  retval = _copyCustomScan(from);
4717  break;
4718  case T_Join:
4719  retval = _copyJoin(from);
4720  break;
4721  case T_NestLoop:
4722  retval = _copyNestLoop(from);
4723  break;
4724  case T_MergeJoin:
4725  retval = _copyMergeJoin(from);
4726  break;
4727  case T_HashJoin:
4728  retval = _copyHashJoin(from);
4729  break;
4730  case T_Material:
4731  retval = _copyMaterial(from);
4732  break;
4733  case T_Sort:
4734  retval = _copySort(from);
4735  break;
4736  case T_Group:
4737  retval = _copyGroup(from);
4738  break;
4739  case T_Agg:
4740  retval = _copyAgg(from);
4741  break;
4742  case T_WindowAgg:
4743  retval = _copyWindowAgg(from);
4744  break;
4745  case T_Unique:
4746  retval = _copyUnique(from);
4747  break;
4748  case T_Hash:
4749  retval = _copyHash(from);
4750  break;
4751  case T_SetOp:
4752  retval = _copySetOp(from);
4753  break;
4754  case T_LockRows:
4755  retval = _copyLockRows(from);
4756  break;
4757  case T_Limit:
4758  retval = _copyLimit(from);
4759  break;
4760  case T_NestLoopParam:
4761  retval = _copyNestLoopParam(from);
4762  break;
4763  case T_PlanRowMark:
4764  retval = _copyPlanRowMark(from);
4765  break;
4766  case T_PlanInvalItem:
4767  retval = _copyPlanInvalItem(from);
4768  break;
4769 
4770  /*
4771  * PRIMITIVE NODES
4772  */
4773  case T_Alias:
4774  retval = _copyAlias(from);
4775  break;
4776  case T_RangeVar:
4777  retval = _copyRangeVar(from);
4778  break;
4779  case T_TableFunc:
4780  retval = _copyTableFunc(from);
4781  break;
4782  case T_IntoClause:
4783  retval = _copyIntoClause(from);
4784  break;
4785  case T_Var:
4786  retval = _copyVar(from);
4787  break;
4788  case T_Const:
4789  retval = _copyConst(from);
4790  break;
4791  case T_Param:
4792  retval = _copyParam(from);
4793  break;
4794  case T_Aggref:
4795  retval = _copyAggref(from);
4796  break;
4797  case T_GroupingFunc:
4798  retval = _copyGroupingFunc(from);
4799  break;
4800  case T_WindowFunc:
4801  retval = _copyWindowFunc(from);
4802  break;
4803  case T_ArrayRef:
4804  retval = _copyArrayRef(from);
4805  break;
4806  case T_FuncExpr:
4807  retval = _copyFuncExpr(from);
4808  break;
4809  case T_NamedArgExpr:
4810  retval = _copyNamedArgExpr(from);
4811  break;
4812  case T_OpExpr:
4813  retval = _copyOpExpr(from);
4814  break;
4815  case T_DistinctExpr:
4816  retval = _copyDistinctExpr(from);
4817  break;
4818  case T_NullIfExpr:
4819  retval = _copyNullIfExpr(from);
4820  break;
4821  case T_ScalarArrayOpExpr:
4822  retval = _copyScalarArrayOpExpr(from);
4823  break;
4824  case T_BoolExpr:
4825  retval = _copyBoolExpr(from);
4826  break;
4827  case T_SubLink:
4828  retval = _copySubLink(from);
4829  break;
4830  case T_SubPlan:
4831  retval = _copySubPlan(from);
4832  break;
4833  case T_AlternativeSubPlan:
4834  retval = _copyAlternativeSubPlan(from);
4835  break;
4836  case T_FieldSelect:
4837  retval = _copyFieldSelect(from);
4838  break;
4839  case T_FieldStore:
4840  retval = _copyFieldStore(from);
4841  break;
4842  case T_RelabelType:
4843  retval = _copyRelabelType(from);
4844  break;
4845  case T_CoerceViaIO:
4846  retval = _copyCoerceViaIO(from);
4847  break;
4848  case T_ArrayCoerceExpr:
4849  retval = _copyArrayCoerceExpr(from);
4850  break;
4851  case T_ConvertRowtypeExpr:
4852  retval = _copyConvertRowtypeExpr(from);
4853  break;
4854  case T_CollateExpr:
4855  retval = _copyCollateExpr(from);
4856  break;
4857  case T_CaseExpr:
4858  retval = _copyCaseExpr(from);
4859  break;
4860  case T_CaseWhen:
4861  retval = _copyCaseWhen(from);
4862  break;
4863  case T_CaseTestExpr:
4864  retval = _copyCaseTestExpr(from);
4865  break;
4866  case T_ArrayExpr:
4867  retval = _copyArrayExpr(from);
4868  break;
4869  case T_RowExpr:
4870  retval = _copyRowExpr(from);
4871  break;
4872  case T_RowCompareExpr:
4873  retval = _copyRowCompareExpr(from);
4874  break;
4875  case T_CoalesceExpr:
4876  retval = _copyCoalesceExpr(from);
4877  break;
4878  case T_MinMaxExpr:
4879  retval = _copyMinMaxExpr(from);
4880  break;
4881  case T_SQLValueFunction:
4882  retval = _copySQLValueFunction(from);
4883  break;
4884  case T_XmlExpr:
4885  retval = _copyXmlExpr(from);
4886  break;
4887  case T_NullTest:
4888  retval = _copyNullTest(from);
4889  break;
4890  case T_BooleanTest:
4891  retval = _copyBooleanTest(from);
4892  break;
4893  case T_CoerceToDomain:
4894  retval = _copyCoerceToDomain(from);
4895  break;
4896  case T_CoerceToDomainValue:
4897  retval = _copyCoerceToDomainValue(from);
4898  break;
4899  case T_SetToDefault:
4900  retval = _copySetToDefault(from);
4901  break;
4902  case T_CurrentOfExpr:
4903  retval = _copyCurrentOfExpr(from);
4904  break;
4905  case T_InferenceElem:
4906  retval = _copyInferenceElem(from);
4907  break;
4908  case T_TargetEntry:
4909  retval = _copyTargetEntry(from);
4910  break;
4911  case T_RangeTblRef:
4912  retval = _copyRangeTblRef(from);
4913  break;
4914  case T_JoinExpr:
4915  retval = _copyJoinExpr(from);
4916  break;
4917  case T_FromExpr:
4918  retval = _copyFromExpr(from);
4919  break;
4920  case T_OnConflictExpr:
4921  retval = _copyOnConflictExpr(from);
4922  break;
4923 
4924  /*
4925  * RELATION NODES
4926  */
4927  case T_PathKey:
4928  retval = _copyPathKey(from);
4929  break;
4930  case T_RestrictInfo:
4931  retval = _copyRestrictInfo(from);
4932  break;
4933  case T_PlaceHolderVar:
4934  retval = _copyPlaceHolderVar(from);
4935  break;
4936  case T_SpecialJoinInfo:
4937  retval = _copySpecialJoinInfo(from);
4938  break;
4939  case T_AppendRelInfo:
4940  retval = _copyAppendRelInfo(from);
4941  break;
4943  retval = _copyPartitionedChildRelInfo(from);
4944  break;
4945  case T_PlaceHolderInfo:
4946  retval = _copyPlaceHolderInfo(from);
4947  break;
4948 
4949  /*
4950  * VALUE NODES
4951  */
4952  case T_Integer:
4953  case T_Float:
4954  case T_String:
4955  case T_BitString:
4956  case T_Null:
4957  retval = _copyValue(from);
4958  break;
4959 
4960  /*
4961  * LIST NODES
4962  */
4963  case T_List:
4964  retval = _copyList(from);
4965  break;
4966 
4967  /*
4968  * Lists of integers and OIDs don't need to be deep-copied, so we
4969  * perform a shallow copy via list_copy()
4970  */
4971  case T_IntList:
4972  case T_OidList:
4973  retval = list_copy(from);
4974  break;
4975 
4976  /*
4977  * EXTENSIBLE NODES
4978  */
4979  case T_ExtensibleNode:
4980  retval = _copyExtensibleNode(from);
4981  break;
4982 
4983  /*
4984  * PARSE NODES
4985  */
4986  case T_Query:
4987  retval = _copyQuery(from);
4988  break;
4989  case T_RawStmt:
4990  retval = _copyRawStmt(from);
4991  break;
4992  case T_InsertStmt:
4993  retval = _copyInsertStmt(from);
4994  break;
4995  case T_DeleteStmt:
4996  retval = _copyDeleteStmt(from);
4997  break;
4998  case T_UpdateStmt:
4999  retval = _copyUpdateStmt(from);
5000  break;
5001  case T_SelectStmt:
5002  retval = _copySelectStmt(from);
5003  break;
5004  case T_SetOperationStmt:
5005  retval = _copySetOperationStmt(from);
5006  break;
5007  case T_AlterTableStmt:
5008  retval = _copyAlterTableStmt(from);
5009  break;
5010  case T_AlterTableCmd:
5011  retval = _copyAlterTableCmd(from);
5012  break;
5013  case T_AlterCollationStmt:
5014  retval = _copyAlterCollationStmt(from);
5015  break;
5016  case T_AlterDomainStmt:
5017  retval = _copyAlterDomainStmt(from);
5018  break;
5019  case T_GrantStmt:
5020  retval = _copyGrantStmt(from);
5021  break;
5022  case T_GrantRoleStmt:
5023  retval = _copyGrantRoleStmt(from);
5024  break;
5026  retval = _copyAlterDefaultPrivilegesStmt(from);
5027  break;
5028  case T_DeclareCursorStmt:
5029  retval = _copyDeclareCursorStmt(from);
5030  break;
5031  case T_ClosePortalStmt:
5032  retval = _copyClosePortalStmt(from);
5033  break;
5034  case T_ClusterStmt:
5035  retval = _copyClusterStmt(from);
5036  break;
5037  case T_CopyStmt:
5038  retval = _copyCopyStmt(from);
5039  break;
5040  case T_CreateStmt:
5041  retval = _copyCreateStmt(from);
5042  break;
5043  case T_TableLikeClause:
5044  retval = _copyTableLikeClause(from);
5045  break;
5046  case T_DefineStmt:
5047  retval = _copyDefineStmt(from);
5048  break;
5049  case T_DropStmt:
5050  retval = _copyDropStmt(from);
5051  break;
5052  case T_TruncateStmt:
5053  retval = _copyTruncateStmt(from);
5054  break;
5055  case T_CommentStmt:
5056  retval = _copyCommentStmt(from);
5057  break;
5058  case T_SecLabelStmt:
5059  retval = _copySecLabelStmt(from);
5060  break;
5061  case T_FetchStmt:
5062  retval = _copyFetchStmt(from);
5063  break;
5064  case T_IndexStmt:
5065  retval = _copyIndexStmt(from);
5066  break;
5067  case T_CreateStatsStmt:
5068  retval = _copyCreateStatsStmt(from);
5069  break;
5070  case T_CreateFunctionStmt:
5071  retval = _copyCreateFunctionStmt(from);
5072  break;
5073  case T_FunctionParameter:
5074  retval = _copyFunctionParameter(from);
5075  break;
5076  case T_AlterFunctionStmt:
5077  retval = _copyAlterFunctionStmt(from);
5078  break;
5079  case T_DoStmt:
5080  retval = _copyDoStmt(from);
5081  break;
5082  case T_RenameStmt:
5083  retval = _copyRenameStmt(from);
5084  break;
5086  retval = _copyAlterObjectDependsStmt(from);
5087  break;
5089  retval = _copyAlterObjectSchemaStmt(from);
5090  break;
5091  case T_AlterOwnerStmt:
5092  retval = _copyAlterOwnerStmt(from);
5093  break;
5094  case T_AlterOperatorStmt:
5095  retval = _copyAlterOperatorStmt(from);
5096  break;
5097  case T_RuleStmt:
5098  retval = _copyRuleStmt(from);
5099  break;
5100  case T_NotifyStmt:
5101  retval = _copyNotifyStmt(from);
5102  break;
5103  case T_ListenStmt:
5104  retval = _copyListenStmt(from);
5105  break;
5106  case T_UnlistenStmt:
5107  retval = _copyUnlistenStmt(from);
5108  break;
5109  case T_TransactionStmt:
5110  retval = _copyTransactionStmt(from);
5111  break;
5112  case T_CompositeTypeStmt:
5113  retval = _copyCompositeTypeStmt(from);
5114  break;
5115  case T_CreateEnumStmt:
5116  retval = _copyCreateEnumStmt(from);
5117  break;
5118  case T_CreateRangeStmt:
5119  retval = _copyCreateRangeStmt(from);
5120  break;
5121  case T_AlterEnumStmt:
5122  retval = _copyAlterEnumStmt(from);
5123  break;
5124  case T_ViewStmt:
5125  retval = _copyViewStmt(from);
5126  break;
5127  case T_LoadStmt:
5128  retval = _copyLoadStmt(from);
5129  break;
5130  case T_CreateDomainStmt:
5131  retval = _copyCreateDomainStmt(from);
5132  break;
5133  case T_CreateOpClassStmt:
5134  retval = _copyCreateOpClassStmt(from);
5135  break;
5136  case T_CreateOpClassItem:
5137  retval = _copyCreateOpClassItem(from);
5138  break;
5139  case T_CreateOpFamilyStmt:
5140  retval = _copyCreateOpFamilyStmt(from);
5141  break;
5142  case T_AlterOpFamilyStmt:
5143  retval = _copyAlterOpFamilyStmt(from);
5144  break;
5145  case T_CreatedbStmt:
5146  retval = _copyCreatedbStmt(from);
5147  break;
5148  case T_AlterDatabaseStmt:
5149  retval = _copyAlterDatabaseStmt(from);
5150  break;
5152  retval = _copyAlterDatabaseSetStmt(from);
5153  break;
5154  case T_DropdbStmt:
5155  retval = _copyDropdbStmt(from);
5156  break;
5157  case T_VacuumStmt:
5158  retval = _copyVacuumStmt(from);
5159  break;
5160  case T_ExplainStmt:
5161  retval = _copyExplainStmt(from);
5162  break;
5163  case T_CreateTableAsStmt:
5164  retval = _copyCreateTableAsStmt(from);
5165  break;
5166  case T_RefreshMatViewStmt:
5167  retval = _copyRefreshMatViewStmt(from);
5168  break;
5169  case T_ReplicaIdentityStmt:
5170  retval = _copyReplicaIdentityStmt(from);
5171  break;
5172  case T_AlterSystemStmt:
5173  retval = _copyAlterSystemStmt(from);
5174  break;
5175  case T_CreateSeqStmt:
5176  retval = _copyCreateSeqStmt(from);
5177  break;
5178  case T_AlterSeqStmt:
5179  retval = _copyAlterSeqStmt(from);
5180  break;
5181  case T_VariableSetStmt:
5182  retval = _copyVariableSetStmt(from);
5183  break;
5184  case T_VariableShowStmt:
5185  retval = _copyVariableShowStmt(from);
5186  break;
5187  case T_DiscardStmt:
5188  retval = _copyDiscardStmt(from);
5189  break;
5191  retval = _copyCreateTableSpaceStmt(from);
5192  break;
5193  case T_DropTableSpaceStmt:
5194  retval = _copyDropTableSpaceStmt(from);
5195  break;
5197  retval = _copyAlterTableSpaceOptionsStmt(from);
5198  break;
5200  retval = _copyAlterTableMoveAllStmt(from);
5201  break;
5202  case T_CreateExtensionStmt:
5203  retval = _copyCreateExtensionStmt(from);
5204  break;
5205  case T_AlterExtensionStmt:
5206  retval = _copyAlterExtensionStmt(from);
5207  break;
5209  retval = _copyAlterExtensionContentsStmt(from);
5210  break;
5211  case T_CreateFdwStmt:
5212  retval = _copyCreateFdwStmt(from);
5213  break;
5214  case T_AlterFdwStmt:
5215  retval = _copyAlterFdwStmt(from);
5216  break;
5218  retval = _copyCreateForeignServerStmt(from);
5219  break;
5221  retval = _copyAlterForeignServerStmt(from);
5222  break;
5224  retval = _copyCreateUserMappingStmt(from);
5225  break;
5227  retval = _copyAlterUserMappingStmt(from);
5228  break;
5229  case T_DropUserMappingStmt:
5230  retval = _copyDropUserMappingStmt(from);
5231  break;
5233  retval = _copyCreateForeignTableStmt(from);
5234  break;
5236  retval = _copyImportForeignSchemaStmt(from);
5237  break;
5238  case T_CreateTransformStmt:
5239  retval = _copyCreateTransformStmt(from);
5240  break;
5241  case T_CreateAmStmt:
5242  retval = _copyCreateAmStmt(from);
5243  break;
5244  case T_CreateTrigStmt:
5245  retval = _copyCreateTrigStmt(from);
5246  break;
5247  case T_CreateEventTrigStmt:
5248  retval = _copyCreateEventTrigStmt(from);
5249  break;
5250  case T_AlterEventTrigStmt:
5251  retval = _copyAlterEventTrigStmt(from);
5252  break;
5253  case T_CreatePLangStmt:
5254  retval = _copyCreatePLangStmt(from);
5255  break;
5256  case T_CreateRoleStmt:
5257  retval = _copyCreateRoleStmt(from);
5258  break;
5259  case T_AlterRoleStmt:
5260  retval = _copyAlterRoleStmt(from);
5261  break;
5262  case T_AlterRoleSetStmt:
5263  retval = _copyAlterRoleSetStmt(from);
5264  break;
5265  case T_DropRoleStmt:
5266  retval = _copyDropRoleStmt(from);
5267  break;
5268  case T_LockStmt:
5269  retval = _copyLockStmt(from);
5270  break;
5271  case T_ConstraintsSetStmt:
5272  retval = _copyConstraintsSetStmt(from);
5273  break;
5274  case T_ReindexStmt:
5275  retval = _copyReindexStmt(from);
5276  break;
5277  case T_CheckPointStmt:
5278  retval = (void *) makeNode(CheckPointStmt);
5279  break;
5280  case T_CreateSchemaStmt:
5281  retval = _copyCreateSchemaStmt(from);
5282  break;
5284  retval = _copyCreateConversionStmt(from);
5285  break;
5286  case T_CreateCastStmt:
5287  retval = _copyCreateCastStmt(from);
5288  break;
5289  case T_PrepareStmt:
5290  retval = _copyPrepareStmt(from);
5291  break;
5292  case T_ExecuteStmt:
5293  retval = _copyExecuteStmt(from);
5294  break;
5295  case T_DeallocateStmt:
5296  retval = _copyDeallocateStmt(from);
5297  break;
5298  case T_DropOwnedStmt:
5299  retval = _copyDropOwnedStmt(from);
5300  break;
5301  case T_ReassignOwnedStmt:
5302  retval = _copyReassignOwnedStmt(from);
5303  break;
5305  retval = _copyAlterTSDictionaryStmt(from);
5306  break;
5308  retval = _copyAlterTSConfigurationStmt(from);
5309  break;
5310  case T_CreatePolicyStmt:
5311  retval = _copyCreatePolicyStmt(from);
5312  break;
5313  case T_AlterPolicyStmt:
5314  retval = _copyAlterPolicyStmt(from);
5315  break;
5317  retval = _copyCreatePublicationStmt(from);
5318  break;
5320  retval = _copyAlterPublicationStmt(from);
5321  break;
5323  retval = _copyCreateSubscriptionStmt(from);
5324  break;
5326  retval = _copyAlterSubscriptionStmt(from);
5327  break;
5329  retval = _copyDropSubscriptionStmt(from);
5330  break;
5331  case T_A_Expr:
5332  retval = _copyAExpr(from);
5333  break;
5334  case T_ColumnRef:
5335  retval = _copyColumnRef(from);
5336  break;
5337  case T_ParamRef:
5338  retval = _copyParamRef(from);
5339  break;
5340  case T_A_Const:
5341  retval = _copyAConst(from);
5342  break;
5343  case T_FuncCall:
5344  retval = _copyFuncCall(from);
5345  break;
5346  case T_A_Star:
5347  retval = _copyAStar(from);
5348  break;
5349  case T_A_Indices:
5350  retval = _copyAIndices(from);
5351  break;
5352  case T_A_Indirection:
5353  retval = _copyA_Indirection(from);
5354  break;
5355  case T_A_ArrayExpr:
5356  retval = _copyA_ArrayExpr(from);
5357  break;
5358  case T_ResTarget:
5359  retval = _copyResTarget(from);
5360  break;
5361  case T_MultiAssignRef:
5362  retval = _copyMultiAssignRef(from);
5363  break;
5364  case T_TypeCast:
5365  retval = _copyTypeCast(from);
5366  break;
5367  case T_CollateClause:
5368  retval = _copyCollateClause(from);
5369  break;
5370  case T_SortBy:
5371  retval = _copySortBy(from);
5372  break;
5373  case T_WindowDef:
5374  retval = _copyWindowDef(from);
5375  break;
5376  case T_RangeSubselect:
5377  retval = _copyRangeSubselect(from);
5378  break;
5379  case T_RangeFunction:
5380  retval = _copyRangeFunction(from);
5381  break;
5382  case T_RangeTableSample:
5383  retval = _copyRangeTableSample(from);
5384  break;
5385  case T_RangeTableFunc:
5386  retval = _copyRangeTableFunc(from);
5387  break;
5388  case T_RangeTableFuncCol:
5389  retval = _copyRangeTableFuncCol(from);
5390  break;
5391  case T_TypeName:
5392  retval = _copyTypeName(from);
5393  break;
5394  case T_IndexElem:
5395  retval = _copyIndexElem(from);
5396  break;
5397  case T_ColumnDef:
5398  retval = _copyColumnDef(from);
5399  break;
5400  case T_Constraint:
5401  retval = _copyConstraint(from);
5402  break;
5403  case T_DefElem:
5404  retval = _copyDefElem(from);
5405  break;
5406  case T_LockingClause:
5407  retval = _copyLockingClause(from);
5408  break;
5409  case T_RangeTblEntry:
5410  retval = _copyRangeTblEntry(from);
5411  break;
5412  case T_RangeTblFunction:
5413  retval = _copyRangeTblFunction(from);
5414  break;
5415  case T_TableSampleClause:
5416  retval = _copyTableSampleClause(from);
5417  break;
5418  case T_WithCheckOption:
5419  retval = _copyWithCheckOption(from);
5420  break;
5421  case T_SortGroupClause:
5422  retval = _copySortGroupClause(from);
5423  break;
5424  case T_GroupingSet:
5425  retval = _copyGroupingSet(from);
5426  break;
5427  case T_WindowClause:
5428  retval = _copyWindowClause(from);
5429  break;
5430  case T_RowMarkClause:
5431  retval = _copyRowMarkClause(from);
5432  break;
5433  case T_WithClause:
5434  retval = _copyWithClause(from);
5435  break;
5436  case T_InferClause:
5437  retval = _copyInferClause(from);
5438  break;
5439  case T_OnConflictClause:
5440  retval = _copyOnConflictClause(from);
5441  break;
5442  case T_CommonTableExpr:
5443  retval = _copyCommonTableExpr(from);
5444  break;
5445  case T_ObjectWithArgs:
5446  retval = _copyObjectWithArgs(from);
5447  break;
5448  case T_AccessPriv:
5449  retval = _copyAccessPriv(from);
5450  break;
5451  case T_XmlSerialize:
5452  retval = _copyXmlSerialize(from);
5453  break;
5454  case T_RoleSpec:
5455  retval = _copyRoleSpec(from);
5456  break;
5457  case T_TriggerTransition:
5458  retval = _copyTriggerTransition(from);
5459  break;
5460  case T_PartitionSpec:
5461  retval = _copyPartitionSpec(from);
5462  break;
5463  case T_PartitionElem:
5464  retval = _copyPartitionElem(from);
5465  break;
5466  case T_PartitionBoundSpec:
5467  retval = _copyPartitionBoundSpec(from);
5468  break;
5469  case T_PartitionRangeDatum:
5470  retval = _copyPartitionRangeDatum(from);
5471  break;
5472  case T_PartitionCmd:
5473  retval = _copyPartitionCmd(from);
5474  break;
5475 
5476  /*
5477  * MISCELLANEOUS NODES
5478  */
5479  case T_ForeignKeyCacheInfo:
5480  retval = _copyForeignKeyCacheInfo(from);
5481  break;
5482 
5483  default:
5484  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
5485  retval = 0; /* keep compiler quiet */
5486  break;
5487  }
5488 
5489  return retval;
5490 }
Datum constvalue
Definition: primnodes.h:196
int numCols
Definition: plannodes.h:792
static Limit * _copyLimit(const Limit *from)
Definition: copyfuncs.c:1089
void(* nodeCopy)(struct ExtensibleNode *newnode, const struct ExtensibleNode *oldnode)
Definition: extensible.h:64
#define COPY_BITMAPSET_FIELD(fldname)
Definition: copyfuncs.c:49
static WindowClause * _copyWindowClause(const WindowClause *from)
Definition: copyfuncs.c:2355
static CreateEnumStmt * _copyCreateEnumStmt(const CreateEnumStmt *from)
Definition: copyfuncs.c:3542
static RefreshMatViewStmt * _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
Definition: copyfuncs.c:3752
static RangeSubselect * _copyRangeSubselect(const RangeSubselect *from)
Definition: copyfuncs.c:2645
int ordNumCols
Definition: plannodes.h:777
static AlterSystemStmt * _copyAlterSystemStmt(const AlterSystemStmt *from)
Definition: copyfuncs.c:3775
static DeallocateStmt * _copyDeallocateStmt(const DeallocateStmt *from)
Definition: copyfuncs.c:4281
#define NIL
Definition: pg_list.h:69
static PlanInvalItem * _copyPlanInvalItem(const PlanInvalItem *from)
Definition: copyfuncs.c:1145
static Scan * _copyScan(const Scan *from)
Definition: copyfuncs.c:411
static AlterEventTrigStmt * _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
Definition: copyfuncs.c:4108
static SeqScan * _copySeqScan(const SeqScan *from)
Definition: copyfuncs.c:427
int numCols
Definition: plannodes.h:756
static AlterTableMoveAllStmt * _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
Definition: copyfuncs.c:3879
static DiscardStmt * _copyDiscardStmt(const DiscardStmt *from)
Definition: copyfuncs.c:3833
static DeleteStmt * _copyDeleteStmt(const DeleteStmt *from)
Definition: copyfuncs.c:2949
static Unique * _copyUnique(const Unique *from)
Definition: copyfuncs.c:991
Datum boolop(PG_FUNCTION_ARGS)
Definition: _int_bool.c:420
static BitmapAnd * _copyBitmapAnd(const BitmapAnd *from)
Definition: copyfuncs.c:305
static AccessPriv * _copyAccessPriv(const AccessPriv *from)
Definition: copyfuncs.c:3104
Definition: nodes.h:76
static FromExpr * _copyFromExpr(const FromExpr *from)
Definition: copyfuncs.c:2056
static DropStmt * _copyDropStmt(const DropStmt *from)
Definition: copyfuncs.c:3249
static Plan * _copyPlan(const Plan *from)
Definition: copyfuncs.c:135
static LockStmt * _copyLockStmt(const LockStmt *from)
Definition: copyfuncs.c:4181
static RowMarkClause * _copyRowMarkClause(const RowMarkClause *from)
Definition: copyfuncs.c:2373
static Var * _copyVar(const Var *from)
Definition: copyfuncs.c:1248
static ValuesScan * _copyValuesScan(const ValuesScan *from)
Definition: copyfuncs.c:646
static AlterForeignServerStmt * _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
Definition: copyfuncs.c:3968
static RowExpr * _copyRowExpr(const RowExpr *from)
Definition: copyfuncs.c:1787
static VariableShowStmt * _copyVariableShowStmt(const VariableShowStmt *from)
Definition: copyfuncs.c:3823
Definition: nodes.h:78
static TransactionStmt * _copyTransactionStmt(const TransactionStmt *from)
Definition: copyfuncs.c:3519
bool constbyval
Definition: primnodes.h:199
static TableLikeClause * _copyTableLikeClause(const TableLikeClause *from)
Definition: copyfuncs.c:3223
static CreatePolicyStmt * _copyCreatePolicyStmt(const CreatePolicyStmt *from)
Definition: copyfuncs.c:4340
static AlterEnumStmt * _copyAlterEnumStmt(const AlterEnumStmt *from)
Definition: copyfuncs.c:3564
Definition: nodes.h:53
static AlterExtensionStmt * _copyAlterExtensionStmt(const AlterExtensionStmt *from)
Definition: copyfuncs.c:3905
static DeclareCursorStmt * _copyDeclareCursorStmt(const DeclareCursorStmt *from)
Definition: copyfuncs.c:3141
static A_Const * _copyAConst(const A_Const *from)
Definition: copyfuncs.c:2480
static HashJoin * _copyHashJoin(const HashJoin *from)
Definition: copyfuncs.c:856
static AlterFdwStmt * _copyAlterFdwStmt(const AlterFdwStmt *from)
Definition: copyfuncs.c:3941
static PartitionSpec * _copyPartitionSpec(const PartitionSpec *from)
Definition: copyfuncs.c:4370
static GroupingSet * _copyGroupingSet(const GroupingSet *from)
Definition: copyfuncs.c:2343
static DropRoleStmt * _copyDropRoleStmt(const DropRoleStmt *from)
Definition: copyfuncs.c:4170
static CreateAmStmt * _copyCreateAmStmt(const CreateAmStmt *from)
Definition: copyfuncs.c:4060
static AlternativeSubPlan * _copyAlternativeSubPlan(const AlternativeSubPlan *from)
Definition: copyfuncs.c:1589
static UnlistenStmt * _copyUnlistenStmt(const UnlistenStmt *from)
Definition: copyfuncs.c:3509
static Hash * _copyHash(const Hash *from)
Definition: copyfuncs.c:1014
static void CopyScanFields(const Scan *from, Scan *newnode)
Definition: copyfuncs.c:400
static AlterTSConfigurationStmt * _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
Definition: copyfuncs.c:4324
static CreateOpClassStmt * _copyCreateOpClassStmt(const CreateOpClassStmt *from)
Definition: copyfuncs.c:3617
static Result * _copyResult(const Result *from)
Definition: copyfuncs.c:152
static Material * _copyMaterial(const Material *from)
Definition: copyfuncs.c:878
static GatherMerge * _copyGatherMerge(const GatherMerge *from)
Definition: copyfuncs.c:371
static PartitionedChildRelInfo * _copyPartitionedChildRelInfo(const PartitionedChildRelInfo *from)
Definition: copyfuncs.c:2215
static ArrayRef * _copyArrayRef(const ArrayRef *from)
Definition: copyfuncs.c:1393
AttrNumber conkey[INDEX_MAX_KEYS]
Definition: rel.h:243
static RestrictInfo * _copyRestrictInfo(const RestrictInfo *from)
Definition: copyfuncs.c:2115
static ClusterStmt * _copyClusterStmt(const ClusterStmt *from)
Definition: copyfuncs.c:3163
static FunctionScan * _copyFunctionScan(const FunctionScan *from)
Definition: copyfuncs.c:603
static AlterFunctionStmt * _copyAlterFunctionStmt(const AlterFunctionStmt *from)
Definition: copyfuncs.c:3383
static SortBy * _copySortBy(const SortBy *from)
Definition: copyfuncs.c:2614
static MergeJoin * _copyMergeJoin(const MergeJoin *from)
Definition: copyfuncs.c:826
static AlterCollationStmt * _copyAlterCollationStmt(const AlterCollationStmt *from)
Definition: copyfuncs.c:3050
static RuleStmt * _copyRuleStmt(const RuleStmt *from)
Definition: copyfuncs.c:3472
static ImportForeignSchemaStmt * _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
Definition: copyfuncs.c:4031
static FuncCall * _copyFuncCall(const FuncCall *from)
Definition: copyfuncs.c:2511
static RangeVar * _copyRangeVar(const RangeVar *from)
Definition: copyfuncs.c:1178
static CreatedbStmt * _copyCreatedbStmt(const CreatedbStmt *from)
Definition: copyfuncs.c:3671
static CopyStmt * _copyCopyStmt(const CopyStmt *from)
Definition: copyfuncs.c:3175
List * list_copy(const List *oldlist)
Definition: list.c:1160
static PartitionBoundSpec * _copyPartitionBoundSpec(const PartitionBoundSpec *from)
Definition: copyfuncs.c:4396
static CreateTableSpaceStmt * _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
Definition: copyfuncs.c:3843
static GrantStmt * _copyGrantStmt(const GrantStmt *from)
Definition: copyfuncs.c:3075
static Value * _copyValue(const Value *from)
Definition: copyfuncs.c:4566
Definition: nodes.h:48
static AlterOperatorStmt * _copyAlterOperatorStmt(const AlterOperatorStmt *from)
Definition: copyfuncs.c:3461
static Alias * _copyAlias(const Alias *from)
Definition: copyfuncs.c:1164
return result
Definition: formatting.c:1618
static BitmapHeapScan * _copyBitmapHeapScan(const BitmapHeapScan *from)
Definition: copyfuncs.c:540
static Sort * _copySort(const Sort *from)
Definition: copyfuncs.c:895
static A_ArrayExpr * _copyA_ArrayExpr(const A_ArrayExpr *from)
Definition: copyfuncs.c:2561
static Agg * _copyAgg(const Agg *from)
Definition: copyfuncs.c:935
static IntoClause * _copyIntoClause(const IntoClause *from)
Definition: copyfuncs.c:1222
static ParamRef * _copyParamRef(const ParamRef *from)
Definition: copyfuncs.c:2469
Definition: nodes.h:74
static IndexStmt * _copyIndexStmt(const IndexStmt *from)
Definition: copyfuncs.c:3313
static FuncExpr * _copyFuncExpr(const FuncExpr *from)
Definition: copyfuncs.c:1413
static ObjectWithArgs * _copyObjectWithArgs(const ObjectWithArgs *from)
Definition: copyfuncs.c:3092
static BoolExpr * _copyBoolExpr(const BoolExpr *from)
Definition: copyfuncs.c:1528
static PathKey * _copyPathKey(const PathKey *from)
Definition: copyfuncs.c:2098
static DefineStmt * _copyDefineStmt(const DefineStmt *from)
Definition: copyfuncs.c:3234
unsigned int Oid
Definition: postgres_ext.h:31
static Join * _copyJoin(const Join *from)
Definition: copyfuncs.c:787
Definition: primnodes.h:163
static WithClause * _copyWithClause(const WithClause *from)
Definition: copyfuncs.c:2386
static TypeName * _copyTypeName(const TypeName *from)
Definition: copyfuncs.c:2597
static WindowAgg * _copyWindowAgg(const WindowAgg *from)
Definition: copyfuncs.c:961
static void CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
Definition: copyfuncs.c:3197
static PlannedStmt * _copyPlannedStmt(const PlannedStmt *from)
Definition: copyfuncs.c:78
static WindowDef * _copyWindowDef(const WindowDef *from)
Definition: copyfuncs.c:2628