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