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