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