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_names);
1226  COPY_NODE_FIELD(ns_uris);
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 
2189  return newnode;
2190 }
2191 
2192 /*
2193  * _copyPlaceHolderVar
2194  */
2195 static PlaceHolderVar *
2197 {
2199 
2200  COPY_NODE_FIELD(phexpr);
2201  COPY_BITMAPSET_FIELD(phrels);
2202  COPY_SCALAR_FIELD(phid);
2203  COPY_SCALAR_FIELD(phlevelsup);
2204 
2205  return newnode;
2206 }
2207 
2208 /*
2209  * _copySpecialJoinInfo
2210  */
2211 static SpecialJoinInfo *
2213 {
2215 
2216  COPY_BITMAPSET_FIELD(min_lefthand);
2217  COPY_BITMAPSET_FIELD(min_righthand);
2218  COPY_BITMAPSET_FIELD(syn_lefthand);
2219  COPY_BITMAPSET_FIELD(syn_righthand);
2220  COPY_SCALAR_FIELD(jointype);
2221  COPY_SCALAR_FIELD(lhs_strict);
2222  COPY_SCALAR_FIELD(delay_upper_joins);
2223  COPY_SCALAR_FIELD(semi_can_btree);
2224  COPY_SCALAR_FIELD(semi_can_hash);
2225  COPY_NODE_FIELD(semi_operators);
2226  COPY_NODE_FIELD(semi_rhs_exprs);
2227 
2228  return newnode;
2229 }
2230 
2231 /*
2232  * _copyAppendRelInfo
2233  */
2234 static AppendRelInfo *
2236 {
2237  AppendRelInfo *newnode = makeNode(AppendRelInfo);
2238 
2239  COPY_SCALAR_FIELD(parent_relid);
2240  COPY_SCALAR_FIELD(child_relid);
2241  COPY_SCALAR_FIELD(parent_reltype);
2242  COPY_SCALAR_FIELD(child_reltype);
2243  COPY_NODE_FIELD(translated_vars);
2244  COPY_SCALAR_FIELD(parent_reloid);
2245 
2246  return newnode;
2247 }
2248 
2249 /*
2250  * _copyPartitionedChildRelInfo
2251  */
2252 static PartitionedChildRelInfo *
2254 {
2256 
2257  COPY_SCALAR_FIELD(parent_relid);
2258  COPY_NODE_FIELD(child_rels);
2259 
2260  return newnode;
2261 }
2262 
2263 /*
2264  * _copyPlaceHolderInfo
2265  */
2266 static PlaceHolderInfo *
2268 {
2270 
2271  COPY_SCALAR_FIELD(phid);
2272  COPY_NODE_FIELD(ph_var);
2273  COPY_BITMAPSET_FIELD(ph_eval_at);
2274  COPY_BITMAPSET_FIELD(ph_lateral);
2275  COPY_BITMAPSET_FIELD(ph_needed);
2276  COPY_SCALAR_FIELD(ph_width);
2277 
2278  return newnode;
2279 }
2280 
2281 /* ****************************************************************
2282  * parsenodes.h copy functions
2283  * ****************************************************************
2284  */
2285 
2286 static RangeTblEntry *
2288 {
2289  RangeTblEntry *newnode = makeNode(RangeTblEntry);
2290 
2291  COPY_SCALAR_FIELD(rtekind);
2292  COPY_SCALAR_FIELD(relid);
2293  COPY_SCALAR_FIELD(relkind);
2294  COPY_NODE_FIELD(tablesample);
2295  COPY_NODE_FIELD(subquery);
2296  COPY_SCALAR_FIELD(security_barrier);
2297  COPY_SCALAR_FIELD(jointype);
2298  COPY_NODE_FIELD(joinaliasvars);
2300  COPY_SCALAR_FIELD(funcordinality);
2301  COPY_NODE_FIELD(tablefunc);
2302  COPY_NODE_FIELD(values_lists);
2303  COPY_STRING_FIELD(ctename);
2304  COPY_SCALAR_FIELD(ctelevelsup);
2305  COPY_SCALAR_FIELD(self_reference);
2306  COPY_STRING_FIELD(enrname);
2307  COPY_NODE_FIELD(coltypes);
2308  COPY_NODE_FIELD(coltypmods);
2309  COPY_NODE_FIELD(colcollations);
2310  COPY_NODE_FIELD(alias);
2311  COPY_NODE_FIELD(eref);
2312  COPY_SCALAR_FIELD(lateral);
2313  COPY_SCALAR_FIELD(inh);
2314  COPY_SCALAR_FIELD(inFromCl);
2315  COPY_SCALAR_FIELD(requiredPerms);
2316  COPY_SCALAR_FIELD(checkAsUser);
2317  COPY_BITMAPSET_FIELD(selectedCols);
2318  COPY_BITMAPSET_FIELD(insertedCols);
2319  COPY_BITMAPSET_FIELD(updatedCols);
2320  COPY_NODE_FIELD(securityQuals);
2321 
2322  return newnode;
2323 }
2324 
2325 static RangeTblFunction *
2327 {
2329 
2330  COPY_NODE_FIELD(funcexpr);
2331  COPY_SCALAR_FIELD(funccolcount);
2332  COPY_NODE_FIELD(funccolnames);
2333  COPY_NODE_FIELD(funccoltypes);
2334  COPY_NODE_FIELD(funccoltypmods);
2335  COPY_NODE_FIELD(funccolcollations);
2336  COPY_BITMAPSET_FIELD(funcparams);
2337 
2338  return newnode;
2339 }
2340 
2341 static TableSampleClause *
2343 {
2345 
2346  COPY_SCALAR_FIELD(tsmhandler);
2348  COPY_NODE_FIELD(repeatable);
2349 
2350  return newnode;
2351 }
2352 
2353 static WithCheckOption *
2355 {
2357 
2358  COPY_SCALAR_FIELD(kind);
2359  COPY_STRING_FIELD(relname);
2360  COPY_STRING_FIELD(polname);
2361  COPY_NODE_FIELD(qual);
2362  COPY_SCALAR_FIELD(cascaded);
2363 
2364  return newnode;
2365 }
2366 
2367 static SortGroupClause *
2369 {
2371 
2372  COPY_SCALAR_FIELD(tleSortGroupRef);
2373  COPY_SCALAR_FIELD(eqop);
2374  COPY_SCALAR_FIELD(sortop);
2375  COPY_SCALAR_FIELD(nulls_first);
2376  COPY_SCALAR_FIELD(hashable);
2377 
2378  return newnode;
2379 }
2380 
2381 static GroupingSet *
2383 {
2384  GroupingSet *newnode = makeNode(GroupingSet);
2385 
2386  COPY_SCALAR_FIELD(kind);
2387  COPY_NODE_FIELD(content);
2388  COPY_LOCATION_FIELD(location);
2389 
2390  return newnode;
2391 }
2392 
2393 static WindowClause *
2395 {
2396  WindowClause *newnode = makeNode(WindowClause);
2397 
2399  COPY_STRING_FIELD(refname);
2400  COPY_NODE_FIELD(partitionClause);
2401  COPY_NODE_FIELD(orderClause);
2402  COPY_SCALAR_FIELD(frameOptions);
2403  COPY_NODE_FIELD(startOffset);
2404  COPY_NODE_FIELD(endOffset);
2405  COPY_SCALAR_FIELD(winref);
2406  COPY_SCALAR_FIELD(copiedOrder);
2407 
2408  return newnode;
2409 }
2410 
2411 static RowMarkClause *
2413 {
2414  RowMarkClause *newnode = makeNode(RowMarkClause);
2415 
2416  COPY_SCALAR_FIELD(rti);
2417  COPY_SCALAR_FIELD(strength);
2418  COPY_SCALAR_FIELD(waitPolicy);
2419  COPY_SCALAR_FIELD(pushedDown);
2420 
2421  return newnode;
2422 }
2423 
2424 static WithClause *
2426 {
2427  WithClause *newnode = makeNode(WithClause);
2428 
2429  COPY_NODE_FIELD(ctes);
2430  COPY_SCALAR_FIELD(recursive);
2431  COPY_LOCATION_FIELD(location);
2432 
2433  return newnode;
2434 }
2435 
2436 static InferClause *
2438 {
2439  InferClause *newnode = makeNode(InferClause);
2440 
2441  COPY_NODE_FIELD(indexElems);
2442  COPY_NODE_FIELD(whereClause);
2443  COPY_STRING_FIELD(conname);
2444  COPY_LOCATION_FIELD(location);
2445 
2446  return newnode;
2447 }
2448 
2449 static OnConflictClause *
2451 {
2453 
2454  COPY_SCALAR_FIELD(action);
2455  COPY_NODE_FIELD(infer);
2456  COPY_NODE_FIELD(targetList);
2457  COPY_NODE_FIELD(whereClause);
2458  COPY_LOCATION_FIELD(location);
2459 
2460  return newnode;
2461 }
2462 
2463 static CommonTableExpr *
2465 {
2467 
2468  COPY_STRING_FIELD(ctename);
2469  COPY_NODE_FIELD(aliascolnames);
2470  COPY_NODE_FIELD(ctequery);
2471  COPY_LOCATION_FIELD(location);
2472  COPY_SCALAR_FIELD(cterecursive);
2473  COPY_SCALAR_FIELD(cterefcount);
2474  COPY_NODE_FIELD(ctecolnames);
2475  COPY_NODE_FIELD(ctecoltypes);
2476  COPY_NODE_FIELD(ctecoltypmods);
2477  COPY_NODE_FIELD(ctecolcollations);
2478 
2479  return newnode;
2480 }
2481 
2482 static A_Expr *
2483 _copyAExpr(const A_Expr *from)
2484 {
2485  A_Expr *newnode = makeNode(A_Expr);
2486 
2487  COPY_SCALAR_FIELD(kind);
2489  COPY_NODE_FIELD(lexpr);
2490  COPY_NODE_FIELD(rexpr);
2491  COPY_LOCATION_FIELD(location);
2492 
2493  return newnode;
2494 }
2495 
2496 static ColumnRef *
2498 {
2499  ColumnRef *newnode = makeNode(ColumnRef);
2500 
2501  COPY_NODE_FIELD(fields);
2502  COPY_LOCATION_FIELD(location);
2503 
2504  return newnode;
2505 }
2506 
2507 static ParamRef *
2509 {
2510  ParamRef *newnode = makeNode(ParamRef);
2511 
2512  COPY_SCALAR_FIELD(number);
2513  COPY_LOCATION_FIELD(location);
2514 
2515  return newnode;
2516 }
2517 
2518 static A_Const *
2519 _copyAConst(const A_Const *from)
2520 {
2521  A_Const *newnode = makeNode(A_Const);
2522 
2523  /* This part must duplicate _copyValue */
2524  COPY_SCALAR_FIELD(val.type);
2525  switch (from->val.type)
2526  {
2527  case T_Integer:
2528  COPY_SCALAR_FIELD(val.val.ival);
2529  break;
2530  case T_Float:
2531  case T_String:
2532  case T_BitString:
2533  COPY_STRING_FIELD(val.val.str);
2534  break;
2535  case T_Null:
2536  /* nothing to do */
2537  break;
2538  default:
2539  elog(ERROR, "unrecognized node type: %d",
2540  (int) from->val.type);
2541  break;
2542  }
2543 
2544  COPY_LOCATION_FIELD(location);
2545 
2546  return newnode;
2547 }
2548 
2549 static FuncCall *
2551 {
2552  FuncCall *newnode = makeNode(FuncCall);
2553 
2554  COPY_NODE_FIELD(funcname);
2556  COPY_NODE_FIELD(agg_order);
2557  COPY_NODE_FIELD(agg_filter);
2558  COPY_SCALAR_FIELD(agg_within_group);
2559  COPY_SCALAR_FIELD(agg_star);
2560  COPY_SCALAR_FIELD(agg_distinct);
2561  COPY_SCALAR_FIELD(func_variadic);
2562  COPY_NODE_FIELD(over);
2563  COPY_LOCATION_FIELD(location);
2564 
2565  return newnode;
2566 }
2567 
2568 static A_Star *
2569 _copyAStar(const A_Star *from)
2570 {
2571  A_Star *newnode = makeNode(A_Star);
2572 
2573  return newnode;
2574 }
2575 
2576 static A_Indices *
2578 {
2579  A_Indices *newnode = makeNode(A_Indices);
2580 
2581  COPY_SCALAR_FIELD(is_slice);
2582  COPY_NODE_FIELD(lidx);
2583  COPY_NODE_FIELD(uidx);
2584 
2585  return newnode;
2586 }
2587 
2588 static A_Indirection *
2590 {
2591  A_Indirection *newnode = makeNode(A_Indirection);
2592 
2594  COPY_NODE_FIELD(indirection);
2595 
2596  return newnode;
2597 }
2598 
2599 static A_ArrayExpr *
2601 {
2602  A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
2603 
2604  COPY_NODE_FIELD(elements);
2605  COPY_LOCATION_FIELD(location);
2606 
2607  return newnode;
2608 }
2609 
2610 static ResTarget *
2612 {
2613  ResTarget *newnode = makeNode(ResTarget);
2614 
2616  COPY_NODE_FIELD(indirection);
2618  COPY_LOCATION_FIELD(location);
2619 
2620  return newnode;
2621 }
2622 
2623 static MultiAssignRef *
2625 {
2627 
2628  COPY_NODE_FIELD(source);
2629  COPY_SCALAR_FIELD(colno);
2630  COPY_SCALAR_FIELD(ncolumns);
2631 
2632  return newnode;
2633 }
2634 
2635 static TypeName *
2637 {
2638  TypeName *newnode = makeNode(TypeName);
2639 
2640  COPY_NODE_FIELD(names);
2641  COPY_SCALAR_FIELD(typeOid);
2642  COPY_SCALAR_FIELD(setof);
2643  COPY_SCALAR_FIELD(pct_type);
2644  COPY_NODE_FIELD(typmods);
2645  COPY_SCALAR_FIELD(typemod);
2646  COPY_NODE_FIELD(arrayBounds);
2647  COPY_LOCATION_FIELD(location);
2648 
2649  return newnode;
2650 }
2651 
2652 static SortBy *
2653 _copySortBy(const SortBy *from)
2654 {
2655  SortBy *newnode = makeNode(SortBy);
2656 
2657  COPY_NODE_FIELD(node);
2658  COPY_SCALAR_FIELD(sortby_dir);
2659  COPY_SCALAR_FIELD(sortby_nulls);
2660  COPY_NODE_FIELD(useOp);
2661  COPY_LOCATION_FIELD(location);
2662 
2663  return newnode;
2664 }
2665 
2666 static WindowDef *
2668 {
2669  WindowDef *newnode = makeNode(WindowDef);
2670 
2672  COPY_STRING_FIELD(refname);
2673  COPY_NODE_FIELD(partitionClause);
2674  COPY_NODE_FIELD(orderClause);
2675  COPY_SCALAR_FIELD(frameOptions);
2676  COPY_NODE_FIELD(startOffset);
2677  COPY_NODE_FIELD(endOffset);
2678  COPY_LOCATION_FIELD(location);
2679 
2680  return newnode;
2681 }
2682 
2683 static RangeSubselect *
2685 {
2687 
2688  COPY_SCALAR_FIELD(lateral);
2689  COPY_NODE_FIELD(subquery);
2690  COPY_NODE_FIELD(alias);
2691 
2692  return newnode;
2693 }
2694 
2695 static RangeFunction *
2697 {
2698  RangeFunction *newnode = makeNode(RangeFunction);
2699 
2700  COPY_SCALAR_FIELD(lateral);
2701  COPY_SCALAR_FIELD(ordinality);
2702  COPY_SCALAR_FIELD(is_rowsfrom);
2704  COPY_NODE_FIELD(alias);
2705  COPY_NODE_FIELD(coldeflist);
2706 
2707  return newnode;
2708 }
2709 
2710 static RangeTableSample *
2712 {
2714 
2715  COPY_NODE_FIELD(relation);
2716  COPY_NODE_FIELD(method);
2718  COPY_NODE_FIELD(repeatable);
2719  COPY_LOCATION_FIELD(location);
2720 
2721  return newnode;
2722 }
2723 
2724 static RangeTableFunc *
2726 {
2728 
2729  COPY_SCALAR_FIELD(lateral);
2730  COPY_NODE_FIELD(docexpr);
2731  COPY_NODE_FIELD(rowexpr);
2732  COPY_NODE_FIELD(namespaces);
2733  COPY_NODE_FIELD(columns);
2734  COPY_NODE_FIELD(alias);
2735  COPY_LOCATION_FIELD(location);
2736 
2737  return newnode;
2738 }
2739 
2740 static RangeTableFuncCol *
2742 {
2744 
2745  COPY_STRING_FIELD(colname);
2746  COPY_NODE_FIELD(typeName);
2747  COPY_SCALAR_FIELD(for_ordinality);
2748  COPY_SCALAR_FIELD(is_not_null);
2749  COPY_NODE_FIELD(colexpr);
2750  COPY_NODE_FIELD(coldefexpr);
2751  COPY_LOCATION_FIELD(location);
2752 
2753  return newnode;
2754 }
2755 
2756 static TypeCast *
2758 {
2759  TypeCast *newnode = makeNode(TypeCast);
2760 
2762  COPY_NODE_FIELD(typeName);
2763  COPY_LOCATION_FIELD(location);
2764 
2765  return newnode;
2766 }
2767 
2768 static CollateClause *
2770 {
2771  CollateClause *newnode = makeNode(CollateClause);
2772 
2774  COPY_NODE_FIELD(collname);
2775  COPY_LOCATION_FIELD(location);
2776 
2777  return newnode;
2778 }
2779 
2780 static IndexElem *
2782 {
2783  IndexElem *newnode = makeNode(IndexElem);
2784 
2786  COPY_NODE_FIELD(expr);
2787  COPY_STRING_FIELD(indexcolname);
2788  COPY_NODE_FIELD(collation);
2789  COPY_NODE_FIELD(opclass);
2790  COPY_SCALAR_FIELD(ordering);
2791  COPY_SCALAR_FIELD(nulls_ordering);
2792 
2793  return newnode;
2794 }
2795 
2796 static ColumnDef *
2798 {
2799  ColumnDef *newnode = makeNode(ColumnDef);
2800 
2801  COPY_STRING_FIELD(colname);
2802  COPY_NODE_FIELD(typeName);
2803  COPY_SCALAR_FIELD(inhcount);
2804  COPY_SCALAR_FIELD(is_local);
2805  COPY_SCALAR_FIELD(is_not_null);
2806  COPY_SCALAR_FIELD(is_from_type);
2807  COPY_SCALAR_FIELD(is_from_parent);
2808  COPY_SCALAR_FIELD(storage);
2809  COPY_NODE_FIELD(raw_default);
2810  COPY_NODE_FIELD(cooked_default);
2811  COPY_SCALAR_FIELD(identity);
2812  COPY_NODE_FIELD(collClause);
2813  COPY_SCALAR_FIELD(collOid);
2814  COPY_NODE_FIELD(constraints);
2815  COPY_NODE_FIELD(fdwoptions);
2816  COPY_LOCATION_FIELD(location);
2817 
2818  return newnode;
2819 }
2820 
2821 static Constraint *
2823 {
2824  Constraint *newnode = makeNode(Constraint);
2825 
2826  COPY_SCALAR_FIELD(contype);
2827  COPY_STRING_FIELD(conname);
2828  COPY_SCALAR_FIELD(deferrable);
2829  COPY_SCALAR_FIELD(initdeferred);
2830  COPY_LOCATION_FIELD(location);
2831  COPY_SCALAR_FIELD(is_no_inherit);
2832  COPY_NODE_FIELD(raw_expr);
2833  COPY_STRING_FIELD(cooked_expr);
2834  COPY_SCALAR_FIELD(generated_when);
2835  COPY_NODE_FIELD(keys);
2836  COPY_NODE_FIELD(exclusions);
2838  COPY_STRING_FIELD(indexname);
2839  COPY_STRING_FIELD(indexspace);
2840  COPY_STRING_FIELD(access_method);
2841  COPY_NODE_FIELD(where_clause);
2842  COPY_NODE_FIELD(pktable);
2843  COPY_NODE_FIELD(fk_attrs);
2844  COPY_NODE_FIELD(pk_attrs);
2845  COPY_SCALAR_FIELD(fk_matchtype);
2846  COPY_SCALAR_FIELD(fk_upd_action);
2847  COPY_SCALAR_FIELD(fk_del_action);
2848  COPY_NODE_FIELD(old_conpfeqop);
2849  COPY_SCALAR_FIELD(old_pktable_oid);
2850  COPY_SCALAR_FIELD(skip_validation);
2851  COPY_SCALAR_FIELD(initially_valid);
2852 
2853  return newnode;
2854 }
2855 
2856 static DefElem *
2857 _copyDefElem(const DefElem *from)
2858 {
2859  DefElem *newnode = makeNode(DefElem);
2860 
2861  COPY_STRING_FIELD(defnamespace);
2862  COPY_STRING_FIELD(defname);
2864  COPY_SCALAR_FIELD(defaction);
2865  COPY_LOCATION_FIELD(location);
2866 
2867  return newnode;
2868 }
2869 
2870 static LockingClause *
2872 {
2873  LockingClause *newnode = makeNode(LockingClause);
2874 
2875  COPY_NODE_FIELD(lockedRels);
2876  COPY_SCALAR_FIELD(strength);
2877  COPY_SCALAR_FIELD(waitPolicy);
2878 
2879  return newnode;
2880 }
2881 
2882 static XmlSerialize *
2884 {
2885  XmlSerialize *newnode = makeNode(XmlSerialize);
2886 
2888  COPY_NODE_FIELD(expr);
2889  COPY_NODE_FIELD(typeName);
2890  COPY_LOCATION_FIELD(location);
2891 
2892  return newnode;
2893 }
2894 
2895 static RoleSpec *
2897 {
2898  RoleSpec *newnode = makeNode(RoleSpec);
2899 
2900  COPY_SCALAR_FIELD(roletype);
2901  COPY_STRING_FIELD(rolename);
2902  COPY_LOCATION_FIELD(location);
2903 
2904  return newnode;
2905 }
2906 
2907 static TriggerTransition *
2909 {
2911 
2913  COPY_SCALAR_FIELD(isNew);
2914  COPY_SCALAR_FIELD(isTable);
2915 
2916  return newnode;
2917 }
2918 
2919 static Query *
2920 _copyQuery(const Query *from)
2921 {
2922  Query *newnode = makeNode(Query);
2923 
2924  COPY_SCALAR_FIELD(commandType);
2925  COPY_SCALAR_FIELD(querySource);
2926  COPY_SCALAR_FIELD(queryId);
2927  COPY_SCALAR_FIELD(canSetTag);
2928  COPY_NODE_FIELD(utilityStmt);
2929  COPY_SCALAR_FIELD(resultRelation);
2930  COPY_SCALAR_FIELD(hasAggs);
2931  COPY_SCALAR_FIELD(hasWindowFuncs);
2932  COPY_SCALAR_FIELD(hasTargetSRFs);
2933  COPY_SCALAR_FIELD(hasSubLinks);
2934  COPY_SCALAR_FIELD(hasDistinctOn);
2935  COPY_SCALAR_FIELD(hasRecursive);
2936  COPY_SCALAR_FIELD(hasModifyingCTE);
2937  COPY_SCALAR_FIELD(hasForUpdate);
2938  COPY_SCALAR_FIELD(hasRowSecurity);
2939  COPY_NODE_FIELD(cteList);
2940  COPY_NODE_FIELD(rtable);
2941  COPY_NODE_FIELD(jointree);
2942  COPY_NODE_FIELD(targetList);
2943  COPY_SCALAR_FIELD(override);
2944  COPY_NODE_FIELD(onConflict);
2945  COPY_NODE_FIELD(returningList);
2946  COPY_NODE_FIELD(groupClause);
2947  COPY_NODE_FIELD(groupingSets);
2948  COPY_NODE_FIELD(havingQual);
2949  COPY_NODE_FIELD(windowClause);
2950  COPY_NODE_FIELD(distinctClause);
2951  COPY_NODE_FIELD(sortClause);
2952  COPY_NODE_FIELD(limitOffset);
2953  COPY_NODE_FIELD(limitCount);
2954  COPY_NODE_FIELD(rowMarks);
2955  COPY_NODE_FIELD(setOperations);
2956  COPY_NODE_FIELD(constraintDeps);
2957  COPY_NODE_FIELD(withCheckOptions);
2958  COPY_LOCATION_FIELD(stmt_location);
2959  COPY_LOCATION_FIELD(stmt_len);
2960 
2961  return newnode;
2962 }
2963 
2964 static RawStmt *
2965 _copyRawStmt(const RawStmt *from)
2966 {
2967  RawStmt *newnode = makeNode(RawStmt);
2968 
2969  COPY_NODE_FIELD(stmt);
2970  COPY_LOCATION_FIELD(stmt_location);
2971  COPY_LOCATION_FIELD(stmt_len);
2972 
2973  return newnode;
2974 }
2975 
2976 static InsertStmt *
2978 {
2979  InsertStmt *newnode = makeNode(InsertStmt);
2980 
2981  COPY_NODE_FIELD(relation);
2982  COPY_NODE_FIELD(cols);
2983  COPY_NODE_FIELD(selectStmt);
2984  COPY_NODE_FIELD(onConflictClause);
2985  COPY_NODE_FIELD(returningList);
2986  COPY_NODE_FIELD(withClause);
2987  COPY_SCALAR_FIELD(override);
2988 
2989  return newnode;
2990 }
2991 
2992 static DeleteStmt *
2994 {
2995  DeleteStmt *newnode = makeNode(DeleteStmt);
2996 
2997  COPY_NODE_FIELD(relation);
2998  COPY_NODE_FIELD(usingClause);
2999  COPY_NODE_FIELD(whereClause);
3000  COPY_NODE_FIELD(returningList);
3001  COPY_NODE_FIELD(withClause);
3002 
3003  return newnode;
3004 }
3005 
3006 static UpdateStmt *
3008 {
3009  UpdateStmt *newnode = makeNode(UpdateStmt);
3010 
3011  COPY_NODE_FIELD(relation);
3012  COPY_NODE_FIELD(targetList);
3013  COPY_NODE_FIELD(whereClause);
3014  COPY_NODE_FIELD(fromClause);
3015  COPY_NODE_FIELD(returningList);
3016  COPY_NODE_FIELD(withClause);
3017 
3018  return newnode;
3019 }
3020 
3021 static SelectStmt *
3023 {
3024  SelectStmt *newnode = makeNode(SelectStmt);
3025 
3026  COPY_NODE_FIELD(distinctClause);
3027  COPY_NODE_FIELD(intoClause);
3028  COPY_NODE_FIELD(targetList);
3029  COPY_NODE_FIELD(fromClause);
3030  COPY_NODE_FIELD(whereClause);
3031  COPY_NODE_FIELD(groupClause);
3032  COPY_NODE_FIELD(havingClause);
3033  COPY_NODE_FIELD(windowClause);
3034  COPY_NODE_FIELD(valuesLists);
3035  COPY_NODE_FIELD(sortClause);
3036  COPY_NODE_FIELD(limitOffset);
3037  COPY_NODE_FIELD(limitCount);
3038  COPY_NODE_FIELD(lockingClause);
3039  COPY_NODE_FIELD(withClause);
3040  COPY_SCALAR_FIELD(op);
3041  COPY_SCALAR_FIELD(all);
3042  COPY_NODE_FIELD(larg);
3043  COPY_NODE_FIELD(rarg);
3044 
3045  return newnode;
3046 }
3047 
3048 static SetOperationStmt *
3050 {
3052 
3053  COPY_SCALAR_FIELD(op);
3054  COPY_SCALAR_FIELD(all);
3055  COPY_NODE_FIELD(larg);
3056  COPY_NODE_FIELD(rarg);
3057  COPY_NODE_FIELD(colTypes);
3058  COPY_NODE_FIELD(colTypmods);
3059  COPY_NODE_FIELD(colCollations);
3060  COPY_NODE_FIELD(groupClauses);
3061 
3062  return newnode;
3063 }
3064 
3065 static AlterTableStmt *
3067 {
3069 
3070  COPY_NODE_FIELD(relation);
3071  COPY_NODE_FIELD(cmds);
3072  COPY_SCALAR_FIELD(relkind);
3073  COPY_SCALAR_FIELD(missing_ok);
3074 
3075  return newnode;
3076 }
3077 
3078 static AlterTableCmd *
3080 {
3081  AlterTableCmd *newnode = makeNode(AlterTableCmd);
3082 
3083  COPY_SCALAR_FIELD(subtype);
3085  COPY_NODE_FIELD(newowner);
3086  COPY_NODE_FIELD(def);
3087  COPY_SCALAR_FIELD(behavior);
3088  COPY_SCALAR_FIELD(missing_ok);
3089 
3090  return newnode;
3091 }
3092 
3093 static AlterCollationStmt *
3095 {
3097 
3098  COPY_NODE_FIELD(collname);
3099 
3100  return newnode;
3101 }
3102 
3103 static AlterDomainStmt *
3105 {
3107 
3108  COPY_SCALAR_FIELD(subtype);
3109  COPY_NODE_FIELD(typeName);
3111  COPY_NODE_FIELD(def);
3112  COPY_SCALAR_FIELD(behavior);
3113  COPY_SCALAR_FIELD(missing_ok);
3114 
3115  return newnode;
3116 }
3117 
3118 static GrantStmt *
3120 {
3121  GrantStmt *newnode = makeNode(GrantStmt);
3122 
3123  COPY_SCALAR_FIELD(is_grant);
3124  COPY_SCALAR_FIELD(targtype);
3125  COPY_SCALAR_FIELD(objtype);
3126  COPY_NODE_FIELD(objects);
3127  COPY_NODE_FIELD(privileges);
3128  COPY_NODE_FIELD(grantees);
3129  COPY_SCALAR_FIELD(grant_option);
3130  COPY_SCALAR_FIELD(behavior);
3131 
3132  return newnode;
3133 }
3134 
3135 static ObjectWithArgs *
3137 {
3139 
3140  COPY_NODE_FIELD(objname);
3141  COPY_NODE_FIELD(objargs);
3142  COPY_SCALAR_FIELD(args_unspecified);
3143 
3144  return newnode;
3145 }
3146 
3147 static AccessPriv *
3149 {
3150  AccessPriv *newnode = makeNode(AccessPriv);
3151 
3152  COPY_STRING_FIELD(priv_name);
3153  COPY_NODE_FIELD(cols);
3154 
3155  return newnode;
3156 }
3157 
3158 static GrantRoleStmt *
3160 {
3161  GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
3162 
3163  COPY_NODE_FIELD(granted_roles);
3164  COPY_NODE_FIELD(grantee_roles);
3165  COPY_SCALAR_FIELD(is_grant);
3166  COPY_SCALAR_FIELD(admin_opt);
3167  COPY_NODE_FIELD(grantor);
3168  COPY_SCALAR_FIELD(behavior);
3169 
3170  return newnode;
3171 }
3172 
3175 {
3177 
3179  COPY_NODE_FIELD(action);
3180 
3181  return newnode;
3182 }
3183 
3184 static DeclareCursorStmt *
3186 {
3188 
3189  COPY_STRING_FIELD(portalname);
3191  COPY_NODE_FIELD(query);
3192 
3193  return newnode;
3194 }
3195 
3196 static ClosePortalStmt *
3198 {
3200 
3201  COPY_STRING_FIELD(portalname);
3202 
3203  return newnode;
3204 }
3205 
3206 static ClusterStmt *
3208 {
3209  ClusterStmt *newnode = makeNode(ClusterStmt);
3210 
3211  COPY_NODE_FIELD(relation);
3212  COPY_STRING_FIELD(indexname);
3214 
3215  return newnode;
3216 }
3217 
3218 static CopyStmt *
3220 {
3221  CopyStmt *newnode = makeNode(CopyStmt);
3222 
3223  COPY_NODE_FIELD(relation);
3224  COPY_NODE_FIELD(query);
3225  COPY_NODE_FIELD(attlist);
3226  COPY_SCALAR_FIELD(is_from);
3227  COPY_SCALAR_FIELD(is_program);
3230 
3231  return newnode;
3232 }
3233 
3234 /*
3235  * CopyCreateStmtFields
3236  *
3237  * This function copies the fields of the CreateStmt node. It is used by
3238  * copy functions for classes which inherit from CreateStmt.
3239  */
3240 static void
3242 {
3243  COPY_NODE_FIELD(relation);
3244  COPY_NODE_FIELD(tableElts);
3245  COPY_NODE_FIELD(inhRelations);
3246  COPY_NODE_FIELD(partspec);
3247  COPY_NODE_FIELD(partbound);
3248  COPY_NODE_FIELD(ofTypename);
3249  COPY_NODE_FIELD(constraints);
3251  COPY_SCALAR_FIELD(oncommit);
3252  COPY_STRING_FIELD(tablespacename);
3253  COPY_SCALAR_FIELD(if_not_exists);
3254 }
3255 
3256 static CreateStmt *
3258 {
3259  CreateStmt *newnode = makeNode(CreateStmt);
3260 
3261  CopyCreateStmtFields(from, newnode);
3262 
3263  return newnode;
3264 }
3265 
3266 static TableLikeClause *
3268 {
3270 
3271  COPY_NODE_FIELD(relation);
3273 
3274  return newnode;
3275 }
3276 
3277 static DefineStmt *
3279 {
3280  DefineStmt *newnode = makeNode(DefineStmt);
3281 
3282  COPY_SCALAR_FIELD(kind);
3283  COPY_SCALAR_FIELD(oldstyle);
3284  COPY_NODE_FIELD(defnames);
3286  COPY_NODE_FIELD(definition);
3287  COPY_SCALAR_FIELD(if_not_exists);
3288 
3289  return newnode;
3290 }
3291 
3292 static DropStmt *
3294 {
3295  DropStmt *newnode = makeNode(DropStmt);
3296 
3297  COPY_NODE_FIELD(objects);
3298  COPY_SCALAR_FIELD(removeType);
3299  COPY_SCALAR_FIELD(behavior);
3300  COPY_SCALAR_FIELD(missing_ok);
3301  COPY_SCALAR_FIELD(concurrent);
3302 
3303  return newnode;
3304 }
3305 
3306 static TruncateStmt *
3308 {
3309  TruncateStmt *newnode = makeNode(TruncateStmt);
3310 
3311  COPY_NODE_FIELD(relations);
3312  COPY_SCALAR_FIELD(restart_seqs);
3313  COPY_SCALAR_FIELD(behavior);
3314 
3315  return newnode;
3316 }
3317 
3318 static CommentStmt *
3320 {
3321  CommentStmt *newnode = makeNode(CommentStmt);
3322 
3323  COPY_SCALAR_FIELD(objtype);
3324  COPY_NODE_FIELD(object);
3325  COPY_STRING_FIELD(comment);
3326 
3327  return newnode;
3328 }
3329 
3330 static SecLabelStmt *
3332 {
3333  SecLabelStmt *newnode = makeNode(SecLabelStmt);
3334 
3335  COPY_SCALAR_FIELD(objtype);
3336  COPY_NODE_FIELD(object);
3337  COPY_STRING_FIELD(provider);
3339 
3340  return newnode;
3341 }
3342 
3343 static FetchStmt *
3345 {
3346  FetchStmt *newnode = makeNode(FetchStmt);
3347 
3348  COPY_SCALAR_FIELD(direction);
3349  COPY_SCALAR_FIELD(howMany);
3350  COPY_STRING_FIELD(portalname);
3351  COPY_SCALAR_FIELD(ismove);
3352 
3353  return newnode;
3354 }
3355 
3356 static IndexStmt *
3358 {
3359  IndexStmt *newnode = makeNode(IndexStmt);
3360 
3361  COPY_STRING_FIELD(idxname);
3362  COPY_NODE_FIELD(relation);
3363  COPY_STRING_FIELD(accessMethod);
3364  COPY_STRING_FIELD(tableSpace);
3365  COPY_NODE_FIELD(indexParams);
3367  COPY_NODE_FIELD(whereClause);
3368  COPY_NODE_FIELD(excludeOpNames);
3369  COPY_STRING_FIELD(idxcomment);
3370  COPY_SCALAR_FIELD(indexOid);
3371  COPY_SCALAR_FIELD(oldNode);
3372  COPY_SCALAR_FIELD(unique);
3373  COPY_SCALAR_FIELD(primary);
3374  COPY_SCALAR_FIELD(isconstraint);
3375  COPY_SCALAR_FIELD(deferrable);
3376  COPY_SCALAR_FIELD(initdeferred);
3377  COPY_SCALAR_FIELD(transformed);
3378  COPY_SCALAR_FIELD(concurrent);
3379  COPY_SCALAR_FIELD(if_not_exists);
3380 
3381  return newnode;
3382 }
3383 
3384 static CreateStatsStmt *
3386 {
3388 
3389  COPY_NODE_FIELD(defnames);
3390  COPY_NODE_FIELD(stat_types);
3391  COPY_NODE_FIELD(exprs);
3392  COPY_NODE_FIELD(relations);
3393  COPY_SCALAR_FIELD(if_not_exists);
3394 
3395  return newnode;
3396 }
3397 
3398 static CreateFunctionStmt *
3400 {
3402 
3403  COPY_SCALAR_FIELD(replace);
3404  COPY_NODE_FIELD(funcname);
3405  COPY_NODE_FIELD(parameters);
3406  COPY_NODE_FIELD(returnType);
3408  COPY_NODE_FIELD(withClause);
3409 
3410  return newnode;
3411 }
3412 
3413 static FunctionParameter *
3415 {
3417 
3419  COPY_NODE_FIELD(argType);
3420  COPY_SCALAR_FIELD(mode);
3421  COPY_NODE_FIELD(defexpr);
3422 
3423  return newnode;
3424 }
3425 
3426 static AlterFunctionStmt *
3428 {
3430 
3431  COPY_NODE_FIELD(func);
3432  COPY_NODE_FIELD(actions);
3433 
3434  return newnode;
3435 }
3436 
3437 static DoStmt *
3438 _copyDoStmt(const DoStmt *from)
3439 {
3440  DoStmt *newnode = makeNode(DoStmt);
3441 
3443 
3444  return newnode;
3445 }
3446 
3447 static RenameStmt *
3449 {
3450  RenameStmt *newnode = makeNode(RenameStmt);
3451 
3452  COPY_SCALAR_FIELD(renameType);
3453  COPY_SCALAR_FIELD(relationType);
3454  COPY_NODE_FIELD(relation);
3455  COPY_NODE_FIELD(object);
3456  COPY_STRING_FIELD(subname);
3457  COPY_STRING_FIELD(newname);
3458  COPY_SCALAR_FIELD(behavior);
3459  COPY_SCALAR_FIELD(missing_ok);
3460 
3461  return newnode;
3462 }
3463 
3464 static AlterObjectDependsStmt *
3466 {
3468 
3469  COPY_SCALAR_FIELD(objectType);
3470  COPY_NODE_FIELD(relation);
3471  COPY_NODE_FIELD(object);
3472  COPY_NODE_FIELD(extname);
3473 
3474  return newnode;
3475 }
3476 
3477 static AlterObjectSchemaStmt *
3479 {
3481 
3482  COPY_SCALAR_FIELD(objectType);
3483  COPY_NODE_FIELD(relation);
3484  COPY_NODE_FIELD(object);
3485  COPY_STRING_FIELD(newschema);
3486  COPY_SCALAR_FIELD(missing_ok);
3487 
3488  return newnode;
3489 }
3490 
3491 static AlterOwnerStmt *
3493 {
3495 
3496  COPY_SCALAR_FIELD(objectType);
3497  COPY_NODE_FIELD(relation);
3498  COPY_NODE_FIELD(object);
3499  COPY_NODE_FIELD(newowner);
3500 
3501  return newnode;
3502 }
3503 
3504 static AlterOperatorStmt *
3506 {
3508 
3509  COPY_NODE_FIELD(opername);
3511 
3512  return newnode;
3513 }
3514 
3515 static RuleStmt *
3517 {
3518  RuleStmt *newnode = makeNode(RuleStmt);
3519 
3520  COPY_NODE_FIELD(relation);
3521  COPY_STRING_FIELD(rulename);
3522  COPY_NODE_FIELD(whereClause);
3523  COPY_SCALAR_FIELD(event);
3524  COPY_SCALAR_FIELD(instead);
3525  COPY_NODE_FIELD(actions);
3526  COPY_SCALAR_FIELD(replace);
3527 
3528  return newnode;
3529 }
3530 
3531 static NotifyStmt *
3533 {
3534  NotifyStmt *newnode = makeNode(NotifyStmt);
3535 
3536  COPY_STRING_FIELD(conditionname);
3537  COPY_STRING_FIELD(payload);
3538 
3539  return newnode;
3540 }
3541 
3542 static ListenStmt *
3544 {
3545  ListenStmt *newnode = makeNode(ListenStmt);
3546 
3547  COPY_STRING_FIELD(conditionname);
3548 
3549  return newnode;
3550 }
3551 
3552 static UnlistenStmt *
3554 {
3555  UnlistenStmt *newnode = makeNode(UnlistenStmt);
3556 
3557  COPY_STRING_FIELD(conditionname);
3558 
3559  return newnode;
3560 }
3561 
3562 static TransactionStmt *
3564 {
3566 
3567  COPY_SCALAR_FIELD(kind);
3569  COPY_STRING_FIELD(gid);
3570 
3571  return newnode;
3572 }
3573 
3574 static CompositeTypeStmt *
3576 {
3578 
3579  COPY_NODE_FIELD(typevar);
3580  COPY_NODE_FIELD(coldeflist);
3581 
3582  return newnode;
3583 }
3584 
3585 static CreateEnumStmt *
3587 {
3589 
3590  COPY_NODE_FIELD(typeName);
3591  COPY_NODE_FIELD(vals);
3592 
3593  return newnode;
3594 }
3595 
3596 static CreateRangeStmt *
3598 {
3600 
3601  COPY_NODE_FIELD(typeName);
3602  COPY_NODE_FIELD(params);
3603 
3604  return newnode;
3605 }
3606 
3607 static AlterEnumStmt *
3609 {
3610  AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
3611 
3612  COPY_NODE_FIELD(typeName);
3613  COPY_STRING_FIELD(oldVal);
3614  COPY_STRING_FIELD(newVal);
3615  COPY_STRING_FIELD(newValNeighbor);
3616  COPY_SCALAR_FIELD(newValIsAfter);
3617  COPY_SCALAR_FIELD(skipIfNewValExists);
3618 
3619  return newnode;
3620 }
3621 
3622 static ViewStmt *
3624 {
3625  ViewStmt *newnode = makeNode(ViewStmt);
3626 
3627  COPY_NODE_FIELD(view);
3628  COPY_NODE_FIELD(aliases);
3629  COPY_NODE_FIELD(query);
3630  COPY_SCALAR_FIELD(replace);
3632  COPY_SCALAR_FIELD(withCheckOption);
3633 
3634  return newnode;
3635 }
3636 
3637 static LoadStmt *
3639 {
3640  LoadStmt *newnode = makeNode(LoadStmt);
3641 
3643 
3644  return newnode;
3645 }
3646 
3647 static CreateDomainStmt *
3649 {
3651 
3652  COPY_NODE_FIELD(domainname);
3653  COPY_NODE_FIELD(typeName);
3654  COPY_NODE_FIELD(collClause);
3655  COPY_NODE_FIELD(constraints);
3656 
3657  return newnode;
3658 }
3659 
3660 static CreateOpClassStmt *
3662 {
3664 
3665  COPY_NODE_FIELD(opclassname);
3666  COPY_NODE_FIELD(opfamilyname);
3667  COPY_STRING_FIELD(amname);
3668  COPY_NODE_FIELD(datatype);
3669  COPY_NODE_FIELD(items);
3670  COPY_SCALAR_FIELD(isDefault);
3671 
3672  return newnode;
3673 }
3674 
3675 static CreateOpClassItem *
3677 {
3679 
3680  COPY_SCALAR_FIELD(itemtype);
3682  COPY_SCALAR_FIELD(number);
3683  COPY_NODE_FIELD(order_family);
3684  COPY_NODE_FIELD(class_args);
3685  COPY_NODE_FIELD(storedtype);
3686 
3687  return newnode;
3688 }
3689 
3690 static CreateOpFamilyStmt *
3692 {
3694 
3695  COPY_NODE_FIELD(opfamilyname);
3696  COPY_STRING_FIELD(amname);
3697 
3698  return newnode;
3699 }
3700 
3701 static AlterOpFamilyStmt *
3703 {
3705 
3706  COPY_NODE_FIELD(opfamilyname);
3707  COPY_STRING_FIELD(amname);
3708  COPY_SCALAR_FIELD(isDrop);
3709  COPY_NODE_FIELD(items);
3710 
3711  return newnode;
3712 }
3713 
3714 static CreatedbStmt *
3716 {
3717  CreatedbStmt *newnode = makeNode(CreatedbStmt);
3718 
3721 
3722  return newnode;
3723 }
3724 
3725 static AlterDatabaseStmt *
3727 {
3729 
3732 
3733  return newnode;
3734 }
3735 
3736 static AlterDatabaseSetStmt *
3738 {
3740 
3742  COPY_NODE_FIELD(setstmt);
3743 
3744  return newnode;
3745 }
3746 
3747 static DropdbStmt *
3749 {
3750  DropdbStmt *newnode = makeNode(DropdbStmt);
3751 
3753  COPY_SCALAR_FIELD(missing_ok);
3754 
3755  return newnode;
3756 }
3757 
3758 static VacuumStmt *
3760 {
3761  VacuumStmt *newnode = makeNode(VacuumStmt);
3762 
3764  COPY_NODE_FIELD(relation);
3765  COPY_NODE_FIELD(va_cols);
3766 
3767  return newnode;
3768 }
3769 
3770 static ExplainStmt *
3772 {
3773  ExplainStmt *newnode = makeNode(ExplainStmt);
3774 
3775  COPY_NODE_FIELD(query);
3777 
3778  return newnode;
3779 }
3780 
3781 static CreateTableAsStmt *
3783 {
3785 
3786  COPY_NODE_FIELD(query);
3787  COPY_NODE_FIELD(into);
3788  COPY_SCALAR_FIELD(relkind);
3789  COPY_SCALAR_FIELD(is_select_into);
3790  COPY_SCALAR_FIELD(if_not_exists);
3791 
3792  return newnode;
3793 }
3794 
3795 static RefreshMatViewStmt *
3797 {
3799 
3800  COPY_SCALAR_FIELD(concurrent);
3801  COPY_SCALAR_FIELD(skipData);
3802  COPY_NODE_FIELD(relation);
3803 
3804  return newnode;
3805 }
3806 
3807 static ReplicaIdentityStmt *
3809 {
3811 
3812  COPY_SCALAR_FIELD(identity_type);
3814 
3815  return newnode;
3816 }
3817 
3818 static AlterSystemStmt *
3820 {
3822 
3823  COPY_NODE_FIELD(setstmt);
3824 
3825  return newnode;
3826 }
3827 
3828 static CreateSeqStmt *
3830 {
3831  CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
3832 
3833  COPY_NODE_FIELD(sequence);
3835  COPY_SCALAR_FIELD(ownerId);
3836  COPY_SCALAR_FIELD(for_identity);
3837  COPY_SCALAR_FIELD(if_not_exists);
3838 
3839  return newnode;
3840 }
3841 
3842 static AlterSeqStmt *
3844 {
3845  AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
3846 
3847  COPY_NODE_FIELD(sequence);
3849  COPY_SCALAR_FIELD(for_identity);
3850  COPY_SCALAR_FIELD(missing_ok);
3851 
3852  return newnode;
3853 }
3854 
3855 static VariableSetStmt *
3857 {
3859 
3860  COPY_SCALAR_FIELD(kind);
3863  COPY_SCALAR_FIELD(is_local);
3864 
3865  return newnode;
3866 }
3867 
3868 static VariableShowStmt *
3870 {
3872 
3874 
3875  return newnode;
3876 }
3877 
3878 static DiscardStmt *
3880 {
3881  DiscardStmt *newnode = makeNode(DiscardStmt);
3882 
3883  COPY_SCALAR_FIELD(target);
3884 
3885  return newnode;
3886 }
3887 
3888 static CreateTableSpaceStmt *
3890 {
3892 
3893  COPY_STRING_FIELD(tablespacename);
3894  COPY_NODE_FIELD(owner);
3895  COPY_STRING_FIELD(location);
3897 
3898  return newnode;
3899 }
3900 
3901 static DropTableSpaceStmt *
3903 {
3905 
3906  COPY_STRING_FIELD(tablespacename);
3907  COPY_SCALAR_FIELD(missing_ok);
3908 
3909  return newnode;
3910 }
3911 
3914 {
3916 
3917  COPY_STRING_FIELD(tablespacename);
3919  COPY_SCALAR_FIELD(isReset);
3920 
3921  return newnode;
3922 }
3923 
3924 static AlterTableMoveAllStmt *
3926 {
3928 
3929  COPY_STRING_FIELD(orig_tablespacename);
3930  COPY_SCALAR_FIELD(objtype);
3931  COPY_NODE_FIELD(roles);
3932  COPY_STRING_FIELD(new_tablespacename);
3933  COPY_SCALAR_FIELD(nowait);
3934 
3935  return newnode;
3936 }
3937 
3938 static CreateExtensionStmt *
3940 {
3942 
3943  COPY_STRING_FIELD(extname);
3944  COPY_SCALAR_FIELD(if_not_exists);
3946 
3947  return newnode;
3948 }
3949 
3950 static AlterExtensionStmt *
3952 {
3954 
3955  COPY_STRING_FIELD(extname);
3957 
3958  return newnode;
3959 }
3960 
3963 {
3965 
3966  COPY_STRING_FIELD(extname);
3967  COPY_SCALAR_FIELD(action);
3968  COPY_SCALAR_FIELD(objtype);
3969  COPY_NODE_FIELD(object);
3970 
3971  return newnode;
3972 }
3973 
3974 static CreateFdwStmt *
3976 {
3977  CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
3978 
3979  COPY_STRING_FIELD(fdwname);
3980  COPY_NODE_FIELD(func_options);
3982 
3983  return newnode;
3984 }
3985 
3986 static AlterFdwStmt *
3988 {
3989  AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
3990 
3991  COPY_STRING_FIELD(fdwname);
3992  COPY_NODE_FIELD(func_options);
3994 
3995  return newnode;
3996 }
3997 
3998 static CreateForeignServerStmt *
4000 {
4002 
4003  COPY_STRING_FIELD(servername);
4004  COPY_STRING_FIELD(servertype);
4005  COPY_STRING_FIELD(version);
4006  COPY_STRING_FIELD(fdwname);
4008  COPY_SCALAR_FIELD(if_not_exists);
4009 
4010  return newnode;
4011 }
4012 
4013 static AlterForeignServerStmt *
4015 {
4017 
4018  COPY_STRING_FIELD(servername);
4019  COPY_STRING_FIELD(version);
4021  COPY_SCALAR_FIELD(has_version);
4022 
4023  return newnode;
4024 }
4025 
4026 static CreateUserMappingStmt *
4028 {
4030 
4032  COPY_STRING_FIELD(servername);
4034  COPY_SCALAR_FIELD(if_not_exists);
4035 
4036  return newnode;
4037 }
4038 
4039 static AlterUserMappingStmt *
4041 {
4043 
4045  COPY_STRING_FIELD(servername);
4047 
4048  return newnode;
4049 }
4050 
4051 static DropUserMappingStmt *
4053 {
4055 
4057  COPY_STRING_FIELD(servername);
4058  COPY_SCALAR_FIELD(missing_ok);
4059 
4060  return newnode;
4061 }
4062 
4063 static CreateForeignTableStmt *
4065 {
4067 
4068  CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
4069 
4070  COPY_STRING_FIELD(servername);
4072 
4073  return newnode;
4074 }
4075 
4076 static ImportForeignSchemaStmt *
4078 {
4080 
4081  COPY_STRING_FIELD(server_name);
4082  COPY_STRING_FIELD(remote_schema);
4083  COPY_STRING_FIELD(local_schema);
4084  COPY_SCALAR_FIELD(list_type);
4085  COPY_NODE_FIELD(table_list);
4087 
4088  return newnode;
4089 }
4090 
4091 static CreateTransformStmt *
4093 {
4095 
4096  COPY_SCALAR_FIELD(replace);
4097  COPY_NODE_FIELD(type_name);
4098  COPY_STRING_FIELD(lang);
4099  COPY_NODE_FIELD(fromsql);
4100  COPY_NODE_FIELD(tosql);
4101 
4102  return newnode;
4103 }
4104 
4105 static CreateAmStmt *
4107 {
4108  CreateAmStmt *newnode = makeNode(CreateAmStmt);
4109 
4110  COPY_STRING_FIELD(amname);
4111  COPY_NODE_FIELD(handler_name);
4112  COPY_SCALAR_FIELD(amtype);
4113 
4114  return newnode;
4115 }
4116 
4117 static CreateTrigStmt *
4119 {
4121 
4122  COPY_STRING_FIELD(trigname);
4123  COPY_NODE_FIELD(relation);
4124  COPY_NODE_FIELD(funcname);
4126  COPY_SCALAR_FIELD(row);
4127  COPY_SCALAR_FIELD(timing);
4128  COPY_SCALAR_FIELD(events);
4129  COPY_NODE_FIELD(columns);
4130  COPY_NODE_FIELD(whenClause);
4131  COPY_SCALAR_FIELD(isconstraint);
4132  COPY_NODE_FIELD(transitionRels);
4133  COPY_SCALAR_FIELD(deferrable);
4134  COPY_SCALAR_FIELD(initdeferred);
4135  COPY_NODE_FIELD(constrrel);
4136 
4137  return newnode;
4138 }
4139 
4140 static CreateEventTrigStmt *
4142 {
4144 
4145  COPY_STRING_FIELD(trigname);
4146  COPY_STRING_FIELD(eventname);
4147  COPY_NODE_FIELD(whenclause);
4148  COPY_NODE_FIELD(funcname);
4149 
4150  return newnode;
4151 }
4152 
4153 static AlterEventTrigStmt *
4155 {
4157 
4158  COPY_STRING_FIELD(trigname);
4159  COPY_SCALAR_FIELD(tgenabled);
4160 
4161  return newnode;
4162 }
4163 
4164 static CreatePLangStmt *
4166 {
4168 
4169  COPY_SCALAR_FIELD(replace);
4170  COPY_STRING_FIELD(plname);
4171  COPY_NODE_FIELD(plhandler);
4172  COPY_NODE_FIELD(plinline);
4173  COPY_NODE_FIELD(plvalidator);
4174  COPY_SCALAR_FIELD(pltrusted);
4175 
4176  return newnode;
4177 }
4178 
4179 static CreateRoleStmt *
4181 {
4183 
4184  COPY_SCALAR_FIELD(stmt_type);
4185  COPY_STRING_FIELD(role);
4187 
4188  return newnode;
4189 }
4190 
4191 static AlterRoleStmt *
4193 {
4194  AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
4195 
4196  COPY_NODE_FIELD(role);
4198  COPY_SCALAR_FIELD(action);
4199 
4200  return newnode;
4201 }
4202 
4203 static AlterRoleSetStmt *
4205 {
4207 
4208  COPY_NODE_FIELD(role);
4209  COPY_STRING_FIELD(database);
4210  COPY_NODE_FIELD(setstmt);
4211 
4212  return newnode;
4213 }
4214 
4215 static DropRoleStmt *
4217 {
4218  DropRoleStmt *newnode = makeNode(DropRoleStmt);
4219 
4220  COPY_NODE_FIELD(roles);
4221  COPY_SCALAR_FIELD(missing_ok);
4222 
4223  return newnode;
4224 }
4225 
4226 static LockStmt *
4228 {
4229  LockStmt *newnode = makeNode(LockStmt);
4230 
4231  COPY_NODE_FIELD(relations);
4232  COPY_SCALAR_FIELD(mode);
4233  COPY_SCALAR_FIELD(nowait);
4234 
4235  return newnode;
4236 }
4237 
4238 static ConstraintsSetStmt *
4240 {
4242 
4243  COPY_NODE_FIELD(constraints);
4244  COPY_SCALAR_FIELD(deferred);
4245 
4246  return newnode;
4247 }
4248 
4249 static ReindexStmt *
4251 {
4252  ReindexStmt *newnode = makeNode(ReindexStmt);
4253 
4254  COPY_SCALAR_FIELD(kind);
4255  COPY_NODE_FIELD(relation);
4258 
4259  return newnode;
4260 }
4261 
4262 static CreateSchemaStmt *
4264 {
4266 
4267  COPY_STRING_FIELD(schemaname);
4268  COPY_NODE_FIELD(authrole);
4269  COPY_NODE_FIELD(schemaElts);
4270  COPY_SCALAR_FIELD(if_not_exists);
4271 
4272  return newnode;
4273 }
4274 
4275 static CreateConversionStmt *
4277 {
4279 
4280  COPY_NODE_FIELD(conversion_name);
4281  COPY_STRING_FIELD(for_encoding_name);
4282  COPY_STRING_FIELD(to_encoding_name);
4283  COPY_NODE_FIELD(func_name);
4284  COPY_SCALAR_FIELD(def);
4285 
4286  return newnode;
4287 }
4288 
4289 static CreateCastStmt *
4291 {
4293 
4294  COPY_NODE_FIELD(sourcetype);
4295  COPY_NODE_FIELD(targettype);
4296  COPY_NODE_FIELD(func);
4297  COPY_SCALAR_FIELD(context);
4298  COPY_SCALAR_FIELD(inout);
4299 
4300  return newnode;
4301 }
4302 
4303 static PrepareStmt *
4305 {
4306  PrepareStmt *newnode = makeNode(PrepareStmt);
4307 
4309  COPY_NODE_FIELD(argtypes);
4310  COPY_NODE_FIELD(query);
4311 
4312  return newnode;
4313 }
4314 
4315 static ExecuteStmt *
4317 {
4318  ExecuteStmt *newnode = makeNode(ExecuteStmt);
4319 
4321  COPY_NODE_FIELD(params);
4322 
4323  return newnode;
4324 }
4325 
4326 static DeallocateStmt *
4328 {
4330 
4332 
4333  return newnode;
4334 }
4335 
4336 static DropOwnedStmt *
4338 {
4339  DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
4340 
4341  COPY_NODE_FIELD(roles);
4342  COPY_SCALAR_FIELD(behavior);
4343 
4344  return newnode;
4345 }
4346 
4347 static ReassignOwnedStmt *
4349 {
4351 
4352  COPY_NODE_FIELD(roles);
4353  COPY_NODE_FIELD(newrole);
4354 
4355  return newnode;
4356 }
4357 
4358 static AlterTSDictionaryStmt *
4360 {
4362 
4363  COPY_NODE_FIELD(dictname);
4365 
4366  return newnode;
4367 }
4368 
4369 static AlterTSConfigurationStmt *
4371 {
4373 
4374  COPY_SCALAR_FIELD(kind);
4375  COPY_NODE_FIELD(cfgname);
4376  COPY_NODE_FIELD(tokentype);
4377  COPY_NODE_FIELD(dicts);
4378  COPY_SCALAR_FIELD(override);
4379  COPY_SCALAR_FIELD(replace);
4380  COPY_SCALAR_FIELD(missing_ok);
4381 
4382  return newnode;
4383 }
4384 
4385 static CreatePolicyStmt *
4387 {
4389 
4390  COPY_STRING_FIELD(policy_name);
4391  COPY_NODE_FIELD(table);
4392  COPY_STRING_FIELD(cmd_name);
4393  COPY_SCALAR_FIELD(permissive);
4394  COPY_NODE_FIELD(roles);
4395  COPY_NODE_FIELD(qual);
4396  COPY_NODE_FIELD(with_check);
4397 
4398  return newnode;
4399 }
4400 
4401 static AlterPolicyStmt *
4403 {
4405 
4406  COPY_STRING_FIELD(policy_name);
4407  COPY_NODE_FIELD(table);
4408  COPY_NODE_FIELD(roles);
4409  COPY_NODE_FIELD(qual);
4410  COPY_NODE_FIELD(with_check);
4411 
4412  return newnode;
4413 }
4414 
4415 static PartitionSpec *
4417 {
4418  PartitionSpec *newnode = makeNode(PartitionSpec);
4419 
4420  COPY_STRING_FIELD(strategy);
4421  COPY_NODE_FIELD(partParams);
4422  COPY_LOCATION_FIELD(location);
4423 
4424  return newnode;
4425 }
4426 
4427 static PartitionElem *
4429 {
4430  PartitionElem *newnode = makeNode(PartitionElem);
4431 
4433  COPY_NODE_FIELD(expr);
4434  COPY_NODE_FIELD(collation);
4435  COPY_NODE_FIELD(opclass);
4436  COPY_LOCATION_FIELD(location);
4437 
4438  return newnode;
4439 }
4440 
4441 static PartitionBoundSpec *
4443 {
4445 
4446  COPY_SCALAR_FIELD(strategy);
4447  COPY_NODE_FIELD(listdatums);
4448  COPY_NODE_FIELD(lowerdatums);
4449  COPY_NODE_FIELD(upperdatums);
4450  COPY_LOCATION_FIELD(location);
4451 
4452  return newnode;
4453 }
4454 
4455 static PartitionRangeDatum *
4457 {
4459 
4460  COPY_SCALAR_FIELD(infinite);
4462  COPY_LOCATION_FIELD(location);
4463 
4464  return newnode;
4465 }
4466 
4467 static PartitionCmd *
4469 {
4470  PartitionCmd *newnode = makeNode(PartitionCmd);
4471 
4473  COPY_NODE_FIELD(bound);
4474 
4475  return newnode;
4476 }
4477 
4478 static CreatePublicationStmt *
4480 {
4482 
4483  COPY_STRING_FIELD(pubname);
4485  COPY_NODE_FIELD(tables);
4486  COPY_SCALAR_FIELD(for_all_tables);
4487 
4488  return newnode;
4489 }
4490 
4491 static AlterPublicationStmt *
4493 {
4495 
4496  COPY_STRING_FIELD(pubname);
4498  COPY_NODE_FIELD(tables);
4499  COPY_SCALAR_FIELD(for_all_tables);
4500  COPY_SCALAR_FIELD(tableAction);
4501 
4502  return newnode;
4503 }
4504 
4505 static CreateSubscriptionStmt *
4507 {
4509 
4510  COPY_STRING_FIELD(subname);
4511  COPY_STRING_FIELD(conninfo);
4512  COPY_NODE_FIELD(publication);
4514 
4515  return newnode;
4516 }
4517 
4518 static AlterSubscriptionStmt *
4520 {
4522 
4523  COPY_SCALAR_FIELD(kind);
4524  COPY_STRING_FIELD(subname);
4525  COPY_STRING_FIELD(conninfo);
4526  COPY_NODE_FIELD(publication);
4528 
4529  return newnode;
4530 }
4531 
4532 static DropSubscriptionStmt *
4534 {
4536 
4537  COPY_STRING_FIELD(subname);
4538  COPY_SCALAR_FIELD(missing_ok);
4539  COPY_SCALAR_FIELD(behavior);
4540 
4541  return newnode;
4542 }
4543 
4544 /* ****************************************************************
4545  * pg_list.h copy functions
4546  * ****************************************************************
4547  */
4548 
4549 /*
4550  * Perform a deep copy of the specified list, using copyObject(). The
4551  * list MUST be of type T_List; T_IntList and T_OidList nodes don't
4552  * need deep copies, so they should be copied via list_copy()
4553  */
4554 #define COPY_NODE_CELL(new, old) \
4555  (new) = (ListCell *) palloc(sizeof(ListCell)); \
4556  lfirst(new) = copyObjectImpl(lfirst(old));
4557 
4558 static List *
4559 _copyList(const List *from)
4560 {
4561  List *new;
4562  ListCell *curr_old;
4563  ListCell *prev_new;
4564 
4565  Assert(list_length(from) >= 1);
4566 
4567  new = makeNode(List);
4568  new->length = from->length;
4569 
4570  COPY_NODE_CELL(new->head, from->head);
4571  prev_new = new->head;
4572  curr_old = lnext(from->head);
4573 
4574  while (curr_old)
4575  {
4576  COPY_NODE_CELL(prev_new->next, curr_old);
4577  prev_new = prev_new->next;
4578  curr_old = curr_old->next;
4579  }
4580  prev_new->next = NULL;
4581  new->tail = prev_new;
4582 
4583  return new;
4584 }
4585 
4586 /* ****************************************************************
4587  * extensible.h copy functions
4588  * ****************************************************************
4589  */
4590 static ExtensibleNode *
4592 {
4593  ExtensibleNode *newnode;
4594  const ExtensibleNodeMethods *methods;
4595 
4596  methods = GetExtensibleNodeMethods(from->extnodename, false);
4597  newnode = (ExtensibleNode *) newNode(methods->node_size,
4599  COPY_STRING_FIELD(extnodename);
4600 
4601  /* copy the private fields */
4602  methods->nodeCopy(newnode, from);
4603 
4604  return newnode;
4605 }
4606 
4607 /* ****************************************************************
4608  * value.h copy functions
4609  * ****************************************************************
4610  */
4611 static Value *
4612 _copyValue(const Value *from)
4613 {
4614  Value *newnode = makeNode(Value);
4615 
4616  /* See also _copyAConst when changing this code! */
4617 
4618  COPY_SCALAR_FIELD(type);
4619  switch (from->type)
4620  {
4621  case T_Integer:
4622  COPY_SCALAR_FIELD(val.ival);
4623  break;
4624  case T_Float:
4625  case T_String:
4626  case T_BitString:
4627  COPY_STRING_FIELD(val.str);
4628  break;
4629  case T_Null:
4630  /* nothing to do */
4631  break;
4632  default:
4633  elog(ERROR, "unrecognized node type: %d",
4634  (int) from->type);
4635  break;
4636  }
4637  return newnode;
4638 }
4639 
4640 
4641 static ForeignKeyCacheInfo *
4643 {
4645 
4646  COPY_SCALAR_FIELD(conrelid);
4647  COPY_SCALAR_FIELD(confrelid);
4648  COPY_SCALAR_FIELD(nkeys);
4649  /* COPY_SCALAR_FIELD might work for these, but let's not assume that */
4650  memcpy(newnode->conkey, from->conkey, sizeof(newnode->conkey));
4651  memcpy(newnode->confkey, from->confkey, sizeof(newnode->confkey));
4652  memcpy(newnode->conpfeqop, from->conpfeqop, sizeof(newnode->conpfeqop));
4653 
4654  return newnode;
4655 }
4656 
4657 
4658 /*
4659  * copyObjectImpl -- implementation of copyObject(); see nodes/nodes.h
4660  *
4661  * Create a copy of a Node tree or list. This is a "deep" copy: all
4662  * substructure is copied too, recursively.
4663  */
4664 void *
4665 copyObjectImpl(const void *from)
4666 {
4667  void *retval;
4668 
4669  if (from == NULL)
4670  return NULL;
4671 
4672  /* Guard against stack overflow due to overly complex expressions */
4674 
4675  switch (nodeTag(from))
4676  {
4677  /*
4678  * PLAN NODES
4679  */
4680  case T_PlannedStmt:
4681  retval = _copyPlannedStmt(from);
4682  break;
4683  case T_Plan:
4684  retval = _copyPlan(from);
4685  break;
4686  case T_Result:
4687  retval = _copyResult(from);
4688  break;
4689  case T_ProjectSet:
4690  retval = _copyProjectSet(from);
4691  break;
4692  case T_ModifyTable:
4693  retval = _copyModifyTable(from);
4694  break;
4695  case T_Append:
4696  retval = _copyAppend(from);
4697  break;
4698  case T_MergeAppend:
4699  retval = _copyMergeAppend(from);
4700  break;
4701  case T_RecursiveUnion:
4702  retval = _copyRecursiveUnion(from);
4703  break;
4704  case T_BitmapAnd:
4705  retval = _copyBitmapAnd(from);
4706  break;
4707  case T_BitmapOr:
4708  retval = _copyBitmapOr(from);
4709  break;
4710  case T_Scan:
4711  retval = _copyScan(from);
4712  break;
4713  case T_Gather:
4714  retval = _copyGather(from);
4715  break;
4716  case T_GatherMerge:
4717  retval = _copyGatherMerge(from);
4718  break;
4719  case T_SeqScan:
4720  retval = _copySeqScan(from);
4721  break;
4722  case T_SampleScan:
4723  retval = _copySampleScan(from);
4724  break;
4725  case T_IndexScan:
4726  retval = _copyIndexScan(from);
4727  break;
4728  case T_IndexOnlyScan:
4729  retval = _copyIndexOnlyScan(from);
4730  break;
4731  case T_BitmapIndexScan:
4732  retval = _copyBitmapIndexScan(from);
4733  break;
4734  case T_BitmapHeapScan:
4735  retval = _copyBitmapHeapScan(from);
4736  break;
4737  case T_TidScan:
4738  retval = _copyTidScan(from);
4739  break;
4740  case T_SubqueryScan:
4741  retval = _copySubqueryScan(from);
4742  break;
4743  case T_FunctionScan:
4744  retval = _copyFunctionScan(from);
4745  break;
4746  case T_TableFuncScan:
4747  retval = _copyTableFuncScan(from);
4748  break;
4749  case T_ValuesScan:
4750  retval = _copyValuesScan(from);
4751  break;
4752  case T_CteScan:
4753  retval = _copyCteScan(from);
4754  break;
4755  case T_NamedTuplestoreScan:
4756  retval = _copyNamedTuplestoreScan(from);
4757  break;
4758  case T_WorkTableScan:
4759  retval = _copyWorkTableScan(from);
4760  break;
4761  case T_ForeignScan:
4762  retval = _copyForeignScan(from);
4763  break;
4764  case T_CustomScan:
4765  retval = _copyCustomScan(from);
4766  break;
4767  case T_Join:
4768  retval = _copyJoin(from);
4769  break;
4770  case T_NestLoop:
4771  retval = _copyNestLoop(from);
4772  break;
4773  case T_MergeJoin:
4774  retval = _copyMergeJoin(from);
4775  break;
4776  case T_HashJoin:
4777  retval = _copyHashJoin(from);
4778  break;
4779  case T_Material:
4780  retval = _copyMaterial(from);
4781  break;
4782  case T_Sort:
4783  retval = _copySort(from);
4784  break;
4785  case T_Group:
4786  retval = _copyGroup(from);
4787  break;
4788  case T_Agg:
4789  retval = _copyAgg(from);
4790  break;
4791  case T_WindowAgg:
4792  retval = _copyWindowAgg(from);
4793  break;
4794  case T_Unique:
4795  retval = _copyUnique(from);
4796  break;
4797  case T_Hash:
4798  retval = _copyHash(from);
4799  break;
4800  case T_SetOp:
4801  retval = _copySetOp(from);
4802  break;
4803  case T_LockRows:
4804  retval = _copyLockRows(from);
4805  break;
4806  case T_Limit:
4807  retval = _copyLimit(from);
4808  break;
4809  case T_NestLoopParam:
4810  retval = _copyNestLoopParam(from);
4811  break;
4812  case T_PlanRowMark:
4813  retval = _copyPlanRowMark(from);
4814  break;
4815  case T_PlanInvalItem:
4816  retval = _copyPlanInvalItem(from);
4817  break;
4818 
4819  /*
4820  * PRIMITIVE NODES
4821  */
4822  case T_Alias:
4823  retval = _copyAlias(from);
4824  break;
4825  case T_RangeVar:
4826  retval = _copyRangeVar(from);
4827  break;
4828  case T_TableFunc:
4829  retval = _copyTableFunc(from);
4830  break;
4831  case T_IntoClause:
4832  retval = _copyIntoClause(from);
4833  break;
4834  case T_Var:
4835  retval = _copyVar(from);
4836  break;
4837  case T_Const:
4838  retval = _copyConst(from);
4839  break;
4840  case T_Param:
4841  retval = _copyParam(from);
4842  break;
4843  case T_Aggref:
4844  retval = _copyAggref(from);
4845  break;
4846  case T_GroupingFunc:
4847  retval = _copyGroupingFunc(from);
4848  break;
4849  case T_WindowFunc:
4850  retval = _copyWindowFunc(from);
4851  break;
4852  case T_ArrayRef:
4853  retval = _copyArrayRef(from);
4854  break;
4855  case T_FuncExpr:
4856  retval = _copyFuncExpr(from);
4857  break;
4858  case T_NamedArgExpr:
4859  retval = _copyNamedArgExpr(from);
4860  break;
4861  case T_OpExpr:
4862  retval = _copyOpExpr(from);
4863  break;
4864  case T_DistinctExpr:
4865  retval = _copyDistinctExpr(from);
4866  break;
4867  case T_NullIfExpr:
4868  retval = _copyNullIfExpr(from);
4869  break;
4870  case T_ScalarArrayOpExpr:
4871  retval = _copyScalarArrayOpExpr(from);
4872  break;
4873  case T_BoolExpr:
4874  retval = _copyBoolExpr(from);
4875  break;
4876  case T_SubLink:
4877  retval = _copySubLink(from);
4878  break;
4879  case T_SubPlan:
4880  retval = _copySubPlan(from);
4881  break;
4882  case T_AlternativeSubPlan:
4883  retval = _copyAlternativeSubPlan(from);
4884  break;
4885  case T_FieldSelect:
4886  retval = _copyFieldSelect(from);
4887  break;
4888  case T_FieldStore:
4889  retval = _copyFieldStore(from);
4890  break;
4891  case T_RelabelType:
4892  retval = _copyRelabelType(from);
4893  break;
4894  case T_CoerceViaIO:
4895  retval = _copyCoerceViaIO(from);
4896  break;
4897  case T_ArrayCoerceExpr:
4898  retval = _copyArrayCoerceExpr(from);
4899  break;
4900  case T_ConvertRowtypeExpr:
4901  retval = _copyConvertRowtypeExpr(from);
4902  break;
4903  case T_CollateExpr:
4904  retval = _copyCollateExpr(from);
4905  break;
4906  case T_CaseExpr:
4907  retval = _copyCaseExpr(from);
4908  break;
4909  case T_CaseWhen:
4910  retval = _copyCaseWhen(from);
4911  break;
4912  case T_CaseTestExpr:
4913  retval = _copyCaseTestExpr(from);
4914  break;
4915  case T_ArrayExpr:
4916  retval = _copyArrayExpr(from);
4917  break;
4918  case T_RowExpr:
4919  retval = _copyRowExpr(from);
4920  break;
4921  case T_RowCompareExpr:
4922  retval = _copyRowCompareExpr(from);
4923  break;
4924  case T_CoalesceExpr:
4925  retval = _copyCoalesceExpr(from);
4926  break;
4927  case T_MinMaxExpr:
4928  retval = _copyMinMaxExpr(from);
4929  break;
4930  case T_SQLValueFunction:
4931  retval = _copySQLValueFunction(from);
4932  break;
4933  case T_XmlExpr:
4934  retval = _copyXmlExpr(from);
4935  break;
4936  case T_NullTest:
4937  retval = _copyNullTest(from);
4938  break;
4939  case T_BooleanTest:
4940  retval = _copyBooleanTest(from);
4941  break;
4942  case T_CoerceToDomain:
4943  retval = _copyCoerceToDomain(from);
4944  break;
4945  case T_CoerceToDomainValue:
4946  retval = _copyCoerceToDomainValue(from);
4947  break;
4948  case T_SetToDefault:
4949  retval = _copySetToDefault(from);
4950  break;
4951  case T_CurrentOfExpr:
4952  retval = _copyCurrentOfExpr(from);
4953  break;
4954  case T_NextValueExpr:
4955  retval = _copyNextValueExpr(from);
4956  break;
4957  case T_InferenceElem:
4958  retval = _copyInferenceElem(from);
4959  break;
4960  case T_TargetEntry:
4961  retval = _copyTargetEntry(from);
4962  break;
4963  case T_RangeTblRef:
4964  retval = _copyRangeTblRef(from);
4965  break;
4966  case T_JoinExpr:
4967  retval = _copyJoinExpr(from);
4968  break;
4969  case T_FromExpr:
4970  retval = _copyFromExpr(from);
4971  break;
4972  case T_OnConflictExpr:
4973  retval = _copyOnConflictExpr(from);
4974  break;
4975 
4976  /*
4977  * RELATION NODES
4978  */
4979  case T_PathKey:
4980  retval = _copyPathKey(from);
4981  break;
4982  case T_RestrictInfo:
4983  retval = _copyRestrictInfo(from);
4984  break;
4985  case T_PlaceHolderVar:
4986  retval = _copyPlaceHolderVar(from);
4987  break;
4988  case T_SpecialJoinInfo:
4989  retval = _copySpecialJoinInfo(from);
4990  break;
4991  case T_AppendRelInfo:
4992  retval = _copyAppendRelInfo(from);
4993  break;
4995  retval = _copyPartitionedChildRelInfo(from);
4996  break;
4997  case T_PlaceHolderInfo:
4998  retval = _copyPlaceHolderInfo(from);
4999  break;
5000 
5001  /*
5002  * VALUE NODES
5003  */
5004  case T_Integer:
5005  case T_Float:
5006  case T_String:
5007  case T_BitString:
5008  case T_Null:
5009  retval = _copyValue(from);
5010  break;
5011 
5012  /*
5013  * LIST NODES
5014  */
5015  case T_List:
5016  retval = _copyList(from);
5017  break;
5018 
5019  /*
5020  * Lists of integers and OIDs don't need to be deep-copied, so we
5021  * perform a shallow copy via list_copy()
5022  */
5023  case T_IntList:
5024  case T_OidList:
5025  retval = list_copy(from);
5026  break;
5027 
5028  /*
5029  * EXTENSIBLE NODES
5030  */
5031  case T_ExtensibleNode:
5032  retval = _copyExtensibleNode(from);
5033  break;
5034 
5035  /*
5036  * PARSE NODES
5037  */
5038  case T_Query:
5039  retval = _copyQuery(from);
5040  break;
5041  case T_RawStmt:
5042  retval = _copyRawStmt(from);
5043  break;
5044  case T_InsertStmt:
5045  retval = _copyInsertStmt(from);
5046  break;
5047  case T_DeleteStmt:
5048  retval = _copyDeleteStmt(from);
5049  break;
5050  case T_UpdateStmt:
5051  retval = _copyUpdateStmt(from);
5052  break;
5053  case T_SelectStmt:
5054  retval = _copySelectStmt(from);
5055  break;
5056  case T_SetOperationStmt:
5057  retval = _copySetOperationStmt(from);
5058  break;
5059  case T_AlterTableStmt:
5060  retval = _copyAlterTableStmt(from);
5061  break;
5062  case T_AlterTableCmd:
5063  retval = _copyAlterTableCmd(from);
5064  break;
5065  case T_AlterCollationStmt:
5066  retval = _copyAlterCollationStmt(from);
5067  break;
5068  case T_AlterDomainStmt:
5069  retval = _copyAlterDomainStmt(from);
5070  break;
5071  case T_GrantStmt:
5072  retval = _copyGrantStmt(from);
5073  break;
5074  case T_GrantRoleStmt:
5075  retval = _copyGrantRoleStmt(from);
5076  break;
5078  retval = _copyAlterDefaultPrivilegesStmt(from);
5079  break;
5080  case T_DeclareCursorStmt:
5081  retval = _copyDeclareCursorStmt(from);
5082  break;
5083  case T_ClosePortalStmt:
5084  retval = _copyClosePortalStmt(from);
5085  break;
5086  case T_ClusterStmt:
5087  retval = _copyClusterStmt(from);
5088  break;
5089  case T_CopyStmt:
5090  retval = _copyCopyStmt(from);
5091  break;
5092  case T_CreateStmt:
5093  retval = _copyCreateStmt(from);
5094  break;
5095  case T_TableLikeClause:
5096  retval = _copyTableLikeClause(from);
5097  break;
5098  case T_DefineStmt:
5099  retval = _copyDefineStmt(from);
5100  break;
5101  case T_DropStmt:
5102  retval = _copyDropStmt(from);
5103  break;
5104  case T_TruncateStmt:
5105  retval = _copyTruncateStmt(from);
5106  break;
5107  case T_CommentStmt:
5108  retval = _copyCommentStmt(from);
5109  break;
5110  case T_SecLabelStmt:
5111  retval = _copySecLabelStmt(from);
5112  break;
5113  case T_FetchStmt:
5114  retval = _copyFetchStmt(from);
5115  break;
5116  case T_IndexStmt:
5117  retval = _copyIndexStmt(from);
5118  break;
5119  case T_CreateStatsStmt:
5120  retval = _copyCreateStatsStmt(from);
5121  break;
5122  case T_CreateFunctionStmt:
5123  retval = _copyCreateFunctionStmt(from);
5124  break;
5125  case T_FunctionParameter:
5126  retval = _copyFunctionParameter(from);
5127  break;
5128  case T_AlterFunctionStmt:
5129  retval = _copyAlterFunctionStmt(from);
5130  break;
5131  case T_DoStmt:
5132  retval = _copyDoStmt(from);
5133  break;
5134  case T_RenameStmt:
5135  retval = _copyRenameStmt(from);
5136  break;
5138  retval = _copyAlterObjectDependsStmt(from);
5139  break;
5141  retval = _copyAlterObjectSchemaStmt(from);
5142  break;
5143  case T_AlterOwnerStmt:
5144  retval = _copyAlterOwnerStmt(from);
5145  break;
5146  case T_AlterOperatorStmt:
5147  retval = _copyAlterOperatorStmt(from);
5148  break;
5149  case T_RuleStmt:
5150  retval = _copyRuleStmt(from);
5151  break;
5152  case T_NotifyStmt:
5153  retval = _copyNotifyStmt(from);
5154  break;
5155  case T_ListenStmt:
5156  retval = _copyListenStmt(from);
5157  break;
5158  case T_UnlistenStmt:
5159  retval = _copyUnlistenStmt(from);
5160  break;
5161  case T_TransactionStmt:
5162  retval = _copyTransactionStmt(from);
5163  break;
5164  case T_CompositeTypeStmt:
5165  retval = _copyCompositeTypeStmt(from);
5166  break;
5167  case T_CreateEnumStmt:
5168  retval = _copyCreateEnumStmt(from);
5169  break;
5170  case T_CreateRangeStmt:
5171  retval = _copyCreateRangeStmt(from);
5172  break;
5173  case T_AlterEnumStmt:
5174  retval = _copyAlterEnumStmt(from);
5175  break;
5176  case T_ViewStmt:
5177  retval = _copyViewStmt(from);
5178  break;
5179  case T_LoadStmt:
5180  retval = _copyLoadStmt(from);
5181  break;
5182  case T_CreateDomainStmt:
5183  retval = _copyCreateDomainStmt(from);
5184  break;
5185  case T_CreateOpClassStmt:
5186  retval = _copyCreateOpClassStmt(from);
5187  break;
5188  case T_CreateOpClassItem:
5189  retval = _copyCreateOpClassItem(from);
5190  break;
5191  case T_CreateOpFamilyStmt:
5192  retval = _copyCreateOpFamilyStmt(from);
5193  break;
5194  case T_AlterOpFamilyStmt:
5195  retval = _copyAlterOpFamilyStmt(from);
5196  break;
5197  case T_CreatedbStmt:
5198  retval = _copyCreatedbStmt(from);
5199  break;
5200  case T_AlterDatabaseStmt:
5201  retval = _copyAlterDatabaseStmt(from);
5202  break;
5204  retval = _copyAlterDatabaseSetStmt(from);
5205  break;
5206  case T_DropdbStmt:
5207  retval = _copyDropdbStmt(from);
5208  break;
5209  case T_VacuumStmt:
5210  retval = _copyVacuumStmt(from);
5211  break;
5212  case T_ExplainStmt:
5213  retval = _copyExplainStmt(from);
5214  break;
5215  case T_CreateTableAsStmt:
5216  retval = _copyCreateTableAsStmt(from);
5217  break;
5218  case T_RefreshMatViewStmt:
5219  retval = _copyRefreshMatViewStmt(from);
5220  break;
5221  case T_ReplicaIdentityStmt:
5222  retval = _copyReplicaIdentityStmt(from);
5223  break;
5224  case T_AlterSystemStmt:
5225  retval = _copyAlterSystemStmt(from);
5226  break;
5227  case T_CreateSeqStmt:
5228  retval = _copyCreateSeqStmt(from);
5229  break;
5230  case T_AlterSeqStmt:
5231  retval = _copyAlterSeqStmt(from);
5232  break;
5233  case T_VariableSetStmt:
5234  retval = _copyVariableSetStmt(from);
5235  break;
5236  case T_VariableShowStmt:
5237  retval = _copyVariableShowStmt(from);
5238  break;
5239  case T_DiscardStmt:
5240  retval = _copyDiscardStmt(from);
5241  break;
5243  retval = _copyCreateTableSpaceStmt(from);
5244  break;
5245  case T_DropTableSpaceStmt:
5246  retval = _copyDropTableSpaceStmt(from);
5247  break;
5249  retval = _copyAlterTableSpaceOptionsStmt(from);
5250  break;
5252  retval = _copyAlterTableMoveAllStmt(from);
5253  break;
5254  case T_CreateExtensionStmt:
5255  retval = _copyCreateExtensionStmt(from);
5256  break;
5257  case T_AlterExtensionStmt:
5258  retval = _copyAlterExtensionStmt(from);
5259  break;
5261  retval = _copyAlterExtensionContentsStmt(from);
5262  break;
5263  case T_CreateFdwStmt:
5264  retval = _copyCreateFdwStmt(from);
5265  break;
5266  case T_AlterFdwStmt:
5267  retval = _copyAlterFdwStmt(from);
5268  break;
5270  retval = _copyCreateForeignServerStmt(from);
5271  break;
5273  retval = _copyAlterForeignServerStmt(from);
5274  break;
5276  retval = _copyCreateUserMappingStmt(from);
5277  break;
5279  retval = _copyAlterUserMappingStmt(from);
5280  break;
5281  case T_DropUserMappingStmt:
5282  retval = _copyDropUserMappingStmt(from);
5283  break;
5285  retval = _copyCreateForeignTableStmt(from);
5286  break;
5288  retval = _copyImportForeignSchemaStmt(from);
5289  break;
5290  case T_CreateTransformStmt:
5291  retval = _copyCreateTransformStmt(from);
5292  break;
5293  case T_CreateAmStmt:
5294  retval = _copyCreateAmStmt(from);
5295  break;
5296  case T_CreateTrigStmt:
5297  retval = _copyCreateTrigStmt(from);
5298  break;
5299  case T_CreateEventTrigStmt:
5300  retval = _copyCreateEventTrigStmt(from);
5301  break;
5302  case T_AlterEventTrigStmt:
5303  retval = _copyAlterEventTrigStmt(from);
5304  break;
5305  case T_CreatePLangStmt:
5306  retval = _copyCreatePLangStmt(from);
5307  break;
5308  case T_CreateRoleStmt:
5309  retval = _copyCreateRoleStmt(from);
5310  break;
5311  case T_AlterRoleStmt:
5312  retval = _copyAlterRoleStmt(from);
5313  break;
5314  case T_AlterRoleSetStmt:
5315  retval = _copyAlterRoleSetStmt(from);
5316  break;
5317  case T_DropRoleStmt:
5318  retval = _copyDropRoleStmt(from);
5319  break;
5320  case T_LockStmt:
5321  retval = _copyLockStmt(from);
5322  break;
5323  case T_ConstraintsSetStmt:
5324  retval = _copyConstraintsSetStmt(from);
5325  break;
5326  case T_ReindexStmt:
5327  retval = _copyReindexStmt(from);
5328  break;
5329  case T_CheckPointStmt:
5330  retval = (void *) makeNode(CheckPointStmt);
5331  break;
5332  case T_CreateSchemaStmt:
5333  retval = _copyCreateSchemaStmt(from);
5334  break;
5336  retval = _copyCreateConversionStmt(from);
5337  break;
5338  case T_CreateCastStmt:
5339  retval = _copyCreateCastStmt(from);
5340  break;
5341  case T_PrepareStmt:
5342  retval = _copyPrepareStmt(from);
5343  break;
5344  case T_ExecuteStmt:
5345  retval = _copyExecuteStmt(from);
5346  break;
5347  case T_DeallocateStmt:
5348  retval = _copyDeallocateStmt(from);
5349  break;
5350  case T_DropOwnedStmt:
5351  retval = _copyDropOwnedStmt(from);
5352  break;
5353  case T_ReassignOwnedStmt:
5354  retval = _copyReassignOwnedStmt(from);
5355  break;
5357  retval = _copyAlterTSDictionaryStmt(from);
5358  break;
5360  retval = _copyAlterTSConfigurationStmt(from);
5361  break;
5362  case T_CreatePolicyStmt:
5363  retval = _copyCreatePolicyStmt(from);
5364  break;
5365  case T_AlterPolicyStmt:
5366  retval = _copyAlterPolicyStmt(from);
5367  break;
5369  retval = _copyCreatePublicationStmt(from);
5370  break;
5372  retval = _copyAlterPublicationStmt(from);
5373  break;
5375  retval = _copyCreateSubscriptionStmt(from);
5376  break;
5378  retval = _copyAlterSubscriptionStmt(from);
5379  break;
5381  retval = _copyDropSubscriptionStmt(from);
5382  break;
5383  case T_A_Expr:
5384  retval = _copyAExpr(from);
5385  break;
5386  case T_ColumnRef:
5387  retval = _copyColumnRef(from);
5388  break;
5389  case T_ParamRef:
5390  retval = _copyParamRef(from);
5391  break;
5392  case T_A_Const:
5393  retval = _copyAConst(from);
5394  break;
5395  case T_FuncCall:
5396  retval = _copyFuncCall(from);
5397  break;
5398  case T_A_Star:
5399  retval = _copyAStar(from);
5400  break;
5401  case T_A_Indices:
5402  retval = _copyAIndices(from);
5403  break;
5404  case T_A_Indirection:
5405  retval = _copyA_Indirection(from);
5406  break;
5407  case T_A_ArrayExpr:
5408  retval = _copyA_ArrayExpr(from);
5409  break;
5410  case T_ResTarget:
5411  retval = _copyResTarget(from);
5412  break;
5413  case T_MultiAssignRef:
5414  retval = _copyMultiAssignRef(from);
5415  break;
5416  case T_TypeCast:
5417  retval = _copyTypeCast(from);
5418  break;
5419  case T_CollateClause:
5420  retval = _copyCollateClause(from);
5421  break;
5422  case T_SortBy:
5423  retval = _copySortBy(from);
5424  break;
5425  case T_WindowDef:
5426  retval = _copyWindowDef(from);
5427  break;
5428  case T_RangeSubselect:
5429  retval = _copyRangeSubselect(from);
5430  break;
5431  case T_RangeFunction:
5432  retval = _copyRangeFunction(from);
5433  break;
5434  case T_RangeTableSample:
5435  retval = _copyRangeTableSample(from);
5436  break;
5437  case T_RangeTableFunc:
5438  retval = _copyRangeTableFunc(from);
5439  break;
5440  case T_RangeTableFuncCol:
5441  retval = _copyRangeTableFuncCol(from);
5442  break;
5443  case T_TypeName:
5444  retval = _copyTypeName(from);
5445  break;
5446  case T_IndexElem:
5447  retval = _copyIndexElem(from);
5448  break;
5449  case T_ColumnDef:
5450  retval = _copyColumnDef(from);
5451  break;
5452  case T_Constraint:
5453  retval = _copyConstraint(from);
5454  break;
5455  case T_DefElem:
5456  retval = _copyDefElem(from);
5457  break;
5458  case T_LockingClause:
5459  retval = _copyLockingClause(from);
5460  break;
5461  case T_RangeTblEntry:
5462  retval = _copyRangeTblEntry(from);
5463  break;
5464  case T_RangeTblFunction:
5465  retval = _copyRangeTblFunction(from);
5466  break;
5467  case T_TableSampleClause:
5468  retval = _copyTableSampleClause(from);
5469  break;
5470  case T_WithCheckOption:
5471  retval = _copyWithCheckOption(from);
5472  break;
5473  case T_SortGroupClause:
5474  retval = _copySortGroupClause(from);
5475  break;
5476  case T_GroupingSet:
5477  retval = _copyGroupingSet(from);
5478  break;
5479  case T_WindowClause:
5480  retval = _copyWindowClause(from);
5481  break;
5482  case T_RowMarkClause:
5483  retval = _copyRowMarkClause(from);
5484  break;
5485  case T_WithClause:
5486  retval = _copyWithClause(from);
5487  break;
5488  case T_InferClause:
5489  retval = _copyInferClause(from);
5490  break;
5491  case T_OnConflictClause:
5492  retval = _copyOnConflictClause(from);
5493  break;
5494  case T_CommonTableExpr:
5495  retval = _copyCommonTableExpr(from);
5496  break;
5497  case T_ObjectWithArgs:
5498  retval = _copyObjectWithArgs(from);
5499  break;
5500  case T_AccessPriv:
5501  retval = _copyAccessPriv(from);
5502  break;
5503  case T_XmlSerialize:
5504  retval = _copyXmlSerialize(from);
5505  break;
5506  case T_RoleSpec:
5507  retval = _copyRoleSpec(from);
5508  break;
5509  case T_TriggerTransition:
5510  retval = _copyTriggerTransition(from);
5511  break;
5512  case T_PartitionSpec:
5513  retval = _copyPartitionSpec(from);
5514  break;
5515  case T_PartitionElem:
5516  retval = _copyPartitionElem(from);
5517  break;
5518  case T_PartitionBoundSpec:
5519  retval = _copyPartitionBoundSpec(from);
5520  break;
5521  case T_PartitionRangeDatum:
5522  retval = _copyPartitionRangeDatum(from);
5523  break;
5524  case T_PartitionCmd:
5525  retval = _copyPartitionCmd(from);
5526  break;
5527 
5528  /*
5529  * MISCELLANEOUS NODES
5530  */
5531  case T_ForeignKeyCacheInfo:
5532  retval = _copyForeignKeyCacheInfo(from);
5533  break;
5534 
5535  default:
5536  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
5537  retval = 0; /* keep compiler quiet */
5538  break;
5539  }
5540 
5541  return retval;
5542 }
Datum constvalue
Definition: primnodes.h:196
int numCols
Definition: plannodes.h:823
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:2394
static CreateEnumStmt * _copyCreateEnumStmt(const CreateEnumStmt *from)
Definition: copyfuncs.c:3586
static RefreshMatViewStmt * _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
Definition: copyfuncs.c:3796
static RangeSubselect * _copyRangeSubselect(const RangeSubselect *from)
Definition: copyfuncs.c:2684
int ordNumCols
Definition: plannodes.h:808
static AlterSystemStmt * _copyAlterSystemStmt(const AlterSystemStmt *from)
Definition: copyfuncs.c:3819
static DeallocateStmt * _copyDeallocateStmt(const DeallocateStmt *from)
Definition: copyfuncs.c:4327
#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:4154
static SeqScan * _copySeqScan(const SeqScan *from)
Definition: copyfuncs.c:430
int numCols
Definition: plannodes.h:787
static AlterTableMoveAllStmt * _copyAlterTableMoveAllStmt(const AlterTableMoveAllStmt *from)
Definition: copyfuncs.c:3925
static DiscardStmt * _copyDiscardStmt(const DiscardStmt *from)
Definition: copyfuncs.c:3879
static DeleteStmt * _copyDeleteStmt(const DeleteStmt *from)
Definition: copyfuncs.c:2993
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:3148
Definition: nodes.h:77
static FromExpr * _copyFromExpr(const FromExpr *from)
Definition: copyfuncs.c:2094
static DropStmt * _copyDropStmt(const DropStmt *from)
Definition: copyfuncs.c:3293
static Plan * _copyPlan(const Plan *from)
Definition: copyfuncs.c:137
static LockStmt * _copyLockStmt(const LockStmt *from)
Definition: copyfuncs.c:4227
static RowMarkClause * _copyRowMarkClause(const RowMarkClause *from)
Definition: copyfuncs.c:2412
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:4014
static RowExpr * _copyRowExpr(const RowExpr *from)
Definition: copyfuncs.c:1811
static VariableShowStmt * _copyVariableShowStmt(const VariableShowStmt *from)
Definition: copyfuncs.c:3869
Definition: nodes.h:79
static TransactionStmt * _copyTransactionStmt(const TransactionStmt *from)
Definition: copyfuncs.c:3563
bool constbyval
Definition: primnodes.h:199
static TableLikeClause * _copyTableLikeClause(const TableLikeClause *from)
Definition: copyfuncs.c:3267
static CreatePolicyStmt * _copyCreatePolicyStmt(const CreatePolicyStmt *from)
Definition: copyfuncs.c:4386
static AlterEnumStmt * _copyAlterEnumStmt(const AlterEnumStmt *from)
Definition: copyfuncs.c:3608
Definition: nodes.h:53
static AlterExtensionStmt * _copyAlterExtensionStmt(const AlterExtensionStmt *from)
Definition: copyfuncs.c:3951
static DeclareCursorStmt * _copyDeclareCursorStmt(const DeclareCursorStmt *from)
Definition: copyfuncs.c:3185
static A_Const * _copyAConst(const A_Const *from)
Definition: copyfuncs.c:2519
static HashJoin * _copyHashJoin(const HashJoin *from)
Definition: copyfuncs.c:882
static AlterFdwStmt * _copyAlterFdwStmt(const AlterFdwStmt *from)
Definition: copyfuncs.c:3987
static PartitionSpec * _copyPartitionSpec(const PartitionSpec *from)
Definition: copyfuncs.c:4416
static GroupingSet * _copyGroupingSet(const GroupingSet *from)
Definition: copyfuncs.c:2382
static DropRoleStmt * _copyDropRoleStmt(const DropRoleStmt *from)
Definition: copyfuncs.c:4216
static CreateAmStmt * _copyCreateAmStmt(const CreateAmStmt *from)
Definition: copyfuncs.c:4106
static AlternativeSubPlan * _copyAlternativeSubPlan(const AlternativeSubPlan *from)
Definition: copyfuncs.c:1613
static UnlistenStmt * _copyUnlistenStmt(const UnlistenStmt *from)
Definition: copyfuncs.c:3553
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:4370
static CreateOpClassStmt * _copyCreateOpClassStmt(const CreateOpClassStmt *from)
Definition: copyfuncs.c:3661
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:2253
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:3207
static FunctionScan * _copyFunctionScan(const FunctionScan *from)
Definition: copyfuncs.c:606
static AlterFunctionStmt * _copyAlterFunctionStmt(const AlterFunctionStmt *from)
Definition: copyfuncs.c:3427
static SortBy * _copySortBy(const SortBy *from)
Definition: copyfuncs.c:2653
static MergeJoin * _copyMergeJoin(const MergeJoin *from)
Definition: copyfuncs.c:851
static AlterCollationStmt * _copyAlterCollationStmt(const AlterCollationStmt *from)
Definition: copyfuncs.c:3094
static RuleStmt * _copyRuleStmt(const RuleStmt *from)
Definition: copyfuncs.c:3516
static ImportForeignSchemaStmt * _copyImportForeignSchemaStmt(const ImportForeignSchemaStmt *from)
Definition: copyfuncs.c:4077
static FuncCall * _copyFuncCall(const FuncCall *from)
Definition: copyfuncs.c:2550
static RangeVar * _copyRangeVar(const RangeVar *from)
Definition: copyfuncs.c:1202
static CreatedbStmt * _copyCreatedbStmt(const CreatedbStmt *from)
Definition: copyfuncs.c:3715
static CopyStmt * _copyCopyStmt(const CopyStmt *from)
Definition: copyfuncs.c:3219
List * list_copy(const List *oldlist)
Definition: list.c:1160
static PartitionBoundSpec * _copyPartitionBoundSpec(const PartitionBoundSpec *from)
Definition: copyfuncs.c:4442
static CreateTableSpaceStmt * _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
Definition: copyfuncs.c:3889
static GrantStmt * _copyGrantStmt(const GrantStmt *from)
Definition: copyfuncs.c:3119
static Value * _copyValue(const Value *from)
Definition: copyfuncs.c:4612
Definition: nodes.h:48
static AlterOperatorStmt * _copyAlterOperatorStmt(const AlterOperatorStmt *from)
Definition: copyfuncs.c:3505
static Alias * _copyAlias(const Alias *from)
Definition: copyfuncs.c:1188
return result
Definition: formatting.c:1632
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:2600
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:2508
Definition: nodes.h:75
static IndexStmt * _copyIndexStmt(const IndexStmt *from)
Definition: copyfuncs.c: