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