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