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