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-2022, 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 an inline array */
57 #define COPY_ARRAY_FIELD(fldname) \
58  memcpy(newnode->fldname, from->fldname, sizeof(newnode->fldname))
59 
60 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
61 #define COPY_POINTER_FIELD(fldname, sz) \
62  do { \
63  Size _size = (sz); \
64  if (_size > 0) \
65  { \
66  newnode->fldname = palloc(_size); \
67  memcpy(newnode->fldname, from->fldname, _size); \
68  } \
69  } while (0)
70 
71 /* Copy a parse location field (for Copy, this is same as scalar case) */
72 #define COPY_LOCATION_FIELD(fldname) \
73  (newnode->fldname = from->fldname)
74 
75 
76 /* ****************************************************************
77  * plannodes.h copy functions
78  * ****************************************************************
79  */
80 
81 /*
82  * _copyPlannedStmt
83  */
84 static PlannedStmt *
86 {
87  PlannedStmt *newnode = makeNode(PlannedStmt);
88 
89  COPY_SCALAR_FIELD(commandType);
90  COPY_SCALAR_FIELD(queryId);
91  COPY_SCALAR_FIELD(hasReturning);
92  COPY_SCALAR_FIELD(hasModifyingCTE);
93  COPY_SCALAR_FIELD(canSetTag);
94  COPY_SCALAR_FIELD(transientPlan);
95  COPY_SCALAR_FIELD(dependsOnRole);
96  COPY_SCALAR_FIELD(parallelModeNeeded);
97  COPY_SCALAR_FIELD(jitFlags);
98  COPY_NODE_FIELD(planTree);
99  COPY_NODE_FIELD(rtable);
100  COPY_NODE_FIELD(resultRelations);
101  COPY_NODE_FIELD(appendRelations);
102  COPY_NODE_FIELD(subplans);
103  COPY_BITMAPSET_FIELD(rewindPlanIDs);
104  COPY_NODE_FIELD(rowMarks);
105  COPY_NODE_FIELD(relationOids);
106  COPY_NODE_FIELD(invalItems);
107  COPY_NODE_FIELD(paramExecTypes);
108  COPY_NODE_FIELD(utilityStmt);
109  COPY_LOCATION_FIELD(stmt_location);
110  COPY_SCALAR_FIELD(stmt_len);
111 
112  return newnode;
113 }
114 
115 /*
116  * CopyPlanFields
117  *
118  * This function copies the fields of the Plan node. It is used by
119  * all the copy functions for classes which inherit from Plan.
120  */
121 static void
122 CopyPlanFields(const Plan *from, Plan *newnode)
123 {
124  COPY_SCALAR_FIELD(startup_cost);
125  COPY_SCALAR_FIELD(total_cost);
126  COPY_SCALAR_FIELD(plan_rows);
127  COPY_SCALAR_FIELD(plan_width);
128  COPY_SCALAR_FIELD(parallel_aware);
129  COPY_SCALAR_FIELD(parallel_safe);
130  COPY_SCALAR_FIELD(async_capable);
131  COPY_SCALAR_FIELD(plan_node_id);
132  COPY_NODE_FIELD(targetlist);
133  COPY_NODE_FIELD(qual);
134  COPY_NODE_FIELD(lefttree);
135  COPY_NODE_FIELD(righttree);
136  COPY_NODE_FIELD(initPlan);
137  COPY_BITMAPSET_FIELD(extParam);
138  COPY_BITMAPSET_FIELD(allParam);
139 }
140 
141 /*
142  * _copyPlan
143  */
144 static Plan *
145 _copyPlan(const Plan *from)
146 {
147  Plan *newnode = makeNode(Plan);
148 
149  /*
150  * copy node superclass fields
151  */
152  CopyPlanFields(from, newnode);
153 
154  return newnode;
155 }
156 
157 
158 /*
159  * _copyResult
160  */
161 static Result *
162 _copyResult(const Result *from)
163 {
164  Result *newnode = makeNode(Result);
165 
166  /*
167  * copy node superclass fields
168  */
169  CopyPlanFields((const Plan *) from, (Plan *) newnode);
170 
171  /*
172  * copy remainder of node
173  */
174  COPY_NODE_FIELD(resconstantqual);
175 
176  return newnode;
177 }
178 
179 /*
180  * _copyProjectSet
181  */
182 static ProjectSet *
184 {
185  ProjectSet *newnode = makeNode(ProjectSet);
186 
187  /*
188  * copy node superclass fields
189  */
190  CopyPlanFields((const Plan *) from, (Plan *) newnode);
191 
192  return newnode;
193 }
194 
195 /*
196  * _copyModifyTable
197  */
198 static ModifyTable *
200 {
201  ModifyTable *newnode = makeNode(ModifyTable);
202 
203  /*
204  * copy node superclass fields
205  */
206  CopyPlanFields((const Plan *) from, (Plan *) newnode);
207 
208  /*
209  * copy remainder of node
210  */
211  COPY_SCALAR_FIELD(operation);
212  COPY_SCALAR_FIELD(canSetTag);
213  COPY_SCALAR_FIELD(nominalRelation);
214  COPY_SCALAR_FIELD(rootRelation);
215  COPY_SCALAR_FIELD(partColsUpdated);
216  COPY_NODE_FIELD(resultRelations);
217  COPY_NODE_FIELD(updateColnosLists);
218  COPY_NODE_FIELD(withCheckOptionLists);
219  COPY_NODE_FIELD(returningLists);
220  COPY_NODE_FIELD(fdwPrivLists);
221  COPY_BITMAPSET_FIELD(fdwDirectModifyPlans);
222  COPY_NODE_FIELD(rowMarks);
223  COPY_SCALAR_FIELD(epqParam);
224  COPY_SCALAR_FIELD(onConflictAction);
225  COPY_NODE_FIELD(arbiterIndexes);
226  COPY_NODE_FIELD(onConflictSet);
227  COPY_NODE_FIELD(onConflictCols);
228  COPY_NODE_FIELD(onConflictWhere);
229  COPY_SCALAR_FIELD(exclRelRTI);
230  COPY_NODE_FIELD(exclRelTlist);
231  COPY_NODE_FIELD(mergeActionLists);
232 
233  return newnode;
234 }
235 
236 /*
237  * _copyAppend
238  */
239 static Append *
240 _copyAppend(const Append *from)
241 {
242  Append *newnode = makeNode(Append);
243 
244  /*
245  * copy node superclass fields
246  */
247  CopyPlanFields((const Plan *) from, (Plan *) newnode);
248 
249  /*
250  * copy remainder of node
251  */
252  COPY_BITMAPSET_FIELD(apprelids);
253  COPY_NODE_FIELD(appendplans);
254  COPY_SCALAR_FIELD(nasyncplans);
255  COPY_SCALAR_FIELD(first_partial_plan);
256  COPY_NODE_FIELD(part_prune_info);
257 
258  return newnode;
259 }
260 
261 /*
262  * _copyMergeAppend
263  */
264 static MergeAppend *
266 {
267  MergeAppend *newnode = makeNode(MergeAppend);
268 
269  /*
270  * copy node superclass fields
271  */
272  CopyPlanFields((const Plan *) from, (Plan *) newnode);
273 
274  /*
275  * copy remainder of node
276  */
277  COPY_BITMAPSET_FIELD(apprelids);
278  COPY_NODE_FIELD(mergeplans);
279  COPY_SCALAR_FIELD(numCols);
280  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
281  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
282  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
283  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
284  COPY_NODE_FIELD(part_prune_info);
285 
286  return newnode;
287 }
288 
289 /*
290  * _copyRecursiveUnion
291  */
292 static RecursiveUnion *
294 {
296 
297  /*
298  * copy node superclass fields
299  */
300  CopyPlanFields((const Plan *) from, (Plan *) newnode);
301 
302  /*
303  * copy remainder of node
304  */
305  COPY_SCALAR_FIELD(wtParam);
306  COPY_SCALAR_FIELD(numCols);
307  COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
308  COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
309  COPY_POINTER_FIELD(dupCollations, from->numCols * sizeof(Oid));
310  COPY_SCALAR_FIELD(numGroups);
311 
312  return newnode;
313 }
314 
315 /*
316  * _copyBitmapAnd
317  */
318 static BitmapAnd *
320 {
321  BitmapAnd *newnode = makeNode(BitmapAnd);
322 
323  /*
324  * copy node superclass fields
325  */
326  CopyPlanFields((const Plan *) from, (Plan *) newnode);
327 
328  /*
329  * copy remainder of node
330  */
331  COPY_NODE_FIELD(bitmapplans);
332 
333  return newnode;
334 }
335 
336 /*
337  * _copyBitmapOr
338  */
339 static BitmapOr *
341 {
342  BitmapOr *newnode = makeNode(BitmapOr);
343 
344  /*
345  * copy node superclass fields
346  */
347  CopyPlanFields((const Plan *) from, (Plan *) newnode);
348 
349  /*
350  * copy remainder of node
351  */
352  COPY_SCALAR_FIELD(isshared);
353  COPY_NODE_FIELD(bitmapplans);
354 
355  return newnode;
356 }
357 
358 /*
359  * _copyGather
360  */
361 static Gather *
362 _copyGather(const Gather *from)
363 {
364  Gather *newnode = makeNode(Gather);
365 
366  /*
367  * copy node superclass fields
368  */
369  CopyPlanFields((const Plan *) from, (Plan *) newnode);
370 
371  /*
372  * copy remainder of node
373  */
374  COPY_SCALAR_FIELD(num_workers);
375  COPY_SCALAR_FIELD(rescan_param);
376  COPY_SCALAR_FIELD(single_copy);
377  COPY_SCALAR_FIELD(invisible);
378  COPY_BITMAPSET_FIELD(initParam);
379 
380  return newnode;
381 }
382 
383 /*
384  * _copyGatherMerge
385  */
386 static GatherMerge *
388 {
389  GatherMerge *newnode = makeNode(GatherMerge);
390 
391  /*
392  * copy node superclass fields
393  */
394  CopyPlanFields((const Plan *) from, (Plan *) newnode);
395 
396  /*
397  * copy remainder of node
398  */
399  COPY_SCALAR_FIELD(num_workers);
400  COPY_SCALAR_FIELD(rescan_param);
401  COPY_SCALAR_FIELD(numCols);
402  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
403  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
404  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
405  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
406  COPY_BITMAPSET_FIELD(initParam);
407 
408  return newnode;
409 }
410 
411 /*
412  * CopyScanFields
413  *
414  * This function copies the fields of the Scan node. It is used by
415  * all the copy functions for classes which inherit from Scan.
416  */
417 static void
418 CopyScanFields(const Scan *from, Scan *newnode)
419 {
420  CopyPlanFields((const Plan *) from, (Plan *) newnode);
421 
422  COPY_SCALAR_FIELD(scanrelid);
423 }
424 
425 /*
426  * _copyScan
427  */
428 static Scan *
429 _copyScan(const Scan *from)
430 {
431  Scan *newnode = makeNode(Scan);
432 
433  /*
434  * copy node superclass fields
435  */
436  CopyScanFields((const Scan *) from, (Scan *) newnode);
437 
438  return newnode;
439 }
440 
441 /*
442  * _copySeqScan
443  */
444 static SeqScan *
445 _copySeqScan(const SeqScan *from)
446 {
447  SeqScan *newnode = makeNode(SeqScan);
448 
449  /*
450  * copy node superclass fields
451  */
452  CopyScanFields((const Scan *) from, (Scan *) newnode);
453 
454  return newnode;
455 }
456 
457 /*
458  * _copySampleScan
459  */
460 static SampleScan *
462 {
463  SampleScan *newnode = makeNode(SampleScan);
464 
465  /*
466  * copy node superclass fields
467  */
468  CopyScanFields((const Scan *) from, (Scan *) newnode);
469 
470  /*
471  * copy remainder of node
472  */
473  COPY_NODE_FIELD(tablesample);
474 
475  return newnode;
476 }
477 
478 /*
479  * _copyIndexScan
480  */
481 static IndexScan *
483 {
484  IndexScan *newnode = makeNode(IndexScan);
485 
486  /*
487  * copy node superclass fields
488  */
489  CopyScanFields((const Scan *) from, (Scan *) newnode);
490 
491  /*
492  * copy remainder of node
493  */
494  COPY_SCALAR_FIELD(indexid);
495  COPY_NODE_FIELD(indexqual);
496  COPY_NODE_FIELD(indexqualorig);
497  COPY_NODE_FIELD(indexorderby);
498  COPY_NODE_FIELD(indexorderbyorig);
499  COPY_NODE_FIELD(indexorderbyops);
500  COPY_SCALAR_FIELD(indexorderdir);
501 
502  return newnode;
503 }
504 
505 /*
506  * _copyIndexOnlyScan
507  */
508 static IndexOnlyScan *
510 {
512 
513  /*
514  * copy node superclass fields
515  */
516  CopyScanFields((const Scan *) from, (Scan *) newnode);
517 
518  /*
519  * copy remainder of node
520  */
521  COPY_SCALAR_FIELD(indexid);
522  COPY_NODE_FIELD(indexqual);
523  COPY_NODE_FIELD(recheckqual);
524  COPY_NODE_FIELD(indexorderby);
525  COPY_NODE_FIELD(indextlist);
526  COPY_SCALAR_FIELD(indexorderdir);
527 
528  return newnode;
529 }
530 
531 /*
532  * _copyBitmapIndexScan
533  */
534 static BitmapIndexScan *
536 {
538 
539  /*
540  * copy node superclass fields
541  */
542  CopyScanFields((const Scan *) from, (Scan *) newnode);
543 
544  /*
545  * copy remainder of node
546  */
547  COPY_SCALAR_FIELD(indexid);
548  COPY_SCALAR_FIELD(isshared);
549  COPY_NODE_FIELD(indexqual);
550  COPY_NODE_FIELD(indexqualorig);
551 
552  return newnode;
553 }
554 
555 /*
556  * _copyBitmapHeapScan
557  */
558 static BitmapHeapScan *
560 {
562 
563  /*
564  * copy node superclass fields
565  */
566  CopyScanFields((const Scan *) from, (Scan *) newnode);
567 
568  /*
569  * copy remainder of node
570  */
571  COPY_NODE_FIELD(bitmapqualorig);
572 
573  return newnode;
574 }
575 
576 /*
577  * _copyTidScan
578  */
579 static TidScan *
580 _copyTidScan(const TidScan *from)
581 {
582  TidScan *newnode = makeNode(TidScan);
583 
584  /*
585  * copy node superclass fields
586  */
587  CopyScanFields((const Scan *) from, (Scan *) newnode);
588 
589  /*
590  * copy remainder of node
591  */
592  COPY_NODE_FIELD(tidquals);
593 
594  return newnode;
595 }
596 
597 /*
598  * _copyTidRangeScan
599  */
600 static TidRangeScan *
602 {
603  TidRangeScan *newnode = makeNode(TidRangeScan);
604 
605  /*
606  * copy node superclass fields
607  */
608  CopyScanFields((const Scan *) from, (Scan *) newnode);
609 
610  /*
611  * copy remainder of node
612  */
613  COPY_NODE_FIELD(tidrangequals);
614 
615  return newnode;
616 }
617 
618 /*
619  * _copySubqueryScan
620  */
621 static SubqueryScan *
623 {
624  SubqueryScan *newnode = makeNode(SubqueryScan);
625 
626  /*
627  * copy node superclass fields
628  */
629  CopyScanFields((const Scan *) from, (Scan *) newnode);
630 
631  /*
632  * copy remainder of node
633  */
634  COPY_NODE_FIELD(subplan);
635  COPY_SCALAR_FIELD(scanstatus);
636 
637  return newnode;
638 }
639 
640 /*
641  * _copyFunctionScan
642  */
643 static FunctionScan *
645 {
646  FunctionScan *newnode = makeNode(FunctionScan);
647 
648  /*
649  * copy node superclass fields
650  */
651  CopyScanFields((const Scan *) from, (Scan *) newnode);
652 
653  /*
654  * copy remainder of node
655  */
657  COPY_SCALAR_FIELD(funcordinality);
658 
659  return newnode;
660 }
661 
662 /*
663  * _copyTableFuncScan
664  */
665 static TableFuncScan *
667 {
669 
670  /*
671  * copy node superclass fields
672  */
673  CopyScanFields((const Scan *) from, (Scan *) newnode);
674 
675  /*
676  * copy remainder of node
677  */
678  COPY_NODE_FIELD(tablefunc);
679 
680  return newnode;
681 }
682 
683 /*
684  * _copyValuesScan
685  */
686 static ValuesScan *
688 {
689  ValuesScan *newnode = makeNode(ValuesScan);
690 
691  /*
692  * copy node superclass fields
693  */
694  CopyScanFields((const Scan *) from, (Scan *) newnode);
695 
696  /*
697  * copy remainder of node
698  */
699  COPY_NODE_FIELD(values_lists);
700 
701  return newnode;
702 }
703 
704 /*
705  * _copyCteScan
706  */
707 static CteScan *
708 _copyCteScan(const CteScan *from)
709 {
710  CteScan *newnode = makeNode(CteScan);
711 
712  /*
713  * copy node superclass fields
714  */
715  CopyScanFields((const Scan *) from, (Scan *) newnode);
716 
717  /*
718  * copy remainder of node
719  */
720  COPY_SCALAR_FIELD(ctePlanId);
721  COPY_SCALAR_FIELD(cteParam);
722 
723  return newnode;
724 }
725 
726 /*
727  * _copyNamedTuplestoreScan
728  */
729 static NamedTuplestoreScan *
731 {
733 
734  /*
735  * copy node superclass fields
736  */
737  CopyScanFields((const Scan *) from, (Scan *) newnode);
738 
739  /*
740  * copy remainder of node
741  */
742  COPY_STRING_FIELD(enrname);
743 
744  return newnode;
745 }
746 
747 /*
748  * _copyWorkTableScan
749  */
750 static WorkTableScan *
752 {
754 
755  /*
756  * copy node superclass fields
757  */
758  CopyScanFields((const Scan *) from, (Scan *) newnode);
759 
760  /*
761  * copy remainder of node
762  */
763  COPY_SCALAR_FIELD(wtParam);
764 
765  return newnode;
766 }
767 
768 /*
769  * _copyForeignScan
770  */
771 static ForeignScan *
773 {
774  ForeignScan *newnode = makeNode(ForeignScan);
775 
776  /*
777  * copy node superclass fields
778  */
779  CopyScanFields((const Scan *) from, (Scan *) newnode);
780 
781  /*
782  * copy remainder of node
783  */
784  COPY_SCALAR_FIELD(operation);
785  COPY_SCALAR_FIELD(resultRelation);
786  COPY_SCALAR_FIELD(fs_server);
787  COPY_NODE_FIELD(fdw_exprs);
788  COPY_NODE_FIELD(fdw_private);
789  COPY_NODE_FIELD(fdw_scan_tlist);
790  COPY_NODE_FIELD(fdw_recheck_quals);
791  COPY_BITMAPSET_FIELD(fs_relids);
792  COPY_SCALAR_FIELD(fsSystemCol);
793 
794  return newnode;
795 }
796 
797 /*
798  * _copyCustomScan
799  */
800 static CustomScan *
802 {
803  CustomScan *newnode = makeNode(CustomScan);
804 
805  /*
806  * copy node superclass fields
807  */
808  CopyScanFields((const Scan *) from, (Scan *) newnode);
809 
810  /*
811  * copy remainder of node
812  */
813  COPY_SCALAR_FIELD(flags);
814  COPY_NODE_FIELD(custom_plans);
815  COPY_NODE_FIELD(custom_exprs);
816  COPY_NODE_FIELD(custom_private);
817  COPY_NODE_FIELD(custom_scan_tlist);
818  COPY_BITMAPSET_FIELD(custom_relids);
819 
820  /*
821  * NOTE: The method field of CustomScan is required to be a pointer to a
822  * static table of callback functions. So we don't copy the table itself,
823  * just reference the original one.
824  */
825  COPY_SCALAR_FIELD(methods);
826 
827  return newnode;
828 }
829 
830 /*
831  * CopyJoinFields
832  *
833  * This function copies the fields of the Join node. It is used by
834  * all the copy functions for classes which inherit from Join.
835  */
836 static void
837 CopyJoinFields(const Join *from, Join *newnode)
838 {
839  CopyPlanFields((const Plan *) from, (Plan *) newnode);
840 
841  COPY_SCALAR_FIELD(jointype);
842  COPY_SCALAR_FIELD(inner_unique);
843  COPY_NODE_FIELD(joinqual);
844 }
845 
846 
847 /*
848  * _copyJoin
849  */
850 static Join *
851 _copyJoin(const Join *from)
852 {
853  Join *newnode = makeNode(Join);
854 
855  /*
856  * copy node superclass fields
857  */
858  CopyJoinFields(from, newnode);
859 
860  return newnode;
861 }
862 
863 
864 /*
865  * _copyNestLoop
866  */
867 static NestLoop *
869 {
870  NestLoop *newnode = makeNode(NestLoop);
871 
872  /*
873  * copy node superclass fields
874  */
875  CopyJoinFields((const Join *) from, (Join *) newnode);
876 
877  /*
878  * copy remainder of node
879  */
880  COPY_NODE_FIELD(nestParams);
881 
882  return newnode;
883 }
884 
885 
886 /*
887  * _copyMergeJoin
888  */
889 static MergeJoin *
891 {
892  MergeJoin *newnode = makeNode(MergeJoin);
893  int numCols;
894 
895  /*
896  * copy node superclass fields
897  */
898  CopyJoinFields((const Join *) from, (Join *) newnode);
899 
900  /*
901  * copy remainder of node
902  */
903  COPY_SCALAR_FIELD(skip_mark_restore);
904  COPY_NODE_FIELD(mergeclauses);
905  numCols = list_length(from->mergeclauses);
906  COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
907  COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
908  COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
909  COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
910 
911  return newnode;
912 }
913 
914 /*
915  * _copyHashJoin
916  */
917 static HashJoin *
919 {
920  HashJoin *newnode = makeNode(HashJoin);
921 
922  /*
923  * copy node superclass fields
924  */
925  CopyJoinFields((const Join *) from, (Join *) newnode);
926 
927  /*
928  * copy remainder of node
929  */
930  COPY_NODE_FIELD(hashclauses);
931  COPY_NODE_FIELD(hashoperators);
932  COPY_NODE_FIELD(hashcollations);
933  COPY_NODE_FIELD(hashkeys);
934 
935  return newnode;
936 }
937 
938 
939 /*
940  * _copyMaterial
941  */
942 static Material *
944 {
945  Material *newnode = makeNode(Material);
946 
947  /*
948  * copy node superclass fields
949  */
950  CopyPlanFields((const Plan *) from, (Plan *) newnode);
951 
952  return newnode;
953 }
954 
955 
956 /*
957  * _copyMemoize
958  */
959 static Memoize *
960 _copyMemoize(const Memoize *from)
961 {
962  Memoize *newnode = makeNode(Memoize);
963 
964  /*
965  * copy node superclass fields
966  */
967  CopyPlanFields((const Plan *) from, (Plan *) newnode);
968 
969  /*
970  * copy remainder of node
971  */
972  COPY_SCALAR_FIELD(numKeys);
973  COPY_POINTER_FIELD(hashOperators, sizeof(Oid) * from->numKeys);
974  COPY_POINTER_FIELD(collations, sizeof(Oid) * from->numKeys);
975  COPY_NODE_FIELD(param_exprs);
976  COPY_SCALAR_FIELD(singlerow);
977  COPY_SCALAR_FIELD(binary_mode);
978  COPY_SCALAR_FIELD(est_entries);
979  COPY_BITMAPSET_FIELD(keyparamids);
980 
981  return newnode;
982 }
983 
984 
985 /*
986  * CopySortFields
987  *
988  * This function copies the fields of the Sort node. It is used by
989  * all the copy functions for classes which inherit from Sort.
990  */
991 static void
992 CopySortFields(const Sort *from, Sort *newnode)
993 {
994  CopyPlanFields((const Plan *) from, (Plan *) newnode);
995 
996  COPY_SCALAR_FIELD(numCols);
997  COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
998  COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
999  COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
1000  COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
1001 }
1002 
1003 /*
1004  * _copySort
1005  */
1006 static Sort *
1007 _copySort(const Sort *from)
1008 {
1009  Sort *newnode = makeNode(Sort);
1010 
1011  /*
1012  * copy node superclass fields
1013  */
1014  CopySortFields(from, newnode);
1015 
1016  return newnode;
1017 }
1018 
1019 
1020 /*
1021  * _copyIncrementalSort
1022  */
1023 static IncrementalSort *
1025 {
1027 
1028  /*
1029  * copy node superclass fields
1030  */
1031  CopySortFields((const Sort *) from, (Sort *) newnode);
1032 
1033  /*
1034  * copy remainder of node
1035  */
1036  COPY_SCALAR_FIELD(nPresortedCols);
1037 
1038  return newnode;
1039 }
1040 
1041 
1042 /*
1043  * _copyGroup
1044  */
1045 static Group *
1046 _copyGroup(const Group *from)
1047 {
1048  Group *newnode = makeNode(Group);
1049 
1050  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1051 
1052  COPY_SCALAR_FIELD(numCols);
1053  COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
1054  COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
1055  COPY_POINTER_FIELD(grpCollations, from->numCols * sizeof(Oid));
1056 
1057  return newnode;
1058 }
1059 
1060 /*
1061  * _copyAgg
1062  */
1063 static Agg *
1064 _copyAgg(const Agg *from)
1065 {
1066  Agg *newnode = makeNode(Agg);
1067 
1068  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1069 
1070  COPY_SCALAR_FIELD(aggstrategy);
1071  COPY_SCALAR_FIELD(aggsplit);
1072  COPY_SCALAR_FIELD(numCols);
1073  COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
1074  COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
1075  COPY_POINTER_FIELD(grpCollations, from->numCols * sizeof(Oid));
1076  COPY_SCALAR_FIELD(numGroups);
1077  COPY_SCALAR_FIELD(transitionSpace);
1078  COPY_BITMAPSET_FIELD(aggParams);
1079  COPY_NODE_FIELD(groupingSets);
1080  COPY_NODE_FIELD(chain);
1081 
1082  return newnode;
1083 }
1084 
1085 /*
1086  * _copyWindowAgg
1087  */
1088 static WindowAgg *
1090 {
1091  WindowAgg *newnode = makeNode(WindowAgg);
1092 
1093  CopyPlanFields((const Plan *) from, (Plan *) newnode);
1094 
1095  COPY_SCALAR_FIELD(winref);
1096  COPY_SCALAR_FIELD(partNumCols);
1097  COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
1098  COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
1099  COPY_POINTER_FIELD(partCollations, from->partNumCols * sizeof(Oid));
1100  COPY_SCALAR_FIELD(ordNumCols);
1101  COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
1102  COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
1103  COPY_POINTER_FIELD(ordCollations, from->ordNumCols * sizeof(Oid));
1104  COPY_SCALAR_FIELD(frameOptions);
1105  COPY_NODE_FIELD(startOffset);
1106  COPY_NODE_FIELD(endOffset);
1107  COPY_NODE_FIELD(runCondition);
1108  COPY_NODE_FIELD(runConditionOrig);
1109  COPY_SCALAR_FIELD(startInRangeFunc);
1110  COPY_SCALAR_FIELD(endInRangeFunc);
1111  COPY_SCALAR_FIELD(inRangeColl);
1112  COPY_SCALAR_FIELD(inRangeAsc);
1113  COPY_SCALAR_FIELD(inRangeNullsFirst);
1114  COPY_SCALAR_FIELD(topWindow);
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_SCALAR_FIELD(functype);
1402  COPY_NODE_FIELD(ns_uris);
1403  COPY_NODE_FIELD(ns_names);
1404  COPY_NODE_FIELD(docexpr);
1405  COPY_NODE_FIELD(rowexpr);
1406  COPY_NODE_FIELD(colnames);
1407  COPY_NODE_FIELD(coltypes);
1408  COPY_NODE_FIELD(coltypmods);
1409  COPY_NODE_FIELD(colcollations);
1410  COPY_NODE_FIELD(colexprs);
1411  COPY_NODE_FIELD(coldefexprs);
1412  COPY_NODE_FIELD(colvalexprs);
1413  COPY_BITMAPSET_FIELD(notnulls);
1414  COPY_NODE_FIELD(plan);
1415  COPY_SCALAR_FIELD(ordinalitycol);
1416  COPY_LOCATION_FIELD(location);
1417 
1418  return newnode;
1419 }
1420 
1421 /*
1422  * _copyIntoClause
1423  */
1424 static IntoClause *
1426 {
1427  IntoClause *newnode = makeNode(IntoClause);
1428 
1429  COPY_NODE_FIELD(rel);
1430  COPY_NODE_FIELD(colNames);
1431  COPY_STRING_FIELD(accessMethod);
1433  COPY_SCALAR_FIELD(onCommit);
1434  COPY_STRING_FIELD(tableSpaceName);
1435  COPY_NODE_FIELD(viewQuery);
1436  COPY_SCALAR_FIELD(skipData);
1437 
1438  return newnode;
1439 }
1440 
1441 /*
1442  * We don't need a _copyExpr because Expr is an abstract supertype which
1443  * should never actually get instantiated. Also, since it has no common
1444  * fields except NodeTag, there's no need for a helper routine to factor
1445  * out copying the common fields...
1446  */
1447 
1448 /*
1449  * _copyVar
1450  */
1451 static Var *
1452 _copyVar(const Var *from)
1453 {
1454  Var *newnode = makeNode(Var);
1455 
1456  COPY_SCALAR_FIELD(varno);
1457  COPY_SCALAR_FIELD(varattno);
1458  COPY_SCALAR_FIELD(vartype);
1459  COPY_SCALAR_FIELD(vartypmod);
1460  COPY_SCALAR_FIELD(varcollid);
1461  COPY_SCALAR_FIELD(varlevelsup);
1462  COPY_SCALAR_FIELD(varnosyn);
1463  COPY_SCALAR_FIELD(varattnosyn);
1464  COPY_LOCATION_FIELD(location);
1465 
1466  return newnode;
1467 }
1468 
1469 /*
1470  * _copyConst
1471  */
1472 static Const *
1473 _copyConst(const Const *from)
1474 {
1475  Const *newnode = makeNode(Const);
1476 
1477  COPY_SCALAR_FIELD(consttype);
1478  COPY_SCALAR_FIELD(consttypmod);
1479  COPY_SCALAR_FIELD(constcollid);
1480  COPY_SCALAR_FIELD(constlen);
1481 
1482  if (from->constbyval || from->constisnull)
1483  {
1484  /*
1485  * passed by value so just copy the datum. Also, don't try to copy
1486  * struct when value is null!
1487  */
1488  newnode->constvalue = from->constvalue;
1489  }
1490  else
1491  {
1492  /*
1493  * passed by reference. We need a palloc'd copy.
1494  */
1495  newnode->constvalue = datumCopy(from->constvalue,
1496  from->constbyval,
1497  from->constlen);
1498  }
1499 
1500  COPY_SCALAR_FIELD(constisnull);
1501  COPY_SCALAR_FIELD(constbyval);
1502  COPY_LOCATION_FIELD(location);
1503 
1504  return newnode;
1505 }
1506 
1507 /*
1508  * _copyParam
1509  */
1510 static Param *
1511 _copyParam(const Param *from)
1512 {
1513  Param *newnode = makeNode(Param);
1514 
1515  COPY_SCALAR_FIELD(paramkind);
1516  COPY_SCALAR_FIELD(paramid);
1517  COPY_SCALAR_FIELD(paramtype);
1518  COPY_SCALAR_FIELD(paramtypmod);
1519  COPY_SCALAR_FIELD(paramcollid);
1520  COPY_LOCATION_FIELD(location);
1521 
1522  return newnode;
1523 }
1524 
1525 /*
1526  * _copyAggref
1527  */
1528 static Aggref *
1529 _copyAggref(const Aggref *from)
1530 {
1531  Aggref *newnode = makeNode(Aggref);
1532 
1533  COPY_SCALAR_FIELD(aggfnoid);
1534  COPY_SCALAR_FIELD(aggtype);
1535  COPY_SCALAR_FIELD(aggcollid);
1536  COPY_SCALAR_FIELD(inputcollid);
1537  COPY_SCALAR_FIELD(aggtranstype);
1538  COPY_NODE_FIELD(aggargtypes);
1539  COPY_NODE_FIELD(aggdirectargs);
1541  COPY_NODE_FIELD(aggorder);
1542  COPY_NODE_FIELD(aggdistinct);
1543  COPY_NODE_FIELD(aggfilter);
1544  COPY_SCALAR_FIELD(aggstar);
1545  COPY_SCALAR_FIELD(aggvariadic);
1546  COPY_SCALAR_FIELD(aggkind);
1547  COPY_SCALAR_FIELD(agglevelsup);
1548  COPY_SCALAR_FIELD(aggsplit);
1549  COPY_SCALAR_FIELD(aggno);
1550  COPY_SCALAR_FIELD(aggtransno);
1551  COPY_LOCATION_FIELD(location);
1552 
1553  return newnode;
1554 }
1555 
1556 /*
1557  * _copyGroupingFunc
1558  */
1559 static GroupingFunc *
1561 {
1562  GroupingFunc *newnode = makeNode(GroupingFunc);
1563 
1565  COPY_NODE_FIELD(refs);
1566  COPY_NODE_FIELD(cols);
1567  COPY_SCALAR_FIELD(agglevelsup);
1568  COPY_LOCATION_FIELD(location);
1569 
1570  return newnode;
1571 }
1572 
1573 /*
1574  * _copyWindowFunc
1575  */
1576 static WindowFunc *
1578 {
1579  WindowFunc *newnode = makeNode(WindowFunc);
1580 
1581  COPY_SCALAR_FIELD(winfnoid);
1582  COPY_SCALAR_FIELD(wintype);
1583  COPY_SCALAR_FIELD(wincollid);
1584  COPY_SCALAR_FIELD(inputcollid);
1586  COPY_NODE_FIELD(aggfilter);
1587  COPY_SCALAR_FIELD(winref);
1588  COPY_SCALAR_FIELD(winstar);
1589  COPY_SCALAR_FIELD(winagg);
1590  COPY_LOCATION_FIELD(location);
1591 
1592  return newnode;
1593 }
1594 
1595 /*
1596  * _copySubscriptingRef
1597  */
1598 static SubscriptingRef *
1600 {
1602 
1603  COPY_SCALAR_FIELD(refcontainertype);
1604  COPY_SCALAR_FIELD(refelemtype);
1605  COPY_SCALAR_FIELD(refrestype);
1606  COPY_SCALAR_FIELD(reftypmod);
1607  COPY_SCALAR_FIELD(refcollid);
1608  COPY_NODE_FIELD(refupperindexpr);
1609  COPY_NODE_FIELD(reflowerindexpr);
1610  COPY_NODE_FIELD(refexpr);
1611  COPY_NODE_FIELD(refassgnexpr);
1612 
1613  return newnode;
1614 }
1615 
1616 /*
1617  * _copyFuncExpr
1618  */
1619 static FuncExpr *
1621 {
1622  FuncExpr *newnode = makeNode(FuncExpr);
1623 
1624  COPY_SCALAR_FIELD(funcid);
1625  COPY_SCALAR_FIELD(funcresulttype);
1626  COPY_SCALAR_FIELD(funcretset);
1627  COPY_SCALAR_FIELD(funcvariadic);
1628  COPY_SCALAR_FIELD(funcformat);
1629  COPY_SCALAR_FIELD(funccollid);
1630  COPY_SCALAR_FIELD(inputcollid);
1632  COPY_LOCATION_FIELD(location);
1633 
1634  return newnode;
1635 }
1636 
1637 /*
1638  * _copyNamedArgExpr *
1639  */
1640 static NamedArgExpr *
1642 {
1643  NamedArgExpr *newnode = makeNode(NamedArgExpr);
1644 
1647  COPY_SCALAR_FIELD(argnumber);
1648  COPY_LOCATION_FIELD(location);
1649 
1650  return newnode;
1651 }
1652 
1653 /*
1654  * _copyOpExpr
1655  */
1656 static OpExpr *
1657 _copyOpExpr(const OpExpr *from)
1658 {
1659  OpExpr *newnode = makeNode(OpExpr);
1660 
1661  COPY_SCALAR_FIELD(opno);
1662  COPY_SCALAR_FIELD(opfuncid);
1663  COPY_SCALAR_FIELD(opresulttype);
1664  COPY_SCALAR_FIELD(opretset);
1665  COPY_SCALAR_FIELD(opcollid);
1666  COPY_SCALAR_FIELD(inputcollid);
1668  COPY_LOCATION_FIELD(location);
1669 
1670  return newnode;
1671 }
1672 
1673 /*
1674  * _copyDistinctExpr (same as OpExpr)
1675  */
1676 static DistinctExpr *
1678 {
1679  DistinctExpr *newnode = makeNode(DistinctExpr);
1680 
1681  COPY_SCALAR_FIELD(opno);
1682  COPY_SCALAR_FIELD(opfuncid);
1683  COPY_SCALAR_FIELD(opresulttype);
1684  COPY_SCALAR_FIELD(opretset);
1685  COPY_SCALAR_FIELD(opcollid);
1686  COPY_SCALAR_FIELD(inputcollid);
1688  COPY_LOCATION_FIELD(location);
1689 
1690  return newnode;
1691 }
1692 
1693 /*
1694  * _copyNullIfExpr (same as OpExpr)
1695  */
1696 static NullIfExpr *
1698 {
1699  NullIfExpr *newnode = makeNode(NullIfExpr);
1700 
1701  COPY_SCALAR_FIELD(opno);
1702  COPY_SCALAR_FIELD(opfuncid);
1703  COPY_SCALAR_FIELD(opresulttype);
1704  COPY_SCALAR_FIELD(opretset);
1705  COPY_SCALAR_FIELD(opcollid);
1706  COPY_SCALAR_FIELD(inputcollid);
1708  COPY_LOCATION_FIELD(location);
1709 
1710  return newnode;
1711 }
1712 
1713 /*
1714  * _copyScalarArrayOpExpr
1715  */
1716 static ScalarArrayOpExpr *
1718 {
1720 
1721  COPY_SCALAR_FIELD(opno);
1722  COPY_SCALAR_FIELD(opfuncid);
1723  COPY_SCALAR_FIELD(hashfuncid);
1724  COPY_SCALAR_FIELD(negfuncid);
1725  COPY_SCALAR_FIELD(useOr);
1726  COPY_SCALAR_FIELD(inputcollid);
1728  COPY_LOCATION_FIELD(location);
1729 
1730  return newnode;
1731 }
1732 
1733 /*
1734  * _copyBoolExpr
1735  */
1736 static BoolExpr *
1738 {
1739  BoolExpr *newnode = makeNode(BoolExpr);
1740 
1743  COPY_LOCATION_FIELD(location);
1744 
1745  return newnode;
1746 }
1747 
1748 /*
1749  * _copySubLink
1750  */
1751 static SubLink *
1752 _copySubLink(const SubLink *from)
1753 {
1754  SubLink *newnode = makeNode(SubLink);
1755 
1756  COPY_SCALAR_FIELD(subLinkType);
1757  COPY_SCALAR_FIELD(subLinkId);
1758  COPY_NODE_FIELD(testexpr);
1759  COPY_NODE_FIELD(operName);
1760  COPY_NODE_FIELD(subselect);
1761  COPY_LOCATION_FIELD(location);
1762 
1763  return newnode;
1764 }
1765 
1766 /*
1767  * _copySubPlan
1768  */
1769 static SubPlan *
1770 _copySubPlan(const SubPlan *from)
1771 {
1772  SubPlan *newnode = makeNode(SubPlan);
1773 
1774  COPY_SCALAR_FIELD(subLinkType);
1775  COPY_NODE_FIELD(testexpr);
1776  COPY_NODE_FIELD(paramIds);
1777  COPY_SCALAR_FIELD(plan_id);
1778  COPY_STRING_FIELD(plan_name);
1779  COPY_SCALAR_FIELD(firstColType);
1780  COPY_SCALAR_FIELD(firstColTypmod);
1781  COPY_SCALAR_FIELD(firstColCollation);
1782  COPY_SCALAR_FIELD(useHashTable);
1783  COPY_SCALAR_FIELD(unknownEqFalse);
1784  COPY_SCALAR_FIELD(parallel_safe);
1785  COPY_NODE_FIELD(setParam);
1786  COPY_NODE_FIELD(parParam);
1788  COPY_SCALAR_FIELD(startup_cost);
1789  COPY_SCALAR_FIELD(per_call_cost);
1790 
1791  return newnode;
1792 }
1793 
1794 /*
1795  * _copyAlternativeSubPlan
1796  */
1797 static AlternativeSubPlan *
1799 {
1801 
1802  COPY_NODE_FIELD(subplans);
1803 
1804  return newnode;
1805 }
1806 
1807 /*
1808  * _copyFieldSelect
1809  */
1810 static FieldSelect *
1812 {
1813  FieldSelect *newnode = makeNode(FieldSelect);
1814 
1816  COPY_SCALAR_FIELD(fieldnum);
1817  COPY_SCALAR_FIELD(resulttype);
1818  COPY_SCALAR_FIELD(resulttypmod);
1819  COPY_SCALAR_FIELD(resultcollid);
1820 
1821  return newnode;
1822 }
1823 
1824 /*
1825  * _copyFieldStore
1826  */
1827 static FieldStore *
1829 {
1830  FieldStore *newnode = makeNode(FieldStore);
1831 
1833  COPY_NODE_FIELD(newvals);
1834  COPY_NODE_FIELD(fieldnums);
1835  COPY_SCALAR_FIELD(resulttype);
1836 
1837  return newnode;
1838 }
1839 
1840 /*
1841  * _copyRelabelType
1842  */
1843 static RelabelType *
1845 {
1846  RelabelType *newnode = makeNode(RelabelType);
1847 
1849  COPY_SCALAR_FIELD(resulttype);
1850  COPY_SCALAR_FIELD(resulttypmod);
1851  COPY_SCALAR_FIELD(resultcollid);
1852  COPY_SCALAR_FIELD(relabelformat);
1853  COPY_LOCATION_FIELD(location);
1854 
1855  return newnode;
1856 }
1857 
1858 /*
1859  * _copyCoerceViaIO
1860  */
1861 static CoerceViaIO *
1863 {
1864  CoerceViaIO *newnode = makeNode(CoerceViaIO);
1865 
1867  COPY_SCALAR_FIELD(resulttype);
1868  COPY_SCALAR_FIELD(resultcollid);
1869  COPY_SCALAR_FIELD(coerceformat);
1870  COPY_LOCATION_FIELD(location);
1871 
1872  return newnode;
1873 }
1874 
1875 /*
1876  * _copyArrayCoerceExpr
1877  */
1878 static ArrayCoerceExpr *
1880 {
1882 
1884  COPY_NODE_FIELD(elemexpr);
1885  COPY_SCALAR_FIELD(resulttype);
1886  COPY_SCALAR_FIELD(resulttypmod);
1887  COPY_SCALAR_FIELD(resultcollid);
1888  COPY_SCALAR_FIELD(coerceformat);
1889  COPY_LOCATION_FIELD(location);
1890 
1891  return newnode;
1892 }
1893 
1894 /*
1895  * _copyConvertRowtypeExpr
1896  */
1897 static ConvertRowtypeExpr *
1899 {
1901 
1903  COPY_SCALAR_FIELD(resulttype);
1904  COPY_SCALAR_FIELD(convertformat);
1905  COPY_LOCATION_FIELD(location);
1906 
1907  return newnode;
1908 }
1909 
1910 /*
1911  * _copyCollateExpr
1912  */
1913 static CollateExpr *
1915 {
1916  CollateExpr *newnode = makeNode(CollateExpr);
1917 
1919  COPY_SCALAR_FIELD(collOid);
1920  COPY_LOCATION_FIELD(location);
1921 
1922  return newnode;
1923 }
1924 
1925 /*
1926  * _copyCaseExpr
1927  */
1928 static CaseExpr *
1930 {
1931  CaseExpr *newnode = makeNode(CaseExpr);
1932 
1933  COPY_SCALAR_FIELD(casetype);
1934  COPY_SCALAR_FIELD(casecollid);
1937  COPY_NODE_FIELD(defresult);
1938  COPY_LOCATION_FIELD(location);
1939 
1940  return newnode;
1941 }
1942 
1943 /*
1944  * _copyCaseWhen
1945  */
1946 static CaseWhen *
1948 {
1949  CaseWhen *newnode = makeNode(CaseWhen);
1950 
1951  COPY_NODE_FIELD(expr);
1952  COPY_NODE_FIELD(result);
1953  COPY_LOCATION_FIELD(location);
1954 
1955  return newnode;
1956 }
1957 
1958 /*
1959  * _copyCaseTestExpr
1960  */
1961 static CaseTestExpr *
1963 {
1964  CaseTestExpr *newnode = makeNode(CaseTestExpr);
1965 
1966  COPY_SCALAR_FIELD(typeId);
1967  COPY_SCALAR_FIELD(typeMod);
1968  COPY_SCALAR_FIELD(collation);
1969 
1970  return newnode;
1971 }
1972 
1973 /*
1974  * _copyArrayExpr
1975  */
1976 static ArrayExpr *
1978 {
1979  ArrayExpr *newnode = makeNode(ArrayExpr);
1980 
1981  COPY_SCALAR_FIELD(array_typeid);
1982  COPY_SCALAR_FIELD(array_collid);
1983  COPY_SCALAR_FIELD(element_typeid);
1984  COPY_NODE_FIELD(elements);
1985  COPY_SCALAR_FIELD(multidims);
1986  COPY_LOCATION_FIELD(location);
1987 
1988  return newnode;
1989 }
1990 
1991 /*
1992  * _copyRowExpr
1993  */
1994 static RowExpr *
1995 _copyRowExpr(const RowExpr *from)
1996 {
1997  RowExpr *newnode = makeNode(RowExpr);
1998 
2000  COPY_SCALAR_FIELD(row_typeid);
2001  COPY_SCALAR_FIELD(row_format);
2002  COPY_NODE_FIELD(colnames);
2003  COPY_LOCATION_FIELD(location);
2004 
2005  return newnode;
2006 }
2007 
2008 /*
2009  * _copyRowCompareExpr
2010  */
2011 static RowCompareExpr *
2013 {
2015 
2016  COPY_SCALAR_FIELD(rctype);
2017  COPY_NODE_FIELD(opnos);
2018  COPY_NODE_FIELD(opfamilies);
2019  COPY_NODE_FIELD(inputcollids);
2020  COPY_NODE_FIELD(largs);
2021  COPY_NODE_FIELD(rargs);
2022 
2023  return newnode;
2024 }
2025 
2026 /*
2027  * _copyCoalesceExpr
2028  */
2029 static CoalesceExpr *
2031 {
2032  CoalesceExpr *newnode = makeNode(CoalesceExpr);
2033 
2034  COPY_SCALAR_FIELD(coalescetype);
2035  COPY_SCALAR_FIELD(coalescecollid);
2037  COPY_LOCATION_FIELD(location);
2038 
2039  return newnode;
2040 }
2041 
2042 /*
2043  * _copyMinMaxExpr
2044  */
2045 static MinMaxExpr *
2047 {
2048  MinMaxExpr *newnode = makeNode(MinMaxExpr);
2049 
2050  COPY_SCALAR_FIELD(minmaxtype);
2051  COPY_SCALAR_FIELD(minmaxcollid);
2052  COPY_SCALAR_FIELD(inputcollid);
2053  COPY_SCALAR_FIELD(op);
2055  COPY_LOCATION_FIELD(location);
2056 
2057  return newnode;
2058 }
2059 
2060 /*
2061  * _copySQLValueFunction
2062  */
2063 static SQLValueFunction *
2065 {
2067 
2068  COPY_SCALAR_FIELD(op);
2070  COPY_SCALAR_FIELD(typmod);
2071  COPY_LOCATION_FIELD(location);
2072 
2073  return newnode;
2074 }
2075 
2076 /*
2077  * _copyXmlExpr
2078  */
2079 static XmlExpr *
2080 _copyXmlExpr(const XmlExpr *from)
2081 {
2082  XmlExpr *newnode = makeNode(XmlExpr);
2083 
2084  COPY_SCALAR_FIELD(op);
2086  COPY_NODE_FIELD(named_args);
2087  COPY_NODE_FIELD(arg_names);
2091  COPY_SCALAR_FIELD(typmod);
2092  COPY_LOCATION_FIELD(location);
2093 
2094  return newnode;
2095 }
2096 
2097 /*
2098  * _copyNullTest
2099  */
2100 static NullTest *
2102 {
2103  NullTest *newnode = makeNode(NullTest);
2104 
2106  COPY_SCALAR_FIELD(nulltesttype);
2107  COPY_SCALAR_FIELD(argisrow);
2108  COPY_LOCATION_FIELD(location);
2109 
2110  return newnode;
2111 }
2112 
2113 /*
2114  * _copyBooleanTest
2115  */
2116 static BooleanTest *
2118 {
2119  BooleanTest *newnode = makeNode(BooleanTest);
2120 
2122  COPY_SCALAR_FIELD(booltesttype);
2123  COPY_LOCATION_FIELD(location);
2124 
2125  return newnode;
2126 }
2127 
2128 /*
2129  * _copyCoerceToDomain
2130  */
2131 static CoerceToDomain *
2133 {
2135 
2137  COPY_SCALAR_FIELD(resulttype);
2138  COPY_SCALAR_FIELD(resulttypmod);
2139  COPY_SCALAR_FIELD(resultcollid);
2140  COPY_SCALAR_FIELD(coercionformat);
2141  COPY_LOCATION_FIELD(location);
2142 
2143  return newnode;
2144 }
2145 
2146 /*
2147  * _copyCoerceToDomainValue
2148  */
2149 static CoerceToDomainValue *
2151 {
2153 
2154  COPY_SCALAR_FIELD(typeId);
2155  COPY_SCALAR_FIELD(typeMod);
2156  COPY_SCALAR_FIELD(collation);
2157  COPY_LOCATION_FIELD(location);
2158 
2159  return newnode;
2160 }
2161 
2162 /*
2163  * _copySetToDefault
2164  */
2165 static SetToDefault *
2167 {
2168  SetToDefault *newnode = makeNode(SetToDefault);
2169 
2170  COPY_SCALAR_FIELD(typeId);
2171  COPY_SCALAR_FIELD(typeMod);
2172  COPY_SCALAR_FIELD(collation);
2173  COPY_LOCATION_FIELD(location);
2174 
2175  return newnode;
2176 }
2177 
2178 /*
2179  * _copyCurrentOfExpr
2180  */
2181 static CurrentOfExpr *
2183 {
2184  CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
2185 
2186  COPY_SCALAR_FIELD(cvarno);
2187  COPY_STRING_FIELD(cursor_name);
2188  COPY_SCALAR_FIELD(cursor_param);
2189 
2190  return newnode;
2191 }
2192 
2193  /*
2194  * _copyNextValueExpr
2195  */
2196 static NextValueExpr *
2198 {
2199  NextValueExpr *newnode = makeNode(NextValueExpr);
2200 
2201  COPY_SCALAR_FIELD(seqid);
2202  COPY_SCALAR_FIELD(typeId);
2203 
2204  return newnode;
2205 }
2206 
2207 /*
2208  * _copyInferenceElem
2209  */
2210 static InferenceElem *
2212 {
2213  InferenceElem *newnode = makeNode(InferenceElem);
2214 
2215  COPY_NODE_FIELD(expr);
2216  COPY_SCALAR_FIELD(infercollid);
2217  COPY_SCALAR_FIELD(inferopclass);
2218 
2219  return newnode;
2220 }
2221 
2222 /*
2223  * _copyTargetEntry
2224  */
2225 static TargetEntry *
2227 {
2228  TargetEntry *newnode = makeNode(TargetEntry);
2229 
2230  COPY_NODE_FIELD(expr);
2231  COPY_SCALAR_FIELD(resno);
2232  COPY_STRING_FIELD(resname);
2233  COPY_SCALAR_FIELD(ressortgroupref);
2234  COPY_SCALAR_FIELD(resorigtbl);
2235  COPY_SCALAR_FIELD(resorigcol);
2236  COPY_SCALAR_FIELD(resjunk);
2237 
2238  return newnode;
2239 }
2240 
2241 /*
2242  * _copyRangeTblRef
2243  */
2244 static RangeTblRef *
2246 {
2247  RangeTblRef *newnode = makeNode(RangeTblRef);
2248 
2249  COPY_SCALAR_FIELD(rtindex);
2250 
2251  return newnode;
2252 }
2253 
2254 /*
2255  * _copyJoinExpr
2256  */
2257 static JoinExpr *
2259 {
2260  JoinExpr *newnode = makeNode(JoinExpr);
2261 
2262  COPY_SCALAR_FIELD(jointype);
2263  COPY_SCALAR_FIELD(isNatural);
2264  COPY_NODE_FIELD(larg);
2265  COPY_NODE_FIELD(rarg);
2266  COPY_NODE_FIELD(usingClause);
2267  COPY_NODE_FIELD(join_using_alias);
2268  COPY_NODE_FIELD(quals);
2269  COPY_NODE_FIELD(alias);
2270  COPY_SCALAR_FIELD(rtindex);
2271 
2272  return newnode;
2273 }
2274 
2275 /*
2276  * _copyFromExpr
2277  */
2278 static FromExpr *
2280 {
2281  FromExpr *newnode = makeNode(FromExpr);
2282 
2283  COPY_NODE_FIELD(fromlist);
2284  COPY_NODE_FIELD(quals);
2285 
2286  return newnode;
2287 }
2288 
2289 /*
2290  * _copyOnConflictExpr
2291  */
2292 static OnConflictExpr *
2294 {
2296 
2298  COPY_NODE_FIELD(arbiterElems);
2299  COPY_NODE_FIELD(arbiterWhere);
2300  COPY_SCALAR_FIELD(constraint);
2301  COPY_NODE_FIELD(onConflictSet);
2302  COPY_NODE_FIELD(onConflictWhere);
2303  COPY_SCALAR_FIELD(exclRelIndex);
2304  COPY_NODE_FIELD(exclRelTlist);
2305 
2306  return newnode;
2307 }
2308 
2309 
2310 /*
2311  * _copyJsonFormat
2312  */
2313 static JsonFormat *
2315 {
2316  JsonFormat *newnode = makeNode(JsonFormat);
2317 
2320  COPY_LOCATION_FIELD(location);
2321 
2322  return newnode;
2323 }
2324 
2325 /*
2326  * _copyJsonReturning
2327  */
2328 static JsonReturning *
2330 {
2331  JsonReturning *newnode = makeNode(JsonReturning);
2332 
2334  COPY_SCALAR_FIELD(typid);
2335  COPY_SCALAR_FIELD(typmod);
2336 
2337  return newnode;
2338 }
2339 
2340 /*
2341  * _copyJsonValueExpr
2342  */
2343 static JsonValueExpr *
2345 {
2346  JsonValueExpr *newnode = makeNode(JsonValueExpr);
2347 
2348  COPY_NODE_FIELD(raw_expr);
2349  COPY_NODE_FIELD(formatted_expr);
2351 
2352  return newnode;
2353 }
2354 
2355 /*
2356  * _copyJsonParseExpr
2357  */
2358 static JsonParseExpr *
2360 {
2361  JsonParseExpr *newnode = makeNode(JsonParseExpr);
2362 
2363  COPY_NODE_FIELD(expr);
2365  COPY_SCALAR_FIELD(unique_keys);
2366  COPY_LOCATION_FIELD(location);
2367 
2368  return newnode;
2369 }
2370 
2371 /*
2372  * _copyJsonScalarExpr
2373  */
2374 static JsonScalarExpr *
2376 {
2378 
2379  COPY_NODE_FIELD(expr);
2381  COPY_LOCATION_FIELD(location);
2382 
2383  return newnode;
2384 }
2385 
2386 /*
2387  * _copyJsonSerializeExpr
2388  */
2389 static JsonSerializeExpr *
2391 {
2393 
2394  COPY_NODE_FIELD(expr);
2396  COPY_LOCATION_FIELD(location);
2397 
2398  return newnode;
2399 }
2400 
2401 /*
2402  * _copyJsonConstructorExpr
2403  */
2404 static JsonConstructorExpr *
2406 {
2408 
2411  COPY_NODE_FIELD(func);
2412  COPY_NODE_FIELD(coercion);
2413  COPY_NODE_FIELD(returning);
2414  COPY_SCALAR_FIELD(absent_on_null);
2415  COPY_SCALAR_FIELD(unique);
2416  COPY_LOCATION_FIELD(location);
2417 
2418  return newnode;
2419 }
2420 
2421 /*
2422  * _copyJsonKeyValue
2423  */
2424 static JsonKeyValue *
2426 {
2427  JsonKeyValue *newnode = makeNode(JsonKeyValue);
2428 
2431 
2432  return newnode;
2433 }
2434 
2435 /*
2436  * _copyJsonObjectConstructor
2437  */
2438 static JsonObjectConstructor *
2440 {
2442 
2443  COPY_NODE_FIELD(exprs);
2445  COPY_SCALAR_FIELD(absent_on_null);
2446  COPY_SCALAR_FIELD(unique);
2447  COPY_LOCATION_FIELD(location);
2448 
2449  return newnode;
2450 }
2451 
2452 /*
2453  * _copyJsonAggConstructor
2454  */
2455 static JsonAggConstructor *
2457 {
2459 
2461  COPY_NODE_FIELD(agg_filter);
2462  COPY_NODE_FIELD(agg_order);
2463  COPY_NODE_FIELD(over);
2464  COPY_LOCATION_FIELD(location);
2465 
2466  return newnode;
2467 }
2468 
2469 /*
2470  * _copyJsonObjectAgg
2471  */
2472 static JsonObjectAgg *
2474 {
2475  JsonObjectAgg *newnode = makeNode(JsonObjectAgg);
2476 
2477  COPY_NODE_FIELD(constructor);
2479  COPY_SCALAR_FIELD(absent_on_null);
2480  COPY_SCALAR_FIELD(unique);
2481 
2482  return newnode;
2483 }
2484 
2485 /*
2486  * _copyJsonOutput
2487  */
2488 static JsonOutput *
2490 {
2491  JsonOutput *newnode = makeNode(JsonOutput);
2492 
2493  COPY_NODE_FIELD(typeName);
2494  COPY_NODE_FIELD(returning);
2495 
2496  return newnode;
2497 }
2498 
2499 /*
2500  * _copyJsonArrayConstructor
2501  */
2502 static JsonArrayConstructor *
2504 {
2506 
2507  COPY_NODE_FIELD(exprs);
2509  COPY_SCALAR_FIELD(absent_on_null);
2510  COPY_LOCATION_FIELD(location);
2511 
2512  return newnode;
2513 }
2514 
2515 /*
2516  * _copyJsonArrayAgg
2517  */
2518 static JsonArrayAgg *
2520 {
2521  JsonArrayAgg *newnode = makeNode(JsonArrayAgg);
2522 
2523  COPY_NODE_FIELD(constructor);
2525  COPY_SCALAR_FIELD(absent_on_null);
2526 
2527  return newnode;
2528 }
2529 
2530 /*
2531  * _copyJsonArrayQueryConstructor
2532  */
2535 {
2537 
2538  COPY_NODE_FIELD(query);
2541  COPY_SCALAR_FIELD(absent_on_null);
2542  COPY_LOCATION_FIELD(location);
2543 
2544  return newnode;
2545 }
2546 
2547 /*
2548  * _copyJsonExpr
2549  */
2550 static JsonExpr *
2552 {
2553  JsonExpr *newnode = makeNode(JsonExpr);
2554 
2555  COPY_SCALAR_FIELD(op);
2556  COPY_NODE_FIELD(formatted_expr);
2557  COPY_NODE_FIELD(result_coercion);
2559  COPY_NODE_FIELD(path_spec);
2560  COPY_NODE_FIELD(passing_names);
2561  COPY_NODE_FIELD(passing_values);
2562  COPY_NODE_FIELD(returning);
2563  COPY_NODE_FIELD(on_empty);
2564  COPY_NODE_FIELD(on_error);
2565  COPY_NODE_FIELD(coercions);
2566  COPY_SCALAR_FIELD(wrapper);
2567  COPY_SCALAR_FIELD(omit_quotes);
2568  COPY_LOCATION_FIELD(location);
2569 
2570  return newnode;
2571 }
2572 
2573 /*
2574  * _copyJsonCoercion
2575  */
2576 static JsonCoercion *
2578 {
2579  JsonCoercion *newnode = makeNode(JsonCoercion);
2580 
2581  COPY_NODE_FIELD(expr);
2582  COPY_SCALAR_FIELD(via_populate);
2583  COPY_SCALAR_FIELD(via_io);
2584  COPY_SCALAR_FIELD(collation);
2585 
2586  return newnode;
2587 }
2588 
2589 /*
2590  * _copyJsonItemCoercions
2591  */
2592 static JsonItemCoercions *
2594 {
2596 
2597  COPY_NODE_FIELD(null);
2598  COPY_NODE_FIELD(string);
2600  COPY_NODE_FIELD(boolean);
2602  COPY_NODE_FIELD(time);
2603  COPY_NODE_FIELD(timetz);
2605  COPY_NODE_FIELD(timestamptz);
2606  COPY_NODE_FIELD(composite);
2607 
2608  return newnode;
2609 }
2610 
2611 /*
2612  * _copyJsonFuncExpr
2613  */
2614 static JsonFuncExpr *
2616 {
2617  JsonFuncExpr *newnode = makeNode(JsonFuncExpr);
2618 
2619  COPY_SCALAR_FIELD(op);
2620  COPY_NODE_FIELD(common);
2622  COPY_NODE_FIELD(on_empty);
2623  COPY_NODE_FIELD(on_error);
2624  COPY_SCALAR_FIELD(wrapper);
2625  COPY_SCALAR_FIELD(omit_quotes);
2626  COPY_LOCATION_FIELD(location);
2627 
2628  return newnode;
2629 }
2630 
2631 /*
2632  * _copyJsonIsPredicate
2633  */
2634 static JsonIsPredicate *
2636 {
2638 
2639  COPY_NODE_FIELD(expr);
2641  COPY_SCALAR_FIELD(item_type);
2642  COPY_SCALAR_FIELD(unique_keys);
2643  COPY_LOCATION_FIELD(location);
2644 
2645  return newnode;
2646 }
2647 
2648 /*
2649  * _copyJsonBehavior
2650  */
2651 static JsonBehavior *
2653 {
2654  JsonBehavior *newnode = makeNode(JsonBehavior);
2655 
2656  COPY_SCALAR_FIELD(btype);
2657  COPY_NODE_FIELD(default_expr);
2658 
2659  return newnode;
2660 }
2661 
2662 /*
2663  * _copyJsonCommon
2664  */
2665 static JsonCommon *
2667 {
2668  JsonCommon *newnode = makeNode(JsonCommon);
2669 
2670  COPY_NODE_FIELD(expr);
2671  COPY_NODE_FIELD(pathspec);
2672  COPY_STRING_FIELD(pathname);
2673  COPY_NODE_FIELD(passing);
2674  COPY_LOCATION_FIELD(location);
2675 
2676  return newnode;
2677 }
2678 
2679 /*
2680  * _copyJsonArgument
2681  */
2682 static JsonArgument *
2684 {
2685  JsonArgument *newnode = makeNode(JsonArgument);
2686 
2689 
2690  return newnode;
2691 }
2692 
2693 /*
2694  * _copyJsonTable
2695  */
2696 static JsonTable *
2698 {
2699  JsonTable *newnode = makeNode(JsonTable);
2700 
2701  COPY_NODE_FIELD(common);
2702  COPY_NODE_FIELD(columns);
2703  COPY_NODE_FIELD(plan);
2704  COPY_NODE_FIELD(on_error);
2705  COPY_NODE_FIELD(alias);
2706  COPY_SCALAR_FIELD(location);
2707 
2708  return newnode;
2709 }
2710 
2711 /*
2712  * _copyJsonTableColumn
2713  */
2714 static JsonTableColumn *
2716 {
2718 
2719  COPY_SCALAR_FIELD(coltype);
2721  COPY_NODE_FIELD(typeName);
2722  COPY_STRING_FIELD(pathspec);
2723  COPY_STRING_FIELD(pathname);
2725  COPY_SCALAR_FIELD(wrapper);
2726  COPY_SCALAR_FIELD(omit_quotes);
2727  COPY_NODE_FIELD(columns);
2728  COPY_NODE_FIELD(on_empty);
2729  COPY_NODE_FIELD(on_error);
2730  COPY_SCALAR_FIELD(location);
2731 
2732  return newnode;
2733 }
2734 
2735 /*
2736  * _copyJsonTablePlan
2737  */
2738 static JsonTablePlan *
2740 {
2741  JsonTablePlan *newnode = makeNode(JsonTablePlan);
2742 
2743  COPY_SCALAR_FIELD(plan_type);
2744  COPY_SCALAR_FIELD(join_type);
2745  COPY_STRING_FIELD(pathname);
2746  COPY_NODE_FIELD(plan1);
2747  COPY_NODE_FIELD(plan2);
2748  COPY_SCALAR_FIELD(location);
2749 
2750  return newnode;
2751 }
2752 
2753 /*
2754  * _copyJsonTableParent
2755  */
2756 static JsonTableParent *
2758 {
2760 
2761  COPY_NODE_FIELD(path);
2763  COPY_NODE_FIELD(child);
2764  COPY_SCALAR_FIELD(outerJoin);
2765  COPY_SCALAR_FIELD(colMin);
2766  COPY_SCALAR_FIELD(colMax);
2767  COPY_SCALAR_FIELD(errorOnError);
2768 
2769  return newnode;
2770 }
2771 
2772 /*
2773  * _copyJsonTableSibling
2774  */
2775 static JsonTableSibling *
2777 {
2779 
2780  COPY_NODE_FIELD(larg);
2781  COPY_NODE_FIELD(rarg);
2782  COPY_SCALAR_FIELD(cross);
2783 
2784  return newnode;
2785 }
2786 
2787 /* ****************************************************************
2788  * pathnodes.h copy functions
2789  *
2790  * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
2791  * There are some subsidiary structs that are useful to copy, though.
2792  * ****************************************************************
2793  */
2794 
2795 /*
2796  * _copyPathKey
2797  */
2798 static PathKey *
2799 _copyPathKey(const PathKey *from)
2800 {
2801  PathKey *newnode = makeNode(PathKey);
2802 
2803  /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
2804  COPY_SCALAR_FIELD(pk_eclass);
2805  COPY_SCALAR_FIELD(pk_opfamily);
2806  COPY_SCALAR_FIELD(pk_strategy);
2807  COPY_SCALAR_FIELD(pk_nulls_first);
2808 
2809  return newnode;
2810 }
2811 
2812 /*
2813  * _copyRestrictInfo
2814  */
2815 static RestrictInfo *
2817 {
2818  RestrictInfo *newnode = makeNode(RestrictInfo);
2819 
2820  COPY_NODE_FIELD(clause);
2821  COPY_SCALAR_FIELD(is_pushed_down);
2822  COPY_SCALAR_FIELD(outerjoin_delayed);
2823  COPY_SCALAR_FIELD(can_join);
2824  COPY_SCALAR_FIELD(pseudoconstant);
2825  COPY_SCALAR_FIELD(leakproof);
2826  COPY_SCALAR_FIELD(has_volatile);
2827  COPY_SCALAR_FIELD(security_level);
2828  COPY_BITMAPSET_FIELD(clause_relids);
2829  COPY_BITMAPSET_FIELD(required_relids);
2830  COPY_BITMAPSET_FIELD(outer_relids);
2831  COPY_BITMAPSET_FIELD(nullable_relids);
2832  COPY_BITMAPSET_FIELD(left_relids);
2833  COPY_BITMAPSET_FIELD(right_relids);
2834  COPY_NODE_FIELD(orclause);
2835  /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2836  COPY_SCALAR_FIELD(parent_ec);
2837  COPY_SCALAR_FIELD(eval_cost);
2838  COPY_SCALAR_FIELD(norm_selec);
2839  COPY_SCALAR_FIELD(outer_selec);
2840  COPY_NODE_FIELD(mergeopfamilies);
2841  /* EquivalenceClasses are never copied, so shallow-copy the pointers */
2842  COPY_SCALAR_FIELD(left_ec);
2843  COPY_SCALAR_FIELD(right_ec);
2844  COPY_SCALAR_FIELD(left_em);
2845  COPY_SCALAR_FIELD(right_em);
2846  /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
2847  newnode->scansel_cache = NIL;
2848  COPY_SCALAR_FIELD(outer_is_left);
2849  COPY_SCALAR_FIELD(hashjoinoperator);
2850  COPY_SCALAR_FIELD(left_bucketsize);
2851  COPY_SCALAR_FIELD(right_bucketsize);
2852  COPY_SCALAR_FIELD(left_mcvfreq);
2853  COPY_SCALAR_FIELD(right_mcvfreq);
2854  COPY_SCALAR_FIELD(left_hasheqoperator);
2855  COPY_SCALAR_FIELD(right_hasheqoperator);
2856 
2857  return newnode;
2858 }
2859 
2860 /*
2861  * _copyPlaceHolderVar
2862  */
2863 static PlaceHolderVar *
2865 {
2867 
2868  COPY_NODE_FIELD(phexpr);
2869  COPY_BITMAPSET_FIELD(phrels);
2870  COPY_SCALAR_FIELD(phid);
2871  COPY_SCALAR_FIELD(phlevelsup);
2872 
2873  return newnode;
2874 }
2875 
2876 /*
2877  * _copySpecialJoinInfo
2878  */
2879 static SpecialJoinInfo *
2881 {
2883 
2884  COPY_BITMAPSET_FIELD(min_lefthand);
2885  COPY_BITMAPSET_FIELD(min_righthand);
2886  COPY_BITMAPSET_FIELD(syn_lefthand);
2887  COPY_BITMAPSET_FIELD(syn_righthand);
2888  COPY_SCALAR_FIELD(jointype);
2889  COPY_SCALAR_FIELD(lhs_strict);
2890  COPY_SCALAR_FIELD(delay_upper_joins);
2891  COPY_SCALAR_FIELD(semi_can_btree);
2892  COPY_SCALAR_FIELD(semi_can_hash);
2893  COPY_NODE_FIELD(semi_operators);
2894  COPY_NODE_FIELD(semi_rhs_exprs);
2895 
2896  return newnode;
2897 }
2898 
2899 /*
2900  * _copyAppendRelInfo
2901  */
2902 static AppendRelInfo *
2904 {
2905  AppendRelInfo *newnode = makeNode(AppendRelInfo);
2906 
2907  COPY_SCALAR_FIELD(parent_relid);
2908  COPY_SCALAR_FIELD(child_relid);
2909  COPY_SCALAR_FIELD(parent_reltype);
2910  COPY_SCALAR_FIELD(child_reltype);
2911  COPY_NODE_FIELD(translated_vars);
2912  COPY_SCALAR_FIELD(num_child_cols);
2913  COPY_POINTER_FIELD(parent_colnos, from->num_child_cols * sizeof(AttrNumber));
2914  COPY_SCALAR_FIELD(parent_reloid);
2915 
2916  return newnode;
2917 }
2918 
2919 /*
2920  * _copyPlaceHolderInfo
2921  */
2922 static PlaceHolderInfo *
2924 {
2926 
2927  COPY_SCALAR_FIELD(phid);
2928  COPY_NODE_FIELD(ph_var);
2929  COPY_BITMAPSET_FIELD(ph_eval_at);
2930  COPY_BITMAPSET_FIELD(ph_lateral);
2931  COPY_BITMAPSET_FIELD(ph_needed);
2932  COPY_SCALAR_FIELD(ph_width);
2933 
2934  return newnode;
2935 }
2936 
2937 /* ****************************************************************
2938  * parsenodes.h copy functions
2939  * ****************************************************************
2940  */
2941 
2942 static RangeTblEntry *
2944 {
2945  RangeTblEntry *newnode = makeNode(RangeTblEntry);
2946 
2947  COPY_SCALAR_FIELD(rtekind);
2948  COPY_SCALAR_FIELD(relid);
2949  COPY_SCALAR_FIELD(relkind);
2950  COPY_SCALAR_FIELD(rellockmode);
2951  COPY_NODE_FIELD(tablesample);
2952  COPY_NODE_FIELD(subquery);
2953  COPY_SCALAR_FIELD(security_barrier);
2954  COPY_SCALAR_FIELD(jointype);
2955  COPY_SCALAR_FIELD(joinmergedcols);
2956  COPY_NODE_FIELD(joinaliasvars);
2957  COPY_NODE_FIELD(joinleftcols);
2958  COPY_NODE_FIELD(joinrightcols);
2959  COPY_NODE_FIELD(join_using_alias);
2961  COPY_SCALAR_FIELD(funcordinality);
2962  COPY_NODE_FIELD(tablefunc);
2963  COPY_NODE_FIELD(values_lists);
2964  COPY_STRING_FIELD(ctename);
2965  COPY_SCALAR_FIELD(ctelevelsup);
2966  COPY_SCALAR_FIELD(self_reference);
2967  COPY_NODE_FIELD(coltypes);
2968  COPY_NODE_FIELD(coltypmods);
2969  COPY_NODE_FIELD(colcollations);
2970  COPY_STRING_FIELD(enrname);
2971  COPY_SCALAR_FIELD(enrtuples);
2972  COPY_NODE_FIELD(alias);
2973  COPY_NODE_FIELD(eref);
2974  COPY_SCALAR_FIELD(lateral);
2975  COPY_SCALAR_FIELD(inh);
2976  COPY_SCALAR_FIELD(inFromCl);
2977  COPY_SCALAR_FIELD(requiredPerms);
2978  COPY_SCALAR_FIELD(checkAsUser);
2979  COPY_BITMAPSET_FIELD(selectedCols);
2980  COPY_BITMAPSET_FIELD(insertedCols);
2981  COPY_BITMAPSET_FIELD(updatedCols);
2982  COPY_BITMAPSET_FIELD(extraUpdatedCols);
2983  COPY_NODE_FIELD(securityQuals);
2984 
2985  return newnode;
2986 }
2987 
2988 static RangeTblFunction *
2990 {
2992 
2993  COPY_NODE_FIELD(funcexpr);
2994  COPY_SCALAR_FIELD(funccolcount);
2995  COPY_NODE_FIELD(funccolnames);
2996  COPY_NODE_FIELD(funccoltypes);
2997  COPY_NODE_FIELD(funccoltypmods);
2998  COPY_NODE_FIELD(funccolcollations);
2999  COPY_BITMAPSET_FIELD(funcparams);
3000 
3001  return newnode;
3002 }
3003 
3004 static TableSampleClause *
3006 {
3008 
3009  COPY_SCALAR_FIELD(tsmhandler);
3011  COPY_NODE_FIELD(repeatable);
3012 
3013  return newnode;
3014 }
3015 
3016 static WithCheckOption *
3018 {
3020 
3021  COPY_SCALAR_FIELD(kind);
3023  COPY_STRING_FIELD(polname);
3024  COPY_NODE_FIELD(qual);
3025  COPY_SCALAR_FIELD(cascaded);
3026 
3027  return newnode;
3028 }
3029 
3030 static SortGroupClause *
3032 {
3034 
3035  COPY_SCALAR_FIELD(tleSortGroupRef);
3036  COPY_SCALAR_FIELD(eqop);
3037  COPY_SCALAR_FIELD(sortop);
3038  COPY_SCALAR_FIELD(nulls_first);
3039  COPY_SCALAR_FIELD(hashable);
3040 
3041  return newnode;
3042 }
3043 
3044 static GroupingSet *
3046 {
3047  GroupingSet *newnode = makeNode(GroupingSet);
3048 
3049  COPY_SCALAR_FIELD(kind);
3050  COPY_NODE_FIELD(content);
3051  COPY_LOCATION_FIELD(location);
3052 
3053  return newnode;
3054 }
3055 
3056 static WindowClause *
3058 {
3059  WindowClause *newnode = makeNode(WindowClause);
3060 
3062  COPY_STRING_FIELD(refname);
3063  COPY_NODE_FIELD(partitionClause);
3064  COPY_NODE_FIELD(orderClause);
3065  COPY_SCALAR_FIELD(frameOptions);
3066  COPY_NODE_FIELD(startOffset);
3067  COPY_NODE_FIELD(endOffset);
3068  COPY_NODE_FIELD(runCondition);
3069  COPY_SCALAR_FIELD(startInRangeFunc);
3070  COPY_SCALAR_FIELD(endInRangeFunc);
3071  COPY_SCALAR_FIELD(inRangeColl);
3072  COPY_SCALAR_FIELD(inRangeAsc);
3073  COPY_SCALAR_FIELD(inRangeNullsFirst);
3074  COPY_SCALAR_FIELD(winref);
3075  COPY_SCALAR_FIELD(copiedOrder);
3076 
3077  return newnode;
3078 }
3079 
3080 static RowMarkClause *
3082 {
3083  RowMarkClause *newnode = makeNode(RowMarkClause);
3084 
3085  COPY_SCALAR_FIELD(rti);
3086  COPY_SCALAR_FIELD(strength);
3087  COPY_SCALAR_FIELD(waitPolicy);
3088  COPY_SCALAR_FIELD(pushedDown);
3089 
3090  return newnode;
3091 }
3092 
3093 static WithClause *
3095 {
3096  WithClause *newnode = makeNode(WithClause);
3097 
3098  COPY_NODE_FIELD(ctes);
3099  COPY_SCALAR_FIELD(recursive);
3100  COPY_LOCATION_FIELD(location);
3101 
3102  return newnode;
3103 }
3104 
3105 static InferClause *
3107 {
3108  InferClause *newnode = makeNode(InferClause);
3109 
3110  COPY_NODE_FIELD(indexElems);
3111  COPY_NODE_FIELD(whereClause);
3112  COPY_STRING_FIELD(conname);
3113  COPY_LOCATION_FIELD(location);
3114 
3115  return newnode;
3116 }
3117 
3118 static OnConflictClause *
3120 {
3122 
3124  COPY_NODE_FIELD(infer);
3125  COPY_NODE_FIELD(targetList);
3126  COPY_NODE_FIELD(whereClause);
3127  COPY_LOCATION_FIELD(location);
3128 
3129  return newnode;
3130 }
3131 
3132 static CTESearchClause *
3134 {
3136 
3137  COPY_NODE_FIELD(search_col_list);
3138  COPY_SCALAR_FIELD(search_breadth_first);
3139  COPY_STRING_FIELD(search_seq_column);
3140  COPY_LOCATION_FIELD(location);
3141 
3142  return newnode;
3143 }
3144 
3145 static CTECycleClause *
3147 {
3149 
3150  COPY_NODE_FIELD(cycle_col_list);
3151  COPY_STRING_FIELD(cycle_mark_column);
3152  COPY_NODE_FIELD(cycle_mark_value);
3153  COPY_NODE_FIELD(cycle_mark_default);
3154  COPY_STRING_FIELD(cycle_path_column);
3155  COPY_LOCATION_FIELD(location);
3156  COPY_SCALAR_FIELD(cycle_mark_type);
3157  COPY_SCALAR_FIELD(cycle_mark_typmod);
3158  COPY_SCALAR_FIELD(cycle_mark_collation);
3159  COPY_SCALAR_FIELD(cycle_mark_neop);
3160 
3161  return newnode;
3162 }
3163 
3164 static CommonTableExpr *
3166 {
3168 
3169  COPY_STRING_FIELD(ctename);
3170  COPY_NODE_FIELD(aliascolnames);
3171  COPY_SCALAR_FIELD(ctematerialized);
3172  COPY_NODE_FIELD(ctequery);
3173  COPY_NODE_FIELD(search_clause);
3174  COPY_NODE_FIELD(cycle_clause);
3175  COPY_LOCATION_FIELD(location);
3176  COPY_SCALAR_FIELD(cterecursive);
3177  COPY_SCALAR_FIELD(cterefcount);
3178  COPY_NODE_FIELD(ctecolnames);
3179  COPY_NODE_FIELD(ctecoltypes);
3180  COPY_NODE_FIELD(ctecoltypmods);
3181  COPY_NODE_FIELD(ctecolcollations);
3182 
3183  return newnode;
3184 }
3185 
3186 static MergeWhenClause *
3188 {
3190 
3191  COPY_SCALAR_FIELD(matched);
3192  COPY_SCALAR_FIELD(commandType);
3193  COPY_SCALAR_FIELD(override);
3194  COPY_NODE_FIELD(condition);
3195  COPY_NODE_FIELD(targetList);
3197  return newnode;
3198 }
3199 
3200 static MergeAction *
3202 {
3203  MergeAction *newnode = makeNode(MergeAction);
3204 
3205  COPY_SCALAR_FIELD(matched);
3206  COPY_SCALAR_FIELD(commandType);
3207  COPY_SCALAR_FIELD(override);
3208  COPY_NODE_FIELD(qual);
3209  COPY_NODE_FIELD(targetList);
3210  COPY_NODE_FIELD(updateColnos);
3211 
3212  return newnode;
3213 }
3214 
3215 static A_Expr *
3216 _copyA_Expr(const A_Expr *from)
3217 {
3218  A_Expr *newnode = makeNode(A_Expr);
3219 
3220  COPY_SCALAR_FIELD(kind);
3222  COPY_NODE_FIELD(lexpr);
3223  COPY_NODE_FIELD(rexpr);
3224  COPY_LOCATION_FIELD(location);
3225 
3226  return newnode;
3227 }
3228 
3229 static ColumnRef *
3231 {
3232  ColumnRef *newnode = makeNode(ColumnRef);
3233 
3234  COPY_NODE_FIELD(fields);
3235  COPY_LOCATION_FIELD(location);
3236 
3237  return newnode;
3238 }
3239 
3240 static ParamRef *
3242 {
3243  ParamRef *newnode = makeNode(ParamRef);
3244 
3245  COPY_SCALAR_FIELD(number);
3246  COPY_LOCATION_FIELD(location);
3247 
3248  return newnode;
3249 }
3250 
3251 static A_Const *
3252 _copyA_Const(const A_Const *from)
3253 {
3254  A_Const *newnode = makeNode(A_Const);
3255 
3256  COPY_SCALAR_FIELD(isnull);
3257  if (!from->isnull)
3258  {
3259  /* This part must duplicate other _copy*() functions. */
3260  COPY_SCALAR_FIELD(val.node.type);
3261  switch (nodeTag(&from->val))
3262  {
3263  case T_Integer:
3264  COPY_SCALAR_FIELD(val.ival.ival);
3265  break;
3266  case T_Float:
3267  COPY_STRING_FIELD(val.fval.fval);
3268  break;
3269  case T_Boolean:
3270  COPY_SCALAR_FIELD(val.boolval.boolval);
3271  break;
3272  case T_String:
3273  COPY_STRING_FIELD(val.sval.sval);
3274  break;
3275  case T_BitString:
3276  COPY_STRING_FIELD(val.bsval.bsval);
3277  break;
3278  default:
3279  elog(ERROR, "unrecognized node type: %d",
3280  (int) nodeTag(&from->val));
3281  break;
3282  }
3283  }
3284 
3285  COPY_LOCATION_FIELD(location);
3286 
3287  return newnode;
3288 }
3289 
3290 static FuncCall *
3292 {
3293  FuncCall *newnode = makeNode(FuncCall);
3294 
3295  COPY_NODE_FIELD(funcname);
3297  COPY_NODE_FIELD(agg_order);
3298  COPY_NODE_FIELD(agg_filter);
3299  COPY_NODE_FIELD(over);
3300  COPY_SCALAR_FIELD(agg_within_group);
3301  COPY_SCALAR_FIELD(agg_star);
3302  COPY_SCALAR_FIELD(agg_distinct);
3303  COPY_SCALAR_FIELD(func_variadic);
3304  COPY_SCALAR_FIELD(funcformat);
3305  COPY_LOCATION_FIELD(location);
3306 
3307  return newnode;
3308 }
3309 
3310 static A_Star *
3311 _copyA_Star(const A_Star *from)
3312 {
3313  A_Star *newnode = makeNode(A_Star);
3314 
3315  return newnode;
3316 }
3317 
3318 static A_Indices *
3320 {
3321  A_Indices *newnode = makeNode(A_Indices);
3322 
3323  COPY_SCALAR_FIELD(is_slice);
3324  COPY_NODE_FIELD(lidx);
3325  COPY_NODE_FIELD(uidx);
3326 
3327  return newnode;
3328 }
3329 
3330 static A_Indirection *
3332 {
3333  A_Indirection *newnode = makeNode(A_Indirection);
3334 
3336  COPY_NODE_FIELD(indirection);
3337 
3338  return newnode;
3339 }
3340 
3341 static A_ArrayExpr *
3343 {
3344  A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
3345 
3346  COPY_NODE_FIELD(elements);
3347  COPY_LOCATION_FIELD(location);
3348 
3349  return newnode;
3350 }
3351 
3352 static ResTarget *
3354 {
3355  ResTarget *newnode = makeNode(ResTarget);
3356 
3358  COPY_NODE_FIELD(indirection);
3360  COPY_LOCATION_FIELD(location);
3361 
3362  return newnode;
3363 }
3364 
3365 static MultiAssignRef *
3367 {
3369 
3371  COPY_SCALAR_FIELD(colno);
3372  COPY_SCALAR_FIELD(ncolumns);
3373 
3374  return newnode;
3375 }
3376 
3377 static TypeName *
3379 {
3380  TypeName *newnode = makeNode(TypeName);
3381 
3382  COPY_NODE_FIELD(names);
3383  COPY_SCALAR_FIELD(typeOid);
3384  COPY_SCALAR_FIELD(setof);
3385  COPY_SCALAR_FIELD(pct_type);
3386  COPY_NODE_FIELD(typmods);
3387  COPY_SCALAR_FIELD(typemod);
3388  COPY_NODE_FIELD(arrayBounds);
3389  COPY_LOCATION_FIELD(location);
3390 
3391  return newnode;
3392 }
3393 
3394 static SortBy *
3395 _copySortBy(const SortBy *from)
3396 {
3397  SortBy *newnode = makeNode(SortBy);
3398 
3399  COPY_NODE_FIELD(node);
3400  COPY_SCALAR_FIELD(sortby_dir);
3401  COPY_SCALAR_FIELD(sortby_nulls);
3402  COPY_NODE_FIELD(useOp);
3403  COPY_LOCATION_FIELD(location);
3404 
3405  return newnode;
3406 }
3407 
3408 static WindowDef *
3410 {
3411  WindowDef *newnode = makeNode(WindowDef);
3412 
3414  COPY_STRING_FIELD(refname);
3415  COPY_NODE_FIELD(partitionClause);
3416  COPY_NODE_FIELD(orderClause);
3417  COPY_SCALAR_FIELD(frameOptions);
3418  COPY_NODE_FIELD(startOffset);
3419  COPY_NODE_FIELD(endOffset);
3420  COPY_LOCATION_FIELD(location);
3421 
3422  return newnode;
3423 }
3424 
3425 static RangeSubselect *
3427 {
3429 
3430  COPY_SCALAR_FIELD(lateral);
3431  COPY_NODE_FIELD(subquery);
3432  COPY_NODE_FIELD(alias);
3433 
3434  return newnode;
3435 }
3436 
3437 static RangeFunction *
3439 {
3440  RangeFunction *newnode = makeNode(RangeFunction);
3441 
3442  COPY_SCALAR_FIELD(lateral);
3443  COPY_SCALAR_FIELD(ordinality);
3444  COPY_SCALAR_FIELD(is_rowsfrom);
3446  COPY_NODE_FIELD(alias);
3447  COPY_NODE_FIELD(coldeflist);
3448 
3449  return newnode;
3450 }
3451 
3452 static RangeTableSample *
3454 {
3456 
3457  COPY_NODE_FIELD(relation);
3458  COPY_NODE_FIELD(method);
3460  COPY_NODE_FIELD(repeatable);
3461  COPY_LOCATION_FIELD(location);
3462 
3463  return newnode;
3464 }
3465 
3466 static RangeTableFunc *
3468 {
3470 
3471  COPY_SCALAR_FIELD(lateral);
3472  COPY_NODE_FIELD(docexpr);
3473  COPY_NODE_FIELD(rowexpr);
3474  COPY_NODE_FIELD(namespaces);
3475  COPY_NODE_FIELD(columns);
3476  COPY_NODE_FIELD(alias);
3477  COPY_LOCATION_FIELD(location);
3478 
3479  return newnode;
3480 }
3481 
3482 static RangeTableFuncCol *
3484 {
3486 
3487  COPY_STRING_FIELD(colname);
3488  COPY_NODE_FIELD(typeName);
3489  COPY_SCALAR_FIELD(for_ordinality);
3490  COPY_SCALAR_FIELD(is_not_null);
3491  COPY_NODE_FIELD(colexpr);
3492  COPY_NODE_FIELD(coldefexpr);
3493  COPY_LOCATION_FIELD(location);
3494 
3495  return newnode;
3496 }
3497 
3498 static TypeCast *
3500 {
3501  TypeCast *newnode = makeNode(TypeCast);
3502 
3504  COPY_NODE_FIELD(typeName);
3505  COPY_LOCATION_FIELD(location);
3506 
3507  return newnode;
3508 }
3509 
3510 static CollateClause *
3512 {
3513  CollateClause *newnode = makeNode(CollateClause);
3514 
3516  COPY_NODE_FIELD(collname);
3517  COPY_LOCATION_FIELD(location);
3518 
3519  return newnode;
3520 }
3521 
3522 static IndexElem *
3524 {
3525  IndexElem *newnode = makeNode(IndexElem);
3526 
3528  COPY_NODE_FIELD(expr);
3529  COPY_STRING_FIELD(indexcolname);
3530  COPY_NODE_FIELD(collation);
3531  COPY_NODE_FIELD(opclass);
3532  COPY_NODE_FIELD(opclassopts);
3533  COPY_SCALAR_FIELD(ordering);
3534  COPY_SCALAR_FIELD(nulls_ordering);
3535 
3536  return newnode;
3537 }
3538 
3539 static StatsElem *
3541 {
3542  StatsElem *newnode = makeNode(StatsElem);
3543 
3545  COPY_NODE_FIELD(expr);
3546 
3547  return newnode;
3548 }
3549 
3550 static ColumnDef *
3552 {
3553  ColumnDef *newnode = makeNode(ColumnDef);
3554 
3555  COPY_STRING_FIELD(colname);
3556  COPY_NODE_FIELD(typeName);
3557  COPY_STRING_FIELD(compression);
3558  COPY_SCALAR_FIELD(inhcount);
3559  COPY_SCALAR_FIELD(is_local);
3560  COPY_SCALAR_FIELD(is_not_null);
3561  COPY_SCALAR_FIELD(is_from_type);
3562  COPY_SCALAR_FIELD(storage);
3563  COPY_NODE_FIELD(raw_default);
3564  COPY_NODE_FIELD(cooked_default);
3565  COPY_SCALAR_FIELD(identity);
3566  COPY_NODE_FIELD(identitySequence);
3567  COPY_SCALAR_FIELD(generated);
3568  COPY_NODE_FIELD(collClause);
3569  COPY_SCALAR_FIELD(collOid);
3570  COPY_NODE_FIELD(constraints);
3571  COPY_NODE_FIELD(fdwoptions);
3572  COPY_LOCATION_FIELD(location);
3573 
3574  return newnode;
3575 }
3576 
3577 static Constraint *
3579 {
3580  Constraint *newnode = makeNode(Constraint);
3581 
3582  COPY_SCALAR_FIELD(contype);
3583  COPY_STRING_FIELD(conname);
3584  COPY_SCALAR_FIELD(deferrable);
3585  COPY_SCALAR_FIELD(initdeferred);
3586  COPY_LOCATION_FIELD(location);
3587  COPY_SCALAR_FIELD(is_no_inherit);
3588  COPY_NODE_FIELD(raw_expr);
3589  COPY_STRING_FIELD(cooked_expr);
3590  COPY_SCALAR_FIELD(generated_when);
3591  COPY_SCALAR_FIELD(nulls_not_distinct);
3592  COPY_NODE_FIELD(keys);
3593  COPY_NODE_FIELD(including);
3594  COPY_NODE_FIELD(exclusions);
3596  COPY_STRING_FIELD(indexname);
3597  COPY_STRING_FIELD(indexspace);
3598  COPY_SCALAR_FIELD(reset_default_tblspc);
3599  COPY_STRING_FIELD(access_method);
3600  COPY_NODE_FIELD(where_clause);
3601  COPY_NODE_FIELD(pktable);
3602  COPY_NODE_FIELD(fk_attrs);
3603  COPY_NODE_FIELD(pk_attrs);
3604  COPY_SCALAR_FIELD(fk_matchtype);
3605  COPY_SCALAR_FIELD(fk_upd_action);
3606  COPY_SCALAR_FIELD(fk_del_action);
3607  COPY_NODE_FIELD(fk_del_set_cols);
3608  COPY_NODE_FIELD(old_conpfeqop);
3609  COPY_SCALAR_FIELD(old_pktable_oid);
3610  COPY_SCALAR_FIELD(skip_validation);
3611  COPY_SCALAR_FIELD(initially_valid);
3612 
3613  return newnode;
3614 }
3615 
3616 static DefElem *
3617 _copyDefElem(const DefElem *from)
3618 {
3619  DefElem *newnode = makeNode(DefElem);
3620 
3621  COPY_STRING_FIELD(defnamespace);
3622  COPY_STRING_FIELD(defname);
3624  COPY_SCALAR_FIELD(defaction);
3625  COPY_LOCATION_FIELD(location);
3626 
3627  return newnode;
3628 }
3629 
3630 static LockingClause *
3632 {
3633  LockingClause *newnode = makeNode(LockingClause);
3634 
3635  COPY_NODE_FIELD(lockedRels);
3636  COPY_SCALAR_FIELD(strength);
3637  COPY_SCALAR_FIELD(waitPolicy);
3638 
3639  return newnode;
3640 }
3641 
3642 static XmlSerialize *
3644 {
3645  XmlSerialize *newnode = makeNode(XmlSerialize);
3646 
3648  COPY_NODE_FIELD(expr);
3649  COPY_NODE_FIELD(typeName);
3650  COPY_LOCATION_FIELD(location);
3651 
3652  return newnode;
3653 }
3654 
3655 static RoleSpec *
3657 {
3658  RoleSpec *newnode = makeNode(RoleSpec);
3659 
3660  COPY_SCALAR_FIELD(roletype);
3661  COPY_STRING_FIELD(rolename);
3662  COPY_LOCATION_FIELD(location);
3663 
3664  return newnode;
3665 }
3666 
3667 static TriggerTransition *
3669 {
3671 
3673  COPY_SCALAR_FIELD(isNew);
3674  COPY_SCALAR_FIELD(isTable);
3675 
3676  return newnode;
3677 }
3678 
3679 static Query *
3680 _copyQuery(const Query *from)
3681 {
3682  Query *newnode = makeNode(Query);
3683 
3684  COPY_SCALAR_FIELD(commandType);
3685  COPY_SCALAR_FIELD(querySource);
3686  COPY_SCALAR_FIELD(queryId);
3687  COPY_SCALAR_FIELD(canSetTag);
3688  COPY_NODE_FIELD(utilityStmt);
3689  COPY_SCALAR_FIELD(resultRelation);
3690  COPY_SCALAR_FIELD(hasAggs);
3691  COPY_SCALAR_FIELD(hasWindowFuncs);
3692  COPY_SCALAR_FIELD(hasTargetSRFs);
3693  COPY_SCALAR_FIELD(hasSubLinks);
3694  COPY_SCALAR_FIELD(hasDistinctOn);
3695  COPY_SCALAR_FIELD(hasRecursive);
3696  COPY_SCALAR_FIELD(hasModifyingCTE);
3697  COPY_SCALAR_FIELD(hasForUpdate);
3698  COPY_SCALAR_FIELD(hasRowSecurity);
3699  COPY_SCALAR_FIELD(isReturn);
3700  COPY_NODE_FIELD(cteList);
3701  COPY_NODE_FIELD(rtable);
3702  COPY_NODE_FIELD(jointree);
3703  COPY_NODE_FIELD(targetList);
3704  COPY_SCALAR_FIELD(override);
3705  COPY_NODE_FIELD(onConflict);
3706  COPY_NODE_FIELD(returningList);
3707  COPY_NODE_FIELD(groupClause);
3708  COPY_SCALAR_FIELD(groupDistinct);
3709  COPY_NODE_FIELD(groupingSets);
3710  COPY_NODE_FIELD(havingQual);
3711  COPY_NODE_FIELD(windowClause);
3712  COPY_NODE_FIELD(distinctClause);
3713  COPY_NODE_FIELD(sortClause);
3714  COPY_NODE_FIELD(limitOffset);
3715  COPY_NODE_FIELD(limitCount);
3716  COPY_SCALAR_FIELD(limitOption);
3717  COPY_NODE_FIELD(rowMarks);
3718  COPY_NODE_FIELD(setOperations);
3719  COPY_NODE_FIELD(constraintDeps);
3720  COPY_NODE_FIELD(withCheckOptions);
3721  COPY_NODE_FIELD(mergeActionList);
3722  COPY_SCALAR_FIELD(mergeUseOuterJoin);
3723  COPY_LOCATION_FIELD(stmt_location);
3724  COPY_SCALAR_FIELD(stmt_len);
3725 
3726  return newnode;
3727 }
3728 
3729 static RawStmt *
3730 _copyRawStmt(const RawStmt *from)
3731 {
3732  RawStmt *newnode = makeNode(RawStmt);
3733 
3734  COPY_NODE_FIELD(stmt);
3735  COPY_LOCATION_FIELD(stmt_location);
3736  COPY_SCALAR_FIELD(stmt_len);
3737 
3738  return newnode;
3739 }
3740 
3741 static InsertStmt *
3743 {
3744  InsertStmt *newnode = makeNode(InsertStmt);
3745 
3746  COPY_NODE_FIELD(relation);
3747  COPY_NODE_FIELD(cols);
3748  COPY_NODE_FIELD(selectStmt);
3749  COPY_NODE_FIELD(onConflictClause);
3750  COPY_NODE_FIELD(returningList);
3751  COPY_NODE_FIELD(withClause);
3752  COPY_SCALAR_FIELD(override);
3753 
3754  return newnode;
3755 }
3756 
3757 static DeleteStmt *
3759 {
3760  DeleteStmt *newnode = makeNode(DeleteStmt);
3761 
3762  COPY_NODE_FIELD(relation);
3763  COPY_NODE_FIELD(usingClause);
3764  COPY_NODE_FIELD(whereClause);
3765  COPY_NODE_FIELD(returningList);
3766  COPY_NODE_FIELD(withClause);
3767 
3768  return newnode;
3769 }
3770 
3771 static UpdateStmt *
3773 {
3774  UpdateStmt *newnode = makeNode(UpdateStmt);
3775 
3776  COPY_NODE_FIELD(relation);
3777  COPY_NODE_FIELD(targetList);
3778  COPY_NODE_FIELD(whereClause);
3779  COPY_NODE_FIELD(fromClause);
3780  COPY_NODE_FIELD(returningList);
3781  COPY_NODE_FIELD(withClause);
3782 
3783  return newnode;
3784 }
3785 
3786 static MergeStmt *
3788 {
3789  MergeStmt *newnode = makeNode(MergeStmt);
3790 
3791  COPY_NODE_FIELD(relation);
3792  COPY_NODE_FIELD(sourceRelation);
3793  COPY_NODE_FIELD(joinCondition);
3794  COPY_NODE_FIELD(mergeWhenClauses);
3795  COPY_NODE_FIELD(withClause);
3796 
3797  return newnode;
3798 }
3799 
3800 static SelectStmt *
3802 {
3803  SelectStmt *newnode = makeNode(SelectStmt);
3804 
3805  COPY_NODE_FIELD(distinctClause);
3806  COPY_NODE_FIELD(intoClause);
3807  COPY_NODE_FIELD(targetList);
3808  COPY_NODE_FIELD(fromClause);
3809  COPY_NODE_FIELD(whereClause);
3810  COPY_NODE_FIELD(groupClause);
3811  COPY_SCALAR_FIELD(groupDistinct);
3812  COPY_NODE_FIELD(havingClause);
3813  COPY_NODE_FIELD(windowClause);
3814  COPY_NODE_FIELD(valuesLists);
3815  COPY_NODE_FIELD(sortClause);
3816  COPY_NODE_FIELD(limitOffset);
3817  COPY_NODE_FIELD(limitCount);
3818  COPY_SCALAR_FIELD(limitOption);
3819  COPY_NODE_FIELD(lockingClause);
3820  COPY_NODE_FIELD(withClause);
3821  COPY_SCALAR_FIELD(op);
3822  COPY_SCALAR_FIELD(all);
3823  COPY_NODE_FIELD(larg);
3824  COPY_NODE_FIELD(rarg);
3825 
3826  return newnode;
3827 }
3828 
3829 static SetOperationStmt *
3831 {
3833 
3834  COPY_SCALAR_FIELD(op);
3835  COPY_SCALAR_FIELD(all);
3836  COPY_NODE_FIELD(larg);
3837  COPY_NODE_FIELD(rarg);
3838  COPY_NODE_FIELD(colTypes);
3839  COPY_NODE_FIELD(colTypmods);
3840  COPY_NODE_FIELD(colCollations);
3841  COPY_NODE_FIELD(groupClauses);
3842 
3843  return newnode;
3844 }
3845 
3846 static ReturnStmt *
3848 {
3849  ReturnStmt *newnode = makeNode(ReturnStmt);
3850 
3851  COPY_NODE_FIELD(returnval);
3852 
3853  return newnode;
3854 }
3855 
3856 static PLAssignStmt *
3858 {
3859  PLAssignStmt *newnode = makeNode(PLAssignStmt);
3860 
3862  COPY_NODE_FIELD(indirection);
3863  COPY_SCALAR_FIELD(nnames);
3865  COPY_LOCATION_FIELD(location);
3866 
3867  return newnode;
3868 }
3869 
3870 static AlterTableStmt *
3872 {
3874 
3875  COPY_NODE_FIELD(relation);
3876  COPY_NODE_FIELD(cmds);
3877  COPY_SCALAR_FIELD(objtype);
3878  COPY_SCALAR_FIELD(missing_ok);
3879 
3880  return newnode;
3881 }
3882 
3883 static AlterTableCmd *
3885 {
3886  AlterTableCmd *newnode = makeNode(AlterTableCmd);
3887 
3888  COPY_SCALAR_FIELD(subtype);
3890  COPY_SCALAR_FIELD(num);
3891  COPY_NODE_FIELD(newowner);
3892  COPY_NODE_FIELD(def);
3893  COPY_SCALAR_FIELD(behavior);
3894  COPY_SCALAR_FIELD(missing_ok);
3895 
3896  return newnode;
3897 }
3898 
3899 static AlterCollationStmt *
3901 {
3903 
3904  COPY_NODE_FIELD(collname);
3905 
3906  return newnode;
3907 }
3908 
3909 static AlterDomainStmt *
3911 {
3913 
3914  COPY_SCALAR_FIELD(subtype);
3915  COPY_NODE_FIELD(typeName);
3917  COPY_NODE_FIELD(def);
3918  COPY_SCALAR_FIELD(behavior);
3919  COPY_SCALAR_FIELD(missing_ok);
3920 
3921  return newnode;
3922 }
3923 
3924 static GrantStmt *
3926 {
3927  GrantStmt *newnode = makeNode(GrantStmt);
3928 
3929  COPY_SCALAR_FIELD(is_grant);
3930  COPY_SCALAR_FIELD(targtype);
3931  COPY_SCALAR_FIELD(objtype);
3932  COPY_NODE_FIELD(objects);
3933  COPY_NODE_FIELD(privileges);
3934  COPY_NODE_FIELD(grantees);
3935  COPY_SCALAR_FIELD(grant_option);
3936  COPY_NODE_FIELD(grantor);
3937  COPY_SCALAR_FIELD(behavior);
3938 
3939  return newnode;
3940 }
3941 
3942 static ObjectWithArgs *
3944 {
3946 
3947  COPY_NODE_FIELD(objname);
3948  COPY_NODE_FIELD(objargs);
3949  COPY_NODE_FIELD(objfuncargs);
3950  COPY_SCALAR_FIELD(args_unspecified);
3951 
3952  return newnode;
3953 }
3954 
3955 static AccessPriv *
3957 {
3958  AccessPriv *newnode = makeNode(AccessPriv);
3959 
3960  COPY_STRING_FIELD(priv_name);
3961  COPY_NODE_FIELD(cols);
3962 
3963  return newnode;
3964 }
3965 
3966 static GrantRoleStmt *
3968 {
3969  GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
3970 
3971  COPY_NODE_FIELD(granted_roles);
3972  COPY_NODE_FIELD(grantee_roles);
3973  COPY_SCALAR_FIELD(is_grant);
3974  COPY_SCALAR_FIELD(admin_opt);
3975  COPY_NODE_FIELD(grantor);
3976  COPY_SCALAR_FIELD(behavior);
3977 
3978  return newnode;
3979 }
3980 
3983 {
3985 
3988 
3989  return newnode;
3990 }
3991 
3992 static DeclareCursorStmt *
3994 {
3996 
3997  COPY_STRING_FIELD(portalname);
3999  COPY_NODE_FIELD(query);
4000 
4001  return newnode;
4002 }
4003 
4004 static ClosePortalStmt *
4006 {
4008 
4009  COPY_STRING_FIELD(portalname);
4010 
4011  return newnode;
4012 }
4013 
4014 static CallStmt *
4016 {
4017  CallStmt *newnode = makeNode(CallStmt);
4018 
4019  COPY_NODE_FIELD(funccall);
4020  COPY_NODE_FIELD(funcexpr);
4021  COPY_NODE_FIELD(outargs);
4022 
4023  return newnode;
4024 }
4025 
4026 static ClusterStmt *
4028 {
4029  ClusterStmt *newnode = makeNode(ClusterStmt);
4030 
4031  COPY_NODE_FIELD(relation);
4032  COPY_STRING_FIELD(indexname);
4033  COPY_NODE_FIELD(params);
4034 
4035  return newnode;
4036 }
4037 
4038 static CopyStmt *
4040 {
4041  CopyStmt *newnode = makeNode(CopyStmt);
4042 
4043  COPY_NODE_FIELD(relation);
4044  COPY_NODE_FIELD(query);
4045  COPY_NODE_FIELD(attlist);
4046  COPY_SCALAR_FIELD(is_from);
4047  COPY_SCALAR_FIELD(is_program);
4050  COPY_NODE_FIELD(whereClause);
4051 
4052  return newnode;
4053 }
4054 
4055 /*
4056  * CopyCreateStmtFields
4057  *
4058  * This function copies the fields of the CreateStmt node. It is used by
4059  * copy functions for classes which inherit from CreateStmt.
4060  */
4061 static void
4063 {
4064  COPY_NODE_FIELD(relation);
4065  COPY_NODE_FIELD(tableElts);
4066  COPY_NODE_FIELD(inhRelations);
4067  COPY_NODE_FIELD(partspec);
4068  COPY_NODE_FIELD(partbound);
4069  COPY_NODE_FIELD(ofTypename);
4070  COPY_NODE_FIELD(constraints);
4072  COPY_SCALAR_FIELD(oncommit);
4073  COPY_STRING_FIELD(tablespacename);
4074  COPY_STRING_FIELD(accessMethod);
4075  COPY_SCALAR_FIELD(if_not_exists);
4076 }
4077 
4078 static CreateStmt *
4080 {
4081  CreateStmt *newnode = makeNode(CreateStmt);
4082 
4083  CopyCreateStmtFields(from, newnode);
4084 
4085  return newnode;
4086 }
4087 
4088 static TableLikeClause *
4090 {
4092 
4093  COPY_NODE_FIELD(relation);
4095  COPY_SCALAR_FIELD(relationOid);
4096 
4097  return newnode;
4098 }
4099 
4100 static DefineStmt *
4102 {
4103  DefineStmt *newnode = makeNode(DefineStmt);
4104 
4105  COPY_SCALAR_FIELD(kind);
4106  COPY_SCALAR_FIELD(oldstyle);
4107  COPY_NODE_FIELD(defnames);
4109  COPY_NODE_FIELD(definition);
4110  COPY_SCALAR_FIELD(if_not_exists);
4111  COPY_SCALAR_FIELD(replace);
4112 
4113  return newnode;
4114 }
4115 
4116 static DropStmt *
4118 {
4119  DropStmt *newnode = makeNode(DropStmt);
4120 
4121  COPY_NODE_FIELD(objects);
4122  COPY_SCALAR_FIELD(removeType);
4123  COPY_SCALAR_FIELD(behavior);
4124  COPY_SCALAR_FIELD(missing_ok);
4125  COPY_SCALAR_FIELD(concurrent);
4126 
4127  return newnode;
4128 }
4129 
4130 static TruncateStmt *
4132 {
4133  TruncateStmt *newnode = makeNode(TruncateStmt);
4134 
4135  COPY_NODE_FIELD(relations);
4136  COPY_SCALAR_FIELD(restart_seqs);
4137  COPY_SCALAR_FIELD(behavior);
4138 
4139  return newnode;
4140 }
4141 
4142 static CommentStmt *
4144 {
4145  CommentStmt *newnode = makeNode(CommentStmt);
4146 
4147  COPY_SCALAR_FIELD(objtype);
4148  COPY_NODE_FIELD(object);
4149  COPY_STRING_FIELD(comment);
4150 
4151  return newnode;
4152 }
4153 
4154 static SecLabelStmt *
4156 {
4157  SecLabelStmt *newnode = makeNode(SecLabelStmt);
4158 
4159  COPY_SCALAR_FIELD(objtype);
4160  COPY_NODE_FIELD(object);
4163 
4164  return newnode;
4165 }
4166 
4167 static FetchStmt *
4169 {
4170  FetchStmt *newnode = makeNode(FetchStmt);
4171 
4172  COPY_SCALAR_FIELD(direction);
4173  COPY_SCALAR_FIELD(howMany);
4174  COPY_STRING_FIELD(portalname);
4175  COPY_SCALAR_FIELD(ismove);
4176 
4177  return newnode;
4178 }
4179 
4180 static IndexStmt *
4182 {
4183  IndexStmt *newnode = makeNode(IndexStmt);
4184 
4185  COPY_STRING_FIELD(idxname);
4186  COPY_NODE_FIELD(relation);
4187  COPY_STRING_FIELD(accessMethod);
4188  COPY_STRING_FIELD(tableSpace);
4189  COPY_NODE_FIELD(indexParams);
4190  COPY_NODE_FIELD(indexIncludingParams);
4192  COPY_NODE_FIELD(whereClause);
4193  COPY_NODE_FIELD(excludeOpNames);
4194  COPY_STRING_FIELD(idxcomment);
4195  COPY_SCALAR_FIELD(indexOid);
4196  COPY_SCALAR_FIELD(oldNode);
4197  COPY_SCALAR_FIELD(oldCreateSubid);
4198  COPY_SCALAR_FIELD(oldFirstRelfilenodeSubid);
4199  COPY_SCALAR_FIELD(unique);
4200  COPY_SCALAR_FIELD(nulls_not_distinct);
4201  COPY_SCALAR_FIELD(primary);
4202  COPY_SCALAR_FIELD(isconstraint);
4203  COPY_SCALAR_FIELD(deferrable);
4204  COPY_SCALAR_FIELD(initdeferred);
4205  COPY_SCALAR_FIELD(transformed);
4206  COPY_SCALAR_FIELD(concurrent);
4207  COPY_SCALAR_FIELD(if_not_exists);
4208  COPY_SCALAR_FIELD(reset_default_tblspc);
4209 
4210  return newnode;
4211 }
4212 
4213 static CreateStatsStmt *
4215 {
4217 
4218  COPY_NODE_FIELD(defnames);
4219  COPY_NODE_FIELD(stat_types);
4220  COPY_NODE_FIELD(exprs);
4221  COPY_NODE_FIELD(relations);
4222  COPY_STRING_FIELD(stxcomment);
4223  COPY_SCALAR_FIELD(transformed);
4224  COPY_SCALAR_FIELD(if_not_exists);
4225 
4226  return newnode;
4227 }
4228 
4229 static AlterStatsStmt *
4231 {
4233 
4234  COPY_NODE_FIELD(defnames);
4235  COPY_SCALAR_FIELD(stxstattarget);
4236  COPY_SCALAR_FIELD(missing_ok);
4237 
4238  return newnode;
4239 }
4240 
4241 static CreateFunctionStmt *
4243 {
4245 
4246  COPY_SCALAR_FIELD(is_procedure);
4247  COPY_SCALAR_FIELD(replace);
4248  COPY_NODE_FIELD(funcname);
4249  COPY_NODE_FIELD(parameters);
4250  COPY_NODE_FIELD(returnType);
4252  COPY_NODE_FIELD(sql_body);
4253 
4254  return newnode;
4255 }
4256 
4257 static FunctionParameter *
4259 {
4261 
4263  COPY_NODE_FIELD(argType);
4265  COPY_NODE_FIELD(defexpr);
4266 
4267  return newnode;
4268 }
4269 
4270 static AlterFunctionStmt *
4272 {
4274 
4275  COPY_SCALAR_FIELD(objtype);
4276  COPY_NODE_FIELD(func);
4277  COPY_NODE_FIELD(actions);
4278 
4279  return newnode;
4280 }
4281 
4282 static DoStmt *
4283 _copyDoStmt(const DoStmt *from)
4284 {
4285  DoStmt *newnode = makeNode(DoStmt);
4286 
4288 
4289  return newnode;
4290 }
4291 
4292 static RenameStmt *
4294 {
4295  RenameStmt *newnode = makeNode(RenameStmt);
4296 
4297  COPY_SCALAR_FIELD(renameType);
4298  COPY_SCALAR_FIELD(relationType);
4299  COPY_NODE_FIELD(relation);
4300  COPY_NODE_FIELD(object);
4302  COPY_STRING_FIELD(newname);
4303  COPY_SCALAR_FIELD(behavior);
4304  COPY_SCALAR_FIELD(missing_ok);
4305 
4306  return newnode;
4307 }
4308 
4309 static AlterObjectDependsStmt *
4311 {
4313 
4314  COPY_SCALAR_FIELD(objectType);
4315  COPY_NODE_FIELD(relation);
4316  COPY_NODE_FIELD(object);
4317  COPY_NODE_FIELD(extname);
4318  COPY_SCALAR_FIELD(remove);
4319 
4320  return newnode;
4321 }
4322 
4323 static AlterObjectSchemaStmt *
4325 {
4327 
4328  COPY_SCALAR_FIELD(objectType);
4329  COPY_NODE_FIELD(relation);
4330  COPY_NODE_FIELD(object);
4331  COPY_STRING_FIELD(newschema);
4332  COPY_SCALAR_FIELD(missing_ok);
4333 
4334  return newnode;
4335 }
4336 
4337 static AlterOwnerStmt *
4339 {
4341 
4342  COPY_SCALAR_FIELD(objectType);
4343  COPY_NODE_FIELD(relation);
4344  COPY_NODE_FIELD(object);
4345  COPY_NODE_FIELD(newowner);
4346 
4347  return newnode;
4348 }
4349 
4350 static AlterOperatorStmt *
4352 {
4354 
4355  COPY_NODE_FIELD(opername);
4357 
4358  return newnode;
4359 }
4360 
4361 static AlterTypeStmt *
4363 {
4364  AlterTypeStmt *newnode = makeNode(AlterTypeStmt);
4365 
4366  COPY_NODE_FIELD(typeName);
4368 
4369  return newnode;
4370 }
4371 
4372 static RuleStmt *
4374 {
4375  RuleStmt *newnode = makeNode(RuleStmt);
4376 
4377  COPY_NODE_FIELD(relation);
4378  COPY_STRING_FIELD(rulename);
4379  COPY_NODE_FIELD(whereClause);
4380  COPY_SCALAR_FIELD(event);
4381  COPY_SCALAR_FIELD(instead);
4382  COPY_NODE_FIELD(actions);
4383  COPY_SCALAR_FIELD(replace);
4384 
4385  return newnode;
4386 }
4387 
4388 static NotifyStmt *
4390 {
4391  NotifyStmt *newnode = makeNode(NotifyStmt);
4392 
4393  COPY_STRING_FIELD(conditionname);
4394  COPY_STRING_FIELD(payload);
4395 
4396  return newnode;
4397 }
4398 
4399 static ListenStmt *
4401 {
4402  ListenStmt *newnode = makeNode(ListenStmt);
4403 
4404  COPY_STRING_FIELD(conditionname);
4405 
4406  return newnode;
4407 }
4408 
4409 static UnlistenStmt *
4411 {
4412  UnlistenStmt *newnode = makeNode(UnlistenStmt);
4413 
4414  COPY_STRING_FIELD(conditionname);
4415 
4416  return newnode;
4417 }
4418 
4419 static TransactionStmt *
4421 {
4423 
4424  COPY_SCALAR_FIELD(kind);
4426  COPY_STRING_FIELD(savepoint_name);
4427  COPY_STRING_FIELD(gid);
4428  COPY_SCALAR_FIELD(chain);
4429 
4430  return newnode;
4431 }
4432 
4433 static CompositeTypeStmt *
4435 {
4437 
4438  COPY_NODE_FIELD(typevar);
4439  COPY_NODE_FIELD(coldeflist);
4440 
4441  return newnode;
4442 }
4443 
4444 static CreateEnumStmt *
4446 {
4448 
4449  COPY_NODE_FIELD(typeName);
4450  COPY_NODE_FIELD(vals);
4451 
4452  return newnode;
4453 }
4454 
4455 static CreateRangeStmt *
4457 {
4459 
4460  COPY_NODE_FIELD(typeName);
4461  COPY_NODE_FIELD(params);
4462 
4463  return newnode;
4464 }
4465 
4466 static AlterEnumStmt *
4468 {
4469  AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
4470 
4471  COPY_NODE_FIELD(typeName);
4472  COPY_STRING_FIELD(oldVal);
4473  COPY_STRING_FIELD(newVal);
4474  COPY_STRING_FIELD(newValNeighbor);
4475  COPY_SCALAR_FIELD(newValIsAfter);
4476  COPY_SCALAR_FIELD(skipIfNewValExists);
4477 
4478  return newnode;
4479 }
4480 
4481 static ViewStmt *
4483 {
4484  ViewStmt *newnode = makeNode(ViewStmt);
4485 
4486  COPY_NODE_FIELD(view);
4487  COPY_NODE_FIELD(aliases);
4488  COPY_NODE_FIELD(query);
4489  COPY_SCALAR_FIELD(replace);
4491  COPY_SCALAR_FIELD(withCheckOption);
4492 
4493  return newnode;
4494 }
4495 
4496 static LoadStmt *
4498 {
4499  LoadStmt *newnode = makeNode(LoadStmt);
4500 
4502 
4503  return newnode;
4504 }
4505 
4506 static CreateDomainStmt *
4508 {
4510 
4511  COPY_NODE_FIELD(domainname);
4512  COPY_NODE_FIELD(typeName);
4513  COPY_NODE_FIELD(collClause);
4514  COPY_NODE_FIELD(constraints);
4515 
4516  return newnode;
4517 }
4518 
4519 static CreateOpClassStmt *
4521 {
4523 
4524  COPY_NODE_FIELD(opclassname);
4525  COPY_NODE_FIELD(opfamilyname);
4526  COPY_STRING_FIELD(amname);
4527  COPY_NODE_FIELD(datatype);
4528  COPY_NODE_FIELD(items);
4529  COPY_SCALAR_FIELD(isDefault);
4530 
4531  return newnode;
4532 }
4533 
4534 static CreateOpClassItem *
4536 {
4538 
4539  COPY_SCALAR_FIELD(itemtype);
4541  COPY_SCALAR_FIELD(number);
4542  COPY_NODE_FIELD(order_family);
4543  COPY_NODE_FIELD(class_args);
4544  COPY_NODE_FIELD(storedtype);
4545 
4546  return newnode;
4547 }
4548 
4549 static CreateOpFamilyStmt *
4551 {
4553 
4554  COPY_NODE_FIELD(opfamilyname);
4555  COPY_STRING_FIELD(amname);
4556 
4557  return newnode;
4558 }
4559 
4560 static AlterOpFamilyStmt *
4562 {
4564 
4565  COPY_NODE_FIELD(opfamilyname);
4566  COPY_STRING_FIELD(amname);
4567  COPY_SCALAR_FIELD(isDrop);
4568  COPY_NODE_FIELD(items);
4569 
4570  return newnode;
4571 }
4572 
4573 static CreatedbStmt *
4575 {
4576  CreatedbStmt *newnode = makeNode(CreatedbStmt);
4577 
4580 
4581  return newnode;
4582 }
4583 
4584 static AlterDatabaseStmt *
4586 {
4588 
4591 
4592  return newnode;
4593 }
4594 
4597 {
4599 
4601 
4602  return newnode;
4603 }
4604 
4605 static AlterDatabaseSetStmt *
4607 {
4609 
4611  COPY_NODE_FIELD(setstmt);
4612 
4613  return newnode;
4614 }
4615 
4616 static DropdbStmt *
4618 {
4619  DropdbStmt *newnode = makeNode(DropdbStmt);
4620 
4622  COPY_SCALAR_FIELD(missing_ok);
4624 
4625  return newnode;
4626 }
4627 
4628 static VacuumStmt *
4630 {
4631  VacuumStmt *newnode = makeNode(VacuumStmt);
4632 
4634  COPY_NODE_FIELD(rels);
4635  COPY_SCALAR_FIELD(is_vacuumcmd);
4636 
4637  return newnode;
4638 }
4639 
4640 static VacuumRelation *
4642 {
4644 
4645  COPY_NODE_FIELD(relation);
4646  COPY_SCALAR_FIELD(oid);
4647  COPY_NODE_FIELD(va_cols);
4648 
4649  return newnode;
4650 }
4651 
4652 static ExplainStmt *
4654 {
4655  ExplainStmt *newnode = makeNode(ExplainStmt);
4656 
4657  COPY_NODE_FIELD(query);
4659 
4660  return newnode;
4661 }
4662 
4663 static CreateTableAsStmt *
4665 {
4667 
4668  COPY_NODE_FIELD(query);
4669  COPY_NODE_FIELD(into);
4670  COPY_SCALAR_FIELD(objtype);
4671  COPY_SCALAR_FIELD(is_select_into);
4672  COPY_SCALAR_FIELD(if_not_exists);
4673 
4674  return newnode;
4675 }
4676 
4677 static RefreshMatViewStmt *
4679 {
4681 
4682  COPY_SCALAR_FIELD(concurrent);
4683  COPY_SCALAR_FIELD(skipData);
4684  COPY_NODE_FIELD(relation);
4685 
4686  return newnode;
4687 }
4688 
4689 static ReplicaIdentityStmt *
4691 {
4693 
4694  COPY_SCALAR_FIELD(identity_type);
4696 
4697  return newnode;
4698 }
4699 
4700 static AlterSystemStmt *
4702 {
4704 
4705  COPY_NODE_FIELD(setstmt);
4706 
4707  return newnode;
4708 }
4709 
4710 static CreateSeqStmt *
4712 {
4713  CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
4714 
4715  COPY_NODE_FIELD(sequence);
4717  COPY_SCALAR_FIELD(ownerId);
4718  COPY_SCALAR_FIELD(for_identity);
4719  COPY_SCALAR_FIELD(if_not_exists);
4720 
4721  return newnode;
4722 }
4723 
4724 static AlterSeqStmt *
4726 {
4727  AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
4728 
4729  COPY_NODE_FIELD(sequence);
4731  COPY_SCALAR_FIELD(for_identity);
4732  COPY_SCALAR_FIELD(missing_ok);
4733 
4734  return newnode;
4735 }
4736 
4737 static VariableSetStmt *
4739 {
4741 
4742  COPY_SCALAR_FIELD(kind);
4745  COPY_SCALAR_FIELD(is_local);
4746 
4747  return newnode;
4748 }
4749 
4750 static VariableShowStmt *
4752 {
4754 
4756 
4757  return newnode;
4758 }
4759 
4760 static DiscardStmt *
4762 {
4763  DiscardStmt *newnode = makeNode(DiscardStmt);
4764 
4765  COPY_SCALAR_FIELD(target);
4766 
4767  return newnode;
4768 }
4769 
4770 static CreateTableSpaceStmt *
4772 {
4774 
4775  COPY_STRING_FIELD(tablespacename);
4776  COPY_NODE_FIELD(owner);
4777  COPY_STRING_FIELD(location);
4779 
4780  return newnode;
4781 }
4782 
4783 static DropTableSpaceStmt *
4785 {
4787 
4788  COPY_STRING_FIELD(tablespacename);
4789  COPY_SCALAR_FIELD(missing_ok);
4790 
4791  return newnode;
4792 }
4793 
4796 {
4798 
4799  COPY_STRING_FIELD(tablespacename);
4801  COPY_SCALAR_FIELD(isReset);
4802 
4803  return newnode;
4804 }
4805 
4806 static AlterTableMoveAllStmt *
4808 {
4810 
4811  COPY_STRING_FIELD(orig_tablespacename);
4812  COPY_SCALAR_FIELD(objtype);
4813  COPY_NODE_FIELD(roles);
4814  COPY_STRING_FIELD(new_tablespacename);
4815  COPY_SCALAR_FIELD(nowait);
4816 
4817  return newnode;
4818 }
4819 
4820 static CreateExtensionStmt *
4822 {
4824 
4825  COPY_STRING_FIELD(extname);
4826  COPY_SCALAR_FIELD(if_not_exists);
4828 
4829  return newnode;
4830 }
4831 
4832 static AlterExtensionStmt *
4834 {
4836 
4837  COPY_STRING_FIELD(extname);
4839 
4840  return newnode;
4841 }
4842 
4845 {
4847 
4848  COPY_STRING_FIELD(extname);
4850  COPY_SCALAR_FIELD(objtype);
4851  COPY_NODE_FIELD(object);
4852 
4853  return newnode;
4854 }
4855 
4856 static CreateFdwStmt *
4858 {
4859  CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
4860 
4861  COPY_STRING_FIELD(fdwname);
4862  COPY_NODE_FIELD(func_options);
4864 
4865  return newnode;
4866 }
4867 
4868 static AlterFdwStmt *
4870 {
4871  AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
4872 
4873  COPY_STRING_FIELD(fdwname);
4874  COPY_NODE_FIELD(func_options);
4876 
4877  return newnode;
4878 }
4879 
4880 static CreateForeignServerStmt *
4882 {
4884 
4885  COPY_STRING_FIELD(servername);
4886  COPY_STRING_FIELD(servertype);
4887  COPY_STRING_FIELD(version);
4888  COPY_STRING_FIELD(fdwname);
4889  COPY_SCALAR_FIELD(if_not_exists);
4891 
4892  return newnode;
4893 }
4894 
4895 static AlterForeignServerStmt *
4897 {
4899 
4900  COPY_STRING_FIELD(servername);
4901  COPY_STRING_FIELD(version);
4903  COPY_SCALAR_FIELD(has_version);
4904 
4905  return newnode;
4906 }
4907 
4908 static CreateUserMappingStmt *
4910 {
4912 
4914  COPY_STRING_FIELD(servername);
4915  COPY_SCALAR_FIELD(if_not_exists);
4917 
4918  return newnode;
4919 }
4920 
4921 static AlterUserMappingStmt *
4923 {
4925 
4927  COPY_STRING_FIELD(servername);
4929 
4930  return newnode;
4931 }
4932 
4933 static DropUserMappingStmt *
4935 {
4937 
4939  COPY_STRING_FIELD(servername);
4940  COPY_SCALAR_FIELD(missing_ok);
4941 
4942  return newnode;
4943 }
4944 
4945 static CreateForeignTableStmt *
4947 {
4949 
4950  CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
4951 
4952  COPY_STRING_FIELD(servername);
4954 
4955  return newnode;
4956 }
4957 
4958 static ImportForeignSchemaStmt *
4960 {
4962 
4963  COPY_STRING_FIELD(server_name);
4964  COPY_STRING_FIELD(remote_schema);
4965  COPY_STRING_FIELD(local_schema);
4966  COPY_SCALAR_FIELD(list_type);
4967  COPY_NODE_FIELD(table_list);
4969 
4970  return newnode;
4971 }
4972 
4973 static CreateTransformStmt *
4975 {
4977 
4978  COPY_SCALAR_FIELD(replace);
4979  COPY_NODE_FIELD(type_name);
4980  COPY_STRING_FIELD(lang);
4981  COPY_NODE_FIELD(fromsql);
4982  COPY_NODE_FIELD(tosql);
4983 
4984  return newnode;
4985 }
4986 
4987 static CreateAmStmt *
4989 {
4990  CreateAmStmt *newnode = makeNode(CreateAmStmt);
4991 
4992  COPY_STRING_FIELD(amname);
4993  COPY_NODE_FIELD(handler_name);
4994  COPY_SCALAR_FIELD(amtype);
4995 
4996  return newnode;
4997 }
4998 
4999 static CreateTrigStmt *
5001 {
5003 
5004  COPY_SCALAR_FIELD(replace);
5005  COPY_SCALAR_FIELD(isconstraint);
5006  COPY_STRING_FIELD(trigname);
5007  COPY_NODE_FIELD(relation);
5008  COPY_NODE_FIELD(funcname);
5010  COPY_SCALAR_FIELD(row);
5011  COPY_SCALAR_FIELD(timing);
5012  COPY_SCALAR_FIELD(events);
5013  COPY_NODE_FIELD(columns);
5014  COPY_NODE_FIELD(whenClause);
5015  COPY_NODE_FIELD(transitionRels);
5016  COPY_SCALAR_FIELD(deferrable);
5017  COPY_SCALAR_FIELD(initdeferred);
5018  COPY_NODE_FIELD(constrrel);
5019 
5020  return newnode;
5021 }
5022 
5023 static CreateEventTrigStmt *
5025 {
5027 
5028  COPY_STRING_FIELD(trigname);
5029  COPY_STRING_FIELD(eventname);
5030  COPY_NODE_FIELD(whenclause);
5031  COPY_NODE_FIELD(funcname);
5032 
5033  return newnode;
5034 }
5035 
5036 static AlterEventTrigStmt *
5038 {
5040 
5041  COPY_STRING_FIELD(trigname);
5042  COPY_SCALAR_FIELD(tgenabled);
5043 
5044  return newnode;
5045 }
5046 
5047 static CreatePLangStmt *
5049 {
5051 
5052  COPY_SCALAR_FIELD(replace);
5053  COPY_STRING_FIELD(plname);
5054  COPY_NODE_FIELD(plhandler);
5055  COPY_NODE_FIELD(plinline);
5056  COPY_NODE_FIELD(plvalidator);
5057  COPY_SCALAR_FIELD(pltrusted);
5058 
5059  return newnode;
5060 }
5061 
5062 static CreateRoleStmt *
5064 {
5066 
5067  COPY_SCALAR_FIELD(stmt_type);
5068  COPY_STRING_FIELD(role);
5070 
5071  return newnode;
5072 }
5073 
5074 static AlterRoleStmt *
5076 {
5077  AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
5078 
5079  COPY_NODE_FIELD(role);
5082 
5083  return newnode;
5084 }
5085 
5086 static AlterRoleSetStmt *
5088 {
5090 
5091  COPY_NODE_FIELD(role);
5092  COPY_STRING_FIELD(database);
5093  COPY_NODE_FIELD(setstmt);
5094 
5095  return newnode;
5096 }
5097 
5098 static DropRoleStmt *
5100 {
5101  DropRoleStmt *newnode = makeNode(DropRoleStmt);
5102 
5103  COPY_NODE_FIELD(roles);
5104  COPY_SCALAR_FIELD(missing_ok);
5105 
5106  return newnode;
5107 }
5108 
5109 static LockStmt *
5111 {
5112  LockStmt *newnode = makeNode(LockStmt);
5113 
5114  COPY_NODE_FIELD(relations);
5116  COPY_SCALAR_FIELD(nowait);
5117 
5118  return newnode;
5119 }
5120 
5121 static ConstraintsSetStmt *
5123 {
5125 
5126  COPY_NODE_FIELD(constraints);
5127  COPY_SCALAR_FIELD(deferred);
5128 
5129  return newnode;
5130 }
5131 
5132 static ReindexStmt *
5134 {
5135  ReindexStmt *newnode = makeNode(ReindexStmt);
5136 
5137  COPY_SCALAR_FIELD(kind);
5138  COPY_NODE_FIELD(relation);
5140  COPY_NODE_FIELD(params);
5141 
5142  return newnode;
5143 }
5144 
5145 static CreateSchemaStmt *
5147 {
5149 
5150  COPY_STRING_FIELD(schemaname);
5151  COPY_NODE_FIELD(authrole);
5152  COPY_NODE_FIELD(schemaElts);
5153  COPY_SCALAR_FIELD(if_not_exists);
5154 
5155  return newnode;
5156 }
5157 
5158 static CreateConversionStmt *
5160 {
5162 
5163  COPY_NODE_FIELD(conversion_name);
5164  COPY_STRING_FIELD(for_encoding_name);
5165  COPY_STRING_FIELD(to_encoding_name);
5166  COPY_NODE_FIELD(func_name);
5167  COPY_SCALAR_FIELD(def);
5168 
5169  return newnode;
5170 }
5171 
5172 static CreateCastStmt *
5174 {
5176 
5177  COPY_NODE_FIELD(sourcetype);
5178  COPY_NODE_FIELD(targettype);
5179  COPY_NODE_FIELD(func);
5180  COPY_SCALAR_FIELD(context);
5181  COPY_SCALAR_FIELD(inout);
5182 
5183  return newnode;
5184 }
5185 
5186 static PrepareStmt *
5188 {
5189  PrepareStmt *newnode = makeNode(PrepareStmt);
5190 
5192  COPY_NODE_FIELD(argtypes);
5193  COPY_NODE_FIELD(query);
5194 
5195  return newnode;
5196 }
5197 
5198 static ExecuteStmt *
5200 {
5201  ExecuteStmt *newnode = makeNode(ExecuteStmt);
5202 
5204  COPY_NODE_FIELD(params);
5205 
5206  return newnode;
5207 }
5208 
5209 static DeallocateStmt *
5211 {
5213 
5215 
5216  return newnode;
5217 }
5218 
5219 static DropOwnedStmt *
5221 {
5222  DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
5223 
5224  COPY_NODE_FIELD(roles);
5225  COPY_SCALAR_FIELD(behavior);
5226 
5227  return newnode;
5228 }
5229 
5230 static ReassignOwnedStmt *
5232 {
5234 
5235  COPY_NODE_FIELD(roles);
5236  COPY_NODE_FIELD(newrole);
5237 
5238  return newnode;
5239 }
5240 
5241 static AlterTSDictionaryStmt *
5243 {
5245 
5246  COPY_NODE_FIELD(dictname);
5248 
5249  return newnode;
5250 }
5251 
5252 static AlterTSConfigurationStmt *
5254 {
5256 
5257  COPY_SCALAR_FIELD(kind);
5258  COPY_NODE_FIELD(cfgname);
5259  COPY_NODE_FIELD(tokentype);
5260  COPY_NODE_FIELD(dicts);
5261  COPY_SCALAR_FIELD(override);
5262  COPY_SCALAR_FIELD(replace);
5263  COPY_SCALAR_FIELD(missing_ok);
5264 
5265  return newnode;
5266 }
5267 
5268 static CreatePolicyStmt *
5270 {
5272 
5273  COPY_STRING_FIELD(policy_name);
5274  COPY_NODE_FIELD(table);
5275  COPY_STRING_FIELD(cmd_name);
5276  COPY_SCALAR_FIELD(permissive);
5277  COPY_NODE_FIELD(roles);
5278  COPY_NODE_FIELD(qual);
5279  COPY_NODE_FIELD(with_check);
5280 
5281  return newnode;
5282 }
5283 
5284 static AlterPolicyStmt *
5286 {
5288 
5289  COPY_STRING_FIELD(policy_name);
5290  COPY_NODE_FIELD(table);
5291  COPY_NODE_FIELD(roles);
5292  COPY_NODE_FIELD(qual);
5293  COPY_NODE_FIELD(with_check);
5294 
5295  return newnode;
5296 }
5297 
5298 static PartitionElem *
5300 {
5301  PartitionElem *newnode = makeNode(PartitionElem);
5302 
5304  COPY_NODE_FIELD(expr);
5305  COPY_NODE_FIELD(collation);
5306  COPY_NODE_FIELD(opclass);
5307  COPY_LOCATION_FIELD(location);
5308 
5309  return newnode;
5310 }
5311 
5312 static PartitionSpec *
5314 {
5315  PartitionSpec *newnode = makeNode(PartitionSpec);
5316 
5317  COPY_STRING_FIELD(strategy);
5318  COPY_NODE_FIELD(partParams);
5319  COPY_LOCATION_FIELD(location);
5320 
5321  return newnode;
5322 }
5323 
5324 static PartitionBoundSpec *
5326 {
5328 
5329  COPY_SCALAR_FIELD(strategy);
5330  COPY_SCALAR_FIELD(is_default);
5331  COPY_SCALAR_FIELD(modulus);
5332  COPY_SCALAR_FIELD(remainder);
5333  COPY_NODE_FIELD(listdatums);
5334  COPY_NODE_FIELD(lowerdatums);
5335  COPY_NODE_FIELD(upperdatums);
5336  COPY_LOCATION_FIELD(location);
5337 
5338  return newnode;
5339 }
5340 
5341 static PartitionRangeDatum *
5343 {
5345 
5346  COPY_SCALAR_FIELD(kind);
5348  COPY_LOCATION_FIELD(location);
5349 
5350  return newnode;
5351 }
5352 
5353 static PartitionCmd *
5355 {
5356  PartitionCmd *newnode = makeNode(PartitionCmd);
5357 
5359  COPY_NODE_FIELD(bound);
5360  COPY_SCALAR_FIELD(concurrent);
5361 
5362  return newnode;
5363 }
5364 
5365 static PublicationObjSpec *
5367 {
5369 
5370  COPY_SCALAR_FIELD(pubobjtype);
5372  COPY_NODE_FIELD(pubtable);
5373  COPY_LOCATION_FIELD(location);
5374 
5375  return newnode;
5376 }
5377 
5378 static PublicationTable *
5380 {
5382 
5383  COPY_NODE_FIELD(relation);
5384  COPY_NODE_FIELD(whereClause);
5385  COPY_NODE_FIELD(columns);
5386 
5387  return newnode;
5388 }
5389 
5390 static CreatePublicationStmt *
5392 {
5394 
5395  COPY_STRING_FIELD(pubname);
5397  COPY_NODE_FIELD(pubobjects);
5398  COPY_SCALAR_FIELD(for_all_tables);
5399 
5400  return newnode;
5401 }
5402 
5403 static AlterPublicationStmt *
5405 {
5407 
5408  COPY_STRING_FIELD(pubname);
5410  COPY_NODE_FIELD(pubobjects);
5411  COPY_SCALAR_FIELD(for_all_tables);
5413 
5414  return newnode;
5415 }
5416 
5417 static CreateSubscriptionStmt *
5419 {
5421 
5423  COPY_STRING_FIELD(conninfo);
5424  COPY_NODE_FIELD(publication);
5426 
5427  return newnode;
5428 }
5429 
5430 static AlterSubscriptionStmt *
5432 {
5434 
5435  COPY_SCALAR_FIELD(kind);
5437  COPY_STRING_FIELD(conninfo);
5438  COPY_NODE_FIELD(publication);
5440 
5441  return newnode;
5442 }
5443 
5444 static DropSubscriptionStmt *
5446 {
5448 
5450  COPY_SCALAR_FIELD(missing_ok);
5451  COPY_SCALAR_FIELD(behavior);
5452 
5453  return newnode;
5454 }
5455 
5456 /* ****************************************************************
5457  * extensible.h copy functions
5458  * ****************************************************************
5459  */
5460 static ExtensibleNode *
5462 {
5463  ExtensibleNode *newnode;
5464  const ExtensibleNodeMethods *methods;
5465 
5466  methods = GetExtensibleNodeMethods(from->extnodename, false);
5467  newnode = (ExtensibleNode *) newNode(methods->node_size,
5469  COPY_STRING_FIELD(extnodename);
5470 
5471  /* copy the private fields */
5472  methods->nodeCopy(newnode, from);
5473 
5474  return newnode;
5475 }
5476 
5477 /* ****************************************************************
5478  * value.h copy functions
5479  * ****************************************************************
5480  */
5481 static Integer *
5482 _copyInteger(const Integer *from)
5483 {
5484  Integer *newnode = makeNode(Integer);
5485 
5486  COPY_SCALAR_FIELD(ival);
5487 
5488  return newnode;
5489 }
5490 
5491 static Float *
5492 _copyFloat(const Float *from)
5493 {
5494  Float *newnode = makeNode(Float);
5495 
5496  COPY_STRING_FIELD(fval);
5497 
5498  return newnode;
5499 }
5500 
5501 static Boolean *
5502 _copyBoolean(const Boolean *from)
5503 {
5504  Boolean *newnode = makeNode(Boolean);
5505 
5506  COPY_SCALAR_FIELD(boolval);
5507 
5508  return newnode;
5509 }
5510 
5511 static String *
5512 _copyString(const String *from)
5513 {
5514  String *newnode = makeNode(String);
5515 
5516  COPY_STRING_FIELD(sval);
5517 
5518  return newnode;
5519 }
5520 
5521 static BitString *
5523 {
5524  BitString *newnode = makeNode(BitString);
5525 
5526  COPY_STRING_FIELD(bsval);
5527 
5528  return newnode;
5529 }
5530 
5531 
5532 static ForeignKeyCacheInfo *
5534 {
5536 
5537  COPY_SCALAR_FIELD(conoid);
5538  COPY_SCALAR_FIELD(conrelid);
5539  COPY_SCALAR_FIELD(confrelid);
5540  COPY_SCALAR_FIELD(nkeys);
5541  COPY_ARRAY_FIELD(conkey);
5542  COPY_ARRAY_FIELD(confkey);
5543  COPY_ARRAY_FIELD(conpfeqop);
5544 
5545  return newnode;
5546 }
5547 
5548 /*
5549  * copyObjectImpl -- implementation of copyObject(); see nodes/nodes.h
5550  *
5551  * Create a copy of a Node tree or list. This is a "deep" copy: all
5552  * substructure is copied too, recursively.
5553  */
5554 void *
5555 copyObjectImpl(const void *from)
5556 {
5557  void *retval;
5558 
5559  if (from == NULL)
5560  return NULL;
5561 
5562  /* Guard against stack overflow due to overly complex expressions */
5564 
5565  switch (nodeTag(from))
5566  {
5567  /*
5568  * PLAN NODES
5569  */
5570  case T_PlannedStmt:
5571  retval = _copyPlannedStmt(from);
5572  break;
5573  case T_Plan:
5574  retval = _copyPlan(from);
5575  break;
5576  case T_Result:
5577  retval = _copyResult(from);
5578  break;
5579  case T_ProjectSet:
5580  retval = _copyProjectSet(from);
5581  break;
5582  case T_ModifyTable:
5583  retval = _copyModifyTable(from);
5584  break;
5585  case T_Append:
5586  retval = _copyAppend(from);
5587  break;
5588  case T_MergeAppend:
5589  retval = _copyMergeAppend(from);
5590  break;
5591  case T_RecursiveUnion:
5592  retval = _copyRecursiveUnion(from);
5593  break;
5594  case T_BitmapAnd:
5595  retval = _copyBitmapAnd(from);
5596  break;
5597  case T_BitmapOr:
5598  retval = _copyBitmapOr(from);
5599  break;
5600  case T_Scan:
5601  retval = _copyScan(from);
5602  break;
5603  case T_Gather:
5604  retval = _copyGather(from);
5605  break;
5606  case T_GatherMerge:
5607  retval = _copyGatherMerge(from);
5608  break;
5609  case T_SeqScan:
5610  retval = _copySeqScan(from);
5611  break;
5612  case T_SampleScan:
5613  retval = _copySampleScan(from);
5614  break;
5615  case T_IndexScan:
5616  retval = _copyIndexScan(from);
5617  break;
5618  case T_IndexOnlyScan:
5619  retval = _copyIndexOnlyScan(from);
5620  break;
5621  case T_BitmapIndexScan:
5622  retval = _copyBitmapIndexScan(from);
5623  break;
5624  case T_BitmapHeapScan:
5625  retval = _copyBitmapHeapScan(from);
5626  break;
5627  case T_TidScan:
5628  retval = _copyTidScan(from);
5629  break;
5630  case T_TidRangeScan:
5631  retval = _copyTidRangeScan(from);
5632  break;
5633  case T_SubqueryScan:
5634  retval = _copySubqueryScan(from);
5635  break;
5636  case T_FunctionScan:
5637  retval = _copyFunctionScan(from);
5638  break;
5639  case T_TableFuncScan:
5640  retval = _copyTableFuncScan(from);
5641  break;
5642  case T_ValuesScan:
5643  retval = _copyValuesScan(from);
5644  break;
5645  case T_CteScan:
5646  retval = _copyCteScan(from);
5647  break;
5648  case T_NamedTuplestoreScan:
5649  retval = _copyNamedTuplestoreScan(from);
5650  break;
5651  case T_WorkTableScan:
5652  retval = _copyWorkTableScan(from);
5653  break;
5654  case T_ForeignScan:
5655  retval = _copyForeignScan(from);
5656  break;
5657  case T_CustomScan:
5658  retval = _copyCustomScan(from);
5659  break;
5660  case T_Join:
5661  retval = _copyJoin(from);
5662  break;
5663  case T_NestLoop:
5664  retval = _copyNestLoop(from);
5665  break;
5666  case T_MergeJoin:
5667  retval = _copyMergeJoin(from);
5668  break;
5669  case T_HashJoin:
5670  retval = _copyHashJoin(from);
5671  break;
5672  case T_Material:
5673  retval = _copyMaterial(from);
5674  break;
5675  case T_Memoize:
5676  retval = _copyMemoize(from);
5677  break;
5678  case T_Sort:
5679  retval = _copySort(from);
5680  break;
5681  case T_IncrementalSort:
5682  retval = _copyIncrementalSort(from);
5683  break;
5684  case T_Group:
5685  retval = _copyGroup(from);
5686  break;
5687  case T_Agg:
5688  retval = _copyAgg(from);
5689  break;
5690  case T_WindowAgg:
5691  retval = _copyWindowAgg(from);
5692  break;
5693  case T_Unique:
5694  retval = _copyUnique(from);
5695  break;
5696  case T_Hash:
5697  retval = _copyHash(from);
5698  break;
5699  case T_SetOp:
5700  retval = _copySetOp(from);
5701  break;
5702  case T_LockRows:
5703  retval = _copyLockRows(from);
5704  break;
5705  case T_Limit:
5706  retval = _copyLimit(from);
5707  break;
5708  case T_NestLoopParam:
5709  retval = _copyNestLoopParam(from);
5710  break;
5711  case T_PlanRowMark:
5712  retval = _copyPlanRowMark(from);
5713  break;
5714  case T_PartitionPruneInfo:
5715  retval = _copyPartitionPruneInfo(from);
5716  break;
5718  retval = _copyPartitionedRelPruneInfo(from);
5719  break;
5721  retval = _copyPartitionPruneStepOp(from);
5722  break;
5724  retval = _copyPartitionPruneStepCombine(from);
5725  break;
5726  case T_PlanInvalItem:
5727  retval = _copyPlanInvalItem(from);
5728  break;
5729 
5730  /*
5731  * PRIMITIVE NODES
5732  */
5733  case T_Alias:
5734  retval = _copyAlias(from);
5735  break;
5736  case T_RangeVar:
5737  retval = _copyRangeVar(from);
5738  break;
5739  case T_TableFunc:
5740  retval = _copyTableFunc(from);
5741  break;
5742  case T_IntoClause:
5743  retval = _copyIntoClause(from);
5744  break;
5745  case T_Var:
5746  retval = _copyVar(from);
5747  break;
5748  case T_Const:
5749  retval = _copyConst(from);
5750  break;
5751  case T_Param:
5752  retval = _copyParam(from);
5753  break;
5754  case T_Aggref:
5755  retval = _copyAggref(from);
5756  break;
5757  case T_GroupingFunc:
5758  retval = _copyGroupingFunc(from);
5759  break;
5760  case T_WindowFunc:
5761  retval = _copyWindowFunc(from);
5762  break;
5763  case T_SubscriptingRef:
5764  retval = _copySubscriptingRef(from);
5765  break;
5766  case T_FuncExpr:
5767  retval = _copyFuncExpr(from);
5768  break;
5769  case T_NamedArgExpr:
5770  retval = _copyNamedArgExpr(from);
5771  break;
5772  case T_OpExpr:
5773  retval = _copyOpExpr(from);
5774  break;
5775  case T_DistinctExpr:
5776  retval = _copyDistinctExpr(from);
5777  break;
5778  case T_NullIfExpr:
5779  retval = _copyNullIfExpr(from);
5780  break;
5781  case T_ScalarArrayOpExpr:
5782  retval = _copyScalarArrayOpExpr(from);
5783  break;
5784  case T_BoolExpr:
5785  retval = _copyBoolExpr(from);
5786  break;
5787  case T_SubLink:
5788  retval = _copySubLink(from);
5789  break;
5790  case T_SubPlan:
5791  retval = _copySubPlan(from);
5792  break;
5793  case T_AlternativeSubPlan:
5794  retval = _copyAlternativeSubPlan(from);
5795  break;
5796  case T_FieldSelect:
5797  retval = _copyFieldSelect(from);
5798  break;
5799  case T_FieldStore:
5800  retval = _copyFieldStore(from);
5801  break;
5802  case T_RelabelType:
5803  retval = _copyRelabelType(from);
5804  break;
5805  case T_CoerceViaIO:
5806  retval = _copyCoerceViaIO(from);
5807  break;
5808  case T_ArrayCoerceExpr:
5809  retval = _copyArrayCoerceExpr(from);
5810  break;
5811  case T_ConvertRowtypeExpr:
5812  retval = _copyConvertRowtypeExpr(from);
5813  break;
5814  case T_CollateExpr:
5815  retval = _copyCollateExpr(from);
5816  break;
5817  case T_CaseExpr:
5818  retval = _copyCaseExpr(from);
5819  break;
5820  case T_CaseWhen:
5821  retval = _copyCaseWhen(from);
5822  break;
5823  case T_CaseTestExpr:
5824  retval = _copyCaseTestExpr(from);
5825  break;
5826  case T_ArrayExpr:
5827  retval = _copyArrayExpr(from);
5828  break;
5829  case T_RowExpr:
5830  retval = _copyRowExpr(from);
5831  break;
5832  case T_RowCompareExpr:
5833  retval = _copyRowCompareExpr(from);
5834  break;
5835  case T_CoalesceExpr:
5836  retval = _copyCoalesceExpr(from);
5837  break;
5838  case T_MinMaxExpr:
5839  retval = _copyMinMaxExpr(from);
5840  break;
5841  case T_SQLValueFunction:
5842  retval = _copySQLValueFunction(from);
5843  break;
5844  case T_XmlExpr:
5845  retval = _copyXmlExpr(from);
5846  break;
5847  case T_NullTest:
5848  retval = _copyNullTest(from);
5849  break;
5850  case T_BooleanTest:
5851  retval = _copyBooleanTest(from);
5852  break;
5853  case T_CoerceToDomain:
5854  retval = _copyCoerceToDomain(from);
5855  break;
5856  case T_CoerceToDomainValue:
5857  retval = _copyCoerceToDomainValue(from);
5858  break;
5859  case T_SetToDefault:
5860  retval = _copySetToDefault(from);
5861  break;
5862  case T_CurrentOfExpr:
5863  retval = _copyCurrentOfExpr(from);
5864  break;
5865  case T_NextValueExpr:
5866  retval = _copyNextValueExpr(from);
5867  break;
5868  case T_InferenceElem:
5869  retval = _copyInferenceElem(from);
5870  break;
5871  case T_TargetEntry:
5872  retval = _copyTargetEntry(from);
5873  break;
5874  case T_RangeTblRef:
5875  retval = _copyRangeTblRef(from);
5876  break;
5877  case T_JoinExpr:
5878  retval = _copyJoinExpr(from);
5879  break;
5880  case T_FromExpr:
5881  retval = _copyFromExpr(from);
5882  break;
5883  case T_OnConflictExpr:
5884  retval = _copyOnConflictExpr(from);
5885  break;
5886  case T_JsonFormat:
5887  retval = _copyJsonFormat(from);
5888  break;
5889  case T_JsonReturning:
5890  retval = _copyJsonReturning(from);
5891  break;
5892  case T_JsonValueExpr:
5893  retval = _copyJsonValueExpr(from);
5894  break;
5895  case T_JsonParseExpr:
5896  retval = _copyJsonParseExpr(from);
5897  break;
5898  case T_JsonScalarExpr:
5899  retval = _copyJsonScalarExpr(from);
5900  break;
5901  case T_JsonSerializeExpr:
5902  retval = _copyJsonSerializeExpr(from);
5903  break;
5904  case T_JsonKeyValue:
5905  retval = _copyJsonKeyValue(from);
5906  break;
5907  case T_JsonConstructorExpr:
5908  retval = _copyJsonConstructorExpr(from);
5909  break;
5911  retval = _copyJsonObjectConstructor(from);
5912  break;
5913  case T_JsonAggConstructor:
5914  retval = _copyJsonAggConstructor(from);
5915  break;
5916  case T_JsonObjectAgg:
5917  retval = _copyJsonObjectAgg(from);
5918  break;
5919  case T_JsonOutput:
5920  retval = _copyJsonOutput(from);
5921  break;
5923  retval = _copyJsonArrayConstructor(from);
5924  break;
5926  retval = _copyJsonArrayQueryConstructor(from);
5927  break;
5928  case T_JsonArrayAgg:
5929  retval = _copyJsonArrayAgg(from);
5930  break;
5931  case T_JsonIsPredicate:
5932  retval = _copyJsonIsPredicate(from);
5933  break;
5934  case T_JsonFuncExpr:
5935  retval = _copyJsonFuncExpr(from);
5936  break;
5937  case T_JsonExpr:
5938  retval = _copyJsonExpr(from);
5939  break;
5940  case T_JsonCommon:
5941  retval = _copyJsonCommon(from);
5942  break;
5943  case T_JsonBehavior:
5944  retval = _copyJsonBehavior(from);
5945  break;
5946  case T_JsonArgument:
5947  retval = _copyJsonArgument(from);
5948  break;
5949  case T_JsonCoercion:
5950  retval = _copyJsonCoercion(from);
5951  break;
5952  case T_JsonItemCoercions:
5953  retval = _copyJsonItemCoercions(from);
5954  break;
5955  case T_JsonTable:
5956  retval = _copyJsonTable(from);
5957  break;
5958  case T_JsonTableColumn:
5959  retval = _copyJsonTableColumn(from);
5960  break;
5961  case T_JsonTablePlan:
5962  retval = _copyJsonTablePlan(from);
5963  break;
5964  case T_JsonTableParent:
5965  retval = _copyJsonTableParent(from);
5966  break;
5967  case T_JsonTableSibling:
5968  retval = _copyJsonTableSibling(from);
5969  break;
5970 
5971  /*
5972  * RELATION NODES
5973  */
5974  case T_PathKey:
5975  retval = _copyPathKey(from);
5976  break;
5977  case T_RestrictInfo:
5978  retval = _copyRestrictInfo(from);
5979  break;
5980  case T_PlaceHolderVar:
5981  retval = _copyPlaceHolderVar(from);
5982  break;
5983  case T_SpecialJoinInfo:
5984  retval = _copySpecialJoinInfo(from);
5985  break;
5986  case T_AppendRelInfo:
5987  retval = _copyAppendRelInfo(from);
5988  break;
5989  case T_PlaceHolderInfo:
5990  retval = _copyPlaceHolderInfo(from);
5991  break;
5992 
5993  /*
5994  * VALUE NODES
5995  */
5996  case T_Integer:
5997  retval = _copyInteger(from);
5998  break;
5999  case T_Float:
6000  retval = _copyFloat(from);
6001  break;
6002  case T_Boolean:
6003  retval = _copyBoolean(from);
6004  break;
6005  case T_String:
6006  retval = _copyString(from);
6007  break;
6008  case T_BitString:
6009  retval = _copyBitString(from);
6010  break;
6011 
6012  /*
6013  * LIST NODES
6014  */
6015  case