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