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