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