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