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