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