Header And Logo

PostgreSQL
| The world's most advanced open source database.

copyfuncs.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * copyfuncs.c
00004  *    Copy functions for Postgres tree nodes.
00005  *
00006  * NOTE: we currently support copying all node types found in parse and
00007  * plan trees.  We do not support copying executor state trees; there
00008  * is no need for that, and no point in maintaining all the code that
00009  * would be needed.  We also do not support copying Path trees, mainly
00010  * because the circular linkages between RelOptInfo and Path nodes can't
00011  * be handled easily in a simple depth-first traversal.
00012  *
00013  *
00014  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00015  * Portions Copyright (c) 1994, Regents of the University of California
00016  *
00017  * IDENTIFICATION
00018  *    src/backend/nodes/copyfuncs.c
00019  *
00020  *-------------------------------------------------------------------------
00021  */
00022 
00023 #include "postgres.h"
00024 
00025 #include "miscadmin.h"
00026 #include "nodes/plannodes.h"
00027 #include "nodes/relation.h"
00028 #include "utils/datum.h"
00029 
00030 
00031 /*
00032  * Macros to simplify copying of different kinds of fields.  Use these
00033  * wherever possible to reduce the chance for silly typos.  Note that these
00034  * hard-wire the convention that the local variables in a Copy routine are
00035  * named 'newnode' and 'from'.
00036  */
00037 
00038 /* Copy a simple scalar field (int, float, bool, enum, etc) */
00039 #define COPY_SCALAR_FIELD(fldname) \
00040     (newnode->fldname = from->fldname)
00041 
00042 /* Copy a field that is a pointer to some kind of Node or Node tree */
00043 #define COPY_NODE_FIELD(fldname) \
00044     (newnode->fldname = copyObject(from->fldname))
00045 
00046 /* Copy a field that is a pointer to a Bitmapset */
00047 #define COPY_BITMAPSET_FIELD(fldname) \
00048     (newnode->fldname = bms_copy(from->fldname))
00049 
00050 /* Copy a field that is a pointer to a C string, or perhaps NULL */
00051 #define COPY_STRING_FIELD(fldname) \
00052     (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
00053 
00054 /* Copy a field that is a pointer to a simple palloc'd object of size sz */
00055 #define COPY_POINTER_FIELD(fldname, sz) \
00056     do { \
00057         Size    _size = (sz); \
00058         newnode->fldname = palloc(_size); \
00059         memcpy(newnode->fldname, from->fldname, _size); \
00060     } while (0)
00061 
00062 /* Copy a parse location field (for Copy, this is same as scalar case) */
00063 #define COPY_LOCATION_FIELD(fldname) \
00064     (newnode->fldname = from->fldname)
00065 
00066 
00067 /* ****************************************************************
00068  *                   plannodes.h copy functions
00069  * ****************************************************************
00070  */
00071 
00072 /*
00073  * _copyPlannedStmt
00074  */
00075 static PlannedStmt *
00076 _copyPlannedStmt(const PlannedStmt *from)
00077 {
00078     PlannedStmt *newnode = makeNode(PlannedStmt);
00079 
00080     COPY_SCALAR_FIELD(commandType);
00081     COPY_SCALAR_FIELD(queryId);
00082     COPY_SCALAR_FIELD(hasReturning);
00083     COPY_SCALAR_FIELD(hasModifyingCTE);
00084     COPY_SCALAR_FIELD(canSetTag);
00085     COPY_SCALAR_FIELD(transientPlan);
00086     COPY_NODE_FIELD(planTree);
00087     COPY_NODE_FIELD(rtable);
00088     COPY_NODE_FIELD(resultRelations);
00089     COPY_NODE_FIELD(utilityStmt);
00090     COPY_NODE_FIELD(subplans);
00091     COPY_BITMAPSET_FIELD(rewindPlanIDs);
00092     COPY_NODE_FIELD(rowMarks);
00093     COPY_NODE_FIELD(relationOids);
00094     COPY_NODE_FIELD(invalItems);
00095     COPY_SCALAR_FIELD(nParamExec);
00096 
00097     return newnode;
00098 }
00099 
00100 /*
00101  * CopyPlanFields
00102  *
00103  *      This function copies the fields of the Plan node.  It is used by
00104  *      all the copy functions for classes which inherit from Plan.
00105  */
00106 static void
00107 CopyPlanFields(const Plan *from, Plan *newnode)
00108 {
00109     COPY_SCALAR_FIELD(startup_cost);
00110     COPY_SCALAR_FIELD(total_cost);
00111     COPY_SCALAR_FIELD(plan_rows);
00112     COPY_SCALAR_FIELD(plan_width);
00113     COPY_NODE_FIELD(targetlist);
00114     COPY_NODE_FIELD(qual);
00115     COPY_NODE_FIELD(lefttree);
00116     COPY_NODE_FIELD(righttree);
00117     COPY_NODE_FIELD(initPlan);
00118     COPY_BITMAPSET_FIELD(extParam);
00119     COPY_BITMAPSET_FIELD(allParam);
00120 }
00121 
00122 /*
00123  * _copyPlan
00124  */
00125 static Plan *
00126 _copyPlan(const Plan *from)
00127 {
00128     Plan       *newnode = makeNode(Plan);
00129 
00130     /*
00131      * copy node superclass fields
00132      */
00133     CopyPlanFields(from, newnode);
00134 
00135     return newnode;
00136 }
00137 
00138 
00139 /*
00140  * _copyResult
00141  */
00142 static Result *
00143 _copyResult(const Result *from)
00144 {
00145     Result     *newnode = makeNode(Result);
00146 
00147     /*
00148      * copy node superclass fields
00149      */
00150     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00151 
00152     /*
00153      * copy remainder of node
00154      */
00155     COPY_NODE_FIELD(resconstantqual);
00156 
00157     return newnode;
00158 }
00159 
00160 /*
00161  * _copyModifyTable
00162  */
00163 static ModifyTable *
00164 _copyModifyTable(const ModifyTable *from)
00165 {
00166     ModifyTable *newnode = makeNode(ModifyTable);
00167 
00168     /*
00169      * copy node superclass fields
00170      */
00171     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00172 
00173     /*
00174      * copy remainder of node
00175      */
00176     COPY_SCALAR_FIELD(operation);
00177     COPY_SCALAR_FIELD(canSetTag);
00178     COPY_NODE_FIELD(resultRelations);
00179     COPY_SCALAR_FIELD(resultRelIndex);
00180     COPY_NODE_FIELD(plans);
00181     COPY_NODE_FIELD(returningLists);
00182     COPY_NODE_FIELD(fdwPrivLists);
00183     COPY_NODE_FIELD(rowMarks);
00184     COPY_SCALAR_FIELD(epqParam);
00185 
00186     return newnode;
00187 }
00188 
00189 /*
00190  * _copyAppend
00191  */
00192 static Append *
00193 _copyAppend(const Append *from)
00194 {
00195     Append     *newnode = makeNode(Append);
00196 
00197     /*
00198      * copy node superclass fields
00199      */
00200     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00201 
00202     /*
00203      * copy remainder of node
00204      */
00205     COPY_NODE_FIELD(appendplans);
00206 
00207     return newnode;
00208 }
00209 
00210 /*
00211  * _copyMergeAppend
00212  */
00213 static MergeAppend *
00214 _copyMergeAppend(const MergeAppend *from)
00215 {
00216     MergeAppend *newnode = makeNode(MergeAppend);
00217 
00218     /*
00219      * copy node superclass fields
00220      */
00221     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00222 
00223     /*
00224      * copy remainder of node
00225      */
00226     COPY_NODE_FIELD(mergeplans);
00227     COPY_SCALAR_FIELD(numCols);
00228     COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
00229     COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
00230     COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
00231     COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
00232 
00233     return newnode;
00234 }
00235 
00236 /*
00237  * _copyRecursiveUnion
00238  */
00239 static RecursiveUnion *
00240 _copyRecursiveUnion(const RecursiveUnion *from)
00241 {
00242     RecursiveUnion *newnode = makeNode(RecursiveUnion);
00243 
00244     /*
00245      * copy node superclass fields
00246      */
00247     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00248 
00249     /*
00250      * copy remainder of node
00251      */
00252     COPY_SCALAR_FIELD(wtParam);
00253     COPY_SCALAR_FIELD(numCols);
00254     if (from->numCols > 0)
00255     {
00256         COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
00257         COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
00258     }
00259     COPY_SCALAR_FIELD(numGroups);
00260 
00261     return newnode;
00262 }
00263 
00264 /*
00265  * _copyBitmapAnd
00266  */
00267 static BitmapAnd *
00268 _copyBitmapAnd(const BitmapAnd *from)
00269 {
00270     BitmapAnd  *newnode = makeNode(BitmapAnd);
00271 
00272     /*
00273      * copy node superclass fields
00274      */
00275     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00276 
00277     /*
00278      * copy remainder of node
00279      */
00280     COPY_NODE_FIELD(bitmapplans);
00281 
00282     return newnode;
00283 }
00284 
00285 /*
00286  * _copyBitmapOr
00287  */
00288 static BitmapOr *
00289 _copyBitmapOr(const BitmapOr *from)
00290 {
00291     BitmapOr   *newnode = makeNode(BitmapOr);
00292 
00293     /*
00294      * copy node superclass fields
00295      */
00296     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00297 
00298     /*
00299      * copy remainder of node
00300      */
00301     COPY_NODE_FIELD(bitmapplans);
00302 
00303     return newnode;
00304 }
00305 
00306 
00307 /*
00308  * CopyScanFields
00309  *
00310  *      This function copies the fields of the Scan node.  It is used by
00311  *      all the copy functions for classes which inherit from Scan.
00312  */
00313 static void
00314 CopyScanFields(const Scan *from, Scan *newnode)
00315 {
00316     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00317 
00318     COPY_SCALAR_FIELD(scanrelid);
00319 }
00320 
00321 /*
00322  * _copyScan
00323  */
00324 static Scan *
00325 _copyScan(const Scan *from)
00326 {
00327     Scan       *newnode = makeNode(Scan);
00328 
00329     /*
00330      * copy node superclass fields
00331      */
00332     CopyScanFields((const Scan *) from, (Scan *) newnode);
00333 
00334     return newnode;
00335 }
00336 
00337 /*
00338  * _copySeqScan
00339  */
00340 static SeqScan *
00341 _copySeqScan(const SeqScan *from)
00342 {
00343     SeqScan    *newnode = makeNode(SeqScan);
00344 
00345     /*
00346      * copy node superclass fields
00347      */
00348     CopyScanFields((const Scan *) from, (Scan *) newnode);
00349 
00350     return newnode;
00351 }
00352 
00353 /*
00354  * _copyIndexScan
00355  */
00356 static IndexScan *
00357 _copyIndexScan(const IndexScan *from)
00358 {
00359     IndexScan  *newnode = makeNode(IndexScan);
00360 
00361     /*
00362      * copy node superclass fields
00363      */
00364     CopyScanFields((const Scan *) from, (Scan *) newnode);
00365 
00366     /*
00367      * copy remainder of node
00368      */
00369     COPY_SCALAR_FIELD(indexid);
00370     COPY_NODE_FIELD(indexqual);
00371     COPY_NODE_FIELD(indexqualorig);
00372     COPY_NODE_FIELD(indexorderby);
00373     COPY_NODE_FIELD(indexorderbyorig);
00374     COPY_SCALAR_FIELD(indexorderdir);
00375 
00376     return newnode;
00377 }
00378 
00379 /*
00380  * _copyIndexOnlyScan
00381  */
00382 static IndexOnlyScan *
00383 _copyIndexOnlyScan(const IndexOnlyScan *from)
00384 {
00385     IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
00386 
00387     /*
00388      * copy node superclass fields
00389      */
00390     CopyScanFields((const Scan *) from, (Scan *) newnode);
00391 
00392     /*
00393      * copy remainder of node
00394      */
00395     COPY_SCALAR_FIELD(indexid);
00396     COPY_NODE_FIELD(indexqual);
00397     COPY_NODE_FIELD(indexorderby);
00398     COPY_NODE_FIELD(indextlist);
00399     COPY_SCALAR_FIELD(indexorderdir);
00400 
00401     return newnode;
00402 }
00403 
00404 /*
00405  * _copyBitmapIndexScan
00406  */
00407 static BitmapIndexScan *
00408 _copyBitmapIndexScan(const BitmapIndexScan *from)
00409 {
00410     BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
00411 
00412     /*
00413      * copy node superclass fields
00414      */
00415     CopyScanFields((const Scan *) from, (Scan *) newnode);
00416 
00417     /*
00418      * copy remainder of node
00419      */
00420     COPY_SCALAR_FIELD(indexid);
00421     COPY_NODE_FIELD(indexqual);
00422     COPY_NODE_FIELD(indexqualorig);
00423 
00424     return newnode;
00425 }
00426 
00427 /*
00428  * _copyBitmapHeapScan
00429  */
00430 static BitmapHeapScan *
00431 _copyBitmapHeapScan(const BitmapHeapScan *from)
00432 {
00433     BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
00434 
00435     /*
00436      * copy node superclass fields
00437      */
00438     CopyScanFields((const Scan *) from, (Scan *) newnode);
00439 
00440     /*
00441      * copy remainder of node
00442      */
00443     COPY_NODE_FIELD(bitmapqualorig);
00444 
00445     return newnode;
00446 }
00447 
00448 /*
00449  * _copyTidScan
00450  */
00451 static TidScan *
00452 _copyTidScan(const TidScan *from)
00453 {
00454     TidScan    *newnode = makeNode(TidScan);
00455 
00456     /*
00457      * copy node superclass fields
00458      */
00459     CopyScanFields((const Scan *) from, (Scan *) newnode);
00460 
00461     /*
00462      * copy remainder of node
00463      */
00464     COPY_NODE_FIELD(tidquals);
00465 
00466     return newnode;
00467 }
00468 
00469 /*
00470  * _copySubqueryScan
00471  */
00472 static SubqueryScan *
00473 _copySubqueryScan(const SubqueryScan *from)
00474 {
00475     SubqueryScan *newnode = makeNode(SubqueryScan);
00476 
00477     /*
00478      * copy node superclass fields
00479      */
00480     CopyScanFields((const Scan *) from, (Scan *) newnode);
00481 
00482     /*
00483      * copy remainder of node
00484      */
00485     COPY_NODE_FIELD(subplan);
00486 
00487     return newnode;
00488 }
00489 
00490 /*
00491  * _copyFunctionScan
00492  */
00493 static FunctionScan *
00494 _copyFunctionScan(const FunctionScan *from)
00495 {
00496     FunctionScan *newnode = makeNode(FunctionScan);
00497 
00498     /*
00499      * copy node superclass fields
00500      */
00501     CopyScanFields((const Scan *) from, (Scan *) newnode);
00502 
00503     /*
00504      * copy remainder of node
00505      */
00506     COPY_NODE_FIELD(funcexpr);
00507     COPY_NODE_FIELD(funccolnames);
00508     COPY_NODE_FIELD(funccoltypes);
00509     COPY_NODE_FIELD(funccoltypmods);
00510     COPY_NODE_FIELD(funccolcollations);
00511 
00512     return newnode;
00513 }
00514 
00515 /*
00516  * _copyValuesScan
00517  */
00518 static ValuesScan *
00519 _copyValuesScan(const ValuesScan *from)
00520 {
00521     ValuesScan *newnode = makeNode(ValuesScan);
00522 
00523     /*
00524      * copy node superclass fields
00525      */
00526     CopyScanFields((const Scan *) from, (Scan *) newnode);
00527 
00528     /*
00529      * copy remainder of node
00530      */
00531     COPY_NODE_FIELD(values_lists);
00532 
00533     return newnode;
00534 }
00535 
00536 /*
00537  * _copyCteScan
00538  */
00539 static CteScan *
00540 _copyCteScan(const CteScan *from)
00541 {
00542     CteScan    *newnode = makeNode(CteScan);
00543 
00544     /*
00545      * copy node superclass fields
00546      */
00547     CopyScanFields((const Scan *) from, (Scan *) newnode);
00548 
00549     /*
00550      * copy remainder of node
00551      */
00552     COPY_SCALAR_FIELD(ctePlanId);
00553     COPY_SCALAR_FIELD(cteParam);
00554 
00555     return newnode;
00556 }
00557 
00558 /*
00559  * _copyWorkTableScan
00560  */
00561 static WorkTableScan *
00562 _copyWorkTableScan(const WorkTableScan *from)
00563 {
00564     WorkTableScan *newnode = makeNode(WorkTableScan);
00565 
00566     /*
00567      * copy node superclass fields
00568      */
00569     CopyScanFields((const Scan *) from, (Scan *) newnode);
00570 
00571     /*
00572      * copy remainder of node
00573      */
00574     COPY_SCALAR_FIELD(wtParam);
00575 
00576     return newnode;
00577 }
00578 
00579 /*
00580  * _copyForeignScan
00581  */
00582 static ForeignScan *
00583 _copyForeignScan(const ForeignScan *from)
00584 {
00585     ForeignScan *newnode = makeNode(ForeignScan);
00586 
00587     /*
00588      * copy node superclass fields
00589      */
00590     CopyScanFields((const Scan *) from, (Scan *) newnode);
00591 
00592     /*
00593      * copy remainder of node
00594      */
00595     COPY_NODE_FIELD(fdw_exprs);
00596     COPY_NODE_FIELD(fdw_private);
00597     COPY_SCALAR_FIELD(fsSystemCol);
00598 
00599     return newnode;
00600 }
00601 
00602 /*
00603  * CopyJoinFields
00604  *
00605  *      This function copies the fields of the Join node.  It is used by
00606  *      all the copy functions for classes which inherit from Join.
00607  */
00608 static void
00609 CopyJoinFields(const Join *from, Join *newnode)
00610 {
00611     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00612 
00613     COPY_SCALAR_FIELD(jointype);
00614     COPY_NODE_FIELD(joinqual);
00615 }
00616 
00617 
00618 /*
00619  * _copyJoin
00620  */
00621 static Join *
00622 _copyJoin(const Join *from)
00623 {
00624     Join       *newnode = makeNode(Join);
00625 
00626     /*
00627      * copy node superclass fields
00628      */
00629     CopyJoinFields(from, newnode);
00630 
00631     return newnode;
00632 }
00633 
00634 
00635 /*
00636  * _copyNestLoop
00637  */
00638 static NestLoop *
00639 _copyNestLoop(const NestLoop *from)
00640 {
00641     NestLoop   *newnode = makeNode(NestLoop);
00642 
00643     /*
00644      * copy node superclass fields
00645      */
00646     CopyJoinFields((const Join *) from, (Join *) newnode);
00647 
00648     /*
00649      * copy remainder of node
00650      */
00651     COPY_NODE_FIELD(nestParams);
00652 
00653     return newnode;
00654 }
00655 
00656 
00657 /*
00658  * _copyMergeJoin
00659  */
00660 static MergeJoin *
00661 _copyMergeJoin(const MergeJoin *from)
00662 {
00663     MergeJoin  *newnode = makeNode(MergeJoin);
00664     int         numCols;
00665 
00666     /*
00667      * copy node superclass fields
00668      */
00669     CopyJoinFields((const Join *) from, (Join *) newnode);
00670 
00671     /*
00672      * copy remainder of node
00673      */
00674     COPY_NODE_FIELD(mergeclauses);
00675     numCols = list_length(from->mergeclauses);
00676     if (numCols > 0)
00677     {
00678         COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
00679         COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
00680         COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
00681         COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
00682     }
00683 
00684     return newnode;
00685 }
00686 
00687 /*
00688  * _copyHashJoin
00689  */
00690 static HashJoin *
00691 _copyHashJoin(const HashJoin *from)
00692 {
00693     HashJoin   *newnode = makeNode(HashJoin);
00694 
00695     /*
00696      * copy node superclass fields
00697      */
00698     CopyJoinFields((const Join *) from, (Join *) newnode);
00699 
00700     /*
00701      * copy remainder of node
00702      */
00703     COPY_NODE_FIELD(hashclauses);
00704 
00705     return newnode;
00706 }
00707 
00708 
00709 /*
00710  * _copyMaterial
00711  */
00712 static Material *
00713 _copyMaterial(const Material *from)
00714 {
00715     Material   *newnode = makeNode(Material);
00716 
00717     /*
00718      * copy node superclass fields
00719      */
00720     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00721 
00722     return newnode;
00723 }
00724 
00725 
00726 /*
00727  * _copySort
00728  */
00729 static Sort *
00730 _copySort(const Sort *from)
00731 {
00732     Sort       *newnode = makeNode(Sort);
00733 
00734     /*
00735      * copy node superclass fields
00736      */
00737     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00738 
00739     COPY_SCALAR_FIELD(numCols);
00740     COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
00741     COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
00742     COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
00743     COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
00744 
00745     return newnode;
00746 }
00747 
00748 
00749 /*
00750  * _copyGroup
00751  */
00752 static Group *
00753 _copyGroup(const Group *from)
00754 {
00755     Group      *newnode = makeNode(Group);
00756 
00757     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00758 
00759     COPY_SCALAR_FIELD(numCols);
00760     COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
00761     COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
00762 
00763     return newnode;
00764 }
00765 
00766 /*
00767  * _copyAgg
00768  */
00769 static Agg *
00770 _copyAgg(const Agg *from)
00771 {
00772     Agg        *newnode = makeNode(Agg);
00773 
00774     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00775 
00776     COPY_SCALAR_FIELD(aggstrategy);
00777     COPY_SCALAR_FIELD(numCols);
00778     if (from->numCols > 0)
00779     {
00780         COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
00781         COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
00782     }
00783     COPY_SCALAR_FIELD(numGroups);
00784 
00785     return newnode;
00786 }
00787 
00788 /*
00789  * _copyWindowAgg
00790  */
00791 static WindowAgg *
00792 _copyWindowAgg(const WindowAgg *from)
00793 {
00794     WindowAgg  *newnode = makeNode(WindowAgg);
00795 
00796     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00797 
00798     COPY_SCALAR_FIELD(winref);
00799     COPY_SCALAR_FIELD(partNumCols);
00800     if (from->partNumCols > 0)
00801     {
00802         COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
00803         COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
00804     }
00805     COPY_SCALAR_FIELD(ordNumCols);
00806     if (from->ordNumCols > 0)
00807     {
00808         COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
00809         COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
00810     }
00811     COPY_SCALAR_FIELD(frameOptions);
00812     COPY_NODE_FIELD(startOffset);
00813     COPY_NODE_FIELD(endOffset);
00814 
00815     return newnode;
00816 }
00817 
00818 /*
00819  * _copyUnique
00820  */
00821 static Unique *
00822 _copyUnique(const Unique *from)
00823 {
00824     Unique     *newnode = makeNode(Unique);
00825 
00826     /*
00827      * copy node superclass fields
00828      */
00829     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00830 
00831     /*
00832      * copy remainder of node
00833      */
00834     COPY_SCALAR_FIELD(numCols);
00835     COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
00836     COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
00837 
00838     return newnode;
00839 }
00840 
00841 /*
00842  * _copyHash
00843  */
00844 static Hash *
00845 _copyHash(const Hash *from)
00846 {
00847     Hash       *newnode = makeNode(Hash);
00848 
00849     /*
00850      * copy node superclass fields
00851      */
00852     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00853 
00854     /*
00855      * copy remainder of node
00856      */
00857     COPY_SCALAR_FIELD(skewTable);
00858     COPY_SCALAR_FIELD(skewColumn);
00859     COPY_SCALAR_FIELD(skewInherit);
00860     COPY_SCALAR_FIELD(skewColType);
00861     COPY_SCALAR_FIELD(skewColTypmod);
00862 
00863     return newnode;
00864 }
00865 
00866 /*
00867  * _copySetOp
00868  */
00869 static SetOp *
00870 _copySetOp(const SetOp *from)
00871 {
00872     SetOp      *newnode = makeNode(SetOp);
00873 
00874     /*
00875      * copy node superclass fields
00876      */
00877     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00878 
00879     /*
00880      * copy remainder of node
00881      */
00882     COPY_SCALAR_FIELD(cmd);
00883     COPY_SCALAR_FIELD(strategy);
00884     COPY_SCALAR_FIELD(numCols);
00885     COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
00886     COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
00887     COPY_SCALAR_FIELD(flagColIdx);
00888     COPY_SCALAR_FIELD(firstFlag);
00889     COPY_SCALAR_FIELD(numGroups);
00890 
00891     return newnode;
00892 }
00893 
00894 /*
00895  * _copyLockRows
00896  */
00897 static LockRows *
00898 _copyLockRows(const LockRows *from)
00899 {
00900     LockRows   *newnode = makeNode(LockRows);
00901 
00902     /*
00903      * copy node superclass fields
00904      */
00905     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00906 
00907     /*
00908      * copy remainder of node
00909      */
00910     COPY_NODE_FIELD(rowMarks);
00911     COPY_SCALAR_FIELD(epqParam);
00912 
00913     return newnode;
00914 }
00915 
00916 /*
00917  * _copyLimit
00918  */
00919 static Limit *
00920 _copyLimit(const Limit *from)
00921 {
00922     Limit      *newnode = makeNode(Limit);
00923 
00924     /*
00925      * copy node superclass fields
00926      */
00927     CopyPlanFields((const Plan *) from, (Plan *) newnode);
00928 
00929     /*
00930      * copy remainder of node
00931      */
00932     COPY_NODE_FIELD(limitOffset);
00933     COPY_NODE_FIELD(limitCount);
00934 
00935     return newnode;
00936 }
00937 
00938 /*
00939  * _copyNestLoopParam
00940  */
00941 static NestLoopParam *
00942 _copyNestLoopParam(const NestLoopParam *from)
00943 {
00944     NestLoopParam *newnode = makeNode(NestLoopParam);
00945 
00946     COPY_SCALAR_FIELD(paramno);
00947     COPY_NODE_FIELD(paramval);
00948 
00949     return newnode;
00950 }
00951 
00952 /*
00953  * _copyPlanRowMark
00954  */
00955 static PlanRowMark *
00956 _copyPlanRowMark(const PlanRowMark *from)
00957 {
00958     PlanRowMark *newnode = makeNode(PlanRowMark);
00959 
00960     COPY_SCALAR_FIELD(rti);
00961     COPY_SCALAR_FIELD(prti);
00962     COPY_SCALAR_FIELD(rowmarkId);
00963     COPY_SCALAR_FIELD(markType);
00964     COPY_SCALAR_FIELD(noWait);
00965     COPY_SCALAR_FIELD(isParent);
00966 
00967     return newnode;
00968 }
00969 
00970 /*
00971  * _copyPlanInvalItem
00972  */
00973 static PlanInvalItem *
00974 _copyPlanInvalItem(const PlanInvalItem *from)
00975 {
00976     PlanInvalItem *newnode = makeNode(PlanInvalItem);
00977 
00978     COPY_SCALAR_FIELD(cacheId);
00979     COPY_SCALAR_FIELD(hashValue);
00980 
00981     return newnode;
00982 }
00983 
00984 /* ****************************************************************
00985  *                     primnodes.h copy functions
00986  * ****************************************************************
00987  */
00988 
00989 /*
00990  * _copyAlias
00991  */
00992 static Alias *
00993 _copyAlias(const Alias *from)
00994 {
00995     Alias      *newnode = makeNode(Alias);
00996 
00997     COPY_STRING_FIELD(aliasname);
00998     COPY_NODE_FIELD(colnames);
00999 
01000     return newnode;
01001 }
01002 
01003 /*
01004  * _copyRangeVar
01005  */
01006 static RangeVar *
01007 _copyRangeVar(const RangeVar *from)
01008 {
01009     RangeVar   *newnode = makeNode(RangeVar);
01010 
01011     COPY_STRING_FIELD(catalogname);
01012     COPY_STRING_FIELD(schemaname);
01013     COPY_STRING_FIELD(relname);
01014     COPY_SCALAR_FIELD(inhOpt);
01015     COPY_SCALAR_FIELD(relpersistence);
01016     COPY_NODE_FIELD(alias);
01017     COPY_LOCATION_FIELD(location);
01018 
01019     return newnode;
01020 }
01021 
01022 /*
01023  * _copyIntoClause
01024  */
01025 static IntoClause *
01026 _copyIntoClause(const IntoClause *from)
01027 {
01028     IntoClause *newnode = makeNode(IntoClause);
01029 
01030     COPY_NODE_FIELD(rel);
01031     COPY_NODE_FIELD(colNames);
01032     COPY_NODE_FIELD(options);
01033     COPY_SCALAR_FIELD(onCommit);
01034     COPY_STRING_FIELD(tableSpaceName);
01035     COPY_NODE_FIELD(viewQuery);
01036     COPY_SCALAR_FIELD(skipData);
01037 
01038     return newnode;
01039 }
01040 
01041 /*
01042  * We don't need a _copyExpr because Expr is an abstract supertype which
01043  * should never actually get instantiated.  Also, since it has no common
01044  * fields except NodeTag, there's no need for a helper routine to factor
01045  * out copying the common fields...
01046  */
01047 
01048 /*
01049  * _copyVar
01050  */
01051 static Var *
01052 _copyVar(const Var *from)
01053 {
01054     Var        *newnode = makeNode(Var);
01055 
01056     COPY_SCALAR_FIELD(varno);
01057     COPY_SCALAR_FIELD(varattno);
01058     COPY_SCALAR_FIELD(vartype);
01059     COPY_SCALAR_FIELD(vartypmod);
01060     COPY_SCALAR_FIELD(varcollid);
01061     COPY_SCALAR_FIELD(varlevelsup);
01062     COPY_SCALAR_FIELD(varnoold);
01063     COPY_SCALAR_FIELD(varoattno);
01064     COPY_LOCATION_FIELD(location);
01065 
01066     return newnode;
01067 }
01068 
01069 /*
01070  * _copyConst
01071  */
01072 static Const *
01073 _copyConst(const Const *from)
01074 {
01075     Const      *newnode = makeNode(Const);
01076 
01077     COPY_SCALAR_FIELD(consttype);
01078     COPY_SCALAR_FIELD(consttypmod);
01079     COPY_SCALAR_FIELD(constcollid);
01080     COPY_SCALAR_FIELD(constlen);
01081 
01082     if (from->constbyval || from->constisnull)
01083     {
01084         /*
01085          * passed by value so just copy the datum. Also, don't try to copy
01086          * struct when value is null!
01087          */
01088         newnode->constvalue = from->constvalue;
01089     }
01090     else
01091     {
01092         /*
01093          * passed by reference.  We need a palloc'd copy.
01094          */
01095         newnode->constvalue = datumCopy(from->constvalue,
01096                                         from->constbyval,
01097                                         from->constlen);
01098     }
01099 
01100     COPY_SCALAR_FIELD(constisnull);
01101     COPY_SCALAR_FIELD(constbyval);
01102     COPY_LOCATION_FIELD(location);
01103 
01104     return newnode;
01105 }
01106 
01107 /*
01108  * _copyParam
01109  */
01110 static Param *
01111 _copyParam(const Param *from)
01112 {
01113     Param      *newnode = makeNode(Param);
01114 
01115     COPY_SCALAR_FIELD(paramkind);
01116     COPY_SCALAR_FIELD(paramid);
01117     COPY_SCALAR_FIELD(paramtype);
01118     COPY_SCALAR_FIELD(paramtypmod);
01119     COPY_SCALAR_FIELD(paramcollid);
01120     COPY_LOCATION_FIELD(location);
01121 
01122     return newnode;
01123 }
01124 
01125 /*
01126  * _copyAggref
01127  */
01128 static Aggref *
01129 _copyAggref(const Aggref *from)
01130 {
01131     Aggref     *newnode = makeNode(Aggref);
01132 
01133     COPY_SCALAR_FIELD(aggfnoid);
01134     COPY_SCALAR_FIELD(aggtype);
01135     COPY_SCALAR_FIELD(aggcollid);
01136     COPY_SCALAR_FIELD(inputcollid);
01137     COPY_NODE_FIELD(args);
01138     COPY_NODE_FIELD(aggorder);
01139     COPY_NODE_FIELD(aggdistinct);
01140     COPY_SCALAR_FIELD(aggstar);
01141     COPY_SCALAR_FIELD(agglevelsup);
01142     COPY_LOCATION_FIELD(location);
01143 
01144     return newnode;
01145 }
01146 
01147 /*
01148  * _copyWindowFunc
01149  */
01150 static WindowFunc *
01151 _copyWindowFunc(const WindowFunc *from)
01152 {
01153     WindowFunc *newnode = makeNode(WindowFunc);
01154 
01155     COPY_SCALAR_FIELD(winfnoid);
01156     COPY_SCALAR_FIELD(wintype);
01157     COPY_SCALAR_FIELD(wincollid);
01158     COPY_SCALAR_FIELD(inputcollid);
01159     COPY_NODE_FIELD(args);
01160     COPY_SCALAR_FIELD(winref);
01161     COPY_SCALAR_FIELD(winstar);
01162     COPY_SCALAR_FIELD(winagg);
01163     COPY_LOCATION_FIELD(location);
01164 
01165     return newnode;
01166 }
01167 
01168 /*
01169  * _copyArrayRef
01170  */
01171 static ArrayRef *
01172 _copyArrayRef(const ArrayRef *from)
01173 {
01174     ArrayRef   *newnode = makeNode(ArrayRef);
01175 
01176     COPY_SCALAR_FIELD(refarraytype);
01177     COPY_SCALAR_FIELD(refelemtype);
01178     COPY_SCALAR_FIELD(reftypmod);
01179     COPY_SCALAR_FIELD(refcollid);
01180     COPY_NODE_FIELD(refupperindexpr);
01181     COPY_NODE_FIELD(reflowerindexpr);
01182     COPY_NODE_FIELD(refexpr);
01183     COPY_NODE_FIELD(refassgnexpr);
01184 
01185     return newnode;
01186 }
01187 
01188 /*
01189  * _copyFuncExpr
01190  */
01191 static FuncExpr *
01192 _copyFuncExpr(const FuncExpr *from)
01193 {
01194     FuncExpr   *newnode = makeNode(FuncExpr);
01195 
01196     COPY_SCALAR_FIELD(funcid);
01197     COPY_SCALAR_FIELD(funcresulttype);
01198     COPY_SCALAR_FIELD(funcretset);
01199     COPY_SCALAR_FIELD(funcvariadic);
01200     COPY_SCALAR_FIELD(funcformat);
01201     COPY_SCALAR_FIELD(funccollid);
01202     COPY_SCALAR_FIELD(inputcollid);
01203     COPY_NODE_FIELD(args);
01204     COPY_LOCATION_FIELD(location);
01205 
01206     return newnode;
01207 }
01208 
01209 /*
01210  * _copyNamedArgExpr *
01211  */
01212 static NamedArgExpr *
01213 _copyNamedArgExpr(const NamedArgExpr *from)
01214 {
01215     NamedArgExpr *newnode = makeNode(NamedArgExpr);
01216 
01217     COPY_NODE_FIELD(arg);
01218     COPY_STRING_FIELD(name);
01219     COPY_SCALAR_FIELD(argnumber);
01220     COPY_LOCATION_FIELD(location);
01221 
01222     return newnode;
01223 }
01224 
01225 /*
01226  * _copyOpExpr
01227  */
01228 static OpExpr *
01229 _copyOpExpr(const OpExpr *from)
01230 {
01231     OpExpr     *newnode = makeNode(OpExpr);
01232 
01233     COPY_SCALAR_FIELD(opno);
01234     COPY_SCALAR_FIELD(opfuncid);
01235     COPY_SCALAR_FIELD(opresulttype);
01236     COPY_SCALAR_FIELD(opretset);
01237     COPY_SCALAR_FIELD(opcollid);
01238     COPY_SCALAR_FIELD(inputcollid);
01239     COPY_NODE_FIELD(args);
01240     COPY_LOCATION_FIELD(location);
01241 
01242     return newnode;
01243 }
01244 
01245 /*
01246  * _copyDistinctExpr (same as OpExpr)
01247  */
01248 static DistinctExpr *
01249 _copyDistinctExpr(const DistinctExpr *from)
01250 {
01251     DistinctExpr *newnode = makeNode(DistinctExpr);
01252 
01253     COPY_SCALAR_FIELD(opno);
01254     COPY_SCALAR_FIELD(opfuncid);
01255     COPY_SCALAR_FIELD(opresulttype);
01256     COPY_SCALAR_FIELD(opretset);
01257     COPY_SCALAR_FIELD(opcollid);
01258     COPY_SCALAR_FIELD(inputcollid);
01259     COPY_NODE_FIELD(args);
01260     COPY_LOCATION_FIELD(location);
01261 
01262     return newnode;
01263 }
01264 
01265 /*
01266  * _copyNullIfExpr (same as OpExpr)
01267  */
01268 static NullIfExpr *
01269 _copyNullIfExpr(const NullIfExpr *from)
01270 {
01271     NullIfExpr *newnode = makeNode(NullIfExpr);
01272 
01273     COPY_SCALAR_FIELD(opno);
01274     COPY_SCALAR_FIELD(opfuncid);
01275     COPY_SCALAR_FIELD(opresulttype);
01276     COPY_SCALAR_FIELD(opretset);
01277     COPY_SCALAR_FIELD(opcollid);
01278     COPY_SCALAR_FIELD(inputcollid);
01279     COPY_NODE_FIELD(args);
01280     COPY_LOCATION_FIELD(location);
01281 
01282     return newnode;
01283 }
01284 
01285 /*
01286  * _copyScalarArrayOpExpr
01287  */
01288 static ScalarArrayOpExpr *
01289 _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
01290 {
01291     ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
01292 
01293     COPY_SCALAR_FIELD(opno);
01294     COPY_SCALAR_FIELD(opfuncid);
01295     COPY_SCALAR_FIELD(useOr);
01296     COPY_SCALAR_FIELD(inputcollid);
01297     COPY_NODE_FIELD(args);
01298     COPY_LOCATION_FIELD(location);
01299 
01300     return newnode;
01301 }
01302 
01303 /*
01304  * _copyBoolExpr
01305  */
01306 static BoolExpr *
01307 _copyBoolExpr(const BoolExpr *from)
01308 {
01309     BoolExpr   *newnode = makeNode(BoolExpr);
01310 
01311     COPY_SCALAR_FIELD(boolop);
01312     COPY_NODE_FIELD(args);
01313     COPY_LOCATION_FIELD(location);
01314 
01315     return newnode;
01316 }
01317 
01318 /*
01319  * _copySubLink
01320  */
01321 static SubLink *
01322 _copySubLink(const SubLink *from)
01323 {
01324     SubLink    *newnode = makeNode(SubLink);
01325 
01326     COPY_SCALAR_FIELD(subLinkType);
01327     COPY_NODE_FIELD(testexpr);
01328     COPY_NODE_FIELD(operName);
01329     COPY_NODE_FIELD(subselect);
01330     COPY_LOCATION_FIELD(location);
01331 
01332     return newnode;
01333 }
01334 
01335 /*
01336  * _copySubPlan
01337  */
01338 static SubPlan *
01339 _copySubPlan(const SubPlan *from)
01340 {
01341     SubPlan    *newnode = makeNode(SubPlan);
01342 
01343     COPY_SCALAR_FIELD(subLinkType);
01344     COPY_NODE_FIELD(testexpr);
01345     COPY_NODE_FIELD(paramIds);
01346     COPY_SCALAR_FIELD(plan_id);
01347     COPY_STRING_FIELD(plan_name);
01348     COPY_SCALAR_FIELD(firstColType);
01349     COPY_SCALAR_FIELD(firstColTypmod);
01350     COPY_SCALAR_FIELD(firstColCollation);
01351     COPY_SCALAR_FIELD(useHashTable);
01352     COPY_SCALAR_FIELD(unknownEqFalse);
01353     COPY_NODE_FIELD(setParam);
01354     COPY_NODE_FIELD(parParam);
01355     COPY_NODE_FIELD(args);
01356     COPY_SCALAR_FIELD(startup_cost);
01357     COPY_SCALAR_FIELD(per_call_cost);
01358 
01359     return newnode;
01360 }
01361 
01362 /*
01363  * _copyAlternativeSubPlan
01364  */
01365 static AlternativeSubPlan *
01366 _copyAlternativeSubPlan(const AlternativeSubPlan *from)
01367 {
01368     AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
01369 
01370     COPY_NODE_FIELD(subplans);
01371 
01372     return newnode;
01373 }
01374 
01375 /*
01376  * _copyFieldSelect
01377  */
01378 static FieldSelect *
01379 _copyFieldSelect(const FieldSelect *from)
01380 {
01381     FieldSelect *newnode = makeNode(FieldSelect);
01382 
01383     COPY_NODE_FIELD(arg);
01384     COPY_SCALAR_FIELD(fieldnum);
01385     COPY_SCALAR_FIELD(resulttype);
01386     COPY_SCALAR_FIELD(resulttypmod);
01387     COPY_SCALAR_FIELD(resultcollid);
01388 
01389     return newnode;
01390 }
01391 
01392 /*
01393  * _copyFieldStore
01394  */
01395 static FieldStore *
01396 _copyFieldStore(const FieldStore *from)
01397 {
01398     FieldStore *newnode = makeNode(FieldStore);
01399 
01400     COPY_NODE_FIELD(arg);
01401     COPY_NODE_FIELD(newvals);
01402     COPY_NODE_FIELD(fieldnums);
01403     COPY_SCALAR_FIELD(resulttype);
01404 
01405     return newnode;
01406 }
01407 
01408 /*
01409  * _copyRelabelType
01410  */
01411 static RelabelType *
01412 _copyRelabelType(const RelabelType *from)
01413 {
01414     RelabelType *newnode = makeNode(RelabelType);
01415 
01416     COPY_NODE_FIELD(arg);
01417     COPY_SCALAR_FIELD(resulttype);
01418     COPY_SCALAR_FIELD(resulttypmod);
01419     COPY_SCALAR_FIELD(resultcollid);
01420     COPY_SCALAR_FIELD(relabelformat);
01421     COPY_LOCATION_FIELD(location);
01422 
01423     return newnode;
01424 }
01425 
01426 /*
01427  * _copyCoerceViaIO
01428  */
01429 static CoerceViaIO *
01430 _copyCoerceViaIO(const CoerceViaIO *from)
01431 {
01432     CoerceViaIO *newnode = makeNode(CoerceViaIO);
01433 
01434     COPY_NODE_FIELD(arg);
01435     COPY_SCALAR_FIELD(resulttype);
01436     COPY_SCALAR_FIELD(resultcollid);
01437     COPY_SCALAR_FIELD(coerceformat);
01438     COPY_LOCATION_FIELD(location);
01439 
01440     return newnode;
01441 }
01442 
01443 /*
01444  * _copyArrayCoerceExpr
01445  */
01446 static ArrayCoerceExpr *
01447 _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
01448 {
01449     ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
01450 
01451     COPY_NODE_FIELD(arg);
01452     COPY_SCALAR_FIELD(elemfuncid);
01453     COPY_SCALAR_FIELD(resulttype);
01454     COPY_SCALAR_FIELD(resulttypmod);
01455     COPY_SCALAR_FIELD(resultcollid);
01456     COPY_SCALAR_FIELD(isExplicit);
01457     COPY_SCALAR_FIELD(coerceformat);
01458     COPY_LOCATION_FIELD(location);
01459 
01460     return newnode;
01461 }
01462 
01463 /*
01464  * _copyConvertRowtypeExpr
01465  */
01466 static ConvertRowtypeExpr *
01467 _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
01468 {
01469     ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
01470 
01471     COPY_NODE_FIELD(arg);
01472     COPY_SCALAR_FIELD(resulttype);
01473     COPY_SCALAR_FIELD(convertformat);
01474     COPY_LOCATION_FIELD(location);
01475 
01476     return newnode;
01477 }
01478 
01479 /*
01480  * _copyCollateExpr
01481  */
01482 static CollateExpr *
01483 _copyCollateExpr(const CollateExpr *from)
01484 {
01485     CollateExpr *newnode = makeNode(CollateExpr);
01486 
01487     COPY_NODE_FIELD(arg);
01488     COPY_SCALAR_FIELD(collOid);
01489     COPY_LOCATION_FIELD(location);
01490 
01491     return newnode;
01492 }
01493 
01494 /*
01495  * _copyCaseExpr
01496  */
01497 static CaseExpr *
01498 _copyCaseExpr(const CaseExpr *from)
01499 {
01500     CaseExpr   *newnode = makeNode(CaseExpr);
01501 
01502     COPY_SCALAR_FIELD(casetype);
01503     COPY_SCALAR_FIELD(casecollid);
01504     COPY_NODE_FIELD(arg);
01505     COPY_NODE_FIELD(args);
01506     COPY_NODE_FIELD(defresult);
01507     COPY_LOCATION_FIELD(location);
01508 
01509     return newnode;
01510 }
01511 
01512 /*
01513  * _copyCaseWhen
01514  */
01515 static CaseWhen *
01516 _copyCaseWhen(const CaseWhen *from)
01517 {
01518     CaseWhen   *newnode = makeNode(CaseWhen);
01519 
01520     COPY_NODE_FIELD(expr);
01521     COPY_NODE_FIELD(result);
01522     COPY_LOCATION_FIELD(location);
01523 
01524     return newnode;
01525 }
01526 
01527 /*
01528  * _copyCaseTestExpr
01529  */
01530 static CaseTestExpr *
01531 _copyCaseTestExpr(const CaseTestExpr *from)
01532 {
01533     CaseTestExpr *newnode = makeNode(CaseTestExpr);
01534 
01535     COPY_SCALAR_FIELD(typeId);
01536     COPY_SCALAR_FIELD(typeMod);
01537     COPY_SCALAR_FIELD(collation);
01538 
01539     return newnode;
01540 }
01541 
01542 /*
01543  * _copyArrayExpr
01544  */
01545 static ArrayExpr *
01546 _copyArrayExpr(const ArrayExpr *from)
01547 {
01548     ArrayExpr  *newnode = makeNode(ArrayExpr);
01549 
01550     COPY_SCALAR_FIELD(array_typeid);
01551     COPY_SCALAR_FIELD(array_collid);
01552     COPY_SCALAR_FIELD(element_typeid);
01553     COPY_NODE_FIELD(elements);
01554     COPY_SCALAR_FIELD(multidims);
01555     COPY_LOCATION_FIELD(location);
01556 
01557     return newnode;
01558 }
01559 
01560 /*
01561  * _copyRowExpr
01562  */
01563 static RowExpr *
01564 _copyRowExpr(const RowExpr *from)
01565 {
01566     RowExpr    *newnode = makeNode(RowExpr);
01567 
01568     COPY_NODE_FIELD(args);
01569     COPY_SCALAR_FIELD(row_typeid);
01570     COPY_SCALAR_FIELD(row_format);
01571     COPY_NODE_FIELD(colnames);
01572     COPY_LOCATION_FIELD(location);
01573 
01574     return newnode;
01575 }
01576 
01577 /*
01578  * _copyRowCompareExpr
01579  */
01580 static RowCompareExpr *
01581 _copyRowCompareExpr(const RowCompareExpr *from)
01582 {
01583     RowCompareExpr *newnode = makeNode(RowCompareExpr);
01584 
01585     COPY_SCALAR_FIELD(rctype);
01586     COPY_NODE_FIELD(opnos);
01587     COPY_NODE_FIELD(opfamilies);
01588     COPY_NODE_FIELD(inputcollids);
01589     COPY_NODE_FIELD(largs);
01590     COPY_NODE_FIELD(rargs);
01591 
01592     return newnode;
01593 }
01594 
01595 /*
01596  * _copyCoalesceExpr
01597  */
01598 static CoalesceExpr *
01599 _copyCoalesceExpr(const CoalesceExpr *from)
01600 {
01601     CoalesceExpr *newnode = makeNode(CoalesceExpr);
01602 
01603     COPY_SCALAR_FIELD(coalescetype);
01604     COPY_SCALAR_FIELD(coalescecollid);
01605     COPY_NODE_FIELD(args);
01606     COPY_LOCATION_FIELD(location);
01607 
01608     return newnode;
01609 }
01610 
01611 /*
01612  * _copyMinMaxExpr
01613  */
01614 static MinMaxExpr *
01615 _copyMinMaxExpr(const MinMaxExpr *from)
01616 {
01617     MinMaxExpr *newnode = makeNode(MinMaxExpr);
01618 
01619     COPY_SCALAR_FIELD(minmaxtype);
01620     COPY_SCALAR_FIELD(minmaxcollid);
01621     COPY_SCALAR_FIELD(inputcollid);
01622     COPY_SCALAR_FIELD(op);
01623     COPY_NODE_FIELD(args);
01624     COPY_LOCATION_FIELD(location);
01625 
01626     return newnode;
01627 }
01628 
01629 /*
01630  * _copyXmlExpr
01631  */
01632 static XmlExpr *
01633 _copyXmlExpr(const XmlExpr *from)
01634 {
01635     XmlExpr    *newnode = makeNode(XmlExpr);
01636 
01637     COPY_SCALAR_FIELD(op);
01638     COPY_STRING_FIELD(name);
01639     COPY_NODE_FIELD(named_args);
01640     COPY_NODE_FIELD(arg_names);
01641     COPY_NODE_FIELD(args);
01642     COPY_SCALAR_FIELD(xmloption);
01643     COPY_SCALAR_FIELD(type);
01644     COPY_SCALAR_FIELD(typmod);
01645     COPY_LOCATION_FIELD(location);
01646 
01647     return newnode;
01648 }
01649 
01650 /*
01651  * _copyNullTest
01652  */
01653 static NullTest *
01654 _copyNullTest(const NullTest *from)
01655 {
01656     NullTest   *newnode = makeNode(NullTest);
01657 
01658     COPY_NODE_FIELD(arg);
01659     COPY_SCALAR_FIELD(nulltesttype);
01660     COPY_SCALAR_FIELD(argisrow);
01661 
01662     return newnode;
01663 }
01664 
01665 /*
01666  * _copyBooleanTest
01667  */
01668 static BooleanTest *
01669 _copyBooleanTest(const BooleanTest *from)
01670 {
01671     BooleanTest *newnode = makeNode(BooleanTest);
01672 
01673     COPY_NODE_FIELD(arg);
01674     COPY_SCALAR_FIELD(booltesttype);
01675 
01676     return newnode;
01677 }
01678 
01679 /*
01680  * _copyCoerceToDomain
01681  */
01682 static CoerceToDomain *
01683 _copyCoerceToDomain(const CoerceToDomain *from)
01684 {
01685     CoerceToDomain *newnode = makeNode(CoerceToDomain);
01686 
01687     COPY_NODE_FIELD(arg);
01688     COPY_SCALAR_FIELD(resulttype);
01689     COPY_SCALAR_FIELD(resulttypmod);
01690     COPY_SCALAR_FIELD(resultcollid);
01691     COPY_SCALAR_FIELD(coercionformat);
01692     COPY_LOCATION_FIELD(location);
01693 
01694     return newnode;
01695 }
01696 
01697 /*
01698  * _copyCoerceToDomainValue
01699  */
01700 static CoerceToDomainValue *
01701 _copyCoerceToDomainValue(const CoerceToDomainValue *from)
01702 {
01703     CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
01704 
01705     COPY_SCALAR_FIELD(typeId);
01706     COPY_SCALAR_FIELD(typeMod);
01707     COPY_SCALAR_FIELD(collation);
01708     COPY_LOCATION_FIELD(location);
01709 
01710     return newnode;
01711 }
01712 
01713 /*
01714  * _copySetToDefault
01715  */
01716 static SetToDefault *
01717 _copySetToDefault(const SetToDefault *from)
01718 {
01719     SetToDefault *newnode = makeNode(SetToDefault);
01720 
01721     COPY_SCALAR_FIELD(typeId);
01722     COPY_SCALAR_FIELD(typeMod);
01723     COPY_SCALAR_FIELD(collation);
01724     COPY_LOCATION_FIELD(location);
01725 
01726     return newnode;
01727 }
01728 
01729 /*
01730  * _copyCurrentOfExpr
01731  */
01732 static CurrentOfExpr *
01733 _copyCurrentOfExpr(const CurrentOfExpr *from)
01734 {
01735     CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
01736 
01737     COPY_SCALAR_FIELD(cvarno);
01738     COPY_STRING_FIELD(cursor_name);
01739     COPY_SCALAR_FIELD(cursor_param);
01740 
01741     return newnode;
01742 }
01743 
01744 /*
01745  * _copyTargetEntry
01746  */
01747 static TargetEntry *
01748 _copyTargetEntry(const TargetEntry *from)
01749 {
01750     TargetEntry *newnode = makeNode(TargetEntry);
01751 
01752     COPY_NODE_FIELD(expr);
01753     COPY_SCALAR_FIELD(resno);
01754     COPY_STRING_FIELD(resname);
01755     COPY_SCALAR_FIELD(ressortgroupref);
01756     COPY_SCALAR_FIELD(resorigtbl);
01757     COPY_SCALAR_FIELD(resorigcol);
01758     COPY_SCALAR_FIELD(resjunk);
01759 
01760     return newnode;
01761 }
01762 
01763 /*
01764  * _copyRangeTblRef
01765  */
01766 static RangeTblRef *
01767 _copyRangeTblRef(const RangeTblRef *from)
01768 {
01769     RangeTblRef *newnode = makeNode(RangeTblRef);
01770 
01771     COPY_SCALAR_FIELD(rtindex);
01772 
01773     return newnode;
01774 }
01775 
01776 /*
01777  * _copyJoinExpr
01778  */
01779 static JoinExpr *
01780 _copyJoinExpr(const JoinExpr *from)
01781 {
01782     JoinExpr   *newnode = makeNode(JoinExpr);
01783 
01784     COPY_SCALAR_FIELD(jointype);
01785     COPY_SCALAR_FIELD(isNatural);
01786     COPY_NODE_FIELD(larg);
01787     COPY_NODE_FIELD(rarg);
01788     COPY_NODE_FIELD(usingClause);
01789     COPY_NODE_FIELD(quals);
01790     COPY_NODE_FIELD(alias);
01791     COPY_SCALAR_FIELD(rtindex);
01792 
01793     return newnode;
01794 }
01795 
01796 /*
01797  * _copyFromExpr
01798  */
01799 static FromExpr *
01800 _copyFromExpr(const FromExpr *from)
01801 {
01802     FromExpr   *newnode = makeNode(FromExpr);
01803 
01804     COPY_NODE_FIELD(fromlist);
01805     COPY_NODE_FIELD(quals);
01806 
01807     return newnode;
01808 }
01809 
01810 /* ****************************************************************
01811  *                      relation.h copy functions
01812  *
01813  * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
01814  * There are some subsidiary structs that are useful to copy, though.
01815  * ****************************************************************
01816  */
01817 
01818 /*
01819  * _copyPathKey
01820  */
01821 static PathKey *
01822 _copyPathKey(const PathKey *from)
01823 {
01824     PathKey    *newnode = makeNode(PathKey);
01825 
01826     /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
01827     COPY_SCALAR_FIELD(pk_eclass);
01828     COPY_SCALAR_FIELD(pk_opfamily);
01829     COPY_SCALAR_FIELD(pk_strategy);
01830     COPY_SCALAR_FIELD(pk_nulls_first);
01831 
01832     return newnode;
01833 }
01834 
01835 /*
01836  * _copyRestrictInfo
01837  */
01838 static RestrictInfo *
01839 _copyRestrictInfo(const RestrictInfo *from)
01840 {
01841     RestrictInfo *newnode = makeNode(RestrictInfo);
01842 
01843     COPY_NODE_FIELD(clause);
01844     COPY_SCALAR_FIELD(is_pushed_down);
01845     COPY_SCALAR_FIELD(outerjoin_delayed);
01846     COPY_SCALAR_FIELD(can_join);
01847     COPY_SCALAR_FIELD(pseudoconstant);
01848     COPY_BITMAPSET_FIELD(clause_relids);
01849     COPY_BITMAPSET_FIELD(required_relids);
01850     COPY_BITMAPSET_FIELD(outer_relids);
01851     COPY_BITMAPSET_FIELD(nullable_relids);
01852     COPY_BITMAPSET_FIELD(left_relids);
01853     COPY_BITMAPSET_FIELD(right_relids);
01854     COPY_NODE_FIELD(orclause);
01855     /* EquivalenceClasses are never copied, so shallow-copy the pointers */
01856     COPY_SCALAR_FIELD(parent_ec);
01857     COPY_SCALAR_FIELD(eval_cost);
01858     COPY_SCALAR_FIELD(norm_selec);
01859     COPY_SCALAR_FIELD(outer_selec);
01860     COPY_NODE_FIELD(mergeopfamilies);
01861     /* EquivalenceClasses are never copied, so shallow-copy the pointers */
01862     COPY_SCALAR_FIELD(left_ec);
01863     COPY_SCALAR_FIELD(right_ec);
01864     COPY_SCALAR_FIELD(left_em);
01865     COPY_SCALAR_FIELD(right_em);
01866     /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
01867     newnode->scansel_cache = NIL;
01868     COPY_SCALAR_FIELD(outer_is_left);
01869     COPY_SCALAR_FIELD(hashjoinoperator);
01870     COPY_SCALAR_FIELD(left_bucketsize);
01871     COPY_SCALAR_FIELD(right_bucketsize);
01872 
01873     return newnode;
01874 }
01875 
01876 /*
01877  * _copyPlaceHolderVar
01878  */
01879 static PlaceHolderVar *
01880 _copyPlaceHolderVar(const PlaceHolderVar *from)
01881 {
01882     PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
01883 
01884     COPY_NODE_FIELD(phexpr);
01885     COPY_BITMAPSET_FIELD(phrels);
01886     COPY_SCALAR_FIELD(phid);
01887     COPY_SCALAR_FIELD(phlevelsup);
01888 
01889     return newnode;
01890 }
01891 
01892 /*
01893  * _copySpecialJoinInfo
01894  */
01895 static SpecialJoinInfo *
01896 _copySpecialJoinInfo(const SpecialJoinInfo *from)
01897 {
01898     SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
01899 
01900     COPY_BITMAPSET_FIELD(min_lefthand);
01901     COPY_BITMAPSET_FIELD(min_righthand);
01902     COPY_BITMAPSET_FIELD(syn_lefthand);
01903     COPY_BITMAPSET_FIELD(syn_righthand);
01904     COPY_SCALAR_FIELD(jointype);
01905     COPY_SCALAR_FIELD(lhs_strict);
01906     COPY_SCALAR_FIELD(delay_upper_joins);
01907     COPY_NODE_FIELD(join_quals);
01908 
01909     return newnode;
01910 }
01911 
01912 /*
01913  * _copyLateralJoinInfo
01914  */
01915 static LateralJoinInfo *
01916 _copyLateralJoinInfo(const LateralJoinInfo *from)
01917 {
01918     LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
01919 
01920     COPY_SCALAR_FIELD(lateral_rhs);
01921     COPY_BITMAPSET_FIELD(lateral_lhs);
01922 
01923     return newnode;
01924 }
01925 
01926 /*
01927  * _copyAppendRelInfo
01928  */
01929 static AppendRelInfo *
01930 _copyAppendRelInfo(const AppendRelInfo *from)
01931 {
01932     AppendRelInfo *newnode = makeNode(AppendRelInfo);
01933 
01934     COPY_SCALAR_FIELD(parent_relid);
01935     COPY_SCALAR_FIELD(child_relid);
01936     COPY_SCALAR_FIELD(parent_reltype);
01937     COPY_SCALAR_FIELD(child_reltype);
01938     COPY_NODE_FIELD(translated_vars);
01939     COPY_SCALAR_FIELD(parent_reloid);
01940 
01941     return newnode;
01942 }
01943 
01944 /*
01945  * _copyPlaceHolderInfo
01946  */
01947 static PlaceHolderInfo *
01948 _copyPlaceHolderInfo(const PlaceHolderInfo *from)
01949 {
01950     PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
01951 
01952     COPY_SCALAR_FIELD(phid);
01953     COPY_NODE_FIELD(ph_var);
01954     COPY_BITMAPSET_FIELD(ph_eval_at);
01955     COPY_BITMAPSET_FIELD(ph_needed);
01956     COPY_BITMAPSET_FIELD(ph_may_need);
01957     COPY_SCALAR_FIELD(ph_width);
01958 
01959     return newnode;
01960 }
01961 
01962 /* ****************************************************************
01963  *                  parsenodes.h copy functions
01964  * ****************************************************************
01965  */
01966 
01967 static RangeTblEntry *
01968 _copyRangeTblEntry(const RangeTblEntry *from)
01969 {
01970     RangeTblEntry *newnode = makeNode(RangeTblEntry);
01971 
01972     COPY_SCALAR_FIELD(rtekind);
01973     COPY_SCALAR_FIELD(relid);
01974     COPY_SCALAR_FIELD(relkind);
01975     COPY_NODE_FIELD(subquery);
01976     COPY_SCALAR_FIELD(security_barrier);
01977     COPY_SCALAR_FIELD(jointype);
01978     COPY_NODE_FIELD(joinaliasvars);
01979     COPY_NODE_FIELD(funcexpr);
01980     COPY_NODE_FIELD(funccoltypes);
01981     COPY_NODE_FIELD(funccoltypmods);
01982     COPY_NODE_FIELD(funccolcollations);
01983     COPY_NODE_FIELD(values_lists);
01984     COPY_NODE_FIELD(values_collations);
01985     COPY_STRING_FIELD(ctename);
01986     COPY_SCALAR_FIELD(ctelevelsup);
01987     COPY_SCALAR_FIELD(self_reference);
01988     COPY_NODE_FIELD(ctecoltypes);
01989     COPY_NODE_FIELD(ctecoltypmods);
01990     COPY_NODE_FIELD(ctecolcollations);
01991     COPY_NODE_FIELD(alias);
01992     COPY_NODE_FIELD(eref);
01993     COPY_SCALAR_FIELD(lateral);
01994     COPY_SCALAR_FIELD(inh);
01995     COPY_SCALAR_FIELD(inFromCl);
01996     COPY_SCALAR_FIELD(requiredPerms);
01997     COPY_SCALAR_FIELD(checkAsUser);
01998     COPY_BITMAPSET_FIELD(selectedCols);
01999     COPY_BITMAPSET_FIELD(modifiedCols);
02000 
02001     return newnode;
02002 }
02003 
02004 static SortGroupClause *
02005 _copySortGroupClause(const SortGroupClause *from)
02006 {
02007     SortGroupClause *newnode = makeNode(SortGroupClause);
02008 
02009     COPY_SCALAR_FIELD(tleSortGroupRef);
02010     COPY_SCALAR_FIELD(eqop);
02011     COPY_SCALAR_FIELD(sortop);
02012     COPY_SCALAR_FIELD(nulls_first);
02013     COPY_SCALAR_FIELD(hashable);
02014 
02015     return newnode;
02016 }
02017 
02018 static WindowClause *
02019 _copyWindowClause(const WindowClause *from)
02020 {
02021     WindowClause *newnode = makeNode(WindowClause);
02022 
02023     COPY_STRING_FIELD(name);
02024     COPY_STRING_FIELD(refname);
02025     COPY_NODE_FIELD(partitionClause);
02026     COPY_NODE_FIELD(orderClause);
02027     COPY_SCALAR_FIELD(frameOptions);
02028     COPY_NODE_FIELD(startOffset);
02029     COPY_NODE_FIELD(endOffset);
02030     COPY_SCALAR_FIELD(winref);
02031     COPY_SCALAR_FIELD(copiedOrder);
02032 
02033     return newnode;
02034 }
02035 
02036 static RowMarkClause *
02037 _copyRowMarkClause(const RowMarkClause *from)
02038 {
02039     RowMarkClause *newnode = makeNode(RowMarkClause);
02040 
02041     COPY_SCALAR_FIELD(rti);
02042     COPY_SCALAR_FIELD(strength);
02043     COPY_SCALAR_FIELD(noWait);
02044     COPY_SCALAR_FIELD(pushedDown);
02045 
02046     return newnode;
02047 }
02048 
02049 static WithClause *
02050 _copyWithClause(const WithClause *from)
02051 {
02052     WithClause *newnode = makeNode(WithClause);
02053 
02054     COPY_NODE_FIELD(ctes);
02055     COPY_SCALAR_FIELD(recursive);
02056     COPY_LOCATION_FIELD(location);
02057 
02058     return newnode;
02059 }
02060 
02061 static CommonTableExpr *
02062 _copyCommonTableExpr(const CommonTableExpr *from)
02063 {
02064     CommonTableExpr *newnode = makeNode(CommonTableExpr);
02065 
02066     COPY_STRING_FIELD(ctename);
02067     COPY_NODE_FIELD(aliascolnames);
02068     COPY_NODE_FIELD(ctequery);
02069     COPY_LOCATION_FIELD(location);
02070     COPY_SCALAR_FIELD(cterecursive);
02071     COPY_SCALAR_FIELD(cterefcount);
02072     COPY_NODE_FIELD(ctecolnames);
02073     COPY_NODE_FIELD(ctecoltypes);
02074     COPY_NODE_FIELD(ctecoltypmods);
02075     COPY_NODE_FIELD(ctecolcollations);
02076 
02077     return newnode;
02078 }
02079 
02080 static A_Expr *
02081 _copyAExpr(const A_Expr *from)
02082 {
02083     A_Expr     *newnode = makeNode(A_Expr);
02084 
02085     COPY_SCALAR_FIELD(kind);
02086     COPY_NODE_FIELD(name);
02087     COPY_NODE_FIELD(lexpr);
02088     COPY_NODE_FIELD(rexpr);
02089     COPY_LOCATION_FIELD(location);
02090 
02091     return newnode;
02092 }
02093 
02094 static ColumnRef *
02095 _copyColumnRef(const ColumnRef *from)
02096 {
02097     ColumnRef  *newnode = makeNode(ColumnRef);
02098 
02099     COPY_NODE_FIELD(fields);
02100     COPY_LOCATION_FIELD(location);
02101 
02102     return newnode;
02103 }
02104 
02105 static ParamRef *
02106 _copyParamRef(const ParamRef *from)
02107 {
02108     ParamRef   *newnode = makeNode(ParamRef);
02109 
02110     COPY_SCALAR_FIELD(number);
02111     COPY_LOCATION_FIELD(location);
02112 
02113     return newnode;
02114 }
02115 
02116 static A_Const *
02117 _copyAConst(const A_Const *from)
02118 {
02119     A_Const    *newnode = makeNode(A_Const);
02120 
02121     /* This part must duplicate _copyValue */
02122     COPY_SCALAR_FIELD(val.type);
02123     switch (from->val.type)
02124     {
02125         case T_Integer:
02126             COPY_SCALAR_FIELD(val.val.ival);
02127             break;
02128         case T_Float:
02129         case T_String:
02130         case T_BitString:
02131             COPY_STRING_FIELD(val.val.str);
02132             break;
02133         case T_Null:
02134             /* nothing to do */
02135             break;
02136         default:
02137             elog(ERROR, "unrecognized node type: %d",
02138                  (int) from->val.type);
02139             break;
02140     }
02141 
02142     COPY_LOCATION_FIELD(location);
02143 
02144     return newnode;
02145 }
02146 
02147 static FuncCall *
02148 _copyFuncCall(const FuncCall *from)
02149 {
02150     FuncCall   *newnode = makeNode(FuncCall);
02151 
02152     COPY_NODE_FIELD(funcname);
02153     COPY_NODE_FIELD(args);
02154     COPY_NODE_FIELD(agg_order);
02155     COPY_SCALAR_FIELD(agg_star);
02156     COPY_SCALAR_FIELD(agg_distinct);
02157     COPY_SCALAR_FIELD(func_variadic);
02158     COPY_NODE_FIELD(over);
02159     COPY_LOCATION_FIELD(location);
02160 
02161     return newnode;
02162 }
02163 
02164 static A_Star *
02165 _copyAStar(const A_Star *from)
02166 {
02167     A_Star     *newnode = makeNode(A_Star);
02168 
02169     return newnode;
02170 }
02171 
02172 static A_Indices *
02173 _copyAIndices(const A_Indices *from)
02174 {
02175     A_Indices  *newnode = makeNode(A_Indices);
02176 
02177     COPY_NODE_FIELD(lidx);
02178     COPY_NODE_FIELD(uidx);
02179 
02180     return newnode;
02181 }
02182 
02183 static A_Indirection *
02184 _copyA_Indirection(const A_Indirection *from)
02185 {
02186     A_Indirection *newnode = makeNode(A_Indirection);
02187 
02188     COPY_NODE_FIELD(arg);
02189     COPY_NODE_FIELD(indirection);
02190 
02191     return newnode;
02192 }
02193 
02194 static A_ArrayExpr *
02195 _copyA_ArrayExpr(const A_ArrayExpr *from)
02196 {
02197     A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
02198 
02199     COPY_NODE_FIELD(elements);
02200     COPY_LOCATION_FIELD(location);
02201 
02202     return newnode;
02203 }
02204 
02205 static ResTarget *
02206 _copyResTarget(const ResTarget *from)
02207 {
02208     ResTarget  *newnode = makeNode(ResTarget);
02209 
02210     COPY_STRING_FIELD(name);
02211     COPY_NODE_FIELD(indirection);
02212     COPY_NODE_FIELD(val);
02213     COPY_LOCATION_FIELD(location);
02214 
02215     return newnode;
02216 }
02217 
02218 static TypeName *
02219 _copyTypeName(const TypeName *from)
02220 {
02221     TypeName   *newnode = makeNode(TypeName);
02222 
02223     COPY_NODE_FIELD(names);
02224     COPY_SCALAR_FIELD(typeOid);
02225     COPY_SCALAR_FIELD(setof);
02226     COPY_SCALAR_FIELD(pct_type);
02227     COPY_NODE_FIELD(typmods);
02228     COPY_SCALAR_FIELD(typemod);
02229     COPY_NODE_FIELD(arrayBounds);
02230     COPY_LOCATION_FIELD(location);
02231 
02232     return newnode;
02233 }
02234 
02235 static SortBy *
02236 _copySortBy(const SortBy *from)
02237 {
02238     SortBy     *newnode = makeNode(SortBy);
02239 
02240     COPY_NODE_FIELD(node);
02241     COPY_SCALAR_FIELD(sortby_dir);
02242     COPY_SCALAR_FIELD(sortby_nulls);
02243     COPY_NODE_FIELD(useOp);
02244     COPY_LOCATION_FIELD(location);
02245 
02246     return newnode;
02247 }
02248 
02249 static WindowDef *
02250 _copyWindowDef(const WindowDef *from)
02251 {
02252     WindowDef  *newnode = makeNode(WindowDef);
02253 
02254     COPY_STRING_FIELD(name);
02255     COPY_STRING_FIELD(refname);
02256     COPY_NODE_FIELD(partitionClause);
02257     COPY_NODE_FIELD(orderClause);
02258     COPY_SCALAR_FIELD(frameOptions);
02259     COPY_NODE_FIELD(startOffset);
02260     COPY_NODE_FIELD(endOffset);
02261     COPY_LOCATION_FIELD(location);
02262 
02263     return newnode;
02264 }
02265 
02266 static RangeSubselect *
02267 _copyRangeSubselect(const RangeSubselect *from)
02268 {
02269     RangeSubselect *newnode = makeNode(RangeSubselect);
02270 
02271     COPY_SCALAR_FIELD(lateral);
02272     COPY_NODE_FIELD(subquery);
02273     COPY_NODE_FIELD(alias);
02274 
02275     return newnode;
02276 }
02277 
02278 static RangeFunction *
02279 _copyRangeFunction(const RangeFunction *from)
02280 {
02281     RangeFunction *newnode = makeNode(RangeFunction);
02282 
02283     COPY_SCALAR_FIELD(lateral);
02284     COPY_NODE_FIELD(funccallnode);
02285     COPY_NODE_FIELD(alias);
02286     COPY_NODE_FIELD(coldeflist);
02287 
02288     return newnode;
02289 }
02290 
02291 static TypeCast *
02292 _copyTypeCast(const TypeCast *from)
02293 {
02294     TypeCast   *newnode = makeNode(TypeCast);
02295 
02296     COPY_NODE_FIELD(arg);
02297     COPY_NODE_FIELD(typeName);
02298     COPY_LOCATION_FIELD(location);
02299 
02300     return newnode;
02301 }
02302 
02303 static CollateClause *
02304 _copyCollateClause(const CollateClause *from)
02305 {
02306     CollateClause *newnode = makeNode(CollateClause);
02307 
02308     COPY_NODE_FIELD(arg);
02309     COPY_NODE_FIELD(collname);
02310     COPY_LOCATION_FIELD(location);
02311 
02312     return newnode;
02313 }
02314 
02315 static IndexElem *
02316 _copyIndexElem(const IndexElem *from)
02317 {
02318     IndexElem  *newnode = makeNode(IndexElem);
02319 
02320     COPY_STRING_FIELD(name);
02321     COPY_NODE_FIELD(expr);
02322     COPY_STRING_FIELD(indexcolname);
02323     COPY_NODE_FIELD(collation);
02324     COPY_NODE_FIELD(opclass);
02325     COPY_SCALAR_FIELD(ordering);
02326     COPY_SCALAR_FIELD(nulls_ordering);
02327 
02328     return newnode;
02329 }
02330 
02331 static ColumnDef *
02332 _copyColumnDef(const ColumnDef *from)
02333 {
02334     ColumnDef  *newnode = makeNode(ColumnDef);
02335 
02336     COPY_STRING_FIELD(colname);
02337     COPY_NODE_FIELD(typeName);
02338     COPY_SCALAR_FIELD(inhcount);
02339     COPY_SCALAR_FIELD(is_local);
02340     COPY_SCALAR_FIELD(is_not_null);
02341     COPY_SCALAR_FIELD(is_from_type);
02342     COPY_SCALAR_FIELD(storage);
02343     COPY_NODE_FIELD(raw_default);
02344     COPY_NODE_FIELD(cooked_default);
02345     COPY_NODE_FIELD(collClause);
02346     COPY_SCALAR_FIELD(collOid);
02347     COPY_NODE_FIELD(constraints);
02348     COPY_NODE_FIELD(fdwoptions);
02349 
02350     return newnode;
02351 }
02352 
02353 static Constraint *
02354 _copyConstraint(const Constraint *from)
02355 {
02356     Constraint *newnode = makeNode(Constraint);
02357 
02358     COPY_SCALAR_FIELD(contype);
02359     COPY_STRING_FIELD(conname);
02360     COPY_SCALAR_FIELD(deferrable);
02361     COPY_SCALAR_FIELD(initdeferred);
02362     COPY_LOCATION_FIELD(location);
02363     COPY_SCALAR_FIELD(is_no_inherit);
02364     COPY_NODE_FIELD(raw_expr);
02365     COPY_STRING_FIELD(cooked_expr);
02366     COPY_NODE_FIELD(keys);
02367     COPY_NODE_FIELD(exclusions);
02368     COPY_NODE_FIELD(options);
02369     COPY_STRING_FIELD(indexname);
02370     COPY_STRING_FIELD(indexspace);
02371     COPY_STRING_FIELD(access_method);
02372     COPY_NODE_FIELD(where_clause);
02373     COPY_NODE_FIELD(pktable);
02374     COPY_NODE_FIELD(fk_attrs);
02375     COPY_NODE_FIELD(pk_attrs);
02376     COPY_SCALAR_FIELD(fk_matchtype);
02377     COPY_SCALAR_FIELD(fk_upd_action);
02378     COPY_SCALAR_FIELD(fk_del_action);
02379     COPY_NODE_FIELD(old_conpfeqop);
02380     COPY_SCALAR_FIELD(skip_validation);
02381     COPY_SCALAR_FIELD(initially_valid);
02382 
02383     return newnode;
02384 }
02385 
02386 static DefElem *
02387 _copyDefElem(const DefElem *from)
02388 {
02389     DefElem    *newnode = makeNode(DefElem);
02390 
02391     COPY_STRING_FIELD(defnamespace);
02392     COPY_STRING_FIELD(defname);
02393     COPY_NODE_FIELD(arg);
02394     COPY_SCALAR_FIELD(defaction);
02395 
02396     return newnode;
02397 }
02398 
02399 static LockingClause *
02400 _copyLockingClause(const LockingClause *from)
02401 {
02402     LockingClause *newnode = makeNode(LockingClause);
02403 
02404     COPY_NODE_FIELD(lockedRels);
02405     COPY_SCALAR_FIELD(strength);
02406     COPY_SCALAR_FIELD(noWait);
02407 
02408     return newnode;
02409 }
02410 
02411 static XmlSerialize *
02412 _copyXmlSerialize(const XmlSerialize *from)
02413 {
02414     XmlSerialize *newnode = makeNode(XmlSerialize);
02415 
02416     COPY_SCALAR_FIELD(xmloption);
02417     COPY_NODE_FIELD(expr);
02418     COPY_NODE_FIELD(typeName);
02419     COPY_LOCATION_FIELD(location);
02420 
02421     return newnode;
02422 }
02423 
02424 static Query *
02425 _copyQuery(const Query *from)
02426 {
02427     Query      *newnode = makeNode(Query);
02428 
02429     COPY_SCALAR_FIELD(commandType);
02430     COPY_SCALAR_FIELD(querySource);
02431     COPY_SCALAR_FIELD(queryId);
02432     COPY_SCALAR_FIELD(canSetTag);
02433     COPY_NODE_FIELD(utilityStmt);
02434     COPY_SCALAR_FIELD(resultRelation);
02435     COPY_SCALAR_FIELD(hasAggs);
02436     COPY_SCALAR_FIELD(hasWindowFuncs);
02437     COPY_SCALAR_FIELD(hasSubLinks);
02438     COPY_SCALAR_FIELD(hasDistinctOn);
02439     COPY_SCALAR_FIELD(hasRecursive);
02440     COPY_SCALAR_FIELD(hasModifyingCTE);
02441     COPY_SCALAR_FIELD(hasForUpdate);
02442     COPY_NODE_FIELD(cteList);
02443     COPY_NODE_FIELD(rtable);
02444     COPY_NODE_FIELD(jointree);
02445     COPY_NODE_FIELD(targetList);
02446     COPY_NODE_FIELD(returningList);
02447     COPY_NODE_FIELD(groupClause);
02448     COPY_NODE_FIELD(havingQual);
02449     COPY_NODE_FIELD(windowClause);
02450     COPY_NODE_FIELD(distinctClause);
02451     COPY_NODE_FIELD(sortClause);
02452     COPY_NODE_FIELD(limitOffset);
02453     COPY_NODE_FIELD(limitCount);
02454     COPY_NODE_FIELD(rowMarks);
02455     COPY_NODE_FIELD(setOperations);
02456     COPY_NODE_FIELD(constraintDeps);
02457 
02458     return newnode;
02459 }
02460 
02461 static InsertStmt *
02462 _copyInsertStmt(const InsertStmt *from)
02463 {
02464     InsertStmt *newnode = makeNode(InsertStmt);
02465 
02466     COPY_NODE_FIELD(relation);
02467     COPY_NODE_FIELD(cols);
02468     COPY_NODE_FIELD(selectStmt);
02469     COPY_NODE_FIELD(returningList);
02470     COPY_NODE_FIELD(withClause);
02471 
02472     return newnode;
02473 }
02474 
02475 static DeleteStmt *
02476 _copyDeleteStmt(const DeleteStmt *from)
02477 {
02478     DeleteStmt *newnode = makeNode(DeleteStmt);
02479 
02480     COPY_NODE_FIELD(relation);
02481     COPY_NODE_FIELD(usingClause);
02482     COPY_NODE_FIELD(whereClause);
02483     COPY_NODE_FIELD(returningList);
02484     COPY_NODE_FIELD(withClause);
02485 
02486     return newnode;
02487 }
02488 
02489 static UpdateStmt *
02490 _copyUpdateStmt(const UpdateStmt *from)
02491 {
02492     UpdateStmt *newnode = makeNode(UpdateStmt);
02493 
02494     COPY_NODE_FIELD(relation);
02495     COPY_NODE_FIELD(targetList);
02496     COPY_NODE_FIELD(whereClause);
02497     COPY_NODE_FIELD(fromClause);
02498     COPY_NODE_FIELD(returningList);
02499     COPY_NODE_FIELD(withClause);
02500 
02501     return newnode;
02502 }
02503 
02504 static SelectStmt *
02505 _copySelectStmt(const SelectStmt *from)
02506 {
02507     SelectStmt *newnode = makeNode(SelectStmt);
02508 
02509     COPY_NODE_FIELD(distinctClause);
02510     COPY_NODE_FIELD(intoClause);
02511     COPY_NODE_FIELD(targetList);
02512     COPY_NODE_FIELD(fromClause);
02513     COPY_NODE_FIELD(whereClause);
02514     COPY_NODE_FIELD(groupClause);
02515     COPY_NODE_FIELD(havingClause);
02516     COPY_NODE_FIELD(windowClause);
02517     COPY_NODE_FIELD(valuesLists);
02518     COPY_NODE_FIELD(sortClause);
02519     COPY_NODE_FIELD(limitOffset);
02520     COPY_NODE_FIELD(limitCount);
02521     COPY_NODE_FIELD(lockingClause);
02522     COPY_NODE_FIELD(withClause);
02523     COPY_SCALAR_FIELD(op);
02524     COPY_SCALAR_FIELD(all);
02525     COPY_NODE_FIELD(larg);
02526     COPY_NODE_FIELD(rarg);
02527 
02528     return newnode;
02529 }
02530 
02531 static SetOperationStmt *
02532 _copySetOperationStmt(const SetOperationStmt *from)
02533 {
02534     SetOperationStmt *newnode = makeNode(SetOperationStmt);
02535 
02536     COPY_SCALAR_FIELD(op);
02537     COPY_SCALAR_FIELD(all);
02538     COPY_NODE_FIELD(larg);
02539     COPY_NODE_FIELD(rarg);
02540     COPY_NODE_FIELD(colTypes);
02541     COPY_NODE_FIELD(colTypmods);
02542     COPY_NODE_FIELD(colCollations);
02543     COPY_NODE_FIELD(groupClauses);
02544 
02545     return newnode;
02546 }
02547 
02548 static AlterTableStmt *
02549 _copyAlterTableStmt(const AlterTableStmt *from)
02550 {
02551     AlterTableStmt *newnode = makeNode(AlterTableStmt);
02552 
02553     COPY_NODE_FIELD(relation);
02554     COPY_NODE_FIELD(cmds);
02555     COPY_SCALAR_FIELD(relkind);
02556     COPY_SCALAR_FIELD(missing_ok);
02557 
02558     return newnode;
02559 }
02560 
02561 static AlterTableCmd *
02562 _copyAlterTableCmd(const AlterTableCmd *from)
02563 {
02564     AlterTableCmd *newnode = makeNode(AlterTableCmd);
02565 
02566     COPY_SCALAR_FIELD(subtype);
02567     COPY_STRING_FIELD(name);
02568     COPY_NODE_FIELD(def);
02569     COPY_SCALAR_FIELD(behavior);
02570     COPY_SCALAR_FIELD(missing_ok);
02571 
02572     return newnode;
02573 }
02574 
02575 static AlterDomainStmt *
02576 _copyAlterDomainStmt(const AlterDomainStmt *from)
02577 {
02578     AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
02579 
02580     COPY_SCALAR_FIELD(subtype);
02581     COPY_NODE_FIELD(typeName);
02582     COPY_STRING_FIELD(name);
02583     COPY_NODE_FIELD(def);
02584     COPY_SCALAR_FIELD(behavior);
02585     COPY_SCALAR_FIELD(missing_ok);
02586 
02587     return newnode;
02588 }
02589 
02590 static GrantStmt *
02591 _copyGrantStmt(const GrantStmt *from)
02592 {
02593     GrantStmt  *newnode = makeNode(GrantStmt);
02594 
02595     COPY_SCALAR_FIELD(is_grant);
02596     COPY_SCALAR_FIELD(targtype);
02597     COPY_SCALAR_FIELD(objtype);
02598     COPY_NODE_FIELD(objects);
02599     COPY_NODE_FIELD(privileges);
02600     COPY_NODE_FIELD(grantees);
02601     COPY_SCALAR_FIELD(grant_option);
02602     COPY_SCALAR_FIELD(behavior);
02603 
02604     return newnode;
02605 }
02606 
02607 static PrivGrantee *
02608 _copyPrivGrantee(const PrivGrantee *from)
02609 {
02610     PrivGrantee *newnode = makeNode(PrivGrantee);
02611 
02612     COPY_STRING_FIELD(rolname);
02613 
02614     return newnode;
02615 }
02616 
02617 static FuncWithArgs *
02618 _copyFuncWithArgs(const FuncWithArgs *from)
02619 {
02620     FuncWithArgs *newnode = makeNode(FuncWithArgs);
02621 
02622     COPY_NODE_FIELD(funcname);
02623     COPY_NODE_FIELD(funcargs);
02624 
02625     return newnode;
02626 }
02627 
02628 static AccessPriv *
02629 _copyAccessPriv(const AccessPriv *from)
02630 {
02631     AccessPriv *newnode = makeNode(AccessPriv);
02632 
02633     COPY_STRING_FIELD(priv_name);
02634     COPY_NODE_FIELD(cols);
02635 
02636     return newnode;
02637 }
02638 
02639 static GrantRoleStmt *
02640 _copyGrantRoleStmt(const GrantRoleStmt *from)
02641 {
02642     GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
02643 
02644     COPY_NODE_FIELD(granted_roles);
02645     COPY_NODE_FIELD(grantee_roles);
02646     COPY_SCALAR_FIELD(is_grant);
02647     COPY_SCALAR_FIELD(admin_opt);
02648     COPY_STRING_FIELD(grantor);
02649     COPY_SCALAR_FIELD(behavior);
02650 
02651     return newnode;
02652 }
02653 
02654 static AlterDefaultPrivilegesStmt *
02655 _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
02656 {
02657     AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
02658 
02659     COPY_NODE_FIELD(options);
02660     COPY_NODE_FIELD(action);
02661 
02662     return newnode;
02663 }
02664 
02665 static DeclareCursorStmt *
02666 _copyDeclareCursorStmt(const DeclareCursorStmt *from)
02667 {
02668     DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
02669 
02670     COPY_STRING_FIELD(portalname);
02671     COPY_SCALAR_FIELD(options);
02672     COPY_NODE_FIELD(query);
02673 
02674     return newnode;
02675 }
02676 
02677 static ClosePortalStmt *
02678 _copyClosePortalStmt(const ClosePortalStmt *from)
02679 {
02680     ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
02681 
02682     COPY_STRING_FIELD(portalname);
02683 
02684     return newnode;
02685 }
02686 
02687 static ClusterStmt *
02688 _copyClusterStmt(const ClusterStmt *from)
02689 {
02690     ClusterStmt *newnode = makeNode(ClusterStmt);
02691 
02692     COPY_NODE_FIELD(relation);
02693     COPY_STRING_FIELD(indexname);
02694     COPY_SCALAR_FIELD(verbose);
02695 
02696     return newnode;
02697 }
02698 
02699 static CopyStmt *
02700 _copyCopyStmt(const CopyStmt *from)
02701 {
02702     CopyStmt   *newnode = makeNode(CopyStmt);
02703 
02704     COPY_NODE_FIELD(relation);
02705     COPY_NODE_FIELD(query);
02706     COPY_NODE_FIELD(attlist);
02707     COPY_SCALAR_FIELD(is_from);
02708     COPY_SCALAR_FIELD(is_program);
02709     COPY_STRING_FIELD(filename);
02710     COPY_NODE_FIELD(options);
02711 
02712     return newnode;
02713 }
02714 
02715 /*
02716  * CopyCreateStmtFields
02717  *
02718  *      This function copies the fields of the CreateStmt node.  It is used by
02719  *      copy functions for classes which inherit from CreateStmt.
02720  */
02721 static void
02722 CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
02723 {
02724     COPY_NODE_FIELD(relation);
02725     COPY_NODE_FIELD(tableElts);
02726     COPY_NODE_FIELD(inhRelations);
02727     COPY_NODE_FIELD(ofTypename);
02728     COPY_NODE_FIELD(constraints);
02729     COPY_NODE_FIELD(options);
02730     COPY_SCALAR_FIELD(oncommit);
02731     COPY_STRING_FIELD(tablespacename);
02732     COPY_SCALAR_FIELD(if_not_exists);
02733 }
02734 
02735 static CreateStmt *
02736 _copyCreateStmt(const CreateStmt *from)
02737 {
02738     CreateStmt *newnode = makeNode(CreateStmt);
02739 
02740     CopyCreateStmtFields(from, newnode);
02741 
02742     return newnode;
02743 }
02744 
02745 static TableLikeClause *
02746 _copyTableLikeClause(const TableLikeClause *from)
02747 {
02748     TableLikeClause *newnode = makeNode(TableLikeClause);
02749 
02750     COPY_NODE_FIELD(relation);
02751     COPY_SCALAR_FIELD(options);
02752 
02753     return newnode;
02754 }
02755 
02756 static DefineStmt *
02757 _copyDefineStmt(const DefineStmt *from)
02758 {
02759     DefineStmt *newnode = makeNode(DefineStmt);
02760 
02761     COPY_SCALAR_FIELD(kind);
02762     COPY_SCALAR_FIELD(oldstyle);
02763     COPY_NODE_FIELD(defnames);
02764     COPY_NODE_FIELD(args);
02765     COPY_NODE_FIELD(definition);
02766 
02767     return newnode;
02768 }
02769 
02770 static DropStmt *
02771 _copyDropStmt(const DropStmt *from)
02772 {
02773     DropStmt   *newnode = makeNode(DropStmt);
02774 
02775     COPY_NODE_FIELD(objects);
02776     COPY_NODE_FIELD(arguments);
02777     COPY_SCALAR_FIELD(removeType);
02778     COPY_SCALAR_FIELD(behavior);
02779     COPY_SCALAR_FIELD(missing_ok);
02780     COPY_SCALAR_FIELD(concurrent);
02781 
02782     return newnode;
02783 }
02784 
02785 static TruncateStmt *
02786 _copyTruncateStmt(const TruncateStmt *from)
02787 {
02788     TruncateStmt *newnode = makeNode(TruncateStmt);
02789 
02790     COPY_NODE_FIELD(relations);
02791     COPY_SCALAR_FIELD(restart_seqs);
02792     COPY_SCALAR_FIELD(behavior);
02793 
02794     return newnode;
02795 }
02796 
02797 static CommentStmt *
02798 _copyCommentStmt(const CommentStmt *from)
02799 {
02800     CommentStmt *newnode = makeNode(CommentStmt);
02801 
02802     COPY_SCALAR_FIELD(objtype);
02803     COPY_NODE_FIELD(objname);
02804     COPY_NODE_FIELD(objargs);
02805     COPY_STRING_FIELD(comment);
02806 
02807     return newnode;
02808 }
02809 
02810 static SecLabelStmt *
02811 _copySecLabelStmt(const SecLabelStmt *from)
02812 {
02813     SecLabelStmt *newnode = makeNode(SecLabelStmt);
02814 
02815     COPY_SCALAR_FIELD(objtype);
02816     COPY_NODE_FIELD(objname);
02817     COPY_NODE_FIELD(objargs);
02818     COPY_STRING_FIELD(provider);
02819     COPY_STRING_FIELD(label);
02820 
02821     return newnode;
02822 }
02823 
02824 static FetchStmt *
02825 _copyFetchStmt(const FetchStmt *from)
02826 {
02827     FetchStmt  *newnode = makeNode(FetchStmt);
02828 
02829     COPY_SCALAR_FIELD(direction);
02830     COPY_SCALAR_FIELD(howMany);
02831     COPY_STRING_FIELD(portalname);
02832     COPY_SCALAR_FIELD(ismove);
02833 
02834     return newnode;
02835 }
02836 
02837 static IndexStmt *
02838 _copyIndexStmt(const IndexStmt *from)
02839 {
02840     IndexStmt  *newnode = makeNode(IndexStmt);
02841 
02842     COPY_STRING_FIELD(idxname);
02843     COPY_NODE_FIELD(relation);
02844     COPY_STRING_FIELD(accessMethod);
02845     COPY_STRING_FIELD(tableSpace);
02846     COPY_NODE_FIELD(indexParams);
02847     COPY_NODE_FIELD(options);
02848     COPY_NODE_FIELD(whereClause);
02849     COPY_NODE_FIELD(excludeOpNames);
02850     COPY_STRING_FIELD(idxcomment);
02851     COPY_SCALAR_FIELD(indexOid);
02852     COPY_SCALAR_FIELD(oldNode);
02853     COPY_SCALAR_FIELD(unique);
02854     COPY_SCALAR_FIELD(primary);
02855     COPY_SCALAR_FIELD(isconstraint);
02856     COPY_SCALAR_FIELD(deferrable);
02857     COPY_SCALAR_FIELD(initdeferred);
02858     COPY_SCALAR_FIELD(concurrent);
02859 
02860     return newnode;
02861 }
02862 
02863 static CreateFunctionStmt *
02864 _copyCreateFunctionStmt(const CreateFunctionStmt *from)
02865 {
02866     CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
02867 
02868     COPY_SCALAR_FIELD(replace);
02869     COPY_NODE_FIELD(funcname);
02870     COPY_NODE_FIELD(parameters);
02871     COPY_NODE_FIELD(returnType);
02872     COPY_NODE_FIELD(options);
02873     COPY_NODE_FIELD(withClause);
02874 
02875     return newnode;
02876 }
02877 
02878 static FunctionParameter *
02879 _copyFunctionParameter(const FunctionParameter *from)
02880 {
02881     FunctionParameter *newnode = makeNode(FunctionParameter);
02882 
02883     COPY_STRING_FIELD(name);
02884     COPY_NODE_FIELD(argType);
02885     COPY_SCALAR_FIELD(mode);
02886     COPY_NODE_FIELD(defexpr);
02887 
02888     return newnode;
02889 }
02890 
02891 static AlterFunctionStmt *
02892 _copyAlterFunctionStmt(const AlterFunctionStmt *from)
02893 {
02894     AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
02895 
02896     COPY_NODE_FIELD(func);
02897     COPY_NODE_FIELD(actions);
02898 
02899     return newnode;
02900 }
02901 
02902 static DoStmt *
02903 _copyDoStmt(const DoStmt *from)
02904 {
02905     DoStmt     *newnode = makeNode(DoStmt);
02906 
02907     COPY_NODE_FIELD(args);
02908 
02909     return newnode;
02910 }
02911 
02912 static RenameStmt *
02913 _copyRenameStmt(const RenameStmt *from)
02914 {
02915     RenameStmt *newnode = makeNode(RenameStmt);
02916 
02917     COPY_SCALAR_FIELD(renameType);
02918     COPY_SCALAR_FIELD(relationType);
02919     COPY_NODE_FIELD(relation);
02920     COPY_NODE_FIELD(object);
02921     COPY_NODE_FIELD(objarg);
02922     COPY_STRING_FIELD(subname);
02923     COPY_STRING_FIELD(newname);
02924     COPY_SCALAR_FIELD(behavior);
02925     COPY_SCALAR_FIELD(missing_ok);
02926 
02927     return newnode;
02928 }
02929 
02930 static AlterObjectSchemaStmt *
02931 _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
02932 {
02933     AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
02934 
02935     COPY_SCALAR_FIELD(objectType);
02936     COPY_NODE_FIELD(relation);
02937     COPY_NODE_FIELD(object);
02938     COPY_NODE_FIELD(objarg);
02939     COPY_STRING_FIELD(newschema);
02940     COPY_SCALAR_FIELD(missing_ok);
02941 
02942     return newnode;
02943 }
02944 
02945 static AlterOwnerStmt *
02946 _copyAlterOwnerStmt(const AlterOwnerStmt *from)
02947 {
02948     AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
02949 
02950     COPY_SCALAR_FIELD(objectType);
02951     COPY_NODE_FIELD(relation);
02952     COPY_NODE_FIELD(object);
02953     COPY_NODE_FIELD(objarg);
02954     COPY_STRING_FIELD(newowner);
02955 
02956     return newnode;
02957 }
02958 
02959 static RuleStmt *
02960 _copyRuleStmt(const RuleStmt *from)
02961 {
02962     RuleStmt   *newnode = makeNode(RuleStmt);
02963 
02964     COPY_NODE_FIELD(relation);
02965     COPY_STRING_FIELD(rulename);
02966     COPY_NODE_FIELD(whereClause);
02967     COPY_SCALAR_FIELD(event);
02968     COPY_SCALAR_FIELD(instead);
02969     COPY_NODE_FIELD(actions);
02970     COPY_SCALAR_FIELD(replace);
02971 
02972     return newnode;
02973 }
02974 
02975 static NotifyStmt *
02976 _copyNotifyStmt(const NotifyStmt *from)
02977 {
02978     NotifyStmt *newnode = makeNode(NotifyStmt);
02979 
02980     COPY_STRING_FIELD(conditionname);
02981     COPY_STRING_FIELD(payload);
02982 
02983     return newnode;
02984 }
02985 
02986 static ListenStmt *
02987 _copyListenStmt(const ListenStmt *from)
02988 {
02989     ListenStmt *newnode = makeNode(ListenStmt);
02990 
02991     COPY_STRING_FIELD(conditionname);
02992 
02993     return newnode;
02994 }
02995 
02996 static UnlistenStmt *
02997 _copyUnlistenStmt(const UnlistenStmt *from)
02998 {
02999     UnlistenStmt *newnode = makeNode(UnlistenStmt);
03000 
03001     COPY_STRING_FIELD(conditionname);
03002 
03003     return newnode;
03004 }
03005 
03006 static TransactionStmt *
03007 _copyTransactionStmt(const TransactionStmt *from)
03008 {
03009     TransactionStmt *newnode = makeNode(TransactionStmt);
03010 
03011     COPY_SCALAR_FIELD(kind);
03012     COPY_NODE_FIELD(options);
03013     COPY_STRING_FIELD(gid);
03014 
03015     return newnode;
03016 }
03017 
03018 static CompositeTypeStmt *
03019 _copyCompositeTypeStmt(const CompositeTypeStmt *from)
03020 {
03021     CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
03022 
03023     COPY_NODE_FIELD(typevar);
03024     COPY_NODE_FIELD(coldeflist);
03025 
03026     return newnode;
03027 }
03028 
03029 static CreateEnumStmt *
03030 _copyCreateEnumStmt(const CreateEnumStmt *from)
03031 {
03032     CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
03033 
03034     COPY_NODE_FIELD(typeName);
03035     COPY_NODE_FIELD(vals);
03036 
03037     return newnode;
03038 }
03039 
03040 static CreateRangeStmt *
03041 _copyCreateRangeStmt(const CreateRangeStmt *from)
03042 {
03043     CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
03044 
03045     COPY_NODE_FIELD(typeName);
03046     COPY_NODE_FIELD(params);
03047 
03048     return newnode;
03049 }
03050 
03051 static AlterEnumStmt *
03052 _copyAlterEnumStmt(const AlterEnumStmt *from)
03053 {
03054     AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
03055 
03056     COPY_NODE_FIELD(typeName);
03057     COPY_STRING_FIELD(newVal);
03058     COPY_STRING_FIELD(newValNeighbor);
03059     COPY_SCALAR_FIELD(newValIsAfter);
03060     COPY_SCALAR_FIELD(skipIfExists);
03061 
03062     return newnode;
03063 }
03064 
03065 static ViewStmt *
03066 _copyViewStmt(const ViewStmt *from)
03067 {
03068     ViewStmt   *newnode = makeNode(ViewStmt);
03069 
03070     COPY_NODE_FIELD(view);
03071     COPY_NODE_FIELD(aliases);
03072     COPY_NODE_FIELD(query);
03073     COPY_SCALAR_FIELD(replace);
03074     COPY_NODE_FIELD(options);
03075 
03076     return newnode;
03077 }
03078 
03079 static LoadStmt *
03080 _copyLoadStmt(const LoadStmt *from)
03081 {
03082     LoadStmt   *newnode = makeNode(LoadStmt);
03083 
03084     COPY_STRING_FIELD(filename);
03085 
03086     return newnode;
03087 }
03088 
03089 static CreateDomainStmt *
03090 _copyCreateDomainStmt(const CreateDomainStmt *from)
03091 {
03092     CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
03093 
03094     COPY_NODE_FIELD(domainname);
03095     COPY_NODE_FIELD(typeName);
03096     COPY_NODE_FIELD(collClause);
03097     COPY_NODE_FIELD(constraints);
03098 
03099     return newnode;
03100 }
03101 
03102 static CreateOpClassStmt *
03103 _copyCreateOpClassStmt(const CreateOpClassStmt *from)
03104 {
03105     CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
03106 
03107     COPY_NODE_FIELD(opclassname);
03108     COPY_NODE_FIELD(opfamilyname);
03109     COPY_STRING_FIELD(amname);
03110     COPY_NODE_FIELD(datatype);
03111     COPY_NODE_FIELD(items);
03112     COPY_SCALAR_FIELD(isDefault);
03113 
03114     return newnode;
03115 }
03116 
03117 static CreateOpClassItem *
03118 _copyCreateOpClassItem(const CreateOpClassItem *from)
03119 {
03120     CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
03121 
03122     COPY_SCALAR_FIELD(itemtype);
03123     COPY_NODE_FIELD(name);
03124     COPY_NODE_FIELD(args);
03125     COPY_SCALAR_FIELD(number);
03126     COPY_NODE_FIELD(order_family);
03127     COPY_NODE_FIELD(class_args);
03128     COPY_NODE_FIELD(storedtype);
03129 
03130     return newnode;
03131 }
03132 
03133 static CreateOpFamilyStmt *
03134 _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
03135 {
03136     CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
03137 
03138     COPY_NODE_FIELD(opfamilyname);
03139     COPY_STRING_FIELD(amname);
03140 
03141     return newnode;
03142 }
03143 
03144 static AlterOpFamilyStmt *
03145 _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
03146 {
03147     AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
03148 
03149     COPY_NODE_FIELD(opfamilyname);
03150     COPY_STRING_FIELD(amname);
03151     COPY_SCALAR_FIELD(isDrop);
03152     COPY_NODE_FIELD(items);
03153 
03154     return newnode;
03155 }
03156 
03157 static CreatedbStmt *
03158 _copyCreatedbStmt(const CreatedbStmt *from)
03159 {
03160     CreatedbStmt *newnode = makeNode(CreatedbStmt);
03161 
03162     COPY_STRING_FIELD(dbname);
03163     COPY_NODE_FIELD(options);
03164 
03165     return newnode;
03166 }
03167 
03168 static AlterDatabaseStmt *
03169 _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
03170 {
03171     AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
03172 
03173     COPY_STRING_FIELD(dbname);
03174     COPY_NODE_FIELD(options);
03175 
03176     return newnode;
03177 }
03178 
03179 static AlterDatabaseSetStmt *
03180 _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
03181 {
03182     AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
03183 
03184     COPY_STRING_FIELD(dbname);
03185     COPY_NODE_FIELD(setstmt);
03186 
03187     return newnode;
03188 }
03189 
03190 static DropdbStmt *
03191 _copyDropdbStmt(const DropdbStmt *from)
03192 {
03193     DropdbStmt *newnode = makeNode(DropdbStmt);
03194 
03195     COPY_STRING_FIELD(dbname);
03196     COPY_SCALAR_FIELD(missing_ok);
03197 
03198     return newnode;
03199 }
03200 
03201 static VacuumStmt *
03202 _copyVacuumStmt(const VacuumStmt *from)
03203 {
03204     VacuumStmt *newnode = makeNode(VacuumStmt);
03205 
03206     COPY_SCALAR_FIELD(options);
03207     COPY_SCALAR_FIELD(freeze_min_age);
03208     COPY_SCALAR_FIELD(freeze_table_age);
03209     COPY_NODE_FIELD(relation);
03210     COPY_NODE_FIELD(va_cols);
03211 
03212     return newnode;
03213 }
03214 
03215 static ExplainStmt *
03216 _copyExplainStmt(const ExplainStmt *from)
03217 {
03218     ExplainStmt *newnode = makeNode(ExplainStmt);
03219 
03220     COPY_NODE_FIELD(query);
03221     COPY_NODE_FIELD(options);
03222 
03223     return newnode;
03224 }
03225 
03226 static CreateTableAsStmt *
03227 _copyCreateTableAsStmt(const CreateTableAsStmt *from)
03228 {
03229     CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
03230 
03231     COPY_NODE_FIELD(query);
03232     COPY_NODE_FIELD(into);
03233     COPY_SCALAR_FIELD(relkind);
03234     COPY_SCALAR_FIELD(is_select_into);
03235 
03236     return newnode;
03237 }
03238 
03239 static RefreshMatViewStmt *
03240 _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
03241 {
03242     RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
03243 
03244     COPY_SCALAR_FIELD(skipData);
03245     COPY_NODE_FIELD(relation);
03246 
03247     return newnode;
03248 }
03249 
03250 static CreateSeqStmt *
03251 _copyCreateSeqStmt(const CreateSeqStmt *from)
03252 {
03253     CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
03254 
03255     COPY_NODE_FIELD(sequence);
03256     COPY_NODE_FIELD(options);
03257     COPY_SCALAR_FIELD(ownerId);
03258 
03259     return newnode;
03260 }
03261 
03262 static AlterSeqStmt *
03263 _copyAlterSeqStmt(const AlterSeqStmt *from)
03264 {
03265     AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
03266 
03267     COPY_NODE_FIELD(sequence);
03268     COPY_NODE_FIELD(options);
03269     COPY_SCALAR_FIELD(missing_ok);
03270 
03271     return newnode;
03272 }
03273 
03274 static VariableSetStmt *
03275 _copyVariableSetStmt(const VariableSetStmt *from)
03276 {
03277     VariableSetStmt *newnode = makeNode(VariableSetStmt);
03278 
03279     COPY_SCALAR_FIELD(kind);
03280     COPY_STRING_FIELD(name);
03281     COPY_NODE_FIELD(args);
03282     COPY_SCALAR_FIELD(is_local);
03283 
03284     return newnode;
03285 }
03286 
03287 static VariableShowStmt *
03288 _copyVariableShowStmt(const VariableShowStmt *from)
03289 {
03290     VariableShowStmt *newnode = makeNode(VariableShowStmt);
03291 
03292     COPY_STRING_FIELD(name);
03293 
03294     return newnode;
03295 }
03296 
03297 static DiscardStmt *
03298 _copyDiscardStmt(const DiscardStmt *from)
03299 {
03300     DiscardStmt *newnode = makeNode(DiscardStmt);
03301 
03302     COPY_SCALAR_FIELD(target);
03303 
03304     return newnode;
03305 }
03306 
03307 static CreateTableSpaceStmt *
03308 _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
03309 {
03310     CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
03311 
03312     COPY_STRING_FIELD(tablespacename);
03313     COPY_STRING_FIELD(owner);
03314     COPY_STRING_FIELD(location);
03315 
03316     return newnode;
03317 }
03318 
03319 static DropTableSpaceStmt *
03320 _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
03321 {
03322     DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
03323 
03324     COPY_STRING_FIELD(tablespacename);
03325     COPY_SCALAR_FIELD(missing_ok);
03326 
03327     return newnode;
03328 }
03329 
03330 static AlterTableSpaceOptionsStmt *
03331 _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
03332 {
03333     AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
03334 
03335     COPY_STRING_FIELD(tablespacename);
03336     COPY_NODE_FIELD(options);
03337     COPY_SCALAR_FIELD(isReset);
03338 
03339     return newnode;
03340 }
03341 
03342 static CreateExtensionStmt *
03343 _copyCreateExtensionStmt(const CreateExtensionStmt *from)
03344 {
03345     CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
03346 
03347     COPY_STRING_FIELD(extname);
03348     COPY_SCALAR_FIELD(if_not_exists);
03349     COPY_NODE_FIELD(options);
03350 
03351     return newnode;
03352 }
03353 
03354 static AlterExtensionStmt *
03355 _copyAlterExtensionStmt(const AlterExtensionStmt *from)
03356 {
03357     AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
03358 
03359     COPY_STRING_FIELD(extname);
03360     COPY_NODE_FIELD(options);
03361 
03362     return newnode;
03363 }
03364 
03365 static AlterExtensionContentsStmt *
03366 _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
03367 {
03368     AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
03369 
03370     COPY_STRING_FIELD(extname);
03371     COPY_SCALAR_FIELD(action);
03372     COPY_SCALAR_FIELD(objtype);
03373     COPY_NODE_FIELD(objname);
03374     COPY_NODE_FIELD(objargs);
03375 
03376     return newnode;
03377 }
03378 
03379 static CreateFdwStmt *
03380 _copyCreateFdwStmt(const CreateFdwStmt *from)
03381 {
03382     CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
03383 
03384     COPY_STRING_FIELD(fdwname);
03385     COPY_NODE_FIELD(func_options);
03386     COPY_NODE_FIELD(options);
03387 
03388     return newnode;
03389 }
03390 
03391 static AlterFdwStmt *
03392 _copyAlterFdwStmt(const AlterFdwStmt *from)
03393 {
03394     AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
03395 
03396     COPY_STRING_FIELD(fdwname);
03397     COPY_NODE_FIELD(func_options);
03398     COPY_NODE_FIELD(options);
03399 
03400     return newnode;
03401 }
03402 
03403 static CreateForeignServerStmt *
03404 _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
03405 {
03406     CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
03407 
03408     COPY_STRING_FIELD(servername);
03409     COPY_STRING_FIELD(servertype);
03410     COPY_STRING_FIELD(version);
03411     COPY_STRING_FIELD(fdwname);
03412     COPY_NODE_FIELD(options);
03413 
03414     return newnode;
03415 }
03416 
03417 static AlterForeignServerStmt *
03418 _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
03419 {
03420     AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
03421 
03422     COPY_STRING_FIELD(servername);
03423     COPY_STRING_FIELD(version);
03424     COPY_NODE_FIELD(options);
03425     COPY_SCALAR_FIELD(has_version);
03426 
03427     return newnode;
03428 }
03429 
03430 static CreateUserMappingStmt *
03431 _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
03432 {
03433     CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
03434 
03435     COPY_STRING_FIELD(username);
03436     COPY_STRING_FIELD(servername);
03437     COPY_NODE_FIELD(options);
03438 
03439     return newnode;
03440 }
03441 
03442 static AlterUserMappingStmt *
03443 _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
03444 {
03445     AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
03446 
03447     COPY_STRING_FIELD(username);
03448     COPY_STRING_FIELD(servername);
03449     COPY_NODE_FIELD(options);
03450 
03451     return newnode;
03452 }
03453 
03454 static DropUserMappingStmt *
03455 _copyDropUserMappingStmt(const DropUserMappingStmt *from)
03456 {
03457     DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
03458 
03459     COPY_STRING_FIELD(username);
03460     COPY_STRING_FIELD(servername);
03461     COPY_SCALAR_FIELD(missing_ok);
03462 
03463     return newnode;
03464 }
03465 
03466 static CreateForeignTableStmt *
03467 _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
03468 {
03469     CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
03470 
03471     CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
03472 
03473     COPY_STRING_FIELD(servername);
03474     COPY_NODE_FIELD(options);
03475 
03476     return newnode;
03477 }
03478 
03479 static CreateTrigStmt *
03480 _copyCreateTrigStmt(const CreateTrigStmt *from)
03481 {
03482     CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
03483 
03484     COPY_STRING_FIELD(trigname);
03485     COPY_NODE_FIELD(relation);
03486     COPY_NODE_FIELD(funcname);
03487     COPY_NODE_FIELD(args);
03488     COPY_SCALAR_FIELD(row);
03489     COPY_SCALAR_FIELD(timing);
03490     COPY_SCALAR_FIELD(events);
03491     COPY_NODE_FIELD(columns);
03492     COPY_NODE_FIELD(whenClause);
03493     COPY_SCALAR_FIELD(isconstraint);
03494     COPY_SCALAR_FIELD(deferrable);
03495     COPY_SCALAR_FIELD(initdeferred);
03496     COPY_NODE_FIELD(constrrel);
03497 
03498     return newnode;
03499 }
03500 
03501 static CreateEventTrigStmt *
03502 _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
03503 {
03504     CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
03505 
03506     COPY_STRING_FIELD(trigname);
03507     COPY_SCALAR_FIELD(eventname);
03508     COPY_NODE_FIELD(whenclause);
03509     COPY_NODE_FIELD(funcname);
03510 
03511     return newnode;
03512 }
03513 
03514 static AlterEventTrigStmt *
03515 _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
03516 {
03517     AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
03518 
03519     COPY_STRING_FIELD(trigname);
03520     COPY_SCALAR_FIELD(tgenabled);
03521 
03522     return newnode;
03523 }
03524 
03525 static CreatePLangStmt *
03526 _copyCreatePLangStmt(const CreatePLangStmt *from)
03527 {
03528     CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
03529 
03530     COPY_SCALAR_FIELD(replace);
03531     COPY_STRING_FIELD(plname);
03532     COPY_NODE_FIELD(plhandler);
03533     COPY_NODE_FIELD(plinline);
03534     COPY_NODE_FIELD(plvalidator);
03535     COPY_SCALAR_FIELD(pltrusted);
03536 
03537     return newnode;
03538 }
03539 
03540 static CreateRoleStmt *
03541 _copyCreateRoleStmt(const CreateRoleStmt *from)
03542 {
03543     CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
03544 
03545     COPY_SCALAR_FIELD(stmt_type);
03546     COPY_STRING_FIELD(role);
03547     COPY_NODE_FIELD(options);
03548 
03549     return newnode;
03550 }
03551 
03552 static AlterRoleStmt *
03553 _copyAlterRoleStmt(const AlterRoleStmt *from)
03554 {
03555     AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
03556 
03557     COPY_STRING_FIELD(role);
03558     COPY_NODE_FIELD(options);
03559     COPY_SCALAR_FIELD(action);
03560 
03561     return newnode;
03562 }
03563 
03564 static AlterRoleSetStmt *
03565 _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
03566 {
03567     AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
03568 
03569     COPY_STRING_FIELD(role);
03570     COPY_STRING_FIELD(database);
03571     COPY_NODE_FIELD(setstmt);
03572 
03573     return newnode;
03574 }
03575 
03576 static DropRoleStmt *
03577 _copyDropRoleStmt(const DropRoleStmt *from)
03578 {
03579     DropRoleStmt *newnode = makeNode(DropRoleStmt);
03580 
03581     COPY_NODE_FIELD(roles);
03582     COPY_SCALAR_FIELD(missing_ok);
03583 
03584     return newnode;
03585 }
03586 
03587 static LockStmt *
03588 _copyLockStmt(const LockStmt *from)
03589 {
03590     LockStmt   *newnode = makeNode(LockStmt);
03591 
03592     COPY_NODE_FIELD(relations);
03593     COPY_SCALAR_FIELD(mode);
03594     COPY_SCALAR_FIELD(nowait);
03595 
03596     return newnode;
03597 }
03598 
03599 static ConstraintsSetStmt *
03600 _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
03601 {
03602     ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
03603 
03604     COPY_NODE_FIELD(constraints);
03605     COPY_SCALAR_FIELD(deferred);
03606 
03607     return newnode;
03608 }
03609 
03610 static ReindexStmt *
03611 _copyReindexStmt(const ReindexStmt *from)
03612 {
03613     ReindexStmt *newnode = makeNode(ReindexStmt);
03614 
03615     COPY_SCALAR_FIELD(kind);
03616     COPY_NODE_FIELD(relation);
03617     COPY_STRING_FIELD(name);
03618     COPY_SCALAR_FIELD(do_system);
03619     COPY_SCALAR_FIELD(do_user);
03620 
03621     return newnode;
03622 }
03623 
03624 static CreateSchemaStmt *
03625 _copyCreateSchemaStmt(const CreateSchemaStmt *from)
03626 {
03627     CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
03628 
03629     COPY_STRING_FIELD(schemaname);
03630     COPY_STRING_FIELD(authid);
03631     COPY_NODE_FIELD(schemaElts);
03632     COPY_SCALAR_FIELD(if_not_exists);
03633 
03634     return newnode;
03635 }
03636 
03637 static CreateConversionStmt *
03638 _copyCreateConversionStmt(const CreateConversionStmt *from)
03639 {
03640     CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
03641 
03642     COPY_NODE_FIELD(conversion_name);
03643     COPY_STRING_FIELD(for_encoding_name);
03644     COPY_STRING_FIELD(to_encoding_name);
03645     COPY_NODE_FIELD(func_name);
03646     COPY_SCALAR_FIELD(def);
03647 
03648     return newnode;
03649 }
03650 
03651 static CreateCastStmt *
03652 _copyCreateCastStmt(const CreateCastStmt *from)
03653 {
03654     CreateCastStmt *newnode = makeNode(CreateCastStmt);
03655 
03656     COPY_NODE_FIELD(sourcetype);
03657     COPY_NODE_FIELD(targettype);
03658     COPY_NODE_FIELD(func);
03659     COPY_SCALAR_FIELD(context);
03660     COPY_SCALAR_FIELD(inout);
03661 
03662     return newnode;
03663 }
03664 
03665 static PrepareStmt *
03666 _copyPrepareStmt(const PrepareStmt *from)
03667 {
03668     PrepareStmt *newnode = makeNode(PrepareStmt);
03669 
03670     COPY_STRING_FIELD(name);
03671     COPY_NODE_FIELD(argtypes);
03672     COPY_NODE_FIELD(query);
03673 
03674     return newnode;
03675 }
03676 
03677 static ExecuteStmt *
03678 _copyExecuteStmt(const ExecuteStmt *from)
03679 {
03680     ExecuteStmt *newnode = makeNode(ExecuteStmt);
03681 
03682     COPY_STRING_FIELD(name);
03683     COPY_NODE_FIELD(params);
03684 
03685     return newnode;
03686 }
03687 
03688 static DeallocateStmt *
03689 _copyDeallocateStmt(const DeallocateStmt *from)
03690 {
03691     DeallocateStmt *newnode = makeNode(DeallocateStmt);
03692 
03693     COPY_STRING_FIELD(name);
03694 
03695     return newnode;
03696 }
03697 
03698 static DropOwnedStmt *
03699 _copyDropOwnedStmt(const DropOwnedStmt *from)
03700 {
03701     DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
03702 
03703     COPY_NODE_FIELD(roles);
03704     COPY_SCALAR_FIELD(behavior);
03705 
03706     return newnode;
03707 }
03708 
03709 static ReassignOwnedStmt *
03710 _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
03711 {
03712     ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
03713 
03714     COPY_NODE_FIELD(roles);
03715     COPY_STRING_FIELD(newrole);
03716 
03717     return newnode;
03718 }
03719 
03720 static AlterTSDictionaryStmt *
03721 _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
03722 {
03723     AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
03724 
03725     COPY_NODE_FIELD(dictname);
03726     COPY_NODE_FIELD(options);
03727 
03728     return newnode;
03729 }
03730 
03731 static AlterTSConfigurationStmt *
03732 _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
03733 {
03734     AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
03735 
03736     COPY_NODE_FIELD(cfgname);
03737     COPY_NODE_FIELD(tokentype);
03738     COPY_NODE_FIELD(dicts);
03739     COPY_SCALAR_FIELD(override);
03740     COPY_SCALAR_FIELD(replace);
03741     COPY_SCALAR_FIELD(missing_ok);
03742 
03743     return newnode;
03744 }
03745 
03746 /* ****************************************************************
03747  *                  pg_list.h copy functions
03748  * ****************************************************************
03749  */
03750 
03751 /*
03752  * Perform a deep copy of the specified list, using copyObject(). The
03753  * list MUST be of type T_List; T_IntList and T_OidList nodes don't
03754  * need deep copies, so they should be copied via list_copy()
03755  */
03756 #define COPY_NODE_CELL(new, old)                    \
03757     (new) = (ListCell *) palloc(sizeof(ListCell));  \
03758     lfirst(new) = copyObject(lfirst(old));
03759 
03760 static List *
03761 _copyList(const List *from)
03762 {
03763     List       *new;
03764     ListCell   *curr_old;
03765     ListCell   *prev_new;
03766 
03767     Assert(list_length(from) >= 1);
03768 
03769     new = makeNode(List);
03770     new->length = from->length;
03771 
03772     COPY_NODE_CELL(new->head, from->head);
03773     prev_new = new->head;
03774     curr_old = lnext(from->head);
03775 
03776     while (curr_old)
03777     {
03778         COPY_NODE_CELL(prev_new->next, curr_old);
03779         prev_new = prev_new->next;
03780         curr_old = curr_old->next;
03781     }
03782     prev_new->next = NULL;
03783     new->tail = prev_new;
03784 
03785     return new;
03786 }
03787 
03788 /* ****************************************************************
03789  *                  value.h copy functions
03790  * ****************************************************************
03791  */
03792 static Value *
03793 _copyValue(const Value *from)
03794 {
03795     Value      *newnode = makeNode(Value);
03796 
03797     /* See also _copyAConst when changing this code! */
03798 
03799     COPY_SCALAR_FIELD(type);
03800     switch (from->type)
03801     {
03802         case T_Integer:
03803             COPY_SCALAR_FIELD(val.ival);
03804             break;
03805         case T_Float:
03806         case T_String:
03807         case T_BitString:
03808             COPY_STRING_FIELD(val.str);
03809             break;
03810         case T_Null:
03811             /* nothing to do */
03812             break;
03813         default:
03814             elog(ERROR, "unrecognized node type: %d",
03815                  (int) from->type);
03816             break;
03817     }
03818     return newnode;
03819 }
03820 
03821 /*
03822  * copyObject
03823  *
03824  * Create a copy of a Node tree or list.  This is a "deep" copy: all
03825  * substructure is copied too, recursively.
03826  */
03827 void *
03828 copyObject(const void *from)
03829 {
03830     void       *retval;
03831 
03832     if (from == NULL)
03833         return NULL;
03834 
03835     /* Guard against stack overflow due to overly complex expressions */
03836     check_stack_depth();
03837 
03838     switch (nodeTag(from))
03839     {
03840             /*
03841              * PLAN NODES
03842              */
03843         case T_PlannedStmt:
03844             retval = _copyPlannedStmt(from);
03845             break;
03846         case T_Plan:
03847             retval = _copyPlan(from);
03848             break;
03849         case T_Result:
03850             retval = _copyResult(from);
03851             break;
03852         case T_ModifyTable:
03853             retval = _copyModifyTable(from);
03854             break;
03855         case T_Append:
03856             retval = _copyAppend(from);
03857             break;
03858         case T_MergeAppend:
03859             retval = _copyMergeAppend(from);
03860             break;
03861         case T_RecursiveUnion:
03862             retval = _copyRecursiveUnion(from);
03863             break;
03864         case T_BitmapAnd:
03865             retval = _copyBitmapAnd(from);
03866             break;
03867         case T_BitmapOr:
03868             retval = _copyBitmapOr(from);
03869             break;
03870         case T_Scan:
03871             retval = _copyScan(from);
03872             break;
03873         case T_SeqScan:
03874             retval = _copySeqScan(from);
03875             break;
03876         case T_IndexScan:
03877             retval = _copyIndexScan(from);
03878             break;
03879         case T_IndexOnlyScan:
03880             retval = _copyIndexOnlyScan(from);
03881             break;
03882         case T_BitmapIndexScan:
03883             retval = _copyBitmapIndexScan(from);
03884             break;
03885         case T_BitmapHeapScan:
03886             retval = _copyBitmapHeapScan(from);
03887             break;
03888         case T_TidScan:
03889             retval = _copyTidScan(from);
03890             break;
03891         case T_SubqueryScan:
03892             retval = _copySubqueryScan(from);
03893             break;
03894         case T_FunctionScan:
03895             retval = _copyFunctionScan(from);
03896             break;
03897         case T_ValuesScan:
03898             retval = _copyValuesScan(from);
03899             break;
03900         case T_CteScan:
03901             retval = _copyCteScan(from);
03902             break;
03903         case T_WorkTableScan:
03904             retval = _copyWorkTableScan(from);
03905             break;
03906         case T_ForeignScan:
03907             retval = _copyForeignScan(from);
03908             break;
03909         case T_Join:
03910             retval = _copyJoin(from);
03911             break;
03912         case T_NestLoop:
03913             retval = _copyNestLoop(from);
03914             break;
03915         case T_MergeJoin:
03916             retval = _copyMergeJoin(from);
03917             break;
03918         case T_HashJoin:
03919             retval = _copyHashJoin(from);
03920             break;
03921         case T_Material:
03922             retval = _copyMaterial(from);
03923             break;
03924         case T_Sort:
03925             retval = _copySort(from);
03926             break;
03927         case T_Group:
03928             retval = _copyGroup(from);
03929             break;
03930         case T_Agg:
03931             retval = _copyAgg(from);
03932             break;
03933         case T_WindowAgg:
03934             retval = _copyWindowAgg(from);
03935             break;
03936         case T_Unique:
03937             retval = _copyUnique(from);
03938             break;
03939         case T_Hash:
03940             retval = _copyHash(from);
03941             break;
03942         case T_SetOp:
03943             retval = _copySetOp(from);
03944             break;
03945         case T_LockRows:
03946             retval = _copyLockRows(from);
03947             break;
03948         case T_Limit:
03949             retval = _copyLimit(from);
03950             break;
03951         case T_NestLoopParam:
03952             retval = _copyNestLoopParam(from);
03953             break;
03954         case T_PlanRowMark:
03955             retval = _copyPlanRowMark(from);
03956             break;
03957         case T_PlanInvalItem:
03958             retval = _copyPlanInvalItem(from);
03959             break;
03960 
03961             /*
03962              * PRIMITIVE NODES
03963              */
03964         case T_Alias:
03965             retval = _copyAlias(from);
03966             break;
03967         case T_RangeVar:
03968             retval = _copyRangeVar(from);
03969             break;
03970         case T_IntoClause:
03971             retval = _copyIntoClause(from);
03972             break;
03973         case T_Var:
03974             retval = _copyVar(from);
03975             break;
03976         case T_Const:
03977             retval = _copyConst(from);
03978             break;
03979         case T_Param:
03980             retval = _copyParam(from);
03981             break;
03982         case T_Aggref:
03983             retval = _copyAggref(from);
03984             break;
03985         case T_WindowFunc:
03986             retval = _copyWindowFunc(from);
03987             break;
03988         case T_ArrayRef:
03989             retval = _copyArrayRef(from);
03990             break;
03991         case T_FuncExpr:
03992             retval = _copyFuncExpr(from);
03993             break;
03994         case T_NamedArgExpr:
03995             retval = _copyNamedArgExpr(from);
03996             break;
03997         case T_OpExpr:
03998             retval = _copyOpExpr(from);
03999             break;
04000         case T_DistinctExpr:
04001             retval = _copyDistinctExpr(from);
04002             break;
04003         case T_NullIfExpr:
04004             retval = _copyNullIfExpr(from);
04005             break;
04006         case T_ScalarArrayOpExpr:
04007             retval = _copyScalarArrayOpExpr(from);
04008             break;
04009         case T_BoolExpr:
04010             retval = _copyBoolExpr(from);
04011             break;
04012         case T_SubLink:
04013             retval = _copySubLink(from);
04014             break;
04015         case T_SubPlan:
04016             retval = _copySubPlan(from);
04017             break;
04018         case T_AlternativeSubPlan:
04019             retval = _copyAlternativeSubPlan(from);
04020             break;
04021         case T_FieldSelect:
04022             retval = _copyFieldSelect(from);
04023             break;
04024         case T_FieldStore:
04025             retval = _copyFieldStore(from);
04026             break;
04027         case T_RelabelType:
04028             retval = _copyRelabelType(from);
04029             break;
04030         case T_CoerceViaIO:
04031             retval = _copyCoerceViaIO(from);
04032             break;
04033         case T_ArrayCoerceExpr:
04034             retval = _copyArrayCoerceExpr(from);
04035             break;
04036         case T_ConvertRowtypeExpr:
04037             retval = _copyConvertRowtypeExpr(from);
04038             break;
04039         case T_CollateExpr:
04040             retval = _copyCollateExpr(from);
04041             break;
04042         case T_CaseExpr:
04043             retval = _copyCaseExpr(from);
04044             break;
04045         case T_CaseWhen:
04046             retval = _copyCaseWhen(from);
04047             break;
04048         case T_CaseTestExpr:
04049             retval = _copyCaseTestExpr(from);
04050             break;
04051         case T_ArrayExpr:
04052             retval = _copyArrayExpr(from);
04053             break;
04054         case T_RowExpr:
04055             retval = _copyRowExpr(from);
04056             break;
04057         case T_RowCompareExpr:
04058             retval = _copyRowCompareExpr(from);
04059             break;
04060         case T_CoalesceExpr:
04061             retval = _copyCoalesceExpr(from);
04062             break;
04063         case T_MinMaxExpr:
04064             retval = _copyMinMaxExpr(from);
04065             break;
04066         case T_XmlExpr:
04067             retval = _copyXmlExpr(from);
04068             break;
04069         case T_NullTest:
04070             retval = _copyNullTest(from);
04071             break;
04072         case T_BooleanTest:
04073             retval = _copyBooleanTest(from);
04074             break;
04075         case T_CoerceToDomain:
04076             retval = _copyCoerceToDomain(from);
04077             break;
04078         case T_CoerceToDomainValue:
04079             retval = _copyCoerceToDomainValue(from);
04080             break;
04081         case T_SetToDefault:
04082             retval = _copySetToDefault(from);
04083             break;
04084         case T_CurrentOfExpr:
04085             retval = _copyCurrentOfExpr(from);
04086             break;
04087         case T_TargetEntry:
04088             retval = _copyTargetEntry(from);
04089             break;
04090         case T_RangeTblRef:
04091             retval = _copyRangeTblRef(from);
04092             break;
04093         case T_JoinExpr:
04094             retval = _copyJoinExpr(from);
04095             break;
04096         case T_FromExpr:
04097             retval = _copyFromExpr(from);
04098             break;
04099 
04100             /*
04101              * RELATION NODES
04102              */
04103         case T_PathKey:
04104             retval = _copyPathKey(from);
04105             break;
04106         case T_RestrictInfo:
04107             retval = _copyRestrictInfo(from);
04108             break;
04109         case T_PlaceHolderVar:
04110             retval = _copyPlaceHolderVar(from);
04111             break;
04112         case T_SpecialJoinInfo:
04113             retval = _copySpecialJoinInfo(from);
04114             break;
04115         case T_LateralJoinInfo:
04116             retval = _copyLateralJoinInfo(from);
04117             break;
04118         case T_AppendRelInfo:
04119             retval = _copyAppendRelInfo(from);
04120             break;
04121         case T_PlaceHolderInfo:
04122             retval = _copyPlaceHolderInfo(from);
04123             break;
04124 
04125             /*
04126              * VALUE NODES
04127              */
04128         case T_Integer:
04129         case T_Float:
04130         case T_String:
04131         case T_BitString:
04132         case T_Null:
04133             retval = _copyValue(from);
04134             break;
04135 
04136             /*
04137              * LIST NODES
04138              */
04139         case T_List:
04140             retval = _copyList(from);
04141             break;
04142 
04143             /*
04144              * Lists of integers and OIDs don't need to be deep-copied, so we
04145              * perform a shallow copy via list_copy()
04146              */
04147         case T_IntList:
04148         case T_OidList:
04149             retval = list_copy(from);
04150             break;
04151 
04152             /*
04153              * PARSE NODES
04154              */
04155         case T_Query:
04156             retval = _copyQuery(from);
04157             break;
04158         case T_InsertStmt:
04159             retval = _copyInsertStmt(from);
04160             break;
04161         case T_DeleteStmt:
04162             retval = _copyDeleteStmt(from);
04163             break;
04164         case T_UpdateStmt:
04165             retval = _copyUpdateStmt(from);
04166             break;
04167         case T_SelectStmt:
04168             retval = _copySelectStmt(from);
04169             break;
04170         case T_SetOperationStmt:
04171             retval = _copySetOperationStmt(from);
04172             break;
04173         case T_AlterTableStmt:
04174             retval = _copyAlterTableStmt(from);
04175             break;
04176         case T_AlterTableCmd:
04177             retval = _copyAlterTableCmd(from);
04178             break;
04179         case T_AlterDomainStmt:
04180             retval = _copyAlterDomainStmt(from);
04181             break;
04182         case T_GrantStmt:
04183             retval = _copyGrantStmt(from);
04184             break;
04185         case T_GrantRoleStmt:
04186             retval = _copyGrantRoleStmt(from);
04187             break;
04188         case T_AlterDefaultPrivilegesStmt:
04189             retval = _copyAlterDefaultPrivilegesStmt(from);
04190             break;
04191         case T_DeclareCursorStmt:
04192             retval = _copyDeclareCursorStmt(from);
04193             break;
04194         case T_ClosePortalStmt:
04195             retval = _copyClosePortalStmt(from);
04196             break;
04197         case T_ClusterStmt:
04198             retval = _copyClusterStmt(from);
04199             break;
04200         case T_CopyStmt:
04201             retval = _copyCopyStmt(from);
04202             break;
04203         case T_CreateStmt:
04204             retval = _copyCreateStmt(from);
04205             break;
04206         case T_TableLikeClause:
04207             retval = _copyTableLikeClause(from);
04208             break;
04209         case T_DefineStmt:
04210             retval = _copyDefineStmt(from);
04211             break;
04212         case T_DropStmt:
04213             retval = _copyDropStmt(from);
04214             break;
04215         case T_TruncateStmt:
04216             retval = _copyTruncateStmt(from);
04217             break;
04218         case T_CommentStmt:
04219             retval = _copyCommentStmt(from);
04220             break;
04221         case T_SecLabelStmt:
04222             retval = _copySecLabelStmt(from);
04223             break;
04224         case T_FetchStmt:
04225             retval = _copyFetchStmt(from);
04226             break;
04227         case T_IndexStmt:
04228             retval = _copyIndexStmt(from);
04229             break;
04230         case T_CreateFunctionStmt:
04231             retval = _copyCreateFunctionStmt(from);
04232             break;
04233         case T_FunctionParameter:
04234             retval = _copyFunctionParameter(from);
04235             break;
04236         case T_AlterFunctionStmt:
04237             retval = _copyAlterFunctionStmt(from);
04238             break;
04239         case T_DoStmt:
04240             retval = _copyDoStmt(from);
04241             break;
04242         case T_RenameStmt:
04243             retval = _copyRenameStmt(from);
04244             break;
04245         case T_AlterObjectSchemaStmt:
04246             retval = _copyAlterObjectSchemaStmt(from);
04247             break;
04248         case T_AlterOwnerStmt:
04249             retval = _copyAlterOwnerStmt(from);
04250             break;
04251         case T_RuleStmt:
04252             retval = _copyRuleStmt(from);
04253             break;
04254         case T_NotifyStmt:
04255             retval = _copyNotifyStmt(from);
04256             break;
04257         case T_ListenStmt:
04258             retval = _copyListenStmt(from);
04259             break;
04260         case T_UnlistenStmt:
04261             retval = _copyUnlistenStmt(from);
04262             break;
04263         case T_TransactionStmt:
04264             retval = _copyTransactionStmt(from);
04265             break;
04266         case T_CompositeTypeStmt:
04267             retval = _copyCompositeTypeStmt(from);
04268             break;
04269         case T_CreateEnumStmt:
04270             retval = _copyCreateEnumStmt(from);
04271             break;
04272         case T_CreateRangeStmt:
04273             retval = _copyCreateRangeStmt(from);
04274             break;
04275         case T_AlterEnumStmt:
04276             retval = _copyAlterEnumStmt(from);
04277             break;
04278         case T_ViewStmt:
04279             retval = _copyViewStmt(from);
04280             break;
04281         case T_LoadStmt:
04282             retval = _copyLoadStmt(from);
04283             break;
04284         case T_CreateDomainStmt:
04285             retval = _copyCreateDomainStmt(from);
04286             break;
04287         case T_CreateOpClassStmt:
04288             retval = _copyCreateOpClassStmt(from);
04289             break;
04290         case T_CreateOpClassItem:
04291             retval = _copyCreateOpClassItem(from);
04292             break;
04293         case T_CreateOpFamilyStmt:
04294             retval = _copyCreateOpFamilyStmt(from);
04295             break;
04296         case T_AlterOpFamilyStmt:
04297             retval = _copyAlterOpFamilyStmt(from);
04298             break;
04299         case T_CreatedbStmt:
04300             retval = _copyCreatedbStmt(from);
04301             break;
04302         case T_AlterDatabaseStmt:
04303             retval = _copyAlterDatabaseStmt(from);
04304             break;
04305         case T_AlterDatabaseSetStmt:
04306             retval = _copyAlterDatabaseSetStmt(from);
04307             break;
04308         case T_DropdbStmt:
04309             retval = _copyDropdbStmt(from);
04310             break;
04311         case T_VacuumStmt:
04312             retval = _copyVacuumStmt(from);
04313             break;
04314         case T_ExplainStmt:
04315             retval = _copyExplainStmt(from);
04316             break;
04317         case T_CreateTableAsStmt:
04318             retval = _copyCreateTableAsStmt(from);
04319             break;
04320         case T_RefreshMatViewStmt:
04321             retval = _copyRefreshMatViewStmt(from);
04322             break;
04323         case T_CreateSeqStmt:
04324             retval = _copyCreateSeqStmt(from);
04325             break;
04326         case T_AlterSeqStmt:
04327             retval = _copyAlterSeqStmt(from);
04328             break;
04329         case T_VariableSetStmt:
04330             retval = _copyVariableSetStmt(from);
04331             break;
04332         case T_VariableShowStmt:
04333             retval = _copyVariableShowStmt(from);
04334             break;
04335         case T_DiscardStmt:
04336             retval = _copyDiscardStmt(from);
04337             break;
04338         case T_CreateTableSpaceStmt:
04339             retval = _copyCreateTableSpaceStmt(from);
04340             break;
04341         case T_DropTableSpaceStmt:
04342             retval = _copyDropTableSpaceStmt(from);
04343             break;
04344         case T_AlterTableSpaceOptionsStmt:
04345             retval = _copyAlterTableSpaceOptionsStmt(from);
04346             break;
04347         case T_CreateExtensionStmt:
04348             retval = _copyCreateExtensionStmt(from);
04349             break;
04350         case T_AlterExtensionStmt:
04351             retval = _copyAlterExtensionStmt(from);
04352             break;
04353         case T_AlterExtensionContentsStmt:
04354             retval = _copyAlterExtensionContentsStmt(from);
04355             break;
04356         case T_CreateFdwStmt:
04357             retval = _copyCreateFdwStmt(from);
04358             break;
04359         case T_AlterFdwStmt:
04360             retval = _copyAlterFdwStmt(from);
04361             break;
04362         case T_CreateForeignServerStmt:
04363             retval = _copyCreateForeignServerStmt(from);
04364             break;
04365         case T_AlterForeignServerStmt:
04366             retval = _copyAlterForeignServerStmt(from);
04367             break;
04368         case T_CreateUserMappingStmt:
04369             retval = _copyCreateUserMappingStmt(from);
04370             break;
04371         case T_AlterUserMappingStmt:
04372             retval = _copyAlterUserMappingStmt(from);
04373             break;
04374         case T_DropUserMappingStmt:
04375             retval = _copyDropUserMappingStmt(from);
04376             break;
04377         case T_CreateForeignTableStmt:
04378             retval = _copyCreateForeignTableStmt(from);
04379             break;
04380         case T_CreateTrigStmt:
04381             retval = _copyCreateTrigStmt(from);
04382             break;
04383         case T_CreateEventTrigStmt:
04384             retval = _copyCreateEventTrigStmt(from);
04385             break;
04386         case T_AlterEventTrigStmt:
04387             retval = _copyAlterEventTrigStmt(from);
04388             break;
04389         case T_CreatePLangStmt:
04390             retval = _copyCreatePLangStmt(from);
04391             break;
04392         case T_CreateRoleStmt:
04393             retval = _copyCreateRoleStmt(from);
04394             break;
04395         case T_AlterRoleStmt:
04396             retval = _copyAlterRoleStmt(from);
04397             break;
04398         case T_AlterRoleSetStmt:
04399             retval = _copyAlterRoleSetStmt(from);
04400             break;
04401         case T_DropRoleStmt:
04402             retval = _copyDropRoleStmt(from);
04403             break;
04404         case T_LockStmt:
04405             retval = _copyLockStmt(from);
04406             break;
04407         case T_ConstraintsSetStmt:
04408             retval = _copyConstraintsSetStmt(from);
04409             break;
04410         case T_ReindexStmt:
04411             retval = _copyReindexStmt(from);
04412             break;
04413         case T_CheckPointStmt:
04414             retval = (void *) makeNode(CheckPointStmt);
04415             break;
04416         case T_CreateSchemaStmt:
04417             retval = _copyCreateSchemaStmt(from);
04418             break;
04419         case T_CreateConversionStmt:
04420             retval = _copyCreateConversionStmt(from);
04421             break;
04422         case T_CreateCastStmt:
04423             retval = _copyCreateCastStmt(from);
04424             break;
04425         case T_PrepareStmt:
04426             retval = _copyPrepareStmt(from);
04427             break;
04428         case T_ExecuteStmt:
04429             retval = _copyExecuteStmt(from);
04430             break;
04431         case T_DeallocateStmt:
04432             retval = _copyDeallocateStmt(from);
04433             break;
04434         case T_DropOwnedStmt:
04435             retval = _copyDropOwnedStmt(from);
04436             break;
04437         case T_ReassignOwnedStmt:
04438             retval = _copyReassignOwnedStmt(from);
04439             break;
04440         case T_AlterTSDictionaryStmt:
04441             retval = _copyAlterTSDictionaryStmt(from);
04442             break;
04443         case T_AlterTSConfigurationStmt:
04444             retval = _copyAlterTSConfigurationStmt(from);
04445             break;
04446 
04447         case T_A_Expr:
04448             retval = _copyAExpr(from);
04449             break;
04450         case T_ColumnRef:
04451             retval = _copyColumnRef(from);
04452             break;
04453         case T_ParamRef:
04454             retval = _copyParamRef(from);
04455             break;
04456         case T_A_Const:
04457             retval = _copyAConst(from);
04458             break;
04459         case T_FuncCall:
04460             retval = _copyFuncCall(from);
04461             break;
04462         case T_A_Star:
04463             retval = _copyAStar(from);
04464             break;
04465         case T_A_Indices:
04466             retval = _copyAIndices(from);
04467             break;
04468         case T_A_Indirection:
04469             retval = _copyA_Indirection(from);
04470             break;
04471         case T_A_ArrayExpr:
04472             retval = _copyA_ArrayExpr(from);
04473             break;
04474         case T_ResTarget:
04475             retval = _copyResTarget(from);
04476             break;
04477         case T_TypeCast:
04478             retval = _copyTypeCast(from);
04479             break;
04480         case T_CollateClause:
04481             retval = _copyCollateClause(from);
04482             break;
04483         case T_SortBy:
04484             retval = _copySortBy(from);
04485             break;
04486         case T_WindowDef:
04487             retval = _copyWindowDef(from);
04488             break;
04489         case T_RangeSubselect:
04490             retval = _copyRangeSubselect(from);
04491             break;
04492         case T_RangeFunction:
04493             retval = _copyRangeFunction(from);
04494             break;
04495         case T_TypeName:
04496             retval = _copyTypeName(from);
04497             break;
04498         case T_IndexElem:
04499             retval = _copyIndexElem(from);
04500             break;
04501         case T_ColumnDef:
04502             retval = _copyColumnDef(from);
04503             break;
04504         case T_Constraint:
04505             retval = _copyConstraint(from);
04506             break;
04507         case T_DefElem:
04508             retval = _copyDefElem(from);
04509             break;
04510         case T_LockingClause:
04511             retval = _copyLockingClause(from);
04512             break;
04513         case T_RangeTblEntry:
04514             retval = _copyRangeTblEntry(from);
04515             break;
04516         case T_SortGroupClause:
04517             retval = _copySortGroupClause(from);
04518             break;
04519         case T_WindowClause:
04520             retval = _copyWindowClause(from);
04521             break;
04522         case T_RowMarkClause:
04523             retval = _copyRowMarkClause(from);
04524             break;
04525         case T_WithClause:
04526             retval = _copyWithClause(from);
04527             break;
04528         case T_CommonTableExpr:
04529             retval = _copyCommonTableExpr(from);
04530             break;
04531         case T_PrivGrantee:
04532             retval = _copyPrivGrantee(from);
04533             break;
04534         case T_FuncWithArgs:
04535             retval = _copyFuncWithArgs(from);
04536             break;
04537         case T_AccessPriv:
04538             retval = _copyAccessPriv(from);
04539             break;
04540         case T_XmlSerialize:
04541             retval = _copyXmlSerialize(from);
04542             break;
04543 
04544         default:
04545             elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
04546             retval = 0;         /* keep compiler quiet */
04547             break;
04548     }
04549 
04550     return retval;
04551 }