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