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