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