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