PostgreSQL Source Code  git master
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-2021, 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/pathnodes.h"
28 #include "nodes/plannodes.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 = copyObjectImpl(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 an inline array */
57 #define COPY_ARRAY_FIELD(fldname) \
58  memcpy(newnode->fldname, from->fldname, sizeof(newnode->fldname))
59 
60 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
61 #define COPY_POINTER_FIELD(fldname, sz) \
62  do { \
63  Size _size = (sz); \
64  if (_size > 0) \
65  { \
66  newnode->fldname = palloc(_size); \
67  memcpy(newnode->fldname, from->fldname, _size); \
68  } \
69  } while (0)
70 
71 /* Copy a parse location field (for Copy, this is same as scalar case) */
72 #define COPY_LOCATION_FIELD(fldname) \
73  (newnode->fldname = from->fldname)
74 
75 
76 /* ****************************************************************
77  * plannodes.h copy functions
78  * ****************************************************************
79  */
80 
81 /*
82  * _copyPlannedStmt
83  */
84 static PlannedStmt *
86 {
87  PlannedStmt *newnode = makeNode(PlannedStmt);
88 
89  COPY_SCALAR_FIELD(commandType);
90  COPY_SCALAR_FIELD(queryId);
91  COPY_SCALAR_FIELD(hasReturning);
92  COPY_SCALAR_FIELD(hasModifyingCTE);
93  COPY_SCALAR_FIELD(canSetTag);
94  COPY_SCALAR_FIELD(transientPlan);
95  COPY_SCALAR_FIELD(dependsOnRole);
96  COPY_SCALAR_FIELD(parallelModeNeeded);
97  COPY_SCALAR_FIELD(jitFlags);
98  COPY_NODE_FIELD(planTree);
99  COPY_NODE_FIELD(rtable);
100  COPY_NODE_FIELD(resultRelations);
101  COPY_NODE_FIELD(appendRelations);
102  COPY_NODE_FIELD(subplans);
103  COPY_BITMAPSET_FIELD(rewindPlanIDs);
104  COPY_NODE_FIELD(rowMarks);
105  COPY_NODE_FIELD(relationOids);
106  COPY_NODE_FIELD(invalItems);
107  COPY_NODE_FIELD(paramExecTypes);
108  COPY_NODE_FIELD(utilityStmt);
109  COPY_LOCATION_FIELD(stmt_location);
110  COPY_SCALAR_FIELD(stmt_len);
111 
112  return newnode;
113 }
114 
115 /*
116  * CopyPlanFields
117  *
118  * This function copies the fields of the Plan node. It is used by
119  * all the copy functions for classes which inherit from Plan.
120  */
121 static void
122 CopyPlanFields(const Plan *from, Plan *newnode)
123 {
124  COPY_SCALAR_FIELD(startup_cost);
125  COPY_SCALAR_FIELD(total_cost);
126  COPY_SCALAR_FIELD(plan_rows);
127  COPY_SCALAR_FIELD(plan_width);
128  COPY_SCALAR_FIELD(parallel_aware);
129  COPY_SCALAR_FIELD(parallel_safe);
130  COPY_SCALAR_FIELD(async_capable);
131  COPY_SCALAR_FIELD(plan_node_id);
132  COPY_NODE_FIELD(targetlist);
133  COPY_NODE_FIELD(qual);
134  COPY_NODE_FIELD(lefttree);
135  COPY_NODE_FIELD(righttree);
136  COPY_NODE_FIELD(initPlan);
137  COPY_BITMAPSET_FIELD(extParam);
138  COPY_BITMAPSET_FIELD(allParam);
139 }
140 
141 /*
142  * _copyPlan
143  */
144 static Plan *
145 _copyPlan(const Plan *from)
146 {
147  Plan *newnode = makeNode(Plan);
148 
149  /*
150  * copy node superclass fields
151  */
152  CopyPlanFields(from, newnode);
153 
154  return newnode;
155 }
156 
157 
158 /*
159  * _copyResult
160  */
161 static Result *
162 _copyResult(const Result *from)
163 {
164  Result *newnode = makeNode(Result);
165 
166  /*
167  * copy node superclass fields
168  */
169  CopyPlanFields((const Plan *) from, (Plan *) newnode);
170 
171  /*
172  * copy remainder of node
173  */
174  COPY_NODE_FIELD(resconstantqual);
175 
176  return newnode;
177 }
178 
179 /*
180  * _copyProjectSet
181  */
182 static ProjectSet *
184 {
185  ProjectSet *newnode = makeNode(ProjectSet);
186 
187  /*
188  * copy node superclass fields
189  */
190  CopyPlanFields((const Plan *) from, (Plan *) newnode);
191 
192  return newnode;
193 }
194 
195 /*
196  * _copyModifyTable
197  */
198 static ModifyTable *
200 {
201  ModifyTable *newnode = makeNode(ModifyTable);
202 
203  /*
204  * copy node superclass fields
205  */
206  CopyPlanFields((const Plan *) from, (Plan *) newnode);
207 
208  /*
209  * copy remainder of node
210  */
211  COPY_SCALAR_FIELD(operation);
212  COPY_SCALAR_FIELD(canSetTag);
213  COPY_SCALAR_FIELD(nominalRelation);
214  COPY_SCALAR_FIELD(rootRelation);
215  COPY_SCALAR_FIELD(partColsUpdated);
216  COPY_NODE_FIELD(resultRelations);
217  COPY_NODE_FIELD(updateColnosLists);
218  COPY_NODE_FIELD(withCheckOptionLists);
219  COPY_NODE_FIELD(returningLists);
220  COPY_NODE_FIELD(fdwPrivLists);
221  COPY_BITMAPSET_FIELD(fdwDirectModifyPlans);
222  COPY_NODE_FIELD(rowMarks);
223  COPY_SCALAR_FIELD(epqParam);
224  COPY_SCALAR_FIELD(onConflictAction);
225  COPY_NODE_FIELD(arbiterIndexes);
226  COPY_NODE_FIELD(onConflictSet);
227  COPY_NODE_FIELD(onConflictCols);
228  COPY_NODE_FIELD(onConflictWhere);
229  COPY_SCALAR_FIELD(exclRelRTI);
230  COPY_NODE_FIELD(exclRelTlist);
231 
232  return newnode;
233 }
234 
235 /*
236  * _copyAppend
237  */
238 static Append *
239 _copyAppend(const Append *from)
240 {
241  Append *newnode = makeNode(Append);
242 
243  /*
244  * copy node superclass fields
245  */
246  CopyPlanFields((const Plan *) from, (Plan *) newnode);
247 
248  /*
249  * copy remainder of node
250  */
251  COPY_BITMAPSET_FIELD(apprelids);
252  COPY_NODE_FIELD(appendplans);
253  COPY_SCALAR_FIELD(nasyncplans);
254  COPY_SCALAR_FIELD(first_partial_plan);
255  COPY_NODE_FIELD(part_prune_info);
256 
257  return newnode;
258 }
259 
260 /*
261  * _copyMergeAppend
262  */
263 static MergeAppend *
265 {
266  MergeAppend *newnode = makeNode(MergeAppend);
267 
268  /*
269  * copy node superclass fields
270  */
271  CopyPlanFields((const Plan *) from, (Plan *) newnode);
272 
273  /*
274  * copy remainder of node
275  */
276  COPY_BITMAPSET_FIELD(apprelids);
277  COPY_NODE_FIELD(mergeplans);
278  COPY_SCALAR_FIELD(numCols);
279  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
280  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
281  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
282  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
283  COPY_NODE_FIELD(part_prune_info);
284 
285  return newnode;
286 }
287 
288 /*
289  * _copyRecursiveUnion
290  */
291 static RecursiveUnion *
293 {
295 
296  /*
297  * copy node superclass fields
298  */
299  CopyPlanFields((const Plan *) from, (Plan *) newnode);
300 
301  /*
302  * copy remainder of node
303  */
304  COPY_SCALAR_FIELD(wtParam);
305  COPY_SCALAR_FIELD(numCols);
306  COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
307  COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
308  COPY_POINTER_FIELD(dupCollations, from->numCols * sizeof(Oid));
309  COPY_SCALAR_FIELD(numGroups);
310 
311  return newnode;
312 }
313 
314 /*
315  * _copyBitmapAnd
316  */
317 static BitmapAnd *
319 {
320  BitmapAnd *newnode = makeNode(BitmapAnd);
321 
322  /*
323  * copy node superclass fields
324  */
325  CopyPlanFields((const Plan *) from, (Plan *) newnode);
326 
327  /*
328  * copy remainder of node
329  */
330  COPY_NODE_FIELD(bitmapplans);
331 
332  return newnode;
333 }
334 
335 /*
336  * _copyBitmapOr
337  */
338 static BitmapOr *
340 {
341  BitmapOr *newnode = makeNode(BitmapOr);
342 
343  /*
344  * copy node superclass fields
345  */
346  CopyPlanFields((const Plan *) from, (Plan *) newnode);
347 
348  /*
349  * copy remainder of node
350  */
351  COPY_SCALAR_FIELD(isshared);
352  COPY_NODE_FIELD(bitmapplans);
353 
354  return newnode;
355 }
356 
357 /*
358  * _copyGather
359  */
360 static Gather *
361 _copyGather(const Gather *from)
362 {
363  Gather *newnode = makeNode(Gather);
364 
365  /*
366  * copy node superclass fields
367  */
368  CopyPlanFields((const Plan *) from, (Plan *) newnode);
369 
370  /*
371  * copy remainder of node
372  */
373  COPY_SCALAR_FIELD(num_workers);
374  COPY_SCALAR_FIELD(rescan_param);
375  COPY_SCALAR_FIELD(single_copy);
376  COPY_SCALAR_FIELD(invisible);
377  COPY_BITMAPSET_FIELD(initParam);
378 
379  return newnode;
380 }
381 
382 /*
383  * _copyGatherMerge
384  */
385 static GatherMerge *
387 {
388  GatherMerge *newnode = makeNode(GatherMerge);
389 
390  /*
391  * copy node superclass fields
392  */
393  CopyPlanFields((const Plan *) from, (Plan *) newnode);
394 
395  /*
396  * copy remainder of node
397  */
398  COPY_SCALAR_FIELD(num_workers);
399  COPY_SCALAR_FIELD(rescan_param);
400  COPY_SCALAR_FIELD(numCols);
401  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
402  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
403  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
404  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
405  COPY_BITMAPSET_FIELD(initParam);
406 
407  return newnode;
408 }
409 
410 /*
411  * CopyScanFields
412  *
413  * This function copies the fields of the Scan node. It is used by
414  * all the copy functions for classes which inherit from Scan.
415  */
416 static void
417 CopyScanFields(const Scan *from, Scan *newnode)
418 {
419  CopyPlanFields((const Plan *) from, (Plan *) newnode);
420 
421  COPY_SCALAR_FIELD(scanrelid);
422 }
423 
424 /*
425  * _copyScan
426  */
427 static Scan *
428 _copyScan(const Scan *from)
429 {
430  Scan *newnode = makeNode(Scan);
431 
432  /*
433  * copy node superclass fields
434  */
435  CopyScanFields((const Scan *) from, (Scan *) newnode);
436 
437  return newnode;
438 }
439 
440 /*
441  * _copySeqScan
442  */
443 static SeqScan *
444 _copySeqScan(const SeqScan *from)
445 {
446  SeqScan *newnode = makeNode(SeqScan);
447 
448  /*
449  * copy node superclass fields
450  */
451  CopyScanFields((const Scan *) from, (Scan *) newnode);
452 
453  return newnode;
454 }
455 
456 /*
457  * _copySampleScan
458  */
459 static SampleScan *
461 {
462  SampleScan *newnode = makeNode(SampleScan);
463 
464  /*
465  * copy node superclass fields
466  */
467  CopyScanFields((const Scan *) from, (Scan *) newnode);
468 
469  /*
470  * copy remainder of node
471  */
472  COPY_NODE_FIELD(tablesample);
473 
474  return newnode;
475 }
476 
477 /*
478  * _copyIndexScan
479  */
480 static IndexScan *
482 {
483  IndexScan *newnode = makeNode(IndexScan);
484 
485  /*
486  * copy node superclass fields
487  */
488  CopyScanFields((const Scan *) from, (Scan *) newnode);
489 
490  /*
491  * copy remainder of node
492  */
493  COPY_SCALAR_FIELD(indexid);
494  COPY_NODE_FIELD(indexqual);
495  COPY_NODE_FIELD(indexqualorig);
496  COPY_NODE_FIELD(indexorderby);
497  COPY_NODE_FIELD(indexorderbyorig);
498  COPY_NODE_FIELD(indexorderbyops);
499  COPY_SCALAR_FIELD(indexorderdir);
500 
501  return newnode;
502 }
503 
504 /*
505  * _copyIndexOnlyScan
506  */
507 static IndexOnlyScan *
509 {
511 
512  /*
513  * copy node superclass fields
514  */
515  CopyScanFields((const Scan *) from, (Scan *) newnode);
516 
517  /*
518  * copy remainder of node
519  */
520  COPY_SCALAR_FIELD(indexid);
521  COPY_NODE_FIELD(indexqual);
522  COPY_NODE_FIELD(indexorderby);
523  COPY_NODE_FIELD(indextlist);
524  COPY_SCALAR_FIELD(indexorderdir);
525 
526  return newnode;
527 }
528 
529 /*
530  * _copyBitmapIndexScan
531  */
532 static BitmapIndexScan *
534 {
536 
537  /*
538  * copy node superclass fields
539  */
540  CopyScanFields((const Scan *) from, (Scan *) newnode);
541 
542  /*
543  * copy remainder of node
544  */
545  COPY_SCALAR_FIELD(indexid);
546  COPY_SCALAR_FIELD(isshared);
547  COPY_NODE_FIELD(indexqual);
548  COPY_NODE_FIELD(indexqualorig);
549 
550  return newnode;
551 }
552 
553 /*
554  * _copyBitmapHeapScan
555  */
556 static BitmapHeapScan *
558 {
560 
561  /*
562  * copy node superclass fields
563  */
564  CopyScanFields((const Scan *) from, (Scan *) newnode);
565 
566  /*
567  * copy remainder of node
568  */
569  COPY_NODE_FIELD(bitmapqualorig);
570 
571  return newnode;
572 }
573 
574 /*
575  * _copyTidScan
576  */
577 static TidScan *
578 _copyTidScan(const TidScan *from)
579 {
580  TidScan *newnode = makeNode(TidScan);
581 
582  /*
583  * copy node superclass fields
584  */
585  CopyScanFields((const Scan *) from, (Scan *) newnode);
586 
587  /*
588  * copy remainder of node
589  */
590  COPY_NODE_FIELD(tidquals);
591 
592  return newnode;
593 }
594 
595 /*
596  * _copyTidRangeScan
597  */
598 static TidRangeScan *
600 {
601  TidRangeScan *newnode = makeNode(TidRangeScan);
602 
603  /*
604  * copy node superclass fields
605  */
606  CopyScanFields((const Scan *) from, (Scan *) newnode);
607 
608  /*
609  * copy remainder of node
610  */
611  COPY_NODE_FIELD(tidrangequals);
612 
613  return newnode;
614 }
615 
616 /*
617  * _copySubqueryScan
618  */
619 static SubqueryScan *
621 {
622  SubqueryScan *newnode = makeNode(SubqueryScan);
623 
624  /*
625  * copy node superclass fields
626  */
627  CopyScanFields((const Scan *) from, (Scan *) newnode);
628 
629  /*
630  * copy remainder of node
631  */
632  COPY_NODE_FIELD(subplan);
633 
634  return newnode;
635 }
636 
637 /*
638  * _copyFunctionScan
639  */
640 static FunctionScan *
642 {
643  FunctionScan *newnode = makeNode(FunctionScan);
644 
645  /*
646  * copy node superclass fields
647  */
648  CopyScanFields((const Scan *) from, (Scan *) newnode);
649 
650  /*
651  * copy remainder of node
652  */
654  COPY_SCALAR_FIELD(funcordinality);
655 
656  return newnode;
657 }
658 
659 /*
660  * _copyTableFuncScan
661  */
662 static TableFuncScan *
664 {
666 
667  /*
668  * copy node superclass fields
669  */
670  CopyScanFields((const Scan *) from, (Scan *) newnode);
671 
672  /*
673  * copy remainder of node
674  */
675  COPY_NODE_FIELD(tablefunc);
676 
677  return newnode;
678 }
679 
680 /*
681  * _copyValuesScan
682  */
683 static ValuesScan *
685 {
686  ValuesScan *newnode = makeNode(ValuesScan);
687 
688  /*
689  * copy node superclass fields
690  */
691  CopyScanFields((const Scan *) from, (Scan *) newnode);
692 
693  /*
694  * copy remainder of node
695  */
696  COPY_NODE_FIELD(values_lists);
697 
698  return newnode;
699 }
700 
701 /*
702  * _copyCteScan
703  */
704 static CteScan *
705 _copyCteScan(const CteScan *from)
706 {
707  CteScan *newnode = makeNode(CteScan);
708 
709  /*
710  * copy node superclass fields
711  */
712  CopyScanFields((const Scan *) from, (Scan *) newnode);
713 
714  /*
715  * copy remainder of node
716  */
717  COPY_SCALAR_FIELD(ctePlanId);
718  COPY_SCALAR_FIELD(cteParam);
719 
720  return newnode;
721 }
722 
723 /*
724  * _copyNamedTuplestoreScan
725  */
726 static NamedTuplestoreScan *
728 {
730 
731  /*
732  * copy node superclass fields
733  */
734  CopyScanFields((const Scan *) from, (Scan *) newnode);
735 
736  /*
737  * copy remainder of node
738  */
739  COPY_STRING_FIELD(enrname);
740 
741  return newnode;
742 }
743 
744 /*
745  * _copyWorkTableScan
746  */
747 static WorkTableScan *
749 {
751 
752  /*
753  * copy node superclass fields
754  */
755  CopyScanFields((const Scan *) from, (Scan *) newnode);
756 
757  /*
758  * copy remainder of node
759  */
760  COPY_SCALAR_FIELD(wtParam);
761 
762  return newnode;
763 }
764 
765 /*
766  * _copyForeignScan
767  */
768 static ForeignScan *
770 {
771  ForeignScan *newnode = makeNode(ForeignScan);
772 
773  /*
774  * copy node superclass fields
775  */
776  CopyScanFields((const Scan *) from, (Scan *) newnode);
777 
778  /*
779  * copy remainder of node
780  */
781  COPY_SCALAR_FIELD(operation);
782  COPY_SCALAR_FIELD(resultRelation);
783  COPY_SCALAR_FIELD(fs_server);
784  COPY_NODE_FIELD(fdw_exprs);
785  COPY_NODE_FIELD(fdw_private);
786  COPY_NODE_FIELD(fdw_scan_tlist);
787  COPY_NODE_FIELD(fdw_recheck_quals);
788  COPY_BITMAPSET_FIELD(fs_relids);
789  COPY_SCALAR_FIELD(fsSystemCol);
790 
791  return newnode;
792 }
793 
794 /*
795  * _copyCustomScan
796  */
797 static CustomScan *
799 {
800  CustomScan *newnode = makeNode(CustomScan);
801 
802  /*
803  * copy node superclass fields
804  */
805  CopyScanFields((const Scan *) from, (Scan *) newnode);
806 
807  /*
808  * copy remainder of node
809  */
810  COPY_SCALAR_FIELD(flags);
811  COPY_NODE_FIELD(custom_plans);
812  COPY_NODE_FIELD(custom_exprs);
813  COPY_NODE_FIELD(custom_private);
814  COPY_NODE_FIELD(custom_scan_tlist);
815  COPY_BITMAPSET_FIELD(custom_relids);
816 
817  /*
818  * NOTE: The method field of CustomScan is required to be a pointer to a
819  * static table of callback functions. So we don't copy the table itself,
820  * just reference the original one.
821  */
822  COPY_SCALAR_FIELD(methods);
823 
824  return newnode;
825 }
826 
827 /*
828  * CopyJoinFields
829  *
830  * This function copies the fields of the Join node. It is used by
831  * all the copy functions for classes which inherit from Join.
832  */
833 static void
834 CopyJoinFields(const Join *from, Join *newnode)
835 {
836  CopyPlanFields((const Plan *) from, (Plan *) newnode);
837 
838  COPY_SCALAR_FIELD(jointype);
839  COPY_SCALAR_FIELD(inner_unique);
840  COPY_NODE_FIELD(joinqual);
841 }
842 
843 
844 /*
845  * _copyJoin
846  */
847 static Join *
848 _copyJoin(const Join *from)
849 {
850  Join *newnode = makeNode(Join);
851 
852  /*
853  * copy node superclass fields
854  */
855  CopyJoinFields(from, newnode);
856 
857  return newnode;
858 }
859 
860 
861 /*
862  * _copyNestLoop
863  */
864 static NestLoop *
866 {
867  NestLoop *newnode = makeNode(NestLoop);
868 
869  /*
870  * copy node superclass fields
871  */
872  CopyJoinFields((const Join *) from, (Join *) newnode);
873 
874  /*
875  * copy remainder of node
876  */
877  COPY_NODE_FIELD(nestParams);
878 
879  return newnode;
880 }
881 
882 
883 /*
884  * _copyMergeJoin
885  */
886 static MergeJoin *
888 {
889  MergeJoin *newnode = makeNode(MergeJoin);
890  int numCols;
891 
892  /*
893  * copy node superclass fields
894  */
895  CopyJoinFields((const Join *) from, (Join *) newnode);
896 
897  /*
898  * copy remainder of node
899  */
900  COPY_SCALAR_FIELD(skip_mark_restore);
901  COPY_NODE_FIELD(mergeclauses);
902  numCols = list_length(from->mergeclauses);
903  COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
904  COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
905  COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
906  COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
907 
908  return newnode;
909 }
910 
911 /*
912  * _copyHashJoin
913  */
914 static HashJoin *
916 {
917  HashJoin *newnode = makeNode(HashJoin);
918 
919  /*
920  * copy node superclass fields
921  */
922  CopyJoinFields((const Join *) from, (Join *) newnode);
923 
924  /*
925  * copy remainder of node
926  */
927  COPY_NODE_FIELD(hashclauses);
928  COPY_NODE_FIELD(hashoperators);
929  COPY_NODE_FIELD(hashcollations);
930  COPY_NODE_FIELD(hashkeys);
931 
932  return newnode;
933 }
934 
935 
936 /*
937  * _copyMaterial
938  */
939 static Material *
941 {
942  Material *newnode = makeNode(Material);
943 
944  /*
945  * copy node superclass fields
946  */
947  CopyPlanFields((const Plan *) from, (Plan *) newnode);
948 
949  return newnode;
950 }
951 
952 
953 /*
954  * _copyMemoize
955  */
956 static Memoize *
957 _copyMemoize(const Memoize *from)
958 {
959  Memoize *newnode = makeNode(Memoize);
960 
961  /*
962  * copy node superclass fields
963  */
964  CopyPlanFields((const Plan *) from, (Plan *) newnode);
965 
966  /*
967  * copy remainder of node
968  */
969  COPY_SCALAR_FIELD(numKeys);
970  COPY_POINTER_FIELD(hashOperators, sizeof(Oid) * from->numKeys);
971  COPY_POINTER_FIELD(collations, sizeof(Oid) * from->numKeys);
972  COPY_NODE_FIELD(param_exprs);
973  COPY_SCALAR_FIELD(singlerow);
974  COPY_SCALAR_FIELD(est_entries);
975 
976  return newnode;
977 }
978 
979 
980 /*
981  * CopySortFields
982  *
983  * This function copies the fields of the Sort node. It is used by
984  * all the copy functions for classes which inherit from Sort.
985  */
986 static void
987 CopySortFields(const Sort *from, Sort *newnode)
988 {
989  CopyPlanFields((const Plan *) from, (Plan *) newnode);
990 
991  COPY_SCALAR_FIELD(numCols);
992  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
993  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
994  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
995  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
996 }
997 
998 /*
999  * _copySort
1000  */
1001 static Sort *
1002 _copySort(const Sort *from)
1003 {
1004  Sort *newnode = makeNode(Sort);
1005 
1006  /*
1007  * copy node superclass fields
1008  */
1009  CopySortFields(from, newnode);
1010 
1011  return newnode;
1012 }
1013 
1014 
1015 /*
1016  * _copyIncrementalSort
1017  */
1018 static IncrementalSort *
1020 {
1022 
1023  /*
1024  * copy node superclass fields
1025  */
1026  CopySortFields((const Sort *) from, (Sort *) newnode);
1027 
1028  /*
1029  * copy remainder of node
1030  */
1031  COPY_SCALAR_FIELD(nPresortedCols);
1032 
1033  return newnode;
1034 }
1035 
1036 
1037 /*
1038  * _copyGroup
1039  */
1040 static Group *
1041 _copyGroup(const Group *from)
1042 {
1043  Group *newnode = makeNode(Group);
1044 
1045  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1046 
1047  COPY_SCALAR_FIELD(numCols);
1048  COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
1049  COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
1050  COPY_POINTER_FIELD(grpCollations, from->numCols * sizeof(Oid));
1051 
1052  return newnode;
1053 }
1054 
1055 /*
1056  * _copyAgg
1057  */
1058 static Agg *
1059 _copyAgg(const Agg *from)
1060 {
1061  Agg *newnode = makeNode(Agg);
1062 
1063  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1064 
1065  COPY_SCALAR_FIELD(aggstrategy);
1066  COPY_SCALAR_FIELD(aggsplit);
1067  COPY_SCALAR_FIELD(numCols);
1068  COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
1069  COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
1070  COPY_POINTER_FIELD(grpCollations, from->numCols * sizeof(Oid));
1071  COPY_SCALAR_FIELD(numGroups);
1072  COPY_SCALAR_FIELD(transitionSpace);
1073  COPY_BITMAPSET_FIELD(aggParams);
1074  COPY_NODE_FIELD(groupingSets);
1075  COPY_NODE_FIELD(chain);
1076 
1077  return newnode;
1078 }
1079 
1080 /*
1081  * _copyWindowAgg
1082  */
1083 static WindowAgg *
1085 {
1086  WindowAgg *newnode = makeNode(WindowAgg);
1087 
1088  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1089 
1090  COPY_SCALAR_FIELD(winref);
1091  COPY_SCALAR_FIELD(partNumCols);
1092  COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
1093  COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
1094  COPY_POINTER_FIELD(partCollations, from->partNumCols * sizeof(Oid));
1095  COPY_SCALAR_FIELD(ordNumCols);
1096  COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
1097  COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
1098  COPY_POINTER_FIELD(ordCollations, from->ordNumCols * sizeof(Oid));
1099  COPY_SCALAR_FIELD(frameOptions);
1100  COPY_NODE_FIELD(startOffset);
1101  COPY_NODE_FIELD(endOffset);
1102  COPY_SCALAR_FIELD(startInRangeFunc);
1103  COPY_SCALAR_FIELD(endInRangeFunc);
1104  COPY_SCALAR_FIELD(inRangeColl);
1105  COPY_SCALAR_FIELD(inRangeAsc);
1106  COPY_SCALAR_FIELD(inRangeNullsFirst);
1107 
1108  return newnode;
1109 }
1110 
1111 /*
1112  * _copyUnique
1113  */
1114 static Unique *
1115 _copyUnique(const Unique *from)
1116 {
1117  Unique *newnode = makeNode(Unique);
1118 
1119  /*
1120  * copy node superclass fields
1121  */
1122  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1123 
1124  /*
1125  * copy remainder of node
1126  */
1127  COPY_SCALAR_FIELD(numCols);
1128  COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
1129  COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
1130  COPY_POINTER_FIELD(uniqCollations, from->numCols * sizeof(Oid));
1131 
1132  return newnode;
1133 }
1134 
1135 /*
1136  * _copyHash
1137  */
1138 static Hash *
1139 _copyHash(const Hash *from)
1140 {
1141  Hash *newnode = makeNode(Hash);
1142 
1143  /*
1144  * copy node superclass fields
1145  */
1146  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1147 
1148  /*
1149  * copy remainder of node
1150  */
1151  COPY_NODE_FIELD(hashkeys);
1152  COPY_SCALAR_FIELD(skewTable);
1153  COPY_SCALAR_FIELD(skewColumn);
1154  COPY_SCALAR_FIELD(skewInherit);
1155  COPY_SCALAR_FIELD(rows_total);
1156 
1157  return newnode;
1158 }
1159 
1160 /*
1161  * _copySetOp
1162  */
1163 static SetOp *
1164 _copySetOp(const SetOp *from)
1165 {
1166  SetOp *newnode = makeNode(SetOp);
1167 
1168  /*
1169  * copy node superclass fields
1170  */
1171  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1172 
1173  /*
1174  * copy remainder of node
1175  */
1176  COPY_SCALAR_FIELD(cmd);
1177  COPY_SCALAR_FIELD(strategy);
1178  COPY_SCALAR_FIELD(numCols);
1179  COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
1180  COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
1181  COPY_POINTER_FIELD(dupCollations, from->numCols * sizeof(Oid));
1182  COPY_SCALAR_FIELD(flagColIdx);
1183  COPY_SCALAR_FIELD(firstFlag);
1184  COPY_SCALAR_FIELD(numGroups);
1185 
1186  return newnode;
1187 }
1188 
1189 /*
1190  * _copyLockRows
1191  */
1192 static LockRows *
1194 {
1195  LockRows *newnode = makeNode(LockRows);
1196 
1197  /*
1198  * copy node superclass fields
1199  */
1200  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1201 
1202  /*
1203  * copy remainder of node
1204  */
1205  COPY_NODE_FIELD(rowMarks);
1206  COPY_SCALAR_FIELD(epqParam);
1207 
1208  return newnode;
1209 }
1210 
1211 /*
1212  * _copyLimit
1213  */
1214 static Limit *
1215 _copyLimit(const Limit *from)
1216 {
1217  Limit *newnode = makeNode(Limit);
1218 
1219  /*
1220  * copy node superclass fields
1221  */
1222  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1223 
1224  /*
1225  * copy remainder of node
1226  */
1227  COPY_NODE_FIELD(limitOffset);
1228  COPY_NODE_FIELD(limitCount);
1229  COPY_SCALAR_FIELD(limitOption);
1230  COPY_SCALAR_FIELD(uniqNumCols);
1231  COPY_POINTER_FIELD(uniqColIdx, from->uniqNumCols * sizeof(AttrNumber));
1232  COPY_POINTER_FIELD(uniqOperators, from->uniqNumCols * sizeof(Oid));
1233  COPY_POINTER_FIELD(uniqCollations, from->uniqNumCols * sizeof(Oid));
1234 
1235  return newnode;
1236 }
1237 
1238 /*
1239  * _copyNestLoopParam
1240  */
1241 static NestLoopParam *
1243 {
1244  NestLoopParam *newnode = makeNode(NestLoopParam);
1245 
1246  COPY_SCALAR_FIELD(paramno);
1247  COPY_NODE_FIELD(paramval);
1248 
1249  return newnode;
1250 }
1251 
1252 /*
1253  * _copyPlanRowMark
1254  */
1255 static PlanRowMark *
1257 {
1258  PlanRowMark *newnode = makeNode(PlanRowMark);
1259 
1260  COPY_SCALAR_FIELD(rti);
1261  COPY_SCALAR_FIELD(prti);
1262  COPY_SCALAR_FIELD(rowmarkId);
1263  COPY_SCALAR_FIELD(markType);
1264  COPY_SCALAR_FIELD(allMarkTypes);
1265  COPY_SCALAR_FIELD(strength);
1266  COPY_SCALAR_FIELD(waitPolicy);
1267  COPY_SCALAR_FIELD(isParent);
1268 
1269  return newnode;
1270 }
1271 
1272 static PartitionPruneInfo *
1274 {
1276 
1277  COPY_NODE_FIELD(prune_infos);
1278  COPY_BITMAPSET_FIELD(other_subplans);
1279 
1280  return newnode;
1281 }
1282 
1283 static PartitionedRelPruneInfo *
1285 {
1287 
1288  COPY_SCALAR_FIELD(rtindex);
1289  COPY_BITMAPSET_FIELD(present_parts);
1290  COPY_SCALAR_FIELD(nparts);
1291  COPY_POINTER_FIELD(subplan_map, from->nparts * sizeof(int));
1292  COPY_POINTER_FIELD(subpart_map, from->nparts * sizeof(int));
1293  COPY_POINTER_FIELD(relid_map, from->nparts * sizeof(Oid));
1294  COPY_NODE_FIELD(initial_pruning_steps);
1295  COPY_NODE_FIELD(exec_pruning_steps);
1296  COPY_BITMAPSET_FIELD(execparamids);
1297 
1298  return newnode;
1299 }
1300 
1301 /*
1302  * _copyPartitionPruneStepOp
1303  */
1304 static PartitionPruneStepOp *
1306 {
1308 
1309  COPY_SCALAR_FIELD(step.step_id);
1310  COPY_SCALAR_FIELD(opstrategy);
1311  COPY_NODE_FIELD(exprs);
1312  COPY_NODE_FIELD(cmpfns);
1313  COPY_BITMAPSET_FIELD(nullkeys);
1314 
1315  return newnode;
1316 }
1317 
1318 /*
1319  * _copyPartitionPruneStepCombine
1320  */
1323 {
1325 
1326  COPY_SCALAR_FIELD(step.step_id);
1327  COPY_SCALAR_FIELD(combineOp);
1328  COPY_NODE_FIELD(source_stepids);
1329 
1330  return newnode;
1331 }
1332 
1333 /*
1334  * _copyPlanInvalItem
1335  */
1336 static PlanInvalItem *
1338 {
1339  PlanInvalItem *newnode = makeNode(PlanInvalItem);
1340 
1341  COPY_SCALAR_FIELD(cacheId);
1342  COPY_SCALAR_FIELD(hashValue);
1343 
1344  return newnode;
1345 }
1346 
1347 /* ****************************************************************
1348  * primnodes.h copy functions
1349  * ****************************************************************
1350  */
1351 
1352 /*
1353  * _copyAlias
1354  */
1355 static Alias *
1356 _copyAlias(const Alias *from)
1357 {
1358  Alias *newnode = makeNode(Alias);
1359 
1360  COPY_STRING_FIELD(aliasname);
1361  COPY_NODE_FIELD(colnames);
1362 
1363  return newnode;
1364 }
1365 
1366 /*
1367  * _copyRangeVar
1368  */
1369 static RangeVar *
1371 {
1372  RangeVar *newnode = makeNode(RangeVar);
1373 
1374  COPY_STRING_FIELD(catalogname);
1375  COPY_STRING_FIELD(schemaname);
1377  COPY_SCALAR_FIELD(inh);
1378  COPY_SCALAR_FIELD(relpersistence);
1379  COPY_NODE_FIELD(alias);
1380  COPY_LOCATION_FIELD(location);
1381 
1382  return newnode;
1383 }
1384 
1385 /*
1386  * _copyTableFunc
1387  */
1388 static TableFunc *
1390 {
1391  TableFunc *newnode = makeNode(TableFunc);
1392 
1393  COPY_NODE_FIELD(ns_uris);
1394  COPY_NODE_FIELD(ns_names);
1395  COPY_NODE_FIELD(docexpr);
1396  COPY_NODE_FIELD(rowexpr);
1397  COPY_NODE_FIELD(colnames);
1398  COPY_NODE_FIELD(coltypes);
1399  COPY_NODE_FIELD(coltypmods);
1400  COPY_NODE_FIELD(colcollations);
1401  COPY_NODE_FIELD(colexprs);
1402  COPY_NODE_FIELD(coldefexprs);
1403  COPY_BITMAPSET_FIELD(notnulls);
1404  COPY_SCALAR_FIELD(ordinalitycol);
1405  COPY_LOCATION_FIELD(location);
1406 
1407  return newnode;
1408 }
1409 
1410 /*
1411  * _copyIntoClause
1412  */
1413 static IntoClause *
1415 {
1416  IntoClause *newnode = makeNode(IntoClause);
1417 
1418  COPY_NODE_FIELD(rel);
1419  COPY_NODE_FIELD(colNames);
1420  COPY_STRING_FIELD(accessMethod);
1422  COPY_SCALAR_FIELD(onCommit);
1423  COPY_STRING_FIELD(tableSpaceName);
1424  COPY_NODE_FIELD(viewQuery);
1425  COPY_SCALAR_FIELD(skipData);
1426 
1427  return newnode;
1428 }
1429 
1430 /*
1431  * We don't need a _copyExpr because Expr is an abstract supertype which
1432  * should never actually get instantiated. Also, since it has no common
1433  * fields except NodeTag, there's no need for a helper routine to factor
1434  * out copying the common fields...
1435  */
1436 
1437 /*
1438  * _copyVar
1439  */
1440 static Var *
1441 _copyVar(const Var *from)
1442 {
1443  Var *newnode = makeNode(Var);
1444 
1445  COPY_SCALAR_FIELD(varno);
1446  COPY_SCALAR_FIELD(varattno);
1447  COPY_SCALAR_FIELD(vartype);
1448  COPY_SCALAR_FIELD(vartypmod);
1449  COPY_SCALAR_FIELD(varcollid);
1450  COPY_SCALAR_FIELD(varlevelsup);
1451  COPY_SCALAR_FIELD(varnosyn);
1452  COPY_SCALAR_FIELD(varattnosyn);
1453  COPY_LOCATION_FIELD(location);
1454 
1455  return newnode;
1456 }
1457 
1458 /*
1459  * _copyConst
1460  */
1461 static Const *
1462 _copyConst(const Const *from)
1463 {
1464  Const *newnode = makeNode(Const);
1465 
1466  COPY_SCALAR_FIELD(consttype);
1467  COPY_SCALAR_FIELD(consttypmod);
1468  COPY_SCALAR_FIELD(constcollid);
1469  COPY_SCALAR_FIELD(constlen);
1470 
1471  if (from->constbyval || from->constisnull)
1472  {
1473  /*
1474  * passed by value so just copy the datum. Also, don't try to copy
1475  * struct when value is null!
1476  */
1477  newnode->constvalue = from->constvalue;
1478  }
1479  else
1480  {
1481  /*
1482  * passed by reference. We need a palloc'd copy.
1483  */
1484  newnode->constvalue = datumCopy(from->constvalue,
1485  from->constbyval,
1486  from->constlen);
1487  }
1488 
1489  COPY_SCALAR_FIELD(constisnull);
1490  COPY_SCALAR_FIELD(constbyval);
1491  COPY_LOCATION_FIELD(location);
1492 
1493  return newnode;
1494 }
1495 
1496 /*
1497  * _copyParam
1498  */
1499 static Param *
1500 _copyParam(const Param *from)
1501 {
1502  Param *newnode = makeNode(Param);
1503 
1504  COPY_SCALAR_FIELD(paramkind);
1505  COPY_SCALAR_FIELD(paramid);
1506  COPY_SCALAR_FIELD(paramtype);
1507  COPY_SCALAR_FIELD(paramtypmod);
1508  COPY_SCALAR_FIELD(paramcollid);
1509  COPY_LOCATION_FIELD(location);
1510 
1511  return newnode;
1512 }
1513 
1514 /*
1515  * _copyAggref
1516  */
1517 static Aggref *
1518 _copyAggref(const Aggref *from)
1519 {
1520  Aggref *newnode = makeNode(Aggref);
1521 
1522  COPY_SCALAR_FIELD(aggfnoid);
1523  COPY_SCALAR_FIELD(aggtype);
1524  COPY_SCALAR_FIELD(aggcollid);
1525  COPY_SCALAR_FIELD(inputcollid);
1526  COPY_SCALAR_FIELD(aggtranstype);
1527  COPY_NODE_FIELD(aggargtypes);
1528  COPY_NODE_FIELD(aggdirectargs);
1530  COPY_NODE_FIELD(aggorder);
1531  COPY_NODE_FIELD(aggdistinct);
1532  COPY_NODE_FIELD(aggfilter);
1533  COPY_SCALAR_FIELD(aggstar);
1534  COPY_SCALAR_FIELD(aggvariadic);
1535  COPY_SCALAR_FIELD(aggkind);
1536  COPY_SCALAR_FIELD(agglevelsup);
1537  COPY_SCALAR_FIELD(aggsplit);
1538  COPY_SCALAR_FIELD(aggno);
1539  COPY_SCALAR_FIELD(aggtransno);
1540  COPY_LOCATION_FIELD(location);
1541 
1542  return newnode;
1543 }
1544 
1545 /*
1546  * _copyGroupingFunc
1547  */
1548 static GroupingFunc *
1550 {
1551  GroupingFunc *newnode = makeNode(GroupingFunc);
1552 
1554  COPY_NODE_FIELD(refs);
1555  COPY_NODE_FIELD(cols);
1556  COPY_SCALAR_FIELD(agglevelsup);
1557  COPY_LOCATION_FIELD(location);
1558 
1559  return newnode;
1560 }
1561 
1562 /*
1563  * _copyWindowFunc
1564  */
1565 static WindowFunc *
1567 {
1568  WindowFunc *newnode = makeNode(WindowFunc);
1569 
1570  COPY_SCALAR_FIELD(winfnoid);
1571  COPY_SCALAR_FIELD(wintype);
1572  COPY_SCALAR_FIELD(wincollid);
1573  COPY_SCALAR_FIELD(inputcollid);
1575  COPY_NODE_FIELD(aggfilter);
1576  COPY_SCALAR_FIELD(winref);
1577  COPY_SCALAR_FIELD(winstar);
1578  COPY_SCALAR_FIELD(winagg);
1579  COPY_LOCATION_FIELD(location);
1580 
1581  return newnode;
1582 }
1583 
1584 /*
1585  * _copySubscriptingRef
1586  */
1587 static SubscriptingRef *
1589 {
1591 
1592  COPY_SCALAR_FIELD(refcontainertype);
1593  COPY_SCALAR_FIELD(refelemtype);
1594  COPY_SCALAR_FIELD(refrestype);
1595  COPY_SCALAR_FIELD(reftypmod);
1596  COPY_SCALAR_FIELD(refcollid);
1597  COPY_NODE_FIELD(refupperindexpr);
1598  COPY_NODE_FIELD(reflowerindexpr);
1599  COPY_NODE_FIELD(refexpr);
1600  COPY_NODE_FIELD(refassgnexpr);
1601 
1602  return newnode;
1603 }
1604 
1605 /*
1606  * _copyFuncExpr
1607  */
1608 static FuncExpr *
1610 {
1611  FuncExpr *newnode = makeNode(FuncExpr);
1612 
1613  COPY_SCALAR_FIELD(funcid);
1614  COPY_SCALAR_FIELD(funcresulttype);
1615  COPY_SCALAR_FIELD(funcretset);
1616  COPY_SCALAR_FIELD(funcvariadic);
1617  COPY_SCALAR_FIELD(funcformat);
1618  COPY_SCALAR_FIELD(funccollid);
1619  COPY_SCALAR_FIELD(inputcollid);
1621  COPY_LOCATION_FIELD(location);
1622 
1623  return newnode;
1624 }
1625 
1626 /*
1627  * _copyNamedArgExpr *
1628  */
1629 static NamedArgExpr *
1631 {
1632  NamedArgExpr *newnode = makeNode(NamedArgExpr);
1633 
1636  COPY_SCALAR_FIELD(argnumber);
1637  COPY_LOCATION_FIELD(location);
1638 
1639  return newnode;
1640 }
1641 
1642 /*
1643  * _copyOpExpr
1644  */
1645 static OpExpr *
1646 _copyOpExpr(const OpExpr *from)
1647 {
1648  OpExpr *newnode = makeNode(OpExpr);
1649 
1650  COPY_SCALAR_FIELD(opno);
1651  COPY_SCALAR_FIELD(opfuncid);
1652  COPY_SCALAR_FIELD(opresulttype);
1653  COPY_SCALAR_FIELD(opretset);
1654  COPY_SCALAR_FIELD(opcollid);
1655  COPY_SCALAR_FIELD(inputcollid);
1657  COPY_LOCATION_FIELD(location);
1658 
1659  return newnode;
1660 }
1661 
1662 /*
1663  * _copyDistinctExpr (same as OpExpr)
1664  */
1665 static DistinctExpr *
1667 {
1668  DistinctExpr *newnode = makeNode(DistinctExpr);
1669 
1670  COPY_SCALAR_FIELD(opno);
1671  COPY_SCALAR_FIELD(opfuncid);
1672  COPY_SCALAR_FIELD(opresulttype);
1673  COPY_SCALAR_FIELD(opretset);
1674  COPY_SCALAR_FIELD(opcollid);
1675  COPY_SCALAR_FIELD(inputcollid);
1677  COPY_LOCATION_FIELD(location);
1678 
1679  return newnode;
1680 }
1681 
1682 /*
1683  * _copyNullIfExpr (same as OpExpr)
1684  */
1685 static NullIfExpr *
1687 {
1688  NullIfExpr *newnode = makeNode(NullIfExpr);
1689 
1690  COPY_SCALAR_FIELD(opno);
1691  COPY_SCALAR_FIELD(opfuncid);
1692  COPY_SCALAR_FIELD(opresulttype);
1693  COPY_SCALAR_FIELD(opretset);
1694  COPY_SCALAR_FIELD(opcollid);
1695  COPY_SCALAR_FIELD(inputcollid);
1697  COPY_LOCATION_FIELD(location);
1698 
1699  return newnode;
1700 }
1701 
1702 /*
1703  * _copyScalarArrayOpExpr
1704  */
1705 static ScalarArrayOpExpr *
1707 {
1709 
1710  COPY_SCALAR_FIELD(opno);
1711  COPY_SCALAR_FIELD(opfuncid);
1712  COPY_SCALAR_FIELD(hashfuncid);
1713  COPY_SCALAR_FIELD(negfuncid);
1714  COPY_SCALAR_FIELD(useOr);
1715  COPY_SCALAR_FIELD(inputcollid);
1717  COPY_LOCATION_FIELD(location);
1718 
1719  return newnode;
1720 }
1721 
1722 /*
1723  * _copyBoolExpr
1724  */
1725 static BoolExpr *
1727 {
1728  BoolExpr *newnode = makeNode(BoolExpr);
1729 
1732  COPY_LOCATION_FIELD(location);
1733 
1734  return newnode;
1735 }
1736 
1737 /*
1738  * _copySubLink
1739  */
1740 static SubLink *
1741 _copySubLink(const SubLink *from)
1742 {
1743  SubLink *newnode = makeNode(SubLink);
1744 
1745  COPY_SCALAR_FIELD(subLinkType);
1746  COPY_SCALAR_FIELD(subLinkId);
1747  COPY_NODE_FIELD(testexpr);
1748  COPY_NODE_FIELD(operName);
1749  COPY_NODE_FIELD(subselect);
1750  COPY_LOCATION_FIELD(location);
1751 
1752  return newnode;
1753 }
1754 
1755 /*
1756  * _copySubPlan
1757  */
1758 static SubPlan *
1759 _copySubPlan(const SubPlan *from)
1760 {
1761  SubPlan *newnode = makeNode(SubPlan);
1762 
1763  COPY_SCALAR_FIELD(subLinkType);
1764  COPY_NODE_FIELD(testexpr);
1765  COPY_NODE_FIELD(paramIds);
1766  COPY_SCALAR_FIELD(plan_id);
1767  COPY_STRING_FIELD(plan_name);
1768  COPY_SCALAR_FIELD(firstColType);
1769  COPY_SCALAR_FIELD(firstColTypmod);
1770  COPY_SCALAR_FIELD(firstColCollation);
1771  COPY_SCALAR_FIELD(useHashTable);
1772  COPY_SCALAR_FIELD(unknownEqFalse);
1773  COPY_SCALAR_FIELD(parallel_safe);
1774  COPY_NODE_FIELD(setParam);
1775  COPY_NODE_FIELD(parParam);
1777  COPY_SCALAR_FIELD(startup_cost);
1778  COPY_SCALAR_FIELD(per_call_cost);
1779 
1780  return newnode;
1781 }
1782 
1783 /*
1784  * _copyAlternativeSubPlan
1785  */
1786 static AlternativeSubPlan *
1788 {
1790 
1791  COPY_NODE_FIELD(subplans);
1792 
1793  return newnode;
1794 }
1795 
1796 /*
1797  * _copyFieldSelect
1798  */
1799 static FieldSelect *
1801 {
1802  FieldSelect *newnode = makeNode(FieldSelect);
1803 
1805  COPY_SCALAR_FIELD(fieldnum);
1806  COPY_SCALAR_FIELD(resulttype);
1807  COPY_SCALAR_FIELD(resulttypmod);
1808  COPY_SCALAR_FIELD(resultcollid);
1809 
1810  return newnode;
1811 }
1812 
1813 /*
1814  * _copyFieldStore
1815  */
1816 static FieldStore *
1818 {
1819  FieldStore *newnode = makeNode(FieldStore);
1820 
1822  COPY_NODE_FIELD(newvals);
1823  COPY_NODE_FIELD(fieldnums);
1824  COPY_SCALAR_FIELD(resulttype);
1825 
1826  return newnode;
1827 }
1828 
1829 /*
1830  * _copyRelabelType
1831  */
1832 static RelabelType *
1834 {
1835  RelabelType *newnode = makeNode(RelabelType);
1836 
1838  COPY_SCALAR_FIELD(resulttype);
1839  COPY_SCALAR_FIELD(resulttypmod);
1840  COPY_SCALAR_FIELD(resultcollid);
1841  COPY_SCALAR_FIELD(relabelformat);
1842  COPY_LOCATION_FIELD(location);
1843 
1844  return newnode;
1845 }
1846 
1847 /*
1848  * _copyCoerceViaIO
1849  */
1850 static CoerceViaIO *
1852 {
1853  CoerceViaIO *newnode = makeNode(CoerceViaIO);
1854 
1856  COPY_SCALAR_FIELD(resulttype);
1857  COPY_SCALAR_FIELD(resultcollid);
1858  COPY_SCALAR_FIELD(coerceformat);
1859  COPY_LOCATION_FIELD(location);
1860 
1861  return newnode;
1862 }
1863 
1864 /*
1865  * _copyArrayCoerceExpr
1866  */
1867 static ArrayCoerceExpr *
1869 {
1871 
1873  COPY_NODE_FIELD(elemexpr);
1874  COPY_SCALAR_FIELD(resulttype);
1875  COPY_SCALAR_FIELD(resulttypmod);
1876  COPY_SCALAR_FIELD(resultcollid);
1877  COPY_SCALAR_FIELD(coerceformat);
1878  COPY_LOCATION_FIELD(location);
1879 
1880  return newnode;
1881 }
1882 
1883 /*
1884  * _copyConvertRowtypeExpr
1885  */
1886 static ConvertRowtypeExpr *
1888 {
1890 
1892  COPY_SCALAR_FIELD(resulttype);
1893  COPY_SCALAR_FIELD(convertformat);
1894  COPY_LOCATION_FIELD(location);
1895 
1896  return newnode;
1897 }
1898 
1899 /*
1900  * _copyCollateExpr
1901  */
1902 static CollateExpr *
1904 {
1905  CollateExpr *newnode = makeNode(CollateExpr);
1906 
1908  COPY_SCALAR_FIELD(collOid);
1909  COPY_LOCATION_FIELD(location);
1910 
1911  return newnode;
1912 }
1913 
1914 /*
1915  * _copyCaseExpr
1916  */
1917 static CaseExpr *
1919 {
1920  CaseExpr *newnode = makeNode(CaseExpr);
1921 
1922  COPY_SCALAR_FIELD(casetype);
1923  COPY_SCALAR_FIELD(casecollid);
1926  COPY_NODE_FIELD(defresult);
1927  COPY_LOCATION_FIELD(location);
1928 
1929  return newnode;
1930 }
1931 
1932 /*
1933  * _copyCaseWhen
1934  */
1935 static CaseWhen *
1937 {
1938  CaseWhen *newnode = makeNode(CaseWhen);
1939 
1940  COPY_NODE_FIELD(expr);
1941  COPY_NODE_FIELD(result);
1942  COPY_LOCATION_FIELD(location);
1943 
1944  return newnode;
1945 }
1946 
1947 /*
1948  * _copyCaseTestExpr
1949  */
1950 static CaseTestExpr *
1952 {
1953  CaseTestExpr *newnode = makeNode(CaseTestExpr);
1954 
1955  COPY_SCALAR_FIELD(typeId);
1956  COPY_SCALAR_FIELD(typeMod);
1957  COPY_SCALAR_FIELD(collation);
1958 
1959  return newnode;
1960 }
1961 
1962 /*
1963  * _copyArrayExpr
1964  */
1965 static ArrayExpr *
1967 {
1968  ArrayExpr *newnode = makeNode(ArrayExpr);
1969 
1970  COPY_SCALAR_FIELD(array_typeid);
1971  COPY_SCALAR_FIELD(array_collid);
1972  COPY_SCALAR_FIELD(element_typeid);
1973  COPY_NODE_FIELD(elements);
1974  COPY_SCALAR_FIELD(multidims);
1975  COPY_LOCATION_FIELD(location);
1976 
1977  return newnode;
1978 }
1979 
1980 /*
1981  * _copyRowExpr
1982  */
1983 static RowExpr *
1984 _copyRowExpr(const RowExpr *from)
1985 {
1986  RowExpr *newnode = makeNode(RowExpr);
1987 
1989  COPY_SCALAR_FIELD(row_typeid);
1990  COPY_SCALAR_FIELD(row_format);
1991  COPY_NODE_FIELD(colnames);
1992  COPY_LOCATION_FIELD(location);
1993 
1994  return newnode;
1995 }
1996 
1997 /*
1998  * _copyRowCompareExpr
1999  */
2000 static RowCompareExpr *
2002 {
2004 
2005  COPY_SCALAR_FIELD(rctype);
2006  COPY_NODE_FIELD(opnos);
2007  COPY_NODE_FIELD(opfamilies);
2008  COPY_NODE_FIELD(inputcollids);
2009  COPY_NODE_FIELD(largs);
2010  COPY_NODE_FIELD(rargs);
2011 
2012  return newnode;
2013 }
2014 
2015 /*
2016  * _copyCoalesceExpr
2017  */
2018 static CoalesceExpr *
2020 {
2021  CoalesceExpr *newnode = makeNode(CoalesceExpr);
2022 
2023  COPY_SCALAR_FIELD(coalescetype);
2024  COPY_SCALAR_FIELD(coalescecollid);
2026  COPY_LOCATION_FIELD(location);
2027 
2028  return newnode;
2029 }
2030 
2031 /*
2032  * _copyMinMaxExpr
2033  */
2034 static MinMaxExpr *
2036 {
2037  MinMaxExpr *newnode = makeNode(MinMaxExpr);
2038 
2039  COPY_SCALAR_FIELD(minmaxtype);
2040  COPY_SCALAR_FIELD(minmaxcollid);
2041  COPY_SCALAR_FIELD(inputcollid);
2042  COPY_SCALAR_FIELD(op);
2044  COPY_LOCATION_FIELD(location);
2045 
2046  return newnode;
2047 }
2048 
2049 /*
2050  * _copySQLValueFunction
2051  */
2052 static SQLValueFunction *
2054 {
2056 
2057  COPY_SCALAR_FIELD(op);
2059  COPY_SCALAR_FIELD(typmod);
2060  COPY_LOCATION_FIELD(location);
2061 
2062  return newnode;
2063 }
2064 
2065 /*
2066  * _copyXmlExpr
2067  */
2068 static XmlExpr *
2069 _copyXmlExpr(const XmlExpr *from)
2070 {
2071  XmlExpr *newnode = makeNode(XmlExpr);
2072 
2073  COPY_SCALAR_FIELD(op);
2075  COPY_NODE_FIELD(named_args);
2076  COPY_NODE_FIELD(arg_names);
2080  COPY_SCALAR_FIELD(typmod);
2081  COPY_LOCATION_FIELD(location);
2082 
2083  return newnode;
2084 }
2085 
2086 /*
2087  * _copyNullTest
2088  */
2089 static NullTest *
2091 {
2092  NullTest *newnode = makeNode(NullTest);
2093 
2095  COPY_SCALAR_FIELD(nulltesttype);
2096  COPY_SCALAR_FIELD(argisrow);
2097  COPY_LOCATION_FIELD(location);
2098 
2099  return newnode;
2100 }
2101 
2102 /*
2103  * _copyBooleanTest
2104  */
2105 static BooleanTest *
2107 {
2108  BooleanTest *newnode = makeNode(BooleanTest);
2109 
2111  COPY_SCALAR_FIELD(booltesttype);
2112  COPY_LOCATION_FIELD(location);
2113 
2114  return newnode;
2115 }
2116 
2117 /*
2118  * _copyCoerceToDomain
2119  */
2120 static CoerceToDomain *
2122 {
2124 
2126  COPY_SCALAR_FIELD(resulttype);
2127  COPY_SCALAR_FIELD(resulttypmod);
2128  COPY_SCALAR_FIELD(resultcollid);
2129  COPY_SCALAR_FIELD(coercionformat);
2130  COPY_LOCATION_FIELD(location);
2131 
2132  return newnode;
2133 }
2134 
2135 /*
2136  * _copyCoerceToDomainValue
2137  */
2138 static CoerceToDomainValue *
2140 {
2142 
2143  COPY_SCALAR_FIELD(typeId);
2144  COPY_SCALAR_FIELD(typeMod);
2145  COPY_SCALAR_FIELD(collation);
2146  COPY_LOCATION_FIELD(location);
2147 
2148  return newnode;
2149 }
2150 
2151 /*
2152  * _copySetToDefault
2153  */
2154 static SetToDefault *
2156 {
2157  SetToDefault *newnode = makeNode(SetToDefault);
2158 
2159  COPY_SCALAR_FIELD(typeId);
2160  COPY_SCALAR_FIELD(typeMod);
2161  COPY_SCALAR_FIELD(collation);
2162  COPY_LOCATION_FIELD(location);
2163 
2164  return newnode;
2165 }
2166 
2167 /*
2168  * _copyCurrentOfExpr
2169  */
2170 static CurrentOfExpr *
2172 {
2173  CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
2174 
2175  COPY_SCALAR_FIELD(cvarno);
2176  COPY_STRING_FIELD(cursor_name);
2177  COPY_SCALAR_FIELD(cursor_param);
2178 
2179  return newnode;
2180 }
2181 
2182  /*
2183  * _copyNextValueExpr
2184  */
2185 static NextValueExpr *
2187 {
2188  NextValueExpr *newnode = makeNode(NextValueExpr);
2189 
2190  COPY_SCALAR_FIELD(seqid);
2191  COPY_SCALAR_FIELD(typeId);
2192 
2193  return newnode;
2194 }
2195 
2196 /*
2197  * _copyInferenceElem
2198  */
2199 static InferenceElem *
2201 {
2202  InferenceElem *newnode = makeNode(InferenceElem);
2203 
2204  COPY_NODE_FIELD(expr);
2205  COPY_SCALAR_FIELD(infercollid);
2206  COPY_SCALAR_FIELD(inferopclass);
2207 
2208  return newnode;
2209 }
2210 
2211 /*
2212  * _copyTargetEntry
2213  */
2214 static TargetEntry *
2216 {
2217  TargetEntry *newnode = makeNode(TargetEntry);
2218 
2219  COPY_NODE_FIELD(expr);
2220  COPY_SCALAR_FIELD(resno);
2221  COPY_STRING_FIELD(resname);
2222  COPY_SCALAR_FIELD(ressortgroupref);
2223  COPY_SCALAR_FIELD(resorigtbl);
2224  COPY_SCALAR_FIELD(resorigcol);
2225  COPY_SCALAR_FIELD(resjunk);
2226 
2227  return newnode;
2228 }
2229 
2230 /*
2231  * _copyRangeTblRef
2232  */
2233 static RangeTblRef *
2235 {
2236  RangeTblRef *newnode = makeNode(RangeTblRef);
2237 
2238  COPY_SCALAR_FIELD(rtindex);
2239 
2240  return newnode;
2241 }
2242 
2243 /*
2244  * _copyJoinExpr
2245  */
2246 static JoinExpr *
2248 {
2249  JoinExpr *newnode = makeNode(JoinExpr);
2250 
2251  COPY_SCALAR_FIELD(jointype);
2252  COPY_SCALAR_FIELD(isNatural);
2253  COPY_NODE_FIELD(larg);
2254  COPY_NODE_FIELD(rarg);
2255  COPY_NODE_FIELD(usingClause);
2256  COPY_NODE_FIELD(join_using_alias);
2257  COPY_NODE_FIELD(quals);
2258  COPY_NODE_FIELD(alias);
2259  COPY_SCALAR_FIELD(rtindex);
2260 
2261  return newnode;
2262 }
2263 
2264 /*
2265  * _copyFromExpr
2266  */
2267 static FromExpr *
2269 {
2270  FromExpr *newnode = makeNode(FromExpr);
2271 
2272  COPY_NODE_FIELD(fromlist);
2273  COPY_NODE_FIELD(quals);
2274 
2275  return newnode;
2276 }
2277 
2278 /*
2279  * _copyOnConflictExpr
2280  */
2281 static OnConflictExpr *
2283 {
2285 
2287  COPY_NODE_FIELD(arbiterElems);
2288  COPY_NODE_FIELD(arbiterWhere);
2289  COPY_SCALAR_FIELD(constraint);
2290  COPY_NODE_FIELD(onConflictSet);
2291  COPY_NODE_FIELD(onConflictWhere);
2292  COPY_SCALAR_FIELD(exclRelIndex);
2293  COPY_NODE_FIELD(exclRelTlist);
2294 
2295  return newnode;
2296 }
2297 
2298 /* ****************************************************************
2299  * pathnodes.h copy functions
2300  *
2301  * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
2302  * There are some subsidiary structs that are useful to copy, though.
2303  * ****************************************************************
2304  */
2305 
2306 /*
2307  * _copyPathKey
2308  */
2309 static PathKey *
2310 _copyPathKey(const PathKey *from)
2311 {
2312  PathKey *newnode = makeNode(PathKey);
2313 
2314  /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
2315  COPY_SCALAR_FIELD(pk_eclass);
2316  COPY_SCALAR_FIELD(pk_opfamily);
2317  COPY_SCALAR_FIELD(pk_strategy);
2318  COPY_SCALAR_FIELD(pk_nulls_first);
2319 
2320  return newnode;
2321 }
2322 
2323 /*
2324  * _copyRestrictInfo
2325  */
2326 static RestrictInfo *
2328 {
2329  RestrictInfo *newnode = makeNode(RestrictInfo);
2330 
2331  COPY_NODE_FIELD(clause);
2332  COPY_SCALAR_FIELD(is_pushed_down);
2333  COPY_SCALAR_FIELD(outerjoin_delayed);
2334  COPY_SCALAR_FIELD(can_join);
2335  COPY_SCALAR_FIELD(pseudoconstant);
2336  COPY_SCALAR_FIELD(leakproof);
2337  COPY_SCALAR_FIELD(has_volatile);
2338  COPY_SCALAR_FIELD(security_level);
2339  COPY_BITMAPSET_FIELD(clause_relids);
2340  COPY_BITMAPSET_FIELD(required_relids);
2341  COPY_BITMAPSET_FIELD(outer_relids);
2342  COPY_BITMAPSET_FIELD(nullable_relids);
2343  COPY_BITMAPSET_FIELD(left_relids);
2344  COPY_BITMAPSET_FIELD(right_relids);
2345  COPY_NODE_FIELD(orclause);
2346  /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2347  COPY_SCALAR_FIELD(parent_ec);
2348  COPY_SCALAR_FIELD(eval_cost);
2349  COPY_SCALAR_FIELD(norm_selec);
2350  COPY_SCALAR_FIELD(outer_selec);
2351  COPY_NODE_FIELD(mergeopfamilies);
2352  /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2353  COPY_SCALAR_FIELD(left_ec);
2354  COPY_SCALAR_FIELD(right_ec);
2355  COPY_SCALAR_FIELD(left_em);
2356  COPY_SCALAR_FIELD(right_em);
2357  /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
2358  newnode->scansel_cache = NIL;
2359  COPY_SCALAR_FIELD(outer_is_left);
2360  COPY_SCALAR_FIELD(hashjoinoperator);
2361  COPY_SCALAR_FIELD(left_bucketsize);
2362  COPY_SCALAR_FIELD(right_bucketsize);
2363  COPY_SCALAR_FIELD(left_mcvfreq);
2364  COPY_SCALAR_FIELD(right_mcvfreq);
2365  COPY_SCALAR_FIELD(hasheqoperator);
2366 
2367  return newnode;
2368 }
2369 
2370 /*
2371  * _copyPlaceHolderVar
2372  */
2373 static PlaceHolderVar *
2375 {
2377 
2378  COPY_NODE_FIELD(phexpr);
2379  COPY_BITMAPSET_FIELD(phrels);
2380  COPY_SCALAR_FIELD(phid);
2381  COPY_SCALAR_FIELD(phlevelsup);
2382 
2383  return newnode;
2384 }
2385 
2386 /*
2387  * _copySpecialJoinInfo
2388  */
2389 static SpecialJoinInfo *
2391 {
2393 
2394  COPY_BITMAPSET_FIELD(min_lefthand);
2395  COPY_BITMAPSET_FIELD(min_righthand);
2396  COPY_BITMAPSET_FIELD(syn_lefthand);
2397  COPY_BITMAPSET_FIELD(syn_righthand);
2398  COPY_SCALAR_FIELD(jointype);
2399  COPY_SCALAR_FIELD(lhs_strict);
2400  COPY_SCALAR_FIELD(delay_upper_joins);
2401  COPY_SCALAR_FIELD(semi_can_btree);
2402  COPY_SCALAR_FIELD(semi_can_hash);
2403  COPY_NODE_FIELD(semi_operators);
2404  COPY_NODE_FIELD(semi_rhs_exprs);
2405 
2406  return newnode;
2407 }
2408 
2409 /*
2410  * _copyAppendRelInfo
2411  */
2412 static AppendRelInfo *
2414 {
2415  AppendRelInfo *newnode = makeNode(AppendRelInfo);
2416 
2417  COPY_SCALAR_FIELD(parent_relid);
2418  COPY_SCALAR_FIELD(child_relid);
2419  COPY_SCALAR_FIELD(parent_reltype);
2420  COPY_SCALAR_FIELD(child_reltype);
2421  COPY_NODE_FIELD(translated_vars);
2422  COPY_SCALAR_FIELD(num_child_cols);
2423  COPY_POINTER_FIELD(parent_colnos, from->num_child_cols * sizeof(AttrNumber));
2424  COPY_SCALAR_FIELD(parent_reloid);
2425 
2426  return newnode;
2427 }
2428 
2429 /*
2430  * _copyPlaceHolderInfo
2431  */
2432 static PlaceHolderInfo *
2434 {
2436 
2437  COPY_SCALAR_FIELD(phid);
2438  COPY_NODE_FIELD(ph_var);
2439  COPY_BITMAPSET_FIELD(ph_eval_at);
2440  COPY_BITMAPSET_FIELD(ph_lateral);
2441  COPY_BITMAPSET_FIELD(ph_needed);
2442  COPY_SCALAR_FIELD(ph_width);
2443 
2444  return newnode;
2445 }
2446 
2447 /* ****************************************************************
2448  * parsenodes.h copy functions
2449  * ****************************************************************
2450  */
2451 
2452 static RangeTblEntry *
2454 {
2455  RangeTblEntry *newnode = makeNode(RangeTblEntry);
2456 
2457  COPY_SCALAR_FIELD(rtekind);
2458  COPY_SCALAR_FIELD(relid);
2459  COPY_SCALAR_FIELD(relkind);
2460  COPY_SCALAR_FIELD(rellockmode);
2461  COPY_NODE_FIELD(tablesample);
2462  COPY_NODE_FIELD(subquery);
2463  COPY_SCALAR_FIELD(security_barrier);
2464  COPY_SCALAR_FIELD(jointype);
2465  COPY_SCALAR_FIELD(joinmergedcols);
2466  COPY_NODE_FIELD(joinaliasvars);
2467  COPY_NODE_FIELD(joinleftcols);
2468  COPY_NODE_FIELD(joinrightcols);
2469  COPY_NODE_FIELD(join_using_alias);
2471  COPY_SCALAR_FIELD(funcordinality);
2472  COPY_NODE_FIELD(tablefunc);
2473  COPY_NODE_FIELD(values_lists);
2474  COPY_STRING_FIELD(ctename);
2475  COPY_SCALAR_FIELD(ctelevelsup);
2476  COPY_SCALAR_FIELD(self_reference);
2477  COPY_NODE_FIELD(coltypes);
2478  COPY_NODE_FIELD(coltypmods);
2479  COPY_NODE_FIELD(colcollations);
2480  COPY_STRING_FIELD(enrname);
2481  COPY_SCALAR_FIELD(enrtuples);
2482  COPY_NODE_FIELD(alias);
2483  COPY_NODE_FIELD(eref);
2484  COPY_SCALAR_FIELD(lateral);
2485  COPY_SCALAR_FIELD(inh);
2486  COPY_SCALAR_FIELD(inFromCl);
2487  COPY_SCALAR_FIELD(requiredPerms);
2488  COPY_SCALAR_FIELD(checkAsUser);
2489  COPY_BITMAPSET_FIELD(selectedCols);
2490  COPY_BITMAPSET_FIELD(insertedCols);
2491  COPY_BITMAPSET_FIELD(updatedCols);
2492  COPY_BITMAPSET_FIELD(extraUpdatedCols);
2493  COPY_NODE_FIELD(securityQuals);
2494 
2495  return newnode;
2496 }
2497 
2498 static RangeTblFunction *
2500 {
2502 
2503  COPY_NODE_FIELD(funcexpr);
2504  COPY_SCALAR_FIELD(funccolcount);
2505  COPY_NODE_FIELD(funccolnames);
2506  COPY_NODE_FIELD(funccoltypes);
2507  COPY_NODE_FIELD(funccoltypmods);
2508  COPY_NODE_FIELD(funccolcollations);
2509  COPY_BITMAPSET_FIELD(funcparams);
2510 
2511  return newnode;
2512 }
2513 
2514 static TableSampleClause *
2516 {
2518 
2519  COPY_SCALAR_FIELD(tsmhandler);
2521  COPY_NODE_FIELD(repeatable);
2522 
2523  return newnode;
2524 }
2525 
2526 static WithCheckOption *
2528 {
2530 
2531  COPY_SCALAR_FIELD(kind);
2533  COPY_STRING_FIELD(polname);
2534  COPY_NODE_FIELD(qual);
2535  COPY_SCALAR_FIELD(cascaded);
2536 
2537  return newnode;
2538 }
2539 
2540 static SortGroupClause *
2542 {
2544 
2545  COPY_SCALAR_FIELD(tleSortGroupRef);
2546  COPY_SCALAR_FIELD(eqop);
2547  COPY_SCALAR_FIELD(sortop);
2548  COPY_SCALAR_FIELD(nulls_first);
2549  COPY_SCALAR_FIELD(hashable);
2550 
2551  return newnode;
2552 }
2553 
2554 static GroupingSet *
2556 {
2557  GroupingSet *newnode = makeNode(GroupingSet);
2558 
2559  COPY_SCALAR_FIELD(kind);
2560  COPY_NODE_FIELD(content);
2561  COPY_LOCATION_FIELD(location);
2562 
2563  return newnode;
2564 }
2565 
2566 static WindowClause *
2568 {
2569  WindowClause *newnode = makeNode(WindowClause);
2570 
2572  COPY_STRING_FIELD(refname);
2573  COPY_NODE_FIELD(partitionClause);
2574  COPY_NODE_FIELD(orderClause);
2575  COPY_SCALAR_FIELD(frameOptions);
2576  COPY_NODE_FIELD(startOffset);
2577  COPY_NODE_FIELD(endOffset);
2578  COPY_SCALAR_FIELD(startInRangeFunc);
2579  COPY_SCALAR_FIELD(endInRangeFunc);
2580  COPY_SCALAR_FIELD(inRangeColl);
2581  COPY_SCALAR_FIELD(inRangeAsc);
2582  COPY_SCALAR_FIELD(inRangeNullsFirst);
2583  COPY_SCALAR_FIELD(winref);
2584  COPY_SCALAR_FIELD(copiedOrder);
2585 
2586  return newnode;
2587 }
2588 
2589 static RowMarkClause *
2591 {
2592  RowMarkClause *newnode = makeNode(RowMarkClause);
2593 
2594  COPY_SCALAR_FIELD(rti);
2595  COPY_SCALAR_FIELD(strength);
2596  COPY_SCALAR_FIELD(waitPolicy);
2597  COPY_SCALAR_FIELD(pushedDown);
2598 
2599  return newnode;
2600 }
2601 
2602 static WithClause *
2604 {
2605  WithClause *newnode = makeNode(WithClause);
2606 
2607  COPY_NODE_FIELD(ctes);
2608  COPY_SCALAR_FIELD(recursive);
2609  COPY_LOCATION_FIELD(location);
2610 
2611  return newnode;
2612 }
2613 
2614 static InferClause *
2616 {
2617  InferClause *newnode = makeNode(InferClause);
2618 
2619  COPY_NODE_FIELD(indexElems);
2620  COPY_NODE_FIELD(whereClause);
2621  COPY_STRING_FIELD(conname);
2622  COPY_LOCATION_FIELD(location);
2623 
2624  return newnode;
2625 }
2626 
2627 static OnConflictClause *
2629 {
2631 
2633  COPY_NODE_FIELD(infer);
2634  COPY_NODE_FIELD(targetList);
2635  COPY_NODE_FIELD(whereClause);
2636  COPY_LOCATION_FIELD(location);
2637 
2638  return newnode;
2639 }
2640 
2641 static CTESearchClause *
2643 {
2645 
2646  COPY_NODE_FIELD(search_col_list);
2647  COPY_SCALAR_FIELD(search_breadth_first);
2648  COPY_STRING_FIELD(search_seq_column);
2649  COPY_LOCATION_FIELD(location);
2650 
2651  return newnode;
2652 }
2653 
2654 static CTECycleClause *
2656 {
2658 
2659  COPY_NODE_FIELD(cycle_col_list);
2660  COPY_STRING_FIELD(cycle_mark_column);
2661  COPY_NODE_FIELD(cycle_mark_value);
2662  COPY_NODE_FIELD(cycle_mark_default);
2663  COPY_STRING_FIELD(cycle_path_column);
2664  COPY_LOCATION_FIELD(location);
2665  COPY_SCALAR_FIELD(cycle_mark_type);
2666  COPY_SCALAR_FIELD(cycle_mark_typmod);
2667  COPY_SCALAR_FIELD(cycle_mark_collation);
2668  COPY_SCALAR_FIELD(cycle_mark_neop);
2669 
2670  return newnode;
2671 }
2672 
2673 static CommonTableExpr *
2675 {
2677 
2678  COPY_STRING_FIELD(ctename);
2679  COPY_NODE_FIELD(aliascolnames);
2680  COPY_SCALAR_FIELD(ctematerialized);
2681  COPY_NODE_FIELD(ctequery);
2682  COPY_NODE_FIELD(search_clause);
2683  COPY_NODE_FIELD(cycle_clause);
2684  COPY_LOCATION_FIELD(location);
2685  COPY_SCALAR_FIELD(cterecursive);
2686  COPY_SCALAR_FIELD(cterefcount);
2687  COPY_NODE_FIELD(ctecolnames);
2688  COPY_NODE_FIELD(ctecoltypes);
2689  COPY_NODE_FIELD(ctecoltypmods);
2690  COPY_NODE_FIELD(ctecolcollations);
2691 
2692  return newnode;
2693 }
2694 
2695 static A_Expr *
2696 _copyA_Expr(const A_Expr *from)
2697 {
2698  A_Expr *newnode = makeNode(A_Expr);
2699 
2700  COPY_SCALAR_FIELD(kind);
2702  COPY_NODE_FIELD(lexpr);
2703  COPY_NODE_FIELD(rexpr);
2704  COPY_LOCATION_FIELD(location);
2705 
2706  return newnode;
2707 }
2708 
2709 static ColumnRef *
2711 {
2712  ColumnRef *newnode = makeNode(ColumnRef);
2713 
2714  COPY_NODE_FIELD(fields);
2715  COPY_LOCATION_FIELD(location);
2716 
2717  return newnode;
2718 }
2719 
2720 static ParamRef *
2722 {
2723  ParamRef *newnode = makeNode(ParamRef);
2724 
2725  COPY_SCALAR_FIELD(number);
2726  COPY_LOCATION_FIELD(location);
2727 
2728  return newnode;
2729 }
2730 
2731 static A_Const *
2732 _copyA_Const(const A_Const *from)
2733 {
2734  A_Const *newnode = makeNode(A_Const);
2735 
2736  COPY_SCALAR_FIELD(isnull);
2737  if (!from->isnull)
2738  {
2739  /* This part must duplicate other _copy*() functions. */
2740  COPY_SCALAR_FIELD(val.node.type);
2741  switch (nodeTag(&from->val))
2742  {
2743  case T_Integer:
2744  COPY_SCALAR_FIELD(val.ival.val);
2745  break;
2746  case T_Float:
2747  COPY_STRING_FIELD(val.fval.val);
2748  break;
2749  case T_String:
2750  COPY_STRING_FIELD(val.sval.val);
2751  break;
2752  case T_BitString:
2753  COPY_STRING_FIELD(val.bsval.val);
2754  break;
2755  default:
2756  elog(ERROR, "unrecognized node type: %d",
2757  (int) nodeTag(&from->val));
2758  break;
2759  }
2760  }
2761 
2762  COPY_LOCATION_FIELD(location);
2763 
2764  return newnode;
2765 }
2766 
2767 static FuncCall *
2769 {
2770  FuncCall *newnode = makeNode(FuncCall);
2771 
2772  COPY_NODE_FIELD(funcname);
2774  COPY_NODE_FIELD(agg_order);
2775  COPY_NODE_FIELD(agg_filter);
2776  COPY_NODE_FIELD(over);
2777  COPY_SCALAR_FIELD(agg_within_group);
2778  COPY_SCALAR_FIELD(agg_star);
2779  COPY_SCALAR_FIELD(agg_distinct);
2780  COPY_SCALAR_FIELD(func_variadic);
2781  COPY_SCALAR_FIELD(funcformat);
2782  COPY_LOCATION_FIELD(location);
2783 
2784  return newnode;
2785 }
2786 
2787 static A_Star *
2788 _copyA_Star(const A_Star *from)
2789 {
2790  A_Star *newnode = makeNode(A_Star);
2791 
2792  return newnode;
2793 }
2794 
2795 static A_Indices *
2797 {
2798  A_Indices *newnode = makeNode(A_Indices);
2799 
2800  COPY_SCALAR_FIELD(is_slice);
2801  COPY_NODE_FIELD(lidx);
2802  COPY_NODE_FIELD(uidx);
2803 
2804  return newnode;
2805 }
2806 
2807 static A_Indirection *
2809 {
2810  A_Indirection *newnode = makeNode(A_Indirection);
2811 
2813  COPY_NODE_FIELD(indirection);
2814 
2815  return newnode;
2816 }
2817 
2818 static A_ArrayExpr *
2820 {
2821  A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2822 
2823  COPY_NODE_FIELD(elements);
2824  COPY_LOCATION_FIELD(location);
2825 
2826  return newnode;
2827 }
2828 
2829 static ResTarget *
2831 {
2832  ResTarget *newnode = makeNode(ResTarget);
2833 
2835  COPY_NODE_FIELD(indirection);
2837  COPY_LOCATION_FIELD(location);
2838 
2839  return newnode;
2840 }
2841 
2842 static MultiAssignRef *
2844 {
2846 
2848  COPY_SCALAR_FIELD(colno);
2849  COPY_SCALAR_FIELD(ncolumns);
2850 
2851  return newnode;
2852 }
2853 
2854 static TypeName *
2856 {
2857  TypeName *newnode = makeNode(TypeName);
2858 
2859  COPY_NODE_FIELD(names);
2860  COPY_SCALAR_FIELD(typeOid);
2861  COPY_SCALAR_FIELD(setof);
2862  COPY_SCALAR_FIELD(pct_type);
2863  COPY_NODE_FIELD(typmods);
2864  COPY_SCALAR_FIELD(typemod);
2865  COPY_NODE_FIELD(arrayBounds);
2866  COPY_LOCATION_FIELD(location);
2867 
2868  return newnode;
2869 }
2870 
2871 static SortBy *
2872 _copySortBy(const SortBy *from)
2873 {
2874  SortBy *newnode = makeNode(SortBy);
2875 
2876  COPY_NODE_FIELD(node);
2877  COPY_SCALAR_FIELD(sortby_dir);
2878  COPY_SCALAR_FIELD(sortby_nulls);
2879  COPY_NODE_FIELD(useOp);
2880  COPY_LOCATION_FIELD(location);
2881 
2882  return newnode;
2883 }
2884 
2885 static WindowDef *
2887 {
2888  WindowDef *newnode = makeNode(WindowDef);
2889 
2891  COPY_STRING_FIELD(refname);
2892  COPY_NODE_FIELD(partitionClause);
2893  COPY_NODE_FIELD(orderClause);
2894  COPY_SCALAR_FIELD(frameOptions);
2895  COPY_NODE_FIELD(startOffset);
2896  COPY_NODE_FIELD(endOffset);
2897  COPY_LOCATION_FIELD(location);
2898 
2899  return newnode;
2900 }
2901 
2902 static RangeSubselect *
2904 {
2906 
2907  COPY_SCALAR_FIELD(lateral);
2908  COPY_NODE_FIELD(subquery);
2909  COPY_NODE_FIELD(alias);
2910 
2911  return newnode;
2912 }
2913 
2914 static RangeFunction *
2916 {
2917  RangeFunction *newnode = makeNode(RangeFunction);
2918 
2919  COPY_SCALAR_FIELD(lateral);
2920  COPY_SCALAR_FIELD(ordinality);
2921  COPY_SCALAR_FIELD(is_rowsfrom);
2923  COPY_NODE_FIELD(alias);
2924  COPY_NODE_FIELD(coldeflist);
2925 
2926  return newnode;
2927 }
2928 
2929 static RangeTableSample *
2931 {
2933 
2934  COPY_NODE_FIELD(relation);
2935  COPY_NODE_FIELD(method);
2937  COPY_NODE_FIELD(repeatable);
2938  COPY_LOCATION_FIELD(location);
2939 
2940  return newnode;
2941 }
2942 
2943 static RangeTableFunc *
2945 {
2947 
2948  COPY_SCALAR_FIELD(lateral);
2949  COPY_NODE_FIELD(docexpr);
2950  COPY_NODE_FIELD(rowexpr);
2951  COPY_NODE_FIELD(namespaces);
2952  COPY_NODE_FIELD(columns);
2953  COPY_NODE_FIELD(alias);
2954  COPY_LOCATION_FIELD(location);
2955 
2956  return newnode;
2957 }
2958 
2959 static RangeTableFuncCol *
2961 {
2963 
2964  COPY_STRING_FIELD(colname);
2965  COPY_NODE_FIELD(typeName);
2966  COPY_SCALAR_FIELD(for_ordinality);
2967  COPY_SCALAR_FIELD(is_not_null);
2968  COPY_NODE_FIELD(colexpr);
2969  COPY_NODE_FIELD(coldefexpr);
2970  COPY_LOCATION_FIELD(location);
2971 
2972  return newnode;
2973 }
2974 
2975 static TypeCast *
2977 {
2978  TypeCast *newnode = makeNode(TypeCast);
2979 
2981  COPY_NODE_FIELD(typeName);
2982  COPY_LOCATION_FIELD(location);
2983 
2984  return newnode;
2985 }
2986 
2987 static CollateClause *
2989 {
2990  CollateClause *newnode = makeNode(CollateClause);
2991 
2993  COPY_NODE_FIELD(collname);
2994  COPY_LOCATION_FIELD(location);
2995 
2996  return newnode;
2997 }
2998 
2999 static IndexElem *
3001 {
3002  IndexElem *newnode = makeNode(IndexElem);
3003 
3005  COPY_NODE_FIELD(expr);
3006  COPY_STRING_FIELD(indexcolname);
3007  COPY_NODE_FIELD(collation);
3008  COPY_NODE_FIELD(opclass);
3009  COPY_NODE_FIELD(opclassopts);
3010  COPY_SCALAR_FIELD(ordering);
3011  COPY_SCALAR_FIELD(nulls_ordering);
3012 
3013  return newnode;
3014 }
3015 
3016 static StatsElem *
3018 {
3019  StatsElem *newnode = makeNode(StatsElem);
3020 
3022  COPY_NODE_FIELD(expr);
3023 
3024  return newnode;
3025 }
3026 
3027 static ColumnDef *
3029 {
3030  ColumnDef *newnode = makeNode(ColumnDef);
3031 
3032  COPY_STRING_FIELD(colname);
3033  COPY_NODE_FIELD(typeName);
3034  COPY_STRING_FIELD(compression);
3035  COPY_SCALAR_FIELD(inhcount);
3036  COPY_SCALAR_FIELD(is_local);
3037  COPY_SCALAR_FIELD(is_not_null);
3038  COPY_SCALAR_FIELD(is_from_type);
3039  COPY_SCALAR_FIELD(storage);
3040  COPY_NODE_FIELD(raw_default);
3041  COPY_NODE_FIELD(cooked_default);
3042  COPY_SCALAR_FIELD(identity);
3043  COPY_NODE_FIELD(identitySequence);
3044  COPY_SCALAR_FIELD(generated);
3045  COPY_NODE_FIELD(collClause);
3046  COPY_SCALAR_FIELD(collOid);
3047  COPY_NODE_FIELD(constraints);
3048  COPY_NODE_FIELD(fdwoptions);
3049  COPY_LOCATION_FIELD(location);
3050 
3051  return newnode;
3052 }
3053 
3054 static Constraint *
3056 {
3057  Constraint *newnode = makeNode(Constraint);
3058 
3059  COPY_SCALAR_FIELD(contype);
3060  COPY_STRING_FIELD(conname);
3061  COPY_SCALAR_FIELD(deferrable);
3062  COPY_SCALAR_FIELD(initdeferred);
3063  COPY_LOCATION_FIELD(location);
3064  COPY_SCALAR_FIELD(is_no_inherit);
3065  COPY_NODE_FIELD(raw_expr);
3066  COPY_STRING_FIELD(cooked_expr);
3067  COPY_SCALAR_FIELD(generated_when);
3068  COPY_NODE_FIELD(keys);
3069  COPY_NODE_FIELD(including);
3070  COPY_NODE_FIELD(exclusions);
3072  COPY_STRING_FIELD(indexname);
3073  COPY_STRING_FIELD(indexspace);
3074  COPY_SCALAR_FIELD(reset_default_tblspc);
3075  COPY_STRING_FIELD(access_method);
3076  COPY_NODE_FIELD(where_clause);
3077  COPY_NODE_FIELD(pktable);
3078  COPY_NODE_FIELD(fk_attrs);
3079  COPY_NODE_FIELD(pk_attrs);
3080  COPY_SCALAR_FIELD(fk_matchtype);
3081  COPY_SCALAR_FIELD(fk_upd_action);
3082  COPY_SCALAR_FIELD(fk_del_action);
3083  COPY_NODE_FIELD(old_conpfeqop);
3084  COPY_SCALAR_FIELD(old_pktable_oid);
3085  COPY_SCALAR_FIELD(skip_validation);
3086  COPY_SCALAR_FIELD(initially_valid);
3087 
3088  return newnode;
3089 }
3090 
3091 static DefElem *
3092 _copyDefElem(const DefElem *from)
3093 {
3094  DefElem *newnode = makeNode(DefElem);
3095 
3096  COPY_STRING_FIELD(defnamespace);
3097  COPY_STRING_FIELD(defname);
3099  COPY_SCALAR_FIELD(defaction);
3100  COPY_LOCATION_FIELD(location);
3101 
3102  return newnode;
3103 }
3104 
3105 static LockingClause *
3107 {
3108  LockingClause *newnode = makeNode(LockingClause);
3109 
3110  COPY_NODE_FIELD(lockedRels);
3111  COPY_SCALAR_FIELD(strength);
3112  COPY_SCALAR_FIELD(waitPolicy);
3113 
3114  return newnode;
3115 }
3116 
3117 static XmlSerialize *
3119 {
3120  XmlSerialize *newnode = makeNode(XmlSerialize);
3121 
3123  COPY_NODE_FIELD(expr);
3124  COPY_NODE_FIELD(typeName);
3125  COPY_LOCATION_FIELD(location);
3126 
3127  return newnode;
3128 }
3129 
3130 static RoleSpec *
3132 {
3133  RoleSpec *newnode = makeNode(RoleSpec);
3134 
3135  COPY_SCALAR_FIELD(roletype);
3136  COPY_STRING_FIELD(rolename);
3137  COPY_LOCATION_FIELD(location);
3138 
3139  return newnode;
3140 }
3141 
3142 static TriggerTransition *
3144 {
3146 
3148  COPY_SCALAR_FIELD(isNew);
3149  COPY_SCALAR_FIELD(isTable);
3150 
3151  return newnode;
3152 }
3153 
3154 static Query *
3155 _copyQuery(const Query *from)
3156 {
3157  Query *newnode = makeNode(Query);
3158 
3159  COPY_SCALAR_FIELD(commandType);
3160  COPY_SCALAR_FIELD(querySource);
3161  COPY_SCALAR_FIELD(queryId);
3162  COPY_SCALAR_FIELD(canSetTag);
3163  COPY_NODE_FIELD(utilityStmt);
3164  COPY_SCALAR_FIELD(resultRelation);
3165  COPY_SCALAR_FIELD(hasAggs);
3166  COPY_SCALAR_FIELD(hasWindowFuncs);
3167  COPY_SCALAR_FIELD(hasTargetSRFs);
3168  COPY_SCALAR_FIELD(hasSubLinks);
3169  COPY_SCALAR_FIELD(hasDistinctOn);
3170  COPY_SCALAR_FIELD(hasRecursive);
3171  COPY_SCALAR_FIELD(hasModifyingCTE);
3172  COPY_SCALAR_FIELD(hasForUpdate);
3173  COPY_SCALAR_FIELD(hasRowSecurity);
3174  COPY_SCALAR_FIELD(isReturn);
3175  COPY_NODE_FIELD(cteList);
3176  COPY_NODE_FIELD(rtable);
3177  COPY_NODE_FIELD(jointree);
3178  COPY_NODE_FIELD(targetList);
3179  COPY_SCALAR_FIELD(override);
3180  COPY_NODE_FIELD(onConflict);
3181  COPY_NODE_FIELD(returningList);
3182  COPY_NODE_FIELD(groupClause);
3183  COPY_SCALAR_FIELD(groupDistinct);
3184  COPY_NODE_FIELD(groupingSets);
3185  COPY_NODE_FIELD(havingQual);
3186  COPY_NODE_FIELD(windowClause);
3187  COPY_NODE_FIELD(distinctClause);
3188  COPY_NODE_FIELD(sortClause);
3189  COPY_NODE_FIELD(limitOffset);
3190  COPY_NODE_FIELD(limitCount);
3191  COPY_SCALAR_FIELD(limitOption);
3192  COPY_NODE_FIELD(rowMarks);
3193  COPY_NODE_FIELD(setOperations);
3194  COPY_NODE_FIELD(constraintDeps);
3195  COPY_NODE_FIELD(withCheckOptions);
3196  COPY_LOCATION_FIELD(stmt_location);
3197  COPY_SCALAR_FIELD(stmt_len);
3198 
3199  return newnode;
3200 }
3201 
3202 static RawStmt *
3203 _copyRawStmt(const RawStmt *from)
3204 {
3205  RawStmt *newnode = makeNode(RawStmt);
3206 
3207  COPY_NODE_FIELD(stmt);
3208  COPY_LOCATION_FIELD(stmt_location);
3209  COPY_SCALAR_FIELD(stmt_len);
3210 
3211  return newnode;
3212 }
3213 
3214 static InsertStmt *
3216 {
3217  InsertStmt *newnode = makeNode(InsertStmt);
3218 
3219  COPY_NODE_FIELD(relation);
3220  COPY_NODE_FIELD(cols);
3221  COPY_NODE_FIELD(selectStmt);
3222  COPY_NODE_FIELD(onConflictClause);
3223  COPY_NODE_FIELD(returningList);
3224  COPY_NODE_FIELD(withClause);
3225  COPY_SCALAR_FIELD(override);
3226 
3227  return newnode;
3228 }
3229 
3230 static DeleteStmt *
3232 {
3233  DeleteStmt *newnode = makeNode(DeleteStmt);
3234 
3235  COPY_NODE_FIELD(relation);
3236  COPY_NODE_FIELD(usingClause);
3237  COPY_NODE_FIELD(whereClause);
3238  COPY_NODE_FIELD(returningList);
3239  COPY_NODE_FIELD(withClause);
3240 
3241  return newnode;
3242 }
3243 
3244 static UpdateStmt *
3246 {
3247  UpdateStmt *newnode = makeNode(UpdateStmt);
3248 
3249  COPY_NODE_FIELD(relation);
3250  COPY_NODE_FIELD(targetList);
3251  COPY_NODE_FIELD(whereClause);
3252  COPY_NODE_FIELD(fromClause);
3253  COPY_NODE_FIELD(returningList);
3254  COPY_NODE_FIELD(withClause);
3255 
3256  return newnode;
3257 }
3258 
3259 static SelectStmt *
3261 {
3262  SelectStmt *newnode = makeNode(SelectStmt);
3263 
3264  COPY_NODE_FIELD(distinctClause);
3265  COPY_NODE_FIELD(intoClause);
3266  COPY_NODE_FIELD(targetList);
3267  COPY_NODE_FIELD(fromClause);
3268  COPY_NODE_FIELD(whereClause);
3269  COPY_NODE_FIELD(groupClause);
3270  COPY_SCALAR_FIELD(groupDistinct);
3271  COPY_NODE_FIELD(havingClause);
3272  COPY_NODE_FIELD(windowClause);
3273  COPY_NODE_FIELD(valuesLists);
3274  COPY_NODE_FIELD(sortClause);
3275  COPY_NODE_FIELD(limitOffset);
3276  COPY_NODE_FIELD(limitCount);
3277  COPY_SCALAR_FIELD(limitOption);
3278  COPY_NODE_FIELD(lockingClause);
3279  COPY_NODE_FIELD(withClause);
3280  COPY_SCALAR_FIELD(op);
3281  COPY_SCALAR_FIELD(all);
3282  COPY_NODE_FIELD(larg);
3283  COPY_NODE_FIELD(rarg);
3284 
3285  return newnode;
3286 }
3287 
3288 static SetOperationStmt *
3290 {
3292 
3293  COPY_SCALAR_FIELD(op);
3294  COPY_SCALAR_FIELD(all);
3295  COPY_NODE_FIELD(larg);
3296  COPY_NODE_FIELD(rarg);
3297  COPY_NODE_FIELD(colTypes);
3298  COPY_NODE_FIELD(colTypmods);
3299  COPY_NODE_FIELD(colCollations);
3300  COPY_NODE_FIELD(groupClauses);
3301 
3302  return newnode;
3303 }
3304 
3305 static ReturnStmt *
3307 {
3308  ReturnStmt *newnode = makeNode(ReturnStmt);
3309 
3310  COPY_NODE_FIELD(returnval);
3311 
3312  return newnode;
3313 }
3314 
3315 static PLAssignStmt *
3317 {
3318  PLAssignStmt *newnode = makeNode(PLAssignStmt);
3319 
3321  COPY_NODE_FIELD(indirection);
3322  COPY_SCALAR_FIELD(nnames);
3324  COPY_LOCATION_FIELD(location);
3325 
3326  return newnode;
3327 }
3328 
3329 static AlterTableStmt *
3331 {
3333 
3334  COPY_NODE_FIELD(relation);
3335  COPY_NODE_FIELD(cmds);
3336  COPY_SCALAR_FIELD(objtype);
3337  COPY_SCALAR_FIELD(missing_ok);
3338 
3339  return newnode;
3340 }
3341 
3342 static AlterTableCmd *
3344 {
3345  AlterTableCmd *newnode = makeNode(AlterTableCmd);
3346 
3347  COPY_SCALAR_FIELD(subtype);
3349  COPY_SCALAR_FIELD(num);
3350  COPY_NODE_FIELD(newowner);
3351  COPY_NODE_FIELD(def);
3352  COPY_SCALAR_FIELD(behavior);
3353  COPY_SCALAR_FIELD(missing_ok);
3354 
3355  return newnode;
3356 }
3357 
3358 static AlterCollationStmt *
3360 {
3362 
3363  COPY_NODE_FIELD(collname);
3364 
3365  return newnode;
3366 }
3367 
3368 static AlterDomainStmt *
3370 {
3372 
3373  COPY_SCALAR_FIELD(subtype);
3374  COPY_NODE_FIELD(typeName);
3376  COPY_NODE_FIELD(def);
3377  COPY_SCALAR_FIELD(behavior);
3378  COPY_SCALAR_FIELD(missing_ok);
3379 
3380  return newnode;
3381 }
3382 
3383 static GrantStmt *
3385 {
3386  GrantStmt *newnode = makeNode(GrantStmt);
3387 
3388  COPY_SCALAR_FIELD(is_grant);
3389  COPY_SCALAR_FIELD(targtype);
3390  COPY_SCALAR_FIELD(objtype);
3391  COPY_NODE_FIELD(objects);
3392  COPY_NODE_FIELD(privileges);
3393  COPY_NODE_FIELD(grantees);
3394  COPY_SCALAR_FIELD(grant_option);
3395  COPY_NODE_FIELD(grantor);
3396  COPY_SCALAR_FIELD(behavior);
3397 
3398  return newnode;
3399 }
3400 
3401 static ObjectWithArgs *
3403 {
3405 
3406  COPY_NODE_FIELD(objname);
3407  COPY_NODE_FIELD(objargs);
3408  COPY_NODE_FIELD(objfuncargs);
3409  COPY_SCALAR_FIELD(args_unspecified);
3410 
3411  return newnode;
3412 }
3413 
3414 static AccessPriv *
3416 {
3417  AccessPriv *newnode = makeNode(AccessPriv);
3418 
3419  COPY_STRING_FIELD(priv_name);
3420  COPY_NODE_FIELD(cols);
3421 
3422  return newnode;
3423 }
3424 
3425 static GrantRoleStmt *
3427 {
3428  GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
3429 
3430  COPY_NODE_FIELD(granted_roles);
3431  COPY_NODE_FIELD(grantee_roles);
3432  COPY_SCALAR_FIELD(is_grant);
3433  COPY_SCALAR_FIELD(admin_opt);
3434  COPY_NODE_FIELD(grantor);
3435  COPY_SCALAR_FIELD(behavior);
3436 
3437  return newnode;
3438 }
3439 
3442 {
3444 
3447 
3448  return newnode;
3449 }
3450 
3451 static DeclareCursorStmt *
3453 {
3455 
3456  COPY_STRING_FIELD(portalname);
3458  COPY_NODE_FIELD(query);
3459 
3460  return newnode;
3461 }
3462 
3463 static ClosePortalStmt *
3465 {
3467 
3468  COPY_STRING_FIELD(portalname);
3469 
3470  return newnode;
3471 }
3472 
3473 static CallStmt *
3475 {
3476  CallStmt *newnode = makeNode(CallStmt);
3477 
3478  COPY_NODE_FIELD(funccall);
3479  COPY_NODE_FIELD(funcexpr);
3480  COPY_NODE_FIELD(outargs);
3481 
3482  return newnode;
3483 }
3484 
3485 static ClusterStmt *
3487 {
3488  ClusterStmt *newnode = makeNode(ClusterStmt);
3489 
3490  COPY_NODE_FIELD(relation);
3491  COPY_STRING_FIELD(indexname);
3492  COPY_NODE_FIELD(params);
3493 
3494  return newnode;
3495 }
3496 
3497 static CopyStmt *
3499 {
3500  CopyStmt *newnode = makeNode(CopyStmt);
3501 
3502  COPY_NODE_FIELD(relation);
3503  COPY_NODE_FIELD(query);
3504  COPY_NODE_FIELD(attlist);
3505  COPY_SCALAR_FIELD(is_from);
3506  COPY_SCALAR_FIELD(is_program);
3509  COPY_NODE_FIELD(whereClause);
3510 
3511  return newnode;
3512 }
3513 
3514 /*
3515  * CopyCreateStmtFields
3516  *
3517  * This function copies the fields of the CreateStmt node. It is used by
3518  * copy functions for classes which inherit from CreateStmt.
3519  */
3520 static void
3522 {
3523  COPY_NODE_FIELD(relation);
3524  COPY_NODE_FIELD(tableElts);
3525  COPY_NODE_FIELD(inhRelations);
3526  COPY_NODE_FIELD(partspec);
3527  COPY_NODE_FIELD(partbound);
3528  COPY_NODE_FIELD(ofTypename);
3529  COPY_NODE_FIELD(constraints);
3531  COPY_SCALAR_FIELD(oncommit);
3532  COPY_STRING_FIELD(tablespacename);
3533  COPY_STRING_FIELD(accessMethod);
3534  COPY_SCALAR_FIELD(if_not_exists);
3535 }
3536 
3537 static CreateStmt *
3539 {
3540  CreateStmt *newnode = makeNode(CreateStmt);
3541 
3542  CopyCreateStmtFields(from, newnode);
3543 
3544  return newnode;
3545 }
3546 
3547 static TableLikeClause *
3549 {
3551 
3552  COPY_NODE_FIELD(relation);
3554  COPY_SCALAR_FIELD(relationOid);
3555 
3556  return newnode;
3557 }
3558 
3559 static DefineStmt *
3561 {
3562  DefineStmt *newnode = makeNode(DefineStmt);
3563 
3564  COPY_SCALAR_FIELD(kind);
3565  COPY_SCALAR_FIELD(oldstyle);
3566  COPY_NODE_FIELD(defnames);
3568  COPY_NODE_FIELD(definition);
3569  COPY_SCALAR_FIELD(if_not_exists);
3570  COPY_SCALAR_FIELD(replace);
3571 
3572  return newnode;
3573 }
3574 
3575 static DropStmt *
3577 {
3578  DropStmt *newnode = makeNode(DropStmt);
3579 
3580  COPY_NODE_FIELD(objects);
3581  COPY_SCALAR_FIELD(removeType);
3582  COPY_SCALAR_FIELD(behavior);
3583  COPY_SCALAR_FIELD(missing_ok);
3584  COPY_SCALAR_FIELD(concurrent);
3585 
3586  return newnode;
3587 }
3588 
3589 static TruncateStmt *
3591 {
3592  TruncateStmt *newnode = makeNode(TruncateStmt);
3593 
3594  COPY_NODE_FIELD(relations);
3595  COPY_SCALAR_FIELD(restart_seqs);
3596  COPY_SCALAR_FIELD(behavior);
3597 
3598  return newnode;
3599 }
3600 
3601 static CommentStmt *
3603 {
3604  CommentStmt *newnode = makeNode(CommentStmt);
3605 
3606  COPY_SCALAR_FIELD(objtype);
3607  COPY_NODE_FIELD(object);
3608  COPY_STRING_FIELD(comment);
3609 
3610  return newnode;
3611 }
3612 
3613 static SecLabelStmt *
3615 {
3616  SecLabelStmt *newnode = makeNode(SecLabelStmt);
3617 
3618  COPY_SCALAR_FIELD(objtype);
3619  COPY_NODE_FIELD(object);
3622 
3623  return newnode;
3624 }
3625 
3626 static FetchStmt *
3628 {
3629  FetchStmt *newnode = makeNode(FetchStmt);
3630 
3631  COPY_SCALAR_FIELD(direction);
3632  COPY_SCALAR_FIELD(howMany);
3633  COPY_STRING_FIELD(portalname);
3634  COPY_SCALAR_FIELD(ismove);
3635 
3636  return newnode;
3637 }
3638 
3639 static IndexStmt *
3641 {
3642  IndexStmt *newnode = makeNode(IndexStmt);
3643 
3644  COPY_STRING_FIELD(idxname);
3645  COPY_NODE_FIELD(relation);
3646  COPY_STRING_FIELD(accessMethod);
3647  COPY_STRING_FIELD(tableSpace);
3648  COPY_NODE_FIELD(indexParams);
3649  COPY_NODE_FIELD(indexIncludingParams);
3651  COPY_NODE_FIELD(whereClause);
3652  COPY_NODE_FIELD(excludeOpNames);
3653  COPY_STRING_FIELD(idxcomment);
3654  COPY_SCALAR_FIELD(indexOid);
3655  COPY_SCALAR_FIELD(oldNode);
3656  COPY_SCALAR_FIELD(oldCreateSubid);
3657  COPY_SCALAR_FIELD(oldFirstRelfilenodeSubid);
3658  COPY_SCALAR_FIELD(unique);
3659  COPY_SCALAR_FIELD(primary);
3660  COPY_SCALAR_FIELD(isconstraint);
3661  COPY_SCALAR_FIELD(deferrable);
3662  COPY_SCALAR_FIELD(initdeferred);
3663  COPY_SCALAR_FIELD(transformed);
3664  COPY_SCALAR_FIELD(concurrent);
3665  COPY_SCALAR_FIELD(if_not_exists);
3666  COPY_SCALAR_FIELD(reset_default_tblspc);
3667 
3668  return newnode;
3669 }
3670 
3671 static CreateStatsStmt *
3673 {
3675 
3676  COPY_NODE_FIELD(defnames);
3677  COPY_NODE_FIELD(stat_types);
3678  COPY_NODE_FIELD(exprs);
3679  COPY_NODE_FIELD(relations);
3680  COPY_STRING_FIELD(stxcomment);
3681  COPY_SCALAR_FIELD(transformed);
3682  COPY_SCALAR_FIELD(if_not_exists);
3683 
3684  return newnode;
3685 }
3686 
3687 static AlterStatsStmt *
3689 {
3691 
3692  COPY_NODE_FIELD(defnames);
3693  COPY_SCALAR_FIELD(stxstattarget);
3694  COPY_SCALAR_FIELD(missing_ok);
3695 
3696  return newnode;
3697 }
3698 
3699 static CreateFunctionStmt *
3701 {
3703 
3704  COPY_SCALAR_FIELD(is_procedure);
3705  COPY_SCALAR_FIELD(replace);
3706  COPY_NODE_FIELD(funcname);
3707  COPY_NODE_FIELD(parameters);
3708  COPY_NODE_FIELD(returnType);
3710  COPY_NODE_FIELD(sql_body);
3711 
3712  return newnode;
3713 }
3714 
3715 static FunctionParameter *
3717 {
3719 
3721  COPY_NODE_FIELD(argType);
3723  COPY_NODE_FIELD(defexpr);
3724 
3725  return newnode;
3726 }
3727 
3728 static AlterFunctionStmt *
3730 {
3732 
3733  COPY_SCALAR_FIELD(objtype);
3734  COPY_NODE_FIELD(func);
3735  COPY_NODE_FIELD(actions);
3736 
3737  return newnode;
3738 }
3739 
3740 static DoStmt *
3741 _copyDoStmt(const DoStmt *from)
3742 {
3743  DoStmt *newnode = makeNode(DoStmt);
3744 
3746 
3747  return newnode;
3748 }
3749 
3750 static RenameStmt *
3752 {
3753  RenameStmt *newnode = makeNode(RenameStmt);
3754 
3755  COPY_SCALAR_FIELD(renameType);
3756  COPY_SCALAR_FIELD(relationType);
3757  COPY_NODE_FIELD(relation);
3758  COPY_NODE_FIELD(object);
3760  COPY_STRING_FIELD(newname);
3761  COPY_SCALAR_FIELD(behavior);
3762  COPY_SCALAR_FIELD(missing_ok);
3763 
3764  return newnode;
3765 }
3766 
3767 static AlterObjectDependsStmt *
3769 {
3771 
3772  COPY_SCALAR_FIELD(objectType);
3773  COPY_NODE_FIELD(relation);
3774  COPY_NODE_FIELD(object);
3775  COPY_NODE_FIELD(extname);
3776  COPY_SCALAR_FIELD(remove);
3777 
3778  return newnode;
3779 }
3780 
3781 static AlterObjectSchemaStmt *
3783 {
3785 
3786  COPY_SCALAR_FIELD(objectType);
3787  COPY_NODE_FIELD(relation);
3788  COPY_NODE_FIELD(object);
3789  COPY_STRING_FIELD(newschema);
3790  COPY_SCALAR_FIELD(missing_ok);
3791 
3792  return newnode;
3793 }
3794 
3795 static AlterOwnerStmt *
3797 {
3799 
3800  COPY_SCALAR_FIELD(objectType);
3801  COPY_NODE_FIELD(relation);
3802  COPY_NODE_FIELD(object);
3803  COPY_NODE_FIELD(newowner);
3804 
3805  return newnode;
3806 }
3807 
3808 static AlterOperatorStmt *
3810 {
3812 
3813  COPY_NODE_FIELD(opername);
3815 
3816  return newnode;
3817 }
3818 
3819 static AlterTypeStmt *
3821 {
3822  AlterTypeStmt *newnode = makeNode(AlterTypeStmt);
3823 
3824  COPY_NODE_FIELD(typeName);
3826 
3827  return newnode;
3828 }
3829 
3830 static RuleStmt *
3832 {
3833  RuleStmt *newnode = makeNode(RuleStmt);
3834 
3835  COPY_NODE_FIELD(relation);
3836  COPY_STRING_FIELD(rulename);
3837  COPY_NODE_FIELD(whereClause);
3838  COPY_SCALAR_FIELD(event);
3839  COPY_SCALAR_FIELD(instead);
3840  COPY_NODE_FIELD(actions);
3841  COPY_SCALAR_FIELD(replace);
3842 
3843  return newnode;
3844 }
3845 
3846 static NotifyStmt *
3848 {
3849  NotifyStmt *newnode = makeNode(NotifyStmt);
3850 
3851  COPY_STRING_FIELD(conditionname);
3852  COPY_STRING_FIELD(payload);
3853 
3854  return newnode;
3855 }
3856 
3857 static ListenStmt *
3859 {
3860  ListenStmt *newnode = makeNode(ListenStmt);
3861 
3862  COPY_STRING_FIELD(conditionname);
3863 
3864  return newnode;
3865 }
3866 
3867 static UnlistenStmt *
3869 {
3870  UnlistenStmt *newnode = makeNode(UnlistenStmt);
3871 
3872  COPY_STRING_FIELD(conditionname);
3873 
3874  return newnode;
3875 }
3876 
3877 static TransactionStmt *
3879 {
3881 
3882  COPY_SCALAR_FIELD(kind);
3884  COPY_STRING_FIELD(savepoint_name);
3885  COPY_STRING_FIELD(gid);
3886  COPY_SCALAR_FIELD(chain);
3887 
3888  return newnode;
3889 }
3890 
3891 static CompositeTypeStmt *
3893 {
3895 
3896  COPY_NODE_FIELD(typevar);
3897  COPY_NODE_FIELD(coldeflist);
3898 
3899  return newnode;
3900 }
3901 
3902 static CreateEnumStmt *
3904 {
3906 
3907  COPY_NODE_FIELD(typeName);
3908  COPY_NODE_FIELD(vals);
3909 
3910  return newnode;
3911 }
3912 
3913 static CreateRangeStmt *
3915 {
3917 
3918  COPY_NODE_FIELD(typeName);
3919  COPY_NODE_FIELD(params);
3920 
3921  return newnode;
3922 }
3923 
3924 static AlterEnumStmt *
3926 {
3927  AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3928 
3929  COPY_NODE_FIELD(typeName);
3930  COPY_STRING_FIELD(oldVal);
3931  COPY_STRING_FIELD(newVal);
3932  COPY_STRING_FIELD(newValNeighbor);
3933  COPY_SCALAR_FIELD(newValIsAfter);
3934  COPY_SCALAR_FIELD(skipIfNewValExists);
3935 
3936  return newnode;
3937 }
3938 
3939 static ViewStmt *
3941 {
3942  ViewStmt *newnode = makeNode(ViewStmt);
3943 
3944  COPY_NODE_FIELD(view);
3945  COPY_NODE_FIELD(aliases);
3946  COPY_NODE_FIELD(query);
3947  COPY_SCALAR_FIELD(replace);
3949  COPY_SCALAR_FIELD(withCheckOption);
3950 
3951  return newnode;
3952 }
3953 
3954 static LoadStmt *
3956 {
3957  LoadStmt *newnode = makeNode(LoadStmt);
3958 
3960 
3961  return newnode;
3962 }
3963 
3964 static CreateDomainStmt *
3966 {
3968 
3969  COPY_NODE_FIELD(domainname);
3970  COPY_NODE_FIELD(typeName);
3971  COPY_NODE_FIELD(collClause);
3972  COPY_NODE_FIELD(constraints);
3973 
3974  return newnode;
3975 }
3976 
3977 static CreateOpClassStmt *
3979 {
3981 
3982  COPY_NODE_FIELD(opclassname);
3983  COPY_NODE_FIELD(opfamilyname);
3984  COPY_STRING_FIELD(amname);
3985  COPY_NODE_FIELD(datatype);
3986  COPY_NODE_FIELD(items);
3987  COPY_SCALAR_FIELD(isDefault);
3988 
3989  return newnode;
3990 }
3991 
3992 static CreateOpClassItem *
3994 {
3996 
3997  COPY_SCALAR_FIELD(itemtype);
3999  COPY_SCALAR_FIELD(number);
4000  COPY_NODE_FIELD(order_family);
4001  COPY_NODE_FIELD(class_args);
4002  COPY_NODE_FIELD(storedtype);
4003 
4004  return newnode;
4005 }
4006 
4007 static CreateOpFamilyStmt *
4009 {
4011 
4012  COPY_NODE_FIELD(opfamilyname);
4013  COPY_STRING_FIELD(amname);
4014 
4015  return newnode;
4016 }
4017 
4018 static AlterOpFamilyStmt *
4020 {
4022 
4023  COPY_NODE_FIELD(opfamilyname);
4024  COPY_STRING_FIELD(amname);
4025  COPY_SCALAR_FIELD(isDrop);
4026  COPY_NODE_FIELD(items);
4027 
4028  return newnode;
4029 }
4030 
4031 static CreatedbStmt *
4033 {
4034  CreatedbStmt *newnode = makeNode(CreatedbStmt);
4035 
4038 
4039  return newnode;
4040 }
4041 
4042 static AlterDatabaseStmt *
4044 {
4046 
4049 
4050  return newnode;
4051 }
4052 
4053 static AlterDatabaseSetStmt *
4055 {
4057 
4059  COPY_NODE_FIELD(setstmt);
4060 
4061  return newnode;
4062 }
4063 
4064 static DropdbStmt *
4066 {
4067  DropdbStmt *newnode = makeNode(DropdbStmt);
4068 
4070  COPY_SCALAR_FIELD(missing_ok);
4072 
4073  return newnode;
4074 }
4075 
4076 static VacuumStmt *
4078 {
4079  VacuumStmt *newnode = makeNode(VacuumStmt);
4080 
4082  COPY_NODE_FIELD(rels);
4083  COPY_SCALAR_FIELD(is_vacuumcmd);
4084 
4085  return newnode;
4086 }
4087 
4088 static VacuumRelation *
4090 {
4092 
4093  COPY_NODE_FIELD(relation);
4094  COPY_SCALAR_FIELD(oid);
4095  COPY_NODE_FIELD(va_cols);
4096 
4097  return newnode;
4098 }
4099 
4100 static ExplainStmt *
4102 {
4103  ExplainStmt *newnode = makeNode(ExplainStmt);
4104 
4105  COPY_NODE_FIELD(query);
4107 
4108  return newnode;
4109 }
4110 
4111 static CreateTableAsStmt *
4113 {
4115 
4116  COPY_NODE_FIELD(query);
4117  COPY_NODE_FIELD(into);
4118  COPY_SCALAR_FIELD(objtype);
4119  COPY_SCALAR_FIELD(is_select_into);
4120  COPY_SCALAR_FIELD(if_not_exists);
4121 
4122  return newnode;
4123 }
4124 
4125 static RefreshMatViewStmt *
4127 {
4129 
4130  COPY_SCALAR_FIELD(concurrent);
4131  COPY_SCALAR_FIELD(skipData);
4132  COPY_NODE_FIELD(relation);
4133 
4134  return newnode;
4135 }
4136 
4137 static ReplicaIdentityStmt *
4139 {
4141 
4142  COPY_SCALAR_FIELD(identity_type);
4144 
4145  return newnode;
4146 }
4147 
4148 static AlterSystemStmt *
4150 {
4152 
4153  COPY_NODE_FIELD(setstmt);
4154 
4155  return newnode;
4156 }
4157 
4158 static CreateSeqStmt *
4160 {
4161  CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
4162 
4163  COPY_NODE_FIELD(sequence);
4165  COPY_SCALAR_FIELD(ownerId);
4166  COPY_SCALAR_FIELD(for_identity);
4167  COPY_SCALAR_FIELD(if_not_exists);
4168 
4169  return newnode;
4170 }
4171 
4172 static AlterSeqStmt *
4174 {
4175  AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
4176 
4177  COPY_NODE_FIELD(sequence);
4179  COPY_SCALAR_FIELD(for_identity);
4180  COPY_SCALAR_FIELD(missing_ok);
4181 
4182  return newnode;
4183 }
4184 
4185 static VariableSetStmt *
4187 {
4189 
4190  COPY_SCALAR_FIELD(kind);
4193  COPY_SCALAR_FIELD(is_local);
4194 
4195  return newnode;
4196 }
4197 
4198 static VariableShowStmt *
4200 {
4202 
4204 
4205  return newnode;
4206 }
4207 
4208 static DiscardStmt *
4210 {
4211  DiscardStmt *newnode = makeNode(DiscardStmt);
4212 
4213  COPY_SCALAR_FIELD(target);
4214 
4215  return newnode;
4216 }
4217 
4218 static CreateTableSpaceStmt *
4220 {
4222 
4223  COPY_STRING_FIELD(tablespacename);
4224  COPY_NODE_FIELD(owner);
4225  COPY_STRING_FIELD(location);
4227 
4228  return newnode;
4229 }
4230 
4231 static DropTableSpaceStmt *
4233 {
4235 
4236  COPY_STRING_FIELD(tablespacename);
4237  COPY_SCALAR_FIELD(missing_ok);
4238 
4239  return newnode;
4240 }
4241 
4244 {
4246 
4247  COPY_STRING_FIELD(tablespacename);
4249  COPY_SCALAR_FIELD(isReset);
4250 
4251  return newnode;
4252 }
4253 
4254 static AlterTableMoveAllStmt *
4256 {
4258 
4259  COPY_STRING_FIELD(orig_tablespacename);
4260  COPY_SCALAR_FIELD(objtype);
4261  COPY_NODE_FIELD(roles);
4262  COPY_STRING_FIELD(new_tablespacename);
4263  COPY_SCALAR_FIELD(nowait);
4264 
4265  return newnode;
4266 }
4267 
4268 static CreateExtensionStmt *
4270 {
4272 
4273  COPY_STRING_FIELD(extname);
4274  COPY_SCALAR_FIELD(if_not_exists);
4276 
4277  return newnode;
4278 }
4279 
4280 static AlterExtensionStmt *
4282 {
4284 
4285  COPY_STRING_FIELD(extname);
4287 
4288  return newnode;
4289 }
4290 
4293 {
4295 
4296  COPY_STRING_FIELD(extname);
4298  COPY_SCALAR_FIELD(objtype);
4299  COPY_NODE_FIELD(object);
4300 
4301  return newnode;
4302 }
4303 
4304 static CreateFdwStmt *
4306 {
4307  CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
4308 
4309  COPY_STRING_FIELD(fdwname);
4310  COPY_NODE_FIELD(func_options);
4312 
4313  return newnode;
4314 }
4315 
4316 static AlterFdwStmt *
4318 {
4319  AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
4320 
4321  COPY_STRING_FIELD(fdwname);
4322  COPY_NODE_FIELD(func_options);
4324 
4325  return newnode;
4326 }
4327 
4328 static CreateForeignServerStmt *
4330 {
4332 
4333  COPY_STRING_FIELD(servername);
4334  COPY_STRING_FIELD(servertype);
4335  COPY_STRING_FIELD(version);
4336  COPY_STRING_FIELD(fdwname);
4337  COPY_SCALAR_FIELD(if_not_exists);
4339 
4340  return newnode;
4341 }
4342 
4343 static AlterForeignServerStmt *
4345 {
4347 
4348  COPY_STRING_FIELD(servername);
4349  COPY_STRING_FIELD(version);
4351  COPY_SCALAR_FIELD(has_version);
4352 
4353  return newnode;
4354 }
4355 
4356 static CreateUserMappingStmt *
4358 {
4360 
4362  COPY_STRING_FIELD(servername);
4363  COPY_SCALAR_FIELD(if_not_exists);
4365 
4366  return newnode;
4367 }
4368 
4369 static AlterUserMappingStmt *
4371 {
4373 
4375  COPY_STRING_FIELD(servername);
4377 
4378  return newnode;
4379 }
4380 
4381 static DropUserMappingStmt *
4383 {
4385 
4387  COPY_STRING_FIELD(servername);
4388  COPY_SCALAR_FIELD(missing_ok);
4389 
4390  return newnode;
4391 }
4392 
4393 static CreateForeignTableStmt *
4395 {
4397 
4398  CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
4399 
4400  COPY_STRING_FIELD(servername);
4402 
4403  return newnode;
4404 }
4405 
4406 static ImportForeignSchemaStmt *
4408 {
4410 
4411  COPY_STRING_FIELD(server_name);
4412  COPY_STRING_FIELD(remote_schema);
4413  COPY_STRING_FIELD(local_schema);
4414  COPY_SCALAR_FIELD(list_type);
4415  COPY_NODE_FIELD(table_list);
4417 
4418  return newnode;
4419 }
4420 
4421 static CreateTransformStmt *
4423 {
4425 
4426  COPY_SCALAR_FIELD(replace);
4427  COPY_NODE_FIELD(type_name);
4428  COPY_STRING_FIELD(lang);
4429  COPY_NODE_FIELD(fromsql);
4430  COPY_NODE_FIELD(tosql);
4431 
4432  return newnode;
4433 }
4434 
4435 static CreateAmStmt *
4437 {
4438  CreateAmStmt *newnode = makeNode(CreateAmStmt);
4439 
4440  COPY_STRING_FIELD(amname);
4441  COPY_NODE_FIELD(handler_name);
4442  COPY_SCALAR_FIELD(amtype);
4443 
4444  return newnode;
4445 }
4446 
4447 static CreateTrigStmt *
4449 {
4451 
4452  COPY_SCALAR_FIELD(replace);
4453  COPY_SCALAR_FIELD(isconstraint);
4454  COPY_STRING_FIELD(trigname);
4455  COPY_NODE_FIELD(relation);
4456  COPY_NODE_FIELD(funcname);
4458  COPY_SCALAR_FIELD(row);
4459  COPY_SCALAR_FIELD(timing);
4460  COPY_SCALAR_FIELD(events);
4461  COPY_NODE_FIELD(columns);
4462  COPY_NODE_FIELD(whenClause);
4463  COPY_NODE_FIELD(transitionRels);
4464  COPY_SCALAR_FIELD(deferrable);
4465  COPY_SCALAR_FIELD(initdeferred);
4466  COPY_NODE_FIELD(constrrel);
4467 
4468  return newnode;
4469 }
4470 
4471 static CreateEventTrigStmt *
4473 {
4475 
4476  COPY_STRING_FIELD(trigname);
4477  COPY_STRING_FIELD(eventname);
4478  COPY_NODE_FIELD(whenclause);
4479  COPY_NODE_FIELD(funcname);
4480 
4481  return newnode;
4482 }
4483 
4484 static AlterEventTrigStmt *
4486 {
4488 
4489  COPY_STRING_FIELD(trigname);
4490  COPY_SCALAR_FIELD(tgenabled);
4491 
4492  return newnode;
4493 }
4494 
4495 static CreatePLangStmt *
4497 {
4499 
4500  COPY_SCALAR_FIELD(replace);
4501  COPY_STRING_FIELD(plname);
4502  COPY_NODE_FIELD(plhandler);
4503  COPY_NODE_FIELD(plinline);
4504  COPY_NODE_FIELD(plvalidator);
4505  COPY_SCALAR_FIELD(pltrusted);
4506 
4507  return newnode;
4508 }
4509 
4510 static CreateRoleStmt *
4512 {
4514 
4515  COPY_SCALAR_FIELD(stmt_type);
4516  COPY_STRING_FIELD(role);
4518 
4519  return newnode;
4520 }
4521 
4522 static AlterRoleStmt *
4524 {
4525  AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
4526 
4527  COPY_NODE_FIELD(role);
4530 
4531  return newnode;
4532 }
4533 
4534 static AlterRoleSetStmt *
4536 {
4538 
4539  COPY_NODE_FIELD(role);
4540  COPY_STRING_FIELD(database);
4541  COPY_NODE_FIELD(setstmt);
4542 
4543  return newnode;
4544 }
4545 
4546 static DropRoleStmt *
4548 {
4549  DropRoleStmt *newnode = makeNode(DropRoleStmt);
4550 
4551  COPY_NODE_FIELD(roles);
4552  COPY_SCALAR_FIELD(missing_ok);
4553 
4554  return newnode;
4555 }
4556 
4557 static LockStmt *
4559 {
4560  LockStmt *newnode = makeNode(LockStmt);
4561 
4562  COPY_NODE_FIELD(relations);
4564  COPY_SCALAR_FIELD(nowait);
4565 
4566  return newnode;
4567 }
4568 
4569 static ConstraintsSetStmt *
4571 {
4573 
4574  COPY_NODE_FIELD(constraints);
4575  COPY_SCALAR_FIELD(deferred);
4576 
4577  return newnode;
4578 }
4579 
4580 static ReindexStmt *
4582 {
4583  ReindexStmt *newnode = makeNode(ReindexStmt);
4584 
4585  COPY_SCALAR_FIELD(kind);
4586  COPY_NODE_FIELD(relation);
4588  COPY_NODE_FIELD(params);
4589 
4590  return newnode;
4591 }
4592 
4593 static CreateSchemaStmt *
4595 {
4597 
4598  COPY_STRING_FIELD(schemaname);
4599  COPY_NODE_FIELD(authrole);
4600  COPY_NODE_FIELD(schemaElts);
4601  COPY_SCALAR_FIELD(if_not_exists);
4602 
4603  return newnode;
4604 }
4605 
4606 static CreateConversionStmt *
4608 {
4610 
4611  COPY_NODE_FIELD(conversion_name);
4612  COPY_STRING_FIELD(for_encoding_name);
4613  COPY_STRING_FIELD(to_encoding_name);
4614  COPY_NODE_FIELD(func_name);
4615  COPY_SCALAR_FIELD(def);
4616 
4617  return newnode;
4618 }
4619 
4620 static CreateCastStmt *
4622 {
4624 
4625  COPY_NODE_FIELD(sourcetype);
4626  COPY_NODE_FIELD(targettype);
4627  COPY_NODE_FIELD(func);
4628  COPY_SCALAR_FIELD(context);
4629  COPY_SCALAR_FIELD(inout);
4630 
4631  return newnode;
4632 }
4633 
4634 static PrepareStmt *
4636 {
4637  PrepareStmt *newnode = makeNode(PrepareStmt);
4638 
4640  COPY_NODE_FIELD(argtypes);
4641  COPY_NODE_FIELD(query);
4642 
4643  return newnode;
4644 }
4645 
4646 static ExecuteStmt *
4648 {
4649  ExecuteStmt *newnode = makeNode(ExecuteStmt);
4650 
4652  COPY_NODE_FIELD(params);
4653 
4654  return newnode;
4655 }
4656 
4657 static DeallocateStmt *
4659 {
4661 
4663 
4664  return newnode;
4665 }
4666 
4667 static DropOwnedStmt *
4669 {
4670  DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
4671 
4672  COPY_NODE_FIELD(roles);
4673  COPY_SCALAR_FIELD(behavior);
4674 
4675  return newnode;
4676 }
4677 
4678 static ReassignOwnedStmt *
4680 {
4682 
4683  COPY_NODE_FIELD(roles);
4684  COPY_NODE_FIELD(newrole);
4685 
4686  return newnode;
4687 }
4688 
4689 static AlterTSDictionaryStmt *
4691 {
4693 
4694  COPY_NODE_FIELD(dictname);
4696 
4697  return newnode;
4698 }
4699 
4700 static AlterTSConfigurationStmt *
4702 {
4704 
4705  COPY_SCALAR_FIELD(kind);
4706  COPY_NODE_FIELD(cfgname);
4707  COPY_NODE_FIELD(tokentype);
4708  COPY_NODE_FIELD(dicts);
4709  COPY_SCALAR_FIELD(override);
4710  COPY_SCALAR_FIELD(replace);
4711  COPY_SCALAR_FIELD(missing_ok);
4712 
4713  return newnode;
4714 }
4715 
4716 static CreatePolicyStmt *
4718 {
4720 
4721  COPY_STRING_FIELD(policy_name);
4722  COPY_NODE_FIELD(table);
4723  COPY_STRING_FIELD(cmd_name);
4724  COPY_SCALAR_FIELD(permissive);
4725  COPY_NODE_FIELD(roles);
4726  COPY_NODE_FIELD(qual);
4727  COPY_NODE_FIELD(with_check);
4728 
4729  return newnode;
4730 }
4731 
4732 static AlterPolicyStmt *
4734 {
4736 
4737  COPY_STRING_FIELD(policy_name);
4738  COPY_NODE_FIELD(table);
4739  COPY_NODE_FIELD(roles);
4740  COPY_NODE_FIELD(qual);
4741  COPY_NODE_FIELD(with_check);
4742 
4743  return newnode;
4744 }
4745 
4746 static PartitionElem *
4748 {
4749  PartitionElem *newnode = makeNode(PartitionElem);
4750 
4752  COPY_NODE_FIELD(expr);
4753  COPY_NODE_FIELD(collation);
4754  COPY_NODE_FIELD(opclass);
4755  COPY_LOCATION_FIELD(location);
4756 
4757  return newnode;
4758 }
4759 
4760 static PartitionSpec *
4762 {
4763  PartitionSpec *newnode = makeNode(PartitionSpec);
4764 
4765  COPY_STRING_FIELD(strategy);
4766  COPY_NODE_FIELD(partParams);
4767  COPY_LOCATION_FIELD(location);
4768 
4769  return newnode;
4770 }
4771 
4772 static PartitionBoundSpec *
4774 {
4776 
4777  COPY_SCALAR_FIELD(strategy);
4778  COPY_SCALAR_FIELD(is_default);
4779  COPY_SCALAR_FIELD(modulus);
4780  COPY_SCALAR_FIELD(remainder);
4781  COPY_NODE_FIELD(listdatums);
4782  COPY_NODE_FIELD(lowerdatums);
4783  COPY_NODE_FIELD(upperdatums);
4784  COPY_LOCATION_FIELD(location);
4785 
4786  return newnode;
4787 }
4788 
4789 static PartitionRangeDatum *
4791 {
4793 
4794  COPY_SCALAR_FIELD(kind);
4796  COPY_LOCATION_FIELD(location);
4797 
4798  return newnode;
4799 }
4800 
4801 static PartitionCmd *
4803 {
4804  PartitionCmd *newnode = makeNode(PartitionCmd);
4805 
4807  COPY_NODE_FIELD(bound);
4808  COPY_SCALAR_FIELD(concurrent);
4809 
4810  return newnode;
4811 }
4812 
4813 static CreatePublicationStmt *
4815 {
4817 
4818  COPY_STRING_FIELD(pubname);
4820  COPY_NODE_FIELD(tables);
4821  COPY_SCALAR_FIELD(for_all_tables);
4822 
4823  return newnode;
4824 }
4825 
4826 static AlterPublicationStmt *
4828 {
4830 
4831  COPY_STRING_FIELD(pubname);
4833  COPY_NODE_FIELD(tables);
4834  COPY_SCALAR_FIELD(for_all_tables);
4835  COPY_SCALAR_FIELD(tableAction);
4836 
4837  return newnode;
4838 }
4839 
4840 static CreateSubscriptionStmt *
4842 {
4844 
4846  COPY_STRING_FIELD(conninfo);
4847  COPY_NODE_FIELD(publication);
4849 
4850  return newnode;
4851 }
4852 
4853 static AlterSubscriptionStmt *
4855 {
4857 
4858  COPY_SCALAR_FIELD(kind);
4860  COPY_STRING_FIELD(conninfo);
4861  COPY_NODE_FIELD(publication);
4863 
4864  return newnode;
4865 }
4866 
4867 static DropSubscriptionStmt *
4869 {
4871 
4873  COPY_SCALAR_FIELD(missing_ok);
4874  COPY_SCALAR_FIELD(behavior);
4875 
4876  return newnode;
4877 }
4878 
4879 /* ****************************************************************
4880  * extensible.h copy functions
4881  * ****************************************************************
4882  */
4883 static ExtensibleNode *
4885 {
4886  ExtensibleNode *newnode;
4887  const ExtensibleNodeMethods *methods;
4888 
4889  methods = GetExtensibleNodeMethods(from->extnodename, false);
4890  newnode = (ExtensibleNode *) newNode(methods->node_size,
4892  COPY_STRING_FIELD(extnodename);
4893 
4894  /* copy the private fields */
4895  methods->nodeCopy(newnode, from);
4896 
4897  return newnode;
4898 }
4899 
4900 /* ****************************************************************
4901  * value.h copy functions
4902  * ****************************************************************
4903  */
4904 static Integer *
4905 _copyInteger(const Integer *from)
4906 {
4907  Integer *newnode = makeNode(Integer);
4908 
4910 
4911  return newnode;
4912 }
4913 
4914 static Float *
4915 _copyFloat(const Float *from)
4916 {
4917  Float *newnode = makeNode(Float);
4918 
4920 
4921  return newnode;
4922 }
4923 
4924 static String *
4925 _copyString(const String *from)
4926 {
4927  String *newnode = makeNode(String);
4928 
4930 
4931  return newnode;
4932 }
4933 
4934 static BitString *
4936 {
4937  BitString *newnode = makeNode(BitString);
4938 
4940 
4941  return newnode;
4942 }
4943 
4944 
4945 static ForeignKeyCacheInfo *
4947 {
4949 
4950  COPY_SCALAR_FIELD(conoid);
4951  COPY_SCALAR_FIELD(conrelid);
4952  COPY_SCALAR_FIELD(confrelid);
4953  COPY_SCALAR_FIELD(nkeys);
4954  COPY_ARRAY_FIELD(conkey);
4955  COPY_ARRAY_FIELD(confkey);
4956  COPY_ARRAY_FIELD(conpfeqop);
4957 
4958  return newnode;
4959 }
4960 
4961 static PublicationTable *
4963 {
4965 
4966  COPY_NODE_FIELD(relation);
4967 
4968  return newnode;
4969 }
4970 
4971 /*
4972  * copyObjectImpl -- implementation of copyObject(); see nodes/nodes.h
4973  *
4974  * Create a copy of a Node tree or list. This is a "deep" copy: all
4975  * substructure is copied too, recursively.
4976  */
4977 void *
4978 copyObjectImpl(const void *from)
4979 {
4980  void *retval;
4981 
4982  if (from == NULL)
4983  return NULL;
4984 
4985  /* Guard against stack overflow due to overly complex expressions */
4987 
4988  switch (nodeTag(from))
4989  {
4990  /*
4991  * PLAN NODES
4992  */
4993  case T_PlannedStmt:
4994  retval = _copyPlannedStmt(from);
4995  break;
4996  case T_Plan:
4997  retval = _copyPlan(from);
4998  break;
4999  case T_Result:
5000  retval = _copyResult(from);
5001  break;
5002  case T_ProjectSet:
5003  retval = _copyProjectSet(from);
5004  break;
5005  case T_ModifyTable:
5006  retval = _copyModifyTable(from);
5007  break;
5008  case T_Append:
5009  retval = _copyAppend(from);
5010  break;
5011  case T_MergeAppend:
5012  retval = _copyMergeAppend(from);
5013  break;
5014  case T_RecursiveUnion:
5015  retval = _copyRecursiveUnion(from);
5016  break;
5017  case T_BitmapAnd:
5018  retval = _copyBitmapAnd(from);
5019  break;
5020  case T_BitmapOr:
5021  retval = _copyBitmapOr(from);
5022  break;
5023  case T_Scan:
5024  retval = _copyScan(from);
5025  break;
5026  case T_Gather:
5027  retval = _copyGather(from);
5028  break;
5029  case T_GatherMerge:
5030  retval = _copyGatherMerge(from);
5031  break;
5032  case T_SeqScan:
5033  retval = _copySeqScan(from);
5034  break;
5035  case T_SampleScan:
5036  retval = _copySampleScan(from);
5037  break;
5038  case T_IndexScan:
5039  retval = _copyIndexScan(from);
5040  break;
5041  case T_IndexOnlyScan:
5042  retval = _copyIndexOnlyScan(from);
5043  break;
5044  case T_BitmapIndexScan:
5045  retval = _copyBitmapIndexScan(from);
5046  break;
5047  case T_BitmapHeapScan:
5048  retval = _copyBitmapHeapScan(from);
5049  break;
5050  case T_TidScan:
5051  retval = _copyTidScan(from);
5052  break;
5053  case T_TidRangeScan:
5054  retval = _copyTidRangeScan(from);
5055  break;
5056  case T_SubqueryScan:
5057  retval = _copySubqueryScan(from);
5058  break;
5059  case T_FunctionScan:
5060  retval = _copyFunctionScan(from);
5061  break;
5062  case T_TableFuncScan:
5063  retval = _copyTableFuncScan(from);
5064  break;
5065  case T_ValuesScan:
5066  retval = _copyValuesScan(from);
5067  break;
5068  case T_CteScan:
5069  retval = _copyCteScan(from);
5070  break;
5071  case T_NamedTuplestoreScan:
5072  retval = _copyNamedTuplestoreScan(from);
5073  break;
5074  case T_WorkTableScan:
5075  retval = _copyWorkTableScan(from);
5076  break;
5077  case T_ForeignScan:
5078  retval = _copyForeignScan(from);
5079  break;
5080  case T_CustomScan:
5081  retval = _copyCustomScan(from);
5082  break;
5083  case T_Join:
5084  retval = _copyJoin(from);
5085  break;
5086  case T_NestLoop:
5087  retval = _copyNestLoop(from);
5088  break;
5089  case T_MergeJoin:
5090  retval = _copyMergeJoin(from);
5091  break;
5092  case T_HashJoin:
5093  retval = _copyHashJoin(from);
5094  break;
5095  case T_Material:
5096  retval = _copyMaterial(from);
5097  break;
5098  case T_Memoize:
5099  retval = _copyMemoize(from);
5100  break;
5101  case T_Sort:
5102  retval = _copySort(from);
5103  break;
5104  case T_IncrementalSort:
5105  retval = _copyIncrementalSort(from);
5106  break;
5107  case T_Group:
5108  retval = _copyGroup(from);
5109  break;
5110  case T_Agg:
5111  retval = _copyAgg(from);
5112  break;
5113  case T_WindowAgg:
5114  retval = _copyWindowAgg(from);
5115  break;
5116  case T_Unique:
5117  retval = _copyUnique(from);
5118  break;
5119  case T_Hash:
5120  retval = _copyHash(from);
5121  break;
5122  case T_SetOp:
5123  retval = _copySetOp(from);
5124  break;
5125  case T_LockRows:
5126  retval = _copyLockRows(from);
5127  break;
5128  case T_Limit:
5129  retval = _copyLimit(from);
5130  break;
5131  case T_NestLoopParam:
5132  retval = _copyNestLoopParam(from);
5133  break;
5134  case T_PlanRowMark:
5135  retval = _copyPlanRowMark(from);
5136  break;
5137  case T_PartitionPruneInfo:
5138  retval = _copyPartitionPruneInfo(from);
5139  break;
5141  retval = _copyPartitionedRelPruneInfo(from);
5142  break;
5144  retval = _copyPartitionPruneStepOp(from);
5145  break;
5147  retval = _copyPartitionPruneStepCombine(from);
5148  break;
5149  case T_PlanInvalItem:
5150  retval = _copyPlanInvalItem(from);
5151  break;
5152 
5153  /*
5154  * PRIMITIVE NODES
5155  */
5156  case T_Alias:
5157  retval = _copyAlias(from);
5158  break;
5159  case T_RangeVar:
5160  retval = _copyRangeVar(from);
5161  break;
5162  case T_TableFunc:
5163  retval = _copyTableFunc(from);
5164  break;
5165  case T_IntoClause:
5166  retval = _copyIntoClause(from);
5167  break;
5168  case T_Var:
5169  retval = _copyVar(from);
5170  break;
5171  case T_Const:
5172  retval = _copyConst(from);
5173  break;
5174  case T_Param:
5175  retval = _copyParam(from);
5176  break;
5177  case T_Aggref:
5178  retval = _copyAggref(from);
5179  break;
5180  case T_GroupingFunc:
5181  retval = _copyGroupingFunc(from);
5182  break;
5183  case T_WindowFunc:
5184  retval = _copyWindowFunc(from);
5185  break;
5186  case T_SubscriptingRef:
5187  retval = _copySubscriptingRef(from);
5188  break;
5189  case T_FuncExpr:
5190  retval = _copyFuncExpr(from);
5191  break;
5192  case T_NamedArgExpr:
5193  retval = _copyNamedArgExpr(from);
5194  break;
5195  case T_OpExpr:
5196  retval = _copyOpExpr(from);
5197  break;
5198  case T_DistinctExpr:
5199  retval = _copyDistinctExpr(from);
5200  break;
5201  case T_NullIfExpr:
5202  retval = _copyNullIfExpr(from);
5203  break;
5204  case T_ScalarArrayOpExpr:
5205  retval = _copyScalarArrayOpExpr(from);
5206  break;
5207  case T_BoolExpr:
5208  retval = _copyBoolExpr(from);
5209  break;
5210  case T_SubLink:
5211  retval = _copySubLink(from);
5212  break;
5213  case T_SubPlan:
5214  retval = _copySubPlan(from);
5215  break;
5216  case T_AlternativeSubPlan:
5217  retval = _copyAlternativeSubPlan(from);
5218  break;
5219  case T_FieldSelect:
5220  retval = _copyFieldSelect(from);
5221  break;
5222  case T_FieldStore:
5223  retval = _copyFieldStore(from);
5224  break;
5225  case T_RelabelType:
5226  retval = _copyRelabelType(from);
5227  break;
5228  case T_CoerceViaIO:
5229  retval = _copyCoerceViaIO(from);
5230  break;
5231  case T_ArrayCoerceExpr:
5232  retval = _copyArrayCoerceExpr(from);
5233  break;
5234  case T_ConvertRowtypeExpr:
5235  retval = _copyConvertRowtypeExpr(from);
5236  break;
5237  case T_CollateExpr:
5238  retval = _copyCollateExpr(from);
5239  break;
5240  case T_CaseExpr:
5241  retval = _copyCaseExpr(from);
5242  break;
5243  case T_CaseWhen:
5244  retval = _copyCaseWhen(from);
5245  break;
5246  case T_CaseTestExpr:
5247  retval = _copyCaseTestExpr(from);
5248  break;
5249  case T_ArrayExpr:
5250  retval = _copyArrayExpr(from);
5251  break;
5252  case T_RowExpr:
5253  retval = _copyRowExpr(from);
5254  break;
5255  case T_RowCompareExpr:
5256  retval = _copyRowCompareExpr(from);
5257  break;
5258  case T_CoalesceExpr:
5259  retval = _copyCoalesceExpr(from);
5260  break;
5261  case T_MinMaxExpr:
5262  retval = _copyMinMaxExpr(from);
5263  break;
5264  case T_SQLValueFunction:
5265  retval = _copySQLValueFunction(from);
5266  break;
5267  case T_XmlExpr:
5268  retval = _copyXmlExpr(from);
5269  break;
5270  case T_NullTest:
5271  retval = _copyNullTest(from);
5272  break;
5273  case T_BooleanTest:
5274  retval = _copyBooleanTest(from);
5275  break;
5276  case T_CoerceToDomain:
5277  retval = _copyCoerceToDomain(from);
5278  break;
5279  case T_CoerceToDomainValue:
5280  retval = _copyCoerceToDomainValue(from);
5281  break;
5282  case T_SetToDefault:
5283  retval = _copySetToDefault(from);
5284  break;
5285  case T_CurrentOfExpr:
5286  retval = _copyCurrentOfExpr(from);
5287  break;
5288  case T_NextValueExpr:
5289  retval = _copyNextValueExpr(from);
5290  break;
5291  case T_InferenceElem:
5292  retval = _copyInferenceElem(from);
5293  break;
5294  case T_TargetEntry:
5295  retval = _copyTargetEntry(from);
5296  break;
5297  case T_RangeTblRef:
5298  retval = _copyRangeTblRef(from);
5299  break;
5300  case T_JoinExpr:
5301  retval = _copyJoinExpr(from);
5302  break;
5303  case T_FromExpr:
5304  retval = _copyFromExpr(from);
5305  break;
5306  case T_OnConflictExpr:
5307  retval = _copyOnConflictExpr(from);
5308  break;
5309 
5310  /*
5311  * RELATION NODES
5312  */
5313  case T_PathKey:
5314  retval = _copyPathKey(from);
5315  break;
5316  case T_RestrictInfo:
5317  retval = _copyRestrictInfo(from);
5318  break;
5319  case T_PlaceHolderVar:
5320  retval = _copyPlaceHolderVar(from);
5321  break;
5322  case T_SpecialJoinInfo:
5323  retval = _copySpecialJoinInfo(from);
5324  break;
5325  case T_AppendRelInfo:
5326  retval = _copyAppendRelInfo(from);
5327  break;
5328  case T_PlaceHolderInfo:
5329  retval = _copyPlaceHolderInfo(from);
5330  break;
5331 
5332  /*
5333  * VALUE NODES
5334  */
5335  case T_Integer:
5336  retval = _copyInteger(from);
5337  break;
5338  case T_Float:
5339  retval = _copyFloat(from);
5340  break;
5341  case T_String:
5342  retval = _copyString(from);
5343  break;
5344  case T_BitString:
5345  retval = _copyBitString(from);
5346  break;
5347 
5348  /*
5349  * LIST NODES
5350  */
5351  case T_List:
5352  retval = list_copy_deep(from);
5353  break;
5354 
5355  /*
5356  * Lists of integers and OIDs don't need to be deep-copied, so we
5357  * perform a shallow copy via list_copy()
5358  */
5359  case T_IntList:
5360  case T_OidList:
5361  retval = list_copy(from);
5362  break;
5363 
5364  /*
5365  * EXTENSIBLE NODES
5366  */
5367  case T_ExtensibleNode:
5368  retval = _copyExtensibleNode(from);
5369  break;
5370 
5371  /*
5372  * PARSE NODES
5373  */
5374  case T_Query:
5375  retval = _copyQuery(from);
5376  break;
5377  case T_RawStmt:
5378  retval = _copyRawStmt(from);
5379  break;
5380  case T_InsertStmt:
5381  retval = _copyInsertStmt(from);
5382  break;
5383  case T_DeleteStmt:
5384  retval = _copyDeleteStmt(from);
5385  break;
5386  case T_UpdateStmt:
5387  retval = _copyUpdateStmt(from);
5388  break;
5389  case T_SelectStmt:
5390  retval = _copySelectStmt(from);
5391  break;
5392  case T_SetOperationStmt:
5393  retval = _copySetOperationStmt(from);
5394  break;
5395  case T_ReturnStmt:
5396  retval = _copyReturnStmt(from);
5397  break;
5398  case T_PLAssignStmt:
5399  retval = _copyPLAssignStmt(from);
5400  break;
5401  case T_AlterTableStmt:
5402  retval = _copyAlterTableStmt(from);
5403  break;
5404  case T_AlterTableCmd:
5405  retval = _copyAlterTableCmd(from);
5406  break;
5407  case T_AlterCollationStmt:
5408  retval = _copyAlterCollationStmt(from);
5409  break;
5410  case T_AlterDomainStmt:
5411  retval = _copyAlterDomainStmt(from);
5412  break;
5413  case T_GrantStmt:
5414  retval = _copyGrantStmt(from);
5415  break;
5416  case T_GrantRoleStmt:
5417  retval = _copyGrantRoleStmt(from);
5418  break;
5420  retval = _copyAlterDefaultPrivilegesStmt(from);
5421  break;
5422  case T_DeclareCursorStmt:
5423  retval = _copyDeclareCursorStmt(from);
5424  break;
5425  case T_ClosePortalStmt:
5426  retval = _copyClosePortalStmt(from);
5427  break;
5428  case T_CallStmt:
5429  retval = _copyCallStmt(from);
5430  break;
5431  case T_ClusterStmt:
5432  retval = _copyClusterStmt(from);
5433  break;
5434  case T_CopyStmt:
5435  retval = _copyCopyStmt(from);
5436  break;
5437  case T_CreateStmt:
5438  retval = _copyCreateStmt(from);
5439  break;
5440  case T_TableLikeClause:
5441  retval = _copyTableLikeClause(from);
5442  break;
5443  case T_DefineStmt:
5444  retval = _copyDefineStmt(from);
5445  break;
5446  case T_DropStmt:
5447  retval = _copyDropStmt(from);
5448  break;
5449  case T_TruncateStmt:
5450  retval = _copyTruncateStmt(from);
5451  break;
5452  case T_CommentStmt:
5453  retval = _copyCommentStmt(from);
5454  break;
5455  case T_SecLabelStmt:
5456  retval = _copySecLabelStmt(from);
5457  break;
5458  case T_FetchStmt:
5459  retval = _copyFetchStmt(from);
5460  break;
5461  case T_IndexStmt:
5462  retval = _copyIndexStmt(from);
5463  break;
5464  case T_CreateStatsStmt:
5465  retval = _copyCreateStatsStmt(from);
5466  break;
5467  case T_AlterStatsStmt:
5468  retval = _copyAlterStatsStmt(from);
5469  break;
5470  case T_CreateFunctionStmt:
5471  retval = _copyCreateFunctionStmt(from);
5472  break;
5473  case T_FunctionParameter:
5474  retval = _copyFunctionParameter(from);
5475  break;
5476  case T_AlterFunctionStmt:
5477  retval = _copyAlterFunctionStmt(from);
5478  break;
5479  case T_DoStmt:
5480  retval = _copyDoStmt(from);
5481  break;
5482  case T_RenameStmt:
5483  retval = _copyRenameStmt(from);
5484  break;
5486  retval = _copyAlterObjectDependsStmt(from);
5487  break;
5489  retval = _copyAlterObjectSchemaStmt(from);
5490  break;
5491  case T_AlterOwnerStmt:
5492  retval = _copyAlterOwnerStmt(from);
5493  break;
5494  case T_AlterOperatorStmt:
5495  retval = _copyAlterOperatorStmt(from);
5496  break;
5497  case T_AlterTypeStmt:
5498  retval = _copyAlterTypeStmt(from);
5499  break;
5500  case T_RuleStmt:
5501  retval = _copyRuleStmt(from);
5502  break;
5503  case T_NotifyStmt:
5504  retval = _copyNotifyStmt(from);
5505  break;
5506  case T_ListenStmt:
5507  retval = _copyListenStmt(from);
5508  break;
5509  case T_UnlistenStmt:
5510  retval = _copyUnlistenStmt(from);
5511  break;
5512  case T_TransactionStmt:
5513  retval = _copyTransactionStmt(from);
5514  break;
5515  case T_CompositeTypeStmt:
5516  retval = _copyCompositeTypeStmt(from);
5517  break;
5518  case T_CreateEnumStmt:
5519  retval = _copyCreateEnumStmt(from);
5520  break;
5521  case T_CreateRangeStmt:
5522  retval = _copyCreateRangeStmt(from);
5523  break;
5524  case T_AlterEnumStmt:
5525  retval = _copyAlterEnumStmt(from);
5526  break;
5527  case T_ViewStmt:
5528  retval = _copyViewStmt(from);
5529  break;
5530  case T_LoadStmt:
5531  retval = _copyLoadStmt(from);
5532  break;
5533  case T_CreateDomainStmt:
5534  retval = _copyCreateDomainStmt(from);
5535  break;
5536  case T_CreateOpClassStmt:
5537  retval = _copyCreateOpClassStmt(from);
5538  break;
5539  case T_CreateOpClassItem:
5540  retval = _copyCreateOpClassItem(from);
5541  break;
5542  case T_CreateOpFamilyStmt:
5543  retval = _copyCreateOpFamilyStmt(from);
5544  break;
5545  case T_AlterOpFamilyStmt:
5546  retval = _copyAlterOpFamilyStmt(from);
5547  break;
5548  case T_CreatedbStmt:
5549  retval = _copyCreatedbStmt(from);
5550  break;
5551  case T_AlterDatabaseStmt:
5552  retval = _copyAlterDatabaseStmt(from);
5553  break;
5555  retval = _copyAlterDatabaseSetStmt(from);
5556  break;
5557  case T_DropdbStmt:
5558  retval = _copyDropdbStmt(from);
5559  break;
5560  case T_VacuumStmt:
5561  retval = _copyVacuumStmt(from);
5562  break;
5563  case T_VacuumRelation:
5564  retval = _copyVacuumRelation(from);
5565  break;
5566  case T_ExplainStmt:
5567  retval = _copyExplainStmt(from);
5568  break;
5569  case T_CreateTableAsStmt:
5570  retval = _copyCreateTableAsStmt(from);
5571  break;
5572  case T_RefreshMatViewStmt:
5573  retval = _copyRefreshMatViewStmt(from);
5574  break;
5575  case T_ReplicaIdentityStmt:
5576  retval = _copyReplicaIdentityStmt(from);
5577  break;
5578  case T_AlterSystemStmt:
5579  retval = _copyAlterSystemStmt(from);
5580  break;
5581  case T_CreateSeqStmt:
5582  retval = _copyCreateSeqStmt(from);
5583  break;
5584  case T_AlterSeqStmt:
5585  retval = _copyAlterSeqStmt(from);
5586  break;
5587  case T_VariableSetStmt:
5588  retval = _copyVariableSetStmt(from);
5589  break;
5590  case T_VariableShowStmt:
5591  retval = _copyVariableShowStmt(from);
5592  break;
5593  case T_DiscardStmt:
5594  retval = _copyDiscardStmt(from);
5595  break;
5597  retval = _copyCreateTableSpaceStmt(from);
5598  break;
5599  case T_DropTableSpaceStmt:
5600  retval = _copyDropTableSpaceStmt(from);
5601  break;
5603  retval = _copyAlterTableSpaceOptionsStmt(from);
5604  break;
5606  retval = _copyAlterTableMoveAllStmt(from);
5607  break;
5608  case T_CreateExtensionStmt:
5609  retval = _copyCreateExtensionStmt(from);
5610  break;
5611  case T_AlterExtensionStmt:
5612  retval = _copyAlterExtensionStmt(from);
5613  break;
5615  retval = _copyAlterExtensionContentsStmt(from);
5616  break;
5617  case T_CreateFdwStmt:
5618  retval = _copyCreateFdwStmt(from);
5619  break;
5620  case T_AlterFdwStmt:
5621  retval = _copyAlterFdwStmt(from);
5622  break;
5624  retval = _copyCreateForeignServerStmt(from);
5625  break;
5627  retval = _copyAlterForeignServerStmt(from);
5628  break;
5630  retval = _copyCreateUserMappingStmt(from);
5631  break;
5633  retval = _copyAlterUserMappingStmt(from);
5634  break;
5635  case T_DropUserMappingStmt:
5636  retval = _copyDropUserMappingStmt(from);
5637  break;
5639  retval = _copyCreateForeignTableStmt(from);
5640  break;
5642  retval = _copyImportForeignSchemaStmt(from);
5643  break;
5644  case T_CreateTransformStmt:
5645  retval = _copyCreateTransformStmt(from);
5646  break;
5647  case T_CreateAmStmt:
5648  retval = _copyCreateAmStmt(from);
5649  break;
5650  case T_CreateTrigStmt:
5651  retval = _copyCreateTrigStmt(from);
5652  break;
5653  case T_CreateEventTrigStmt:
5654  retval = _copyCreateEventTrigStmt(from);
5655  break;
5656  case T_AlterEventTrigStmt:
5657  retval = _copyAlterEventTrigStmt(from);
5658  break;
5659  case T_CreatePLangStmt:
5660  retval = _copyCreatePLangStmt(from);
5661  break;
5662  case T_CreateRoleStmt:
5663  retval = _copyCreateRoleStmt(from);
5664  break;
5665  case T_AlterRoleStmt:
5666  retval = _copyAlterRoleStmt(from);
5667  break;
5668  case T_AlterRoleSetStmt:
5669  retval = _copyAlterRoleSetStmt(from);
5670  break;
5671  case T_DropRoleStmt:
5672  retval = _copyDropRoleStmt(from);
5673  break;
5674  case T_LockStmt:
5675  retval = _copyLockStmt(from);
5676  break;
5677  case T_ConstraintsSetStmt:
5678  retval = _copyConstraintsSetStmt(from);
5679  break;
5680  case T_ReindexStmt:
5681  retval = _copyReindexStmt(from);
5682  break;
5683  case T_CheckPointStmt:
5684  retval = (void *) makeNode(CheckPointStmt);
5685  break;
5686  case T_CreateSchemaStmt:
5687  retval = _copyCreateSchemaStmt(from);
5688  break;
5690  retval = _copyCreateConversionStmt(from);
5691  break;
5692  case T_CreateCastStmt:
5693  retval = _copyCreateCastStmt(from);
5694  break;
5695  case T_PrepareStmt:
5696  retval = _copyPrepareStmt(from);
5697  break;
5698  case T_ExecuteStmt:
5699  retval = _copyExecuteStmt(from);
5700  break;
5701  case T_DeallocateStmt:
5702  retval = _copyDeallocateStmt(from);
5703  break;
5704  case T_DropOwnedStmt:
5705  retval = _copyDropOwnedStmt(from);
5706  break;
5707  case T_ReassignOwnedStmt:
5708  retval = _copyReassignOwnedStmt(from);
5709  break;
5711  retval = _copyAlterTSDictionaryStmt(from);
5712  break;
5714  retval = _copyAlterTSConfigurationStmt(from);
5715  break;
5716  case T_CreatePolicyStmt:
5717  retval = _copyCreatePolicyStmt(from);
5718  break;
5719  case T_AlterPolicyStmt:
5720  retval = _copyAlterPolicyStmt(from);
5721  break;
5723  retval = _copyCreatePublicationStmt(from);
5724  break;
5726  retval = _copyAlterPublicationStmt(from);
5727  break;
5729  retval = _copyCreateSubscriptionStmt(from);
5730  break;
5732  retval = _copyAlterSubscriptionStmt(from);
5733  break;
5735  retval = _copyDropSubscriptionStmt(from);
5736  break;
5737  case T_A_Expr:
5738  retval = _copyA_Expr(from);
5739  break;
5740  case T_ColumnRef:
5741  retval = _copyColumnRef(from);
5742  break;
5743  case T_ParamRef:
5744  retval = _copyParamRef(from);
5745  break;
5746  case T_A_Const:
5747  retval = _copyA_Const(from);
5748  break;
5749  case T_FuncCall:
5750  retval = _copyFuncCall(from);
5751  break;
5752  case T_A_Star:
5753  retval = _copyA_Star(from);
5754  break;
5755  case T_A_Indices:
5756  retval = _copyA_Indices(from);
5757  break;
5758  case T_A_Indirection:
5759  retval = _copyA_Indirection(from);
5760  break;
5761  case T_A_ArrayExpr:
5762  retval = _copyA_ArrayExpr(from);
5763  break;
5764  case T_ResTarget:
5765  retval = _copyResTarget(from);
5766  break;
5767  case T_MultiAssignRef:
5768  retval = _copyMultiAssignRef(from);
5769  break;
5770  case T_TypeCast:
5771  retval = _copyTypeCast(from);
5772  break;
5773  case T_CollateClause:
5774  retval = _copyCollateClause(from);
5775  break;
5776  case T_SortBy:
5777  retval = _copySortBy(from);
5778  break;
5779  case T_WindowDef:
5780  retval = _copyWindowDef(from);
5781  break;
5782  case T_RangeSubselect:
5783  retval = _copyRangeSubselect(from);
5784  break;
5785  case T_RangeFunction:
5786  retval = _copyRangeFunction(from);
5787  break;
5788  case T_RangeTableSample:
5789  retval = _copyRangeTableSample(from);
5790  break;
5791  case T_RangeTableFunc:
5792  retval = _copyRangeTableFunc(from);
5793  break;
5794  case T_RangeTableFuncCol:
5795  retval = _copyRangeTableFuncCol(from);
5796  break;
5797  case T_TypeName:
5798  retval = _copyTypeName(from);
5799  break;
5800  case T_IndexElem:
5801  retval = _copyIndexElem(from);
5802  break;
5803  case T_StatsElem:
5804  retval = _copyStatsElem(from);
5805  break;
5806  case T_ColumnDef:
5807  retval = _copyColumnDef(from);
5808  break;
5809  case T_Constraint:
5810  retval = _copyConstraint(from);
5811  break;
5812  case T_DefElem:
5813  retval = _copyDefElem(from);
5814  break;
5815  case T_LockingClause:
5816  retval = _copyLockingClause(from);
5817  break;
5818  case T_RangeTblEntry:
5819  retval = _copyRangeTblEntry(from);
5820  break;
5821  case T_RangeTblFunction:
5822  retval = _copyRangeTblFunction(from);
5823  break;
5824  case T_TableSampleClause:
5825  retval = _copyTableSampleClause(from);
5826  break;
5827  case T_WithCheckOption:
5828  retval = _copyWithCheckOption(from);
5829  break;
5830  case T_SortGroupClause:
5831  retval = _copySortGroupClause(from);
5832  break;
5833  case T_GroupingSet:
5834  retval = _copyGroupingSet(from);
5835  break;
5836  case T_WindowClause:
5837  retval = _copyWindowClause(from);
5838  break;
5839  case T_RowMarkClause:
5840  retval = _copyRowMarkClause(from);
5841  break;
5842  case T_WithClause:
5843  retval = _copyWithClause(from);
5844  break;
5845  case T_InferClause:
5846  retval = _copyInferClause(from);
5847  break;
5848  case T_OnConflictClause:
5849  retval = _copyOnConflictClause(from);
5850  break;
5851  case T_CTESearchClause:
5852  retval = _copyCTESearchClause(from);
5853  break;
5854  case T_CTECycleClause:
5855  retval = _copyCTECycleClause(from);
5856  break;
5857  case T_CommonTableExpr:
5858  retval = _copyCommonTableExpr(from);
5859  break;
5860  case T_ObjectWithArgs:
5861  retval = _copyObjectWithArgs(from);
5862  break;
5863  case T_AccessPriv:
5864  retval = _copyAccessPriv(from);
5865  break;
5866  case T_XmlSerialize:
5867  retval = _copyXmlSerialize(from);
5868  break;
5869  case T_RoleSpec:
5870  retval = _copyRoleSpec(from);
5871  break;
5872  case T_TriggerTransition:
5873  retval = _copyTriggerTransition(from);
5874  break;
5875  case T_PartitionElem:
5876  retval = _copyPartitionElem(from);
5877  break;
5878  case T_PartitionSpec:
5879  retval = _copyPartitionSpec(from);
5880  break;
5881  case T_PartitionBoundSpec:
5882  retval = _copyPartitionBoundSpec(from);
5883  break;
5884  case T_PartitionRangeDatum:
5885  retval = _copyPartitionRangeDatum(from);
5886  break;
5887  case T_PartitionCmd:
5888  retval = _copyPartitionCmd(from);
5889  break;
5890  case T_PublicationTable:
5891  retval = _copyPublicationTable(from);
5892  break;
5893 
5894  /*
5895  * MISCELLANEOUS NODES
5896  */
5897  case T_ForeignKeyCacheInfo:
5898  retval = _copyForeignKeyCacheInfo(from);
5899  break;
5900 
5901  default:
5902  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
5903  retval = 0; /* keep compiler quiet */
5904  break;
5905  }
5906 
5907  return retval;
5908 }
static Integer * _copyInteger(const Integer *from)
Definition: copyfuncs.c:4905
Datum constvalue
Definition: primnodes.h:219
static PartitionPruneStepOp * _copyPartitionPruneStepOp(const PartitionPruneStepOp *from)
Definition: copyfuncs.c:1305
static Limit * _copyLimit(const Limit *from)
Definition: copyfuncs.c:1215
#define COPY_BITMAPSET_FIELD(fldname)
Definition: copyfuncs.c:49
static WindowClause * _copyWindowClause(const WindowClause *from)
Definition: copyfuncs.c:2567
static CreateEnumStmt * _copyCreateEnumStmt(const CreateEnumStmt *from)
Definition: copyfuncs.c:3903
static RefreshMatViewStmt * _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
Definition: copyfuncs.c:4126
static RangeSubselect * _copyRangeSubselect(const RangeSubselect *from)
Definition: copyfuncs.c:2903
static AlterSystemStmt * _copyAlterSystemStmt(const AlterSystemStmt *from)
Definition: copyfuncs.c:4149
static DeallocateStmt * _copyDeallocateStmt(const DeallocateStmt *from)
Definition: copyfuncs.c:4658
#define NIL
Definition: pg_list.h:65
static PlanInvalItem * _copyPlanInvalItem(const PlanInvalItem *from)
Definition: copyfuncs.c:1337
static Scan * _copyScan(const Scan *from)
Definition: copyfuncs.c:428
static AlterEventTrigStmt * _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
Definition: copyfuncs.c:4485
static PgChecksumMode mode
Definition: pg_checksums.c:65
static SeqScan * _copySeqScan(const SeqScan *from)
Definition: copyfuncs.c:444
static AlterTableMoveAllStmt * _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
Definition: copyfuncs.c:4255
static DiscardStmt * _copyDiscardStmt(const DiscardStmt *from)
Definition: copyfuncs.c:4209
static DeleteStmt * _copyDeleteStmt(const DeleteStmt *from)
Definition: copyfuncs.c:3231
static Unique * _copyUnique(const Unique *from)
Definition: copyfuncs.c:1115
Datum boolop(PG_FUNCTION_ARGS)
Definition: _int_bool.c:419
static Memoize * _copyMemoize(const Memoize *from)
Definition: copyfuncs.c:957