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