OSDN Git Service

First phase of applying Rod Taylor's pg_depend patch. This just adds
[pg-rex/syncrep.git] / src / backend / nodes / copyfuncs.c
index d6883bb..739161b 100644 (file)
@@ -6,16 +6,16 @@
  * NOTE: a general convention when copying or comparing plan nodes is
  * that we ignore the executor state subnode.  We do not need to look
  * at it because no current uses of copyObject() or equal() need to
- * deal with already-executing plan trees.  By leaving the state subnodes
+ * deal with already-executing plan trees.     By leaving the state subnodes
  * out, we avoid needing to write copy/compare routines for all the
  * different executor state node types.
  *
  *
- * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
+ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.122 2000/09/20 15:28:01 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.192 2002/07/01 15:27:51 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,7 +24,6 @@
 
 #include "optimizer/clauses.h"
 #include "optimizer/planmain.h"
-#include "utils/acl.h"
 
 
 /*
@@ -58,11 +57,11 @@ listCopy(List *list)
        if (list == NIL)
                return NIL;
 
-       newlist = nl = lcons(lfirst(list), NIL);
+       newlist = nl = makeList1(lfirst(list));
 
        foreach(l, lnext(list))
        {
-               lnext(nl) = lcons(lfirst(l), NIL);
+               lnext(nl) = makeList1(lfirst(l));
                nl = lnext(nl);
        }
        return newlist;
@@ -114,9 +113,8 @@ _copyPlan(Plan *from)
 {
        Plan       *newnode = makeNode(Plan);
 
-       /* ----------------
-        *      copy the node superclass fields
-        * ----------------
+       /*
+        * copy the node superclass fields
         */
        CopyPlanFields(from, newnode);
 
@@ -133,15 +131,13 @@ _copyResult(Result *from)
 {
        Result     *newnode = makeNode(Result);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, resconstantqual);
 
@@ -165,20 +161,16 @@ _copyAppend(Append *from)
 {
        Append     *newnode = makeNode(Append);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, appendplans);
-       Node_Copy(from, newnode, unionrtables);
-       newnode->inheritrelid = from->inheritrelid;
-       Node_Copy(from, newnode, inheritrtable);
+       newnode->isTarget = from->isTarget;
 
        return newnode;
 }
@@ -207,9 +199,8 @@ _copyScan(Scan *from)
 {
        Scan       *newnode = makeNode(Scan);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyScanFields((Scan *) from, (Scan *) newnode);
@@ -226,9 +217,8 @@ _copySeqScan(SeqScan *from)
 {
        SeqScan    *newnode = makeNode(SeqScan);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyScanFields((Scan *) from, (Scan *) newnode);
@@ -245,16 +235,14 @@ _copyIndexScan(IndexScan *from)
 {
        IndexScan  *newnode = makeNode(IndexScan);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyScanFields((Scan *) from, (Scan *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->indxid = listCopy(from->indxid);
        Node_Copy(from, newnode, indxqual);
@@ -284,15 +272,14 @@ _copyTidScan(TidScan *from)
 {
        TidScan    *newnode = makeNode(TidScan);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyScanFields((Scan *) from, (Scan *) newnode);
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+
+       /*
+        * copy remainder of node
         */
        newnode->needRescan = from->needRescan;
        Node_Copy(from, newnode, tideval);
@@ -300,6 +287,46 @@ _copyTidScan(TidScan *from)
        return newnode;
 }
 
+/* ----------------
+ *             _copySubqueryScan
+ * ----------------
+ */
+static SubqueryScan *
+_copySubqueryScan(SubqueryScan *from)
+{
+       SubqueryScan *newnode = makeNode(SubqueryScan);
+
+       /*
+        * copy node superclass fields
+        */
+       CopyPlanFields((Plan *) from, (Plan *) newnode);
+       CopyScanFields((Scan *) from, (Scan *) newnode);
+
+       /*
+        * copy remainder of node
+        */
+       Node_Copy(from, newnode, subplan);
+
+       return newnode;
+}
+
+/* ----------------
+ *             _copyFunctionScan
+ * ----------------
+ */
+static FunctionScan *
+_copyFunctionScan(FunctionScan *from)
+{
+       FunctionScan *newnode = makeNode(FunctionScan);
+
+       /*
+        * copy node superclass fields
+        */
+       CopyPlanFields((Plan *) from, (Plan *) newnode);
+       CopyScanFields((Scan *) from, (Scan *) newnode);
+
+       return newnode;
+}
 
 /* ----------------
  *             CopyJoinFields
@@ -316,7 +343,7 @@ CopyJoinFields(Join *from, Join *newnode)
        /* subPlan list must point to subplans in the new subtree, not the old */
        if (from->plan.subPlan != NIL)
                newnode->plan.subPlan = nconc(newnode->plan.subPlan,
-                                                                         pull_subplans((Node *) newnode->joinqual));
+                                                         pull_subplans((Node *) newnode->joinqual));
 }
 
 
@@ -329,9 +356,8 @@ _copyJoin(Join *from)
 {
        Join       *newnode = makeNode(Join);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyJoinFields(from, newnode);
@@ -349,9 +375,8 @@ _copyNestLoop(NestLoop *from)
 {
        NestLoop   *newnode = makeNode(NestLoop);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyJoinFields((Join *) from, (Join *) newnode);
@@ -369,16 +394,14 @@ _copyMergeJoin(MergeJoin *from)
 {
        MergeJoin  *newnode = makeNode(MergeJoin);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyJoinFields((Join *) from, (Join *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, mergeclauses);
 
@@ -401,16 +424,14 @@ _copyHashJoin(HashJoin *from)
 {
        HashJoin   *newnode = makeNode(HashJoin);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
        CopyJoinFields((Join *) from, (Join *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, hashclauses);
        newnode->hashjoinop = from->hashjoinop;
@@ -435,9 +456,8 @@ _copyMaterial(Material *from)
 {
        Material   *newnode = makeNode(Material);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
 
@@ -454,9 +474,8 @@ _copySort(Sort *from)
 {
        Sort       *newnode = makeNode(Sort);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
 
@@ -523,15 +542,13 @@ _copyUnique(Unique *from)
 {
        Unique     *newnode = makeNode(Unique);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->numCols = from->numCols;
        newnode->uniqColIdx = palloc(from->numCols * sizeof(AttrNumber));
@@ -540,6 +557,54 @@ _copyUnique(Unique *from)
        return newnode;
 }
 
+/* ----------------
+ *             _copySetOp
+ * ----------------
+ */
+static SetOp *
+_copySetOp(SetOp *from)
+{
+       SetOp      *newnode = makeNode(SetOp);
+
+       /*
+        * copy node superclass fields
+        */
+       CopyPlanFields((Plan *) from, (Plan *) newnode);
+
+       /*
+        * copy remainder of node
+        */
+       newnode->cmd = from->cmd;
+       newnode->numCols = from->numCols;
+       newnode->dupColIdx = palloc(from->numCols * sizeof(AttrNumber));
+       memcpy(newnode->dupColIdx, from->dupColIdx, from->numCols * sizeof(AttrNumber));
+       newnode->flagColIdx = from->flagColIdx;
+
+       return newnode;
+}
+
+/* ----------------
+ *             _copyLimit
+ * ----------------
+ */
+static Limit *
+_copyLimit(Limit *from)
+{
+       Limit      *newnode = makeNode(Limit);
+
+       /*
+        * copy node superclass fields
+        */
+       CopyPlanFields((Plan *) from, (Plan *) newnode);
+
+       /*
+        * copy remainder of node
+        */
+       Node_Copy(from, newnode, limitOffset);
+       Node_Copy(from, newnode, limitCount);
+
+       return newnode;
+}
 
 /* ----------------
  *             _copyHash
@@ -550,15 +615,13 @@ _copyHash(Hash *from)
 {
        Hash       *newnode = makeNode(Hash);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        CopyPlanFields((Plan *) from, (Plan *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, hashkey);
 
@@ -616,9 +679,8 @@ _copyFjoin(Fjoin *from)
 {
        Fjoin      *newnode = makeNode(Fjoin);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
 
        newnode->fj_initialized = from->fj_initialized;
@@ -651,9 +713,8 @@ _copyExpr(Expr *from)
 {
        Expr       *newnode = makeNode(Expr);
 
-       /* ----------------
-        *      copy node superclass fields
-        * ----------------
+       /*
+        * copy node superclass fields
         */
        newnode->typeOid = from->typeOid;
        newnode->opType = from->opType;
@@ -673,9 +734,8 @@ _copyVar(Var *from)
 {
        Var                *newnode = makeNode(Var);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->varno = from->varno;
        newnode->varattno = from->varattno;
@@ -689,18 +749,6 @@ _copyVar(Var *from)
        return newnode;
 }
 
-static Attr *
-_copyAttr(Attr *from)
-{
-       Attr       *newnode = makeNode(Attr);
-
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
-       Node_Copy(from, newnode, attrs);
-
-       return newnode;
-}
-
 /* ----------------
  *             _copyOper
  * ----------------
@@ -710,13 +758,13 @@ _copyOper(Oper *from)
 {
        Oper       *newnode = makeNode(Oper);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->opno = from->opno;
        newnode->opid = from->opid;
        newnode->opresulttype = from->opresulttype;
+       newnode->opretset = from->opretset;
        /* Do not copy the run-time state, if any */
        newnode->op_fcache = NULL;
 
@@ -732,27 +780,25 @@ _copyConst(Const *from)
 {
        Const      *newnode = makeNode(Const);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->consttype = from->consttype;
        newnode->constlen = from->constlen;
 
        if (from->constbyval || from->constisnull)
        {
-               /* ----------------
-                *      passed by value so just copy the datum.
-                *      Also, don't try to copy struct when value is null!
-                * ----------------
+               /*
+                * passed by value so just copy the datum. Also, don't try to copy
+                * struct when value is null!
+                *
                 */
                newnode->constvalue = from->constvalue;
        }
        else
        {
-               /* ----------------
-                *      not passed by value. datum contains a pointer.
-                * ----------------
+               /*
+                * not passed by value. datum contains a pointer.
                 */
                int                     length = from->constlen;
 
@@ -781,9 +827,8 @@ _copyParam(Param *from)
 {
        Param      *newnode = makeNode(Param);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->paramkind = from->paramkind;
        newnode->paramid = from->paramid;
@@ -804,12 +849,12 @@ _copyFunc(Func *from)
 {
        Func       *newnode = makeNode(Func);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->funcid = from->funcid;
-       newnode->functype = from->functype;
+       newnode->funcresulttype = from->funcresulttype;
+       newnode->funcretset = from->funcretset;
        /* Do not copy the run-time state, if any */
        newnode->func_fcache = NULL;
 
@@ -825,12 +870,7 @@ _copyAggref(Aggref *from)
 {
        Aggref     *newnode = makeNode(Aggref);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
-        */
-       newnode->aggname = pstrdup(from->aggname);
-       newnode->basetype = from->basetype;
+       newnode->aggfnoid = from->aggfnoid;
        newnode->aggtype = from->aggtype;
        Node_Copy(from, newnode, target);
        newnode->aggstar = from->aggstar;
@@ -849,9 +889,8 @@ _copySubLink(SubLink *from)
 {
        SubLink    *newnode = makeNode(SubLink);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->subLinkType = from->subLinkType;
        newnode->useor = from->useor;
@@ -871,9 +910,8 @@ _copyFieldSelect(FieldSelect *from)
 {
        FieldSelect *newnode = makeNode(FieldSelect);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, arg);
        newnode->fieldnum = from->fieldnum;
@@ -892,9 +930,8 @@ _copyRelabelType(RelabelType *from)
 {
        RelabelType *newnode = makeNode(RelabelType);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, arg);
        newnode->resulttype = from->resulttype;
@@ -913,10 +950,21 @@ _copyRangeTblRef(RangeTblRef *from)
        return newnode;
 }
 
+static FromExpr *
+_copyFromExpr(FromExpr *from)
+{
+       FromExpr   *newnode = makeNode(FromExpr);
+
+       Node_Copy(from, newnode, fromlist);
+       Node_Copy(from, newnode, quals);
+
+       return newnode;
+}
+
 static JoinExpr *
 _copyJoinExpr(JoinExpr *from)
 {
-       JoinExpr *newnode = makeNode(JoinExpr);
+       JoinExpr   *newnode = makeNode(JoinExpr);
 
        newnode->jointype = from->jointype;
        newnode->isNatural = from->isNatural;
@@ -925,8 +973,7 @@ _copyJoinExpr(JoinExpr *from)
        Node_Copy(from, newnode, using);
        Node_Copy(from, newnode, quals);
        Node_Copy(from, newnode, alias);
-       Node_Copy(from, newnode, colnames);
-       Node_Copy(from, newnode, colvars);
+       newnode->rtindex = from->rtindex;
 
        return newnode;
 }
@@ -940,9 +987,8 @@ _copyCaseExpr(CaseExpr *from)
 {
        CaseExpr   *newnode = makeNode(CaseExpr);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->casetype = from->casetype;
 
@@ -962,9 +1008,8 @@ _copyCaseWhen(CaseWhen *from)
 {
        CaseWhen   *newnode = makeNode(CaseWhen);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, expr);
        Node_Copy(from, newnode, result);
@@ -972,14 +1017,49 @@ _copyCaseWhen(CaseWhen *from)
        return newnode;
 }
 
+/* ----------------
+ *             _copyNullTest
+ * ----------------
+ */
+static NullTest *
+_copyNullTest(NullTest *from)
+{
+       NullTest   *newnode = makeNode(NullTest);
+
+       /*
+        * copy remainder of node
+        */
+       Node_Copy(from, newnode, arg);
+       newnode->nulltesttype = from->nulltesttype;
+
+       return newnode;
+}
+
+/* ----------------
+ *             _copyBooleanTest
+ * ----------------
+ */
+static BooleanTest *
+_copyBooleanTest(BooleanTest *from)
+{
+       BooleanTest *newnode = makeNode(BooleanTest);
+
+       /*
+        * copy remainder of node
+        */
+       Node_Copy(from, newnode, arg);
+       newnode->booltesttype = from->booltesttype;
+
+       return newnode;
+}
+
 static ArrayRef *
 _copyArrayRef(ArrayRef *from)
 {
        ArrayRef   *newnode = makeNode(ArrayRef);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->refattrlength = from->refattrlength;
        newnode->refelemlength = from->refelemlength;
@@ -1003,16 +1083,13 @@ _copyArrayRef(ArrayRef *from)
  *             _copyRelOptInfo
  * ----------------
  */
-/*
- *     when you change this, also make sure to fix up xfunc_copyRelOptInfo in
- *     planner/path/xfunc.c accordingly!!!
- *             -- JMH, 8/2/93
- */
 static RelOptInfo *
 _copyRelOptInfo(RelOptInfo *from)
 {
        RelOptInfo *newnode = makeNode(RelOptInfo);
 
+       newnode->reloptkind = from->reloptkind;
+
        newnode->relids = listCopy(from->relids);
 
        newnode->rows = from->rows;
@@ -1025,9 +1102,14 @@ _copyRelOptInfo(RelOptInfo *from)
        Node_Copy(from, newnode, cheapest_total_path);
        newnode->pruneable = from->pruneable;
 
-       newnode->indexed = from->indexed;
+       newnode->rtekind = from->rtekind;
+       Node_Copy(from, newnode, indexlist);
        newnode->pages = from->pages;
        newnode->tuples = from->tuples;
+       Node_Copy(from, newnode, subplan);
+
+       newnode->joinrti = from->joinrti;
+       newnode->joinrteids = listCopy(from->joinrteids);
 
        Node_Copy(from, newnode, baserestrictinfo);
        newnode->baserestrictcost = from->baserestrictcost;
@@ -1046,48 +1128,44 @@ static IndexOptInfo *
 _copyIndexOptInfo(IndexOptInfo *from)
 {
        IndexOptInfo *newnode = makeNode(IndexOptInfo);
-       int                     i,
-                               len;
+       Size            len;
 
        newnode->indexoid = from->indexoid;
        newnode->pages = from->pages;
        newnode->tuples = from->tuples;
 
+       newnode->ncolumns = from->ncolumns;
+       newnode->nkeys = from->nkeys;
+
        if (from->classlist)
        {
-               for (len = 0; from->classlist[len] != 0; len++)
-                       ;
-               newnode->classlist = (Oid *) palloc(sizeof(Oid) * (len + 1));
-               for (i = 0; i < len; i++)
-                       newnode->classlist[i] = from->classlist[i];
-               newnode->classlist[len] = 0;
+               /* copy the trailing zero too */
+               len = (from->ncolumns + 1) * sizeof(Oid);
+               newnode->classlist = (Oid *) palloc(len);
+               memcpy(newnode->classlist, from->classlist, len);
        }
 
        if (from->indexkeys)
        {
-               for (len = 0; from->indexkeys[len] != 0; len++)
-                       ;
-               newnode->indexkeys = (int *) palloc(sizeof(int) * (len + 1));
-               for (i = 0; i < len; i++)
-                       newnode->indexkeys[i] = from->indexkeys[i];
-               newnode->indexkeys[len] = 0;
+               /* copy the trailing zero too */
+               len = (from->nkeys + 1) * sizeof(int);
+               newnode->indexkeys = (int *) palloc(len);
+               memcpy(newnode->indexkeys, from->indexkeys, len);
        }
 
        if (from->ordering)
        {
-               for (len = 0; from->ordering[len] != 0; len++)
-                       ;
-               newnode->ordering = (Oid *) palloc(sizeof(Oid) * (len + 1));
-               for (i = 0; i < len; i++)
-                       newnode->ordering[i] = from->ordering[i];
-               newnode->ordering[len] = 0;
+               /* copy the trailing zero too */
+               len = (from->ncolumns + 1) * sizeof(Oid);
+               newnode->ordering = (Oid *) palloc(len);
+               memcpy(newnode->ordering, from->ordering, len);
        }
 
        newnode->relam = from->relam;
        newnode->amcostestimate = from->amcostestimate;
        newnode->indproc = from->indproc;
        Node_Copy(from, newnode, indpred);
-       newnode->lossy = from->lossy;
+       newnode->unique = from->unique;
 
        return newnode;
 }
@@ -1102,7 +1180,6 @@ _copyIndexOptInfo(IndexOptInfo *from)
 static void
 CopyPathFields(Path *from, Path *newnode)
 {
-
        /*
         * Modify the next line, since it causes the copying to cycle (i.e.
         * the parent points right back here! -- JMH, 7/7/92. Old version:
@@ -1141,17 +1218,15 @@ _copyIndexPath(IndexPath *from)
 {
        IndexPath  *newnode = makeNode(IndexPath);
 
-       /* ----------------
-        *      copy the node superclass fields
-        * ----------------
+       /*
+        * copy the node superclass fields
         */
        CopyPathFields((Path *) from, (Path *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
-       newnode->indexid = listCopy(from->indexid);
+       Node_Copy(from, newnode, indexinfo);
        Node_Copy(from, newnode, indexqual);
        newnode->indexscandir = from->indexscandir;
        newnode->joinrelids = listCopy(from->joinrelids);
@@ -1170,15 +1245,13 @@ _copyTidPath(TidPath *from)
 {
        TidPath    *newnode = makeNode(TidPath);
 
-       /* ----------------
-        *      copy the node superclass fields
-        * ----------------
+       /*
+        * copy the node superclass fields
         */
        CopyPathFields((Path *) from, (Path *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, tideval);
        newnode->unjoined_relids = listCopy(from->unjoined_relids);
@@ -1187,6 +1260,28 @@ _copyTidPath(TidPath *from)
 }
 
 /* ----------------
+ *                             _copyAppendPath
+ * ----------------
+ */
+static AppendPath *
+_copyAppendPath(AppendPath *from)
+{
+       AppendPath *newnode = makeNode(AppendPath);
+
+       /*
+        * copy the node superclass fields
+        */
+       CopyPathFields((Path *) from, (Path *) newnode);
+
+       /*
+        * copy remainder of node
+        */
+       Node_Copy(from, newnode, subpaths);
+
+       return newnode;
+}
+
+/* ----------------
  *             CopyJoinPathFields
  *
  *             This function copies the fields of the JoinPath node.  It is used by
@@ -1211,9 +1306,8 @@ _copyNestPath(NestPath *from)
 {
        NestPath   *newnode = makeNode(NestPath);
 
-       /* ----------------
-        *      copy the node superclass fields
-        * ----------------
+       /*
+        * copy the node superclass fields
         */
        CopyPathFields((Path *) from, (Path *) newnode);
        CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
@@ -1230,16 +1324,14 @@ _copyMergePath(MergePath *from)
 {
        MergePath  *newnode = makeNode(MergePath);
 
-       /* ----------------
-        *      copy the node superclass fields
-        * ----------------
+       /*
+        * copy the node superclass fields
         */
        CopyPathFields((Path *) from, (Path *) newnode);
        CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
 
-       /* ----------------
-        *      copy the remainder of the node
-        * ----------------
+       /*
+        * copy the remainder of the node
         */
        Node_Copy(from, newnode, path_mergeclauses);
        Node_Copy(from, newnode, outersortkeys);
@@ -1257,16 +1349,14 @@ _copyHashPath(HashPath *from)
 {
        HashPath   *newnode = makeNode(HashPath);
 
-       /* ----------------
-        *      copy the node superclass fields
-        * ----------------
+       /*
+        * copy the node superclass fields
         */
        CopyPathFields((Path *) from, (Path *) newnode);
        CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, path_hashclauses);
 
@@ -1282,9 +1372,8 @@ _copyPathKeyItem(PathKeyItem *from)
 {
        PathKeyItem *newnode = makeNode(PathKeyItem);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, key);
        newnode->sortop = from->sortop;
@@ -1301,17 +1390,29 @@ _copyRestrictInfo(RestrictInfo *from)
 {
        RestrictInfo *newnode = makeNode(RestrictInfo);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        Node_Copy(from, newnode, clause);
-       newnode->isjoinqual = from->isjoinqual;
+       newnode->ispusheddown = from->ispusheddown;
        Node_Copy(from, newnode, subclauseindices);
+       newnode->eval_cost = from->eval_cost;
+       newnode->this_selec = from->this_selec;
        newnode->mergejoinoperator = from->mergejoinoperator;
        newnode->left_sortop = from->left_sortop;
        newnode->right_sortop = from->right_sortop;
+
+       /*
+        * Do not copy pathkeys, since they'd not be canonical in a copied
+        * query
+        */
+       newnode->left_pathkey = NIL;
+       newnode->right_pathkey = NIL;
+       newnode->left_mergescansel = from->left_mergescansel;
+       newnode->right_mergescansel = from->right_mergescansel;
        newnode->hashjoinoperator = from->hashjoinoperator;
+       newnode->left_bucketsize = from->left_bucketsize;
+       newnode->right_bucketsize = from->right_bucketsize;
 
        return newnode;
 }
@@ -1325,9 +1426,8 @@ _copyJoinInfo(JoinInfo *from)
 {
        JoinInfo   *newnode = makeNode(JoinInfo);
 
-       /* ----------------
-        *      copy remainder of node
-        * ----------------
+       /*
+        * copy remainder of node
         */
        newnode->unjoined_relids = listCopy(from->unjoined_relids);
        Node_Copy(from, newnode, jinfo_restrictinfo);
@@ -1335,17 +1435,6 @@ _copyJoinInfo(JoinInfo *from)
        return newnode;
 }
 
-static Iter *
-_copyIter(Iter *from)
-{
-       Iter       *newnode = makeNode(Iter);
-
-       Node_Copy(from, newnode, iterexpr);
-       newnode->itertype = from->itertype;
-
-       return newnode;
-}
-
 static Stream *
 _copyStream(Stream *from)
 {
@@ -1389,25 +1478,19 @@ _copyRangeTblEntry(RangeTblEntry *from)
 {
        RangeTblEntry *newnode = makeNode(RangeTblEntry);
 
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+       newnode->rtekind = from->rtekind;
        newnode->relid = from->relid;
+       Node_Copy(from, newnode, subquery);
+       Node_Copy(from, newnode, funcexpr);
+       newnode->jointype = from->jointype;
+       Node_Copy(from, newnode, joinaliasvars);
        Node_Copy(from, newnode, alias);
        Node_Copy(from, newnode, eref);
        newnode->inh = from->inh;
        newnode->inFromCl = from->inFromCl;
-       newnode->skipAcl = from->skipAcl;
-
-       return newnode;
-}
-
-static RowMark *
-_copyRowMark(RowMark *from)
-{
-       RowMark    *newnode = makeNode(RowMark);
-
-       newnode->rti = from->rti;
-       newnode->info = from->info;
+       newnode->checkForRead = from->checkForRead;
+       newnode->checkForWrite = from->checkForWrite;
+       newnode->checkAsUser = from->checkAsUser;
 
        return newnode;
 }
@@ -1415,12 +1498,11 @@ _copyRowMark(RowMark *from)
 static FkConstraint *
 _copyFkConstraint(FkConstraint *from)
 {
-       FkConstraint    *newnode = makeNode(FkConstraint);
+       FkConstraint *newnode = makeNode(FkConstraint);
 
        if (from->constr_name)
                newnode->constr_name = pstrdup(from->constr_name);
-       if (from->pktable_name)
-               newnode->pktable_name = pstrdup(from->pktable_name);
+       Node_Copy(from, newnode, pktable);
        Node_Copy(from, newnode, fk_attrs);
        Node_Copy(from, newnode, pk_attrs);
        if (from->match_type)
@@ -1428,7 +1510,7 @@ _copyFkConstraint(FkConstraint *from)
        newnode->actions = from->actions;
        newnode->deferrable = from->deferrable;
        newnode->initdeferred = from->initdeferred;
-       
+
        return newnode;
 }
 
@@ -1446,49 +1528,56 @@ _copySortClause(SortClause *from)
 static A_Expr *
 _copyAExpr(A_Expr *from)
 {
-       A_Expr    *newnode = makeNode(A_Expr);
+       A_Expr     *newnode = makeNode(A_Expr);
 
        newnode->oper = from->oper;
-       if (from->opname)
-               newnode->opname = pstrdup(from->opname);
+       Node_Copy(from, newnode, name);
        Node_Copy(from, newnode, lexpr);
        Node_Copy(from, newnode, rexpr);
 
        return newnode;
 }
 
-static A_Const *
-_copyAConst(A_Const *from)
+static ColumnRef *
+_copyColumnRef(ColumnRef *from)
 {
-       A_Const    *newnode = makeNode(A_Const);
+       ColumnRef          *newnode = makeNode(ColumnRef);
 
-       newnode->val = *((Value *) (copyObject(&(from->val))));
-       Node_Copy(from, newnode, typename);
+       Node_Copy(from, newnode, fields);
+       Node_Copy(from, newnode, indirection);
 
        return newnode;
 }
 
-static ParamNo *
-_copyParamNo(ParamNo *from)
+static ParamRef *
+_copyParamRef(ParamRef *from)
 {
-       ParamNo    *newnode = makeNode(ParamNo);
+       ParamRef    *newnode = makeNode(ParamRef);
 
        newnode->number = from->number;
-       Node_Copy(from, newnode, typename);
+       Node_Copy(from, newnode, fields);
        Node_Copy(from, newnode, indirection);
 
        return newnode;
 }
 
+static A_Const *
+_copyAConst(A_Const *from)
+{
+       A_Const    *newnode = makeNode(A_Const);
+
+       newnode->val = *((Value *) (copyObject(&(from->val))));
+       Node_Copy(from, newnode, typename);
+
+       return newnode;
+}
+
 static Ident *
 _copyIdent(Ident *from)
 {
-       Ident    *newnode = makeNode(Ident);
+       Ident      *newnode = makeNode(Ident);
 
-       if (from->name)
-               newnode->name = pstrdup(from->name);
-       Node_Copy(from, newnode, indirection);
-       newnode->isRel = from->isRel;
+       newnode->name = pstrdup(from->name);
 
        return newnode;
 }
@@ -1496,10 +1585,9 @@ _copyIdent(Ident *from)
 static FuncCall *
 _copyFuncCall(FuncCall *from)
 {
-       FuncCall    *newnode = makeNode(FuncCall);
+       FuncCall   *newnode = makeNode(FuncCall);
 
-       if (from->funcname)
-               newnode->funcname = pstrdup(from->funcname);
+       Node_Copy(from, newnode, funcname);
        Node_Copy(from, newnode, args);
        newnode->agg_star = from->agg_star;
        newnode->agg_distinct = from->agg_distinct;
@@ -1510,7 +1598,7 @@ _copyFuncCall(FuncCall *from)
 static A_Indices *
 _copyAIndices(A_Indices *from)
 {
-       A_Indices    *newnode = makeNode(A_Indices);
+       A_Indices  *newnode = makeNode(A_Indices);
 
        Node_Copy(from, newnode, lidx);
        Node_Copy(from, newnode, uidx);
@@ -1518,10 +1606,22 @@ _copyAIndices(A_Indices *from)
        return newnode;
 }
 
+static ExprFieldSelect *
+_copyExprFieldSelect(ExprFieldSelect *from)
+{
+       ExprFieldSelect    *newnode = makeNode(ExprFieldSelect);
+
+       Node_Copy(from, newnode, arg);
+       Node_Copy(from, newnode, fields);
+       Node_Copy(from, newnode, indirection);
+
+       return newnode;
+}
+
 static ResTarget *
 _copyResTarget(ResTarget *from)
 {
-       ResTarget    *newnode = makeNode(ResTarget);
+       ResTarget  *newnode = makeNode(ResTarget);
 
        if (from->name)
                newnode->name = pstrdup(from->name);
@@ -1536,10 +1636,11 @@ _copyTypeName(TypeName *from)
 {
        TypeName   *newnode = makeNode(TypeName);
 
-       if (from->name)
-               newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, names);
+       newnode->typeid = from->typeid;
        newnode->timezone = from->timezone;
        newnode->setof = from->setof;
+       newnode->pct_type = from->pct_type;
        newnode->typmod = from->typmod;
        Node_Copy(from, newnode, arrayBounds);
 
@@ -1549,24 +1650,40 @@ _copyTypeName(TypeName *from)
 static SortGroupBy *
 _copySortGroupBy(SortGroupBy *from)
 {
-       SortGroupBy   *newnode = makeNode(SortGroupBy);
+       SortGroupBy *newnode = makeNode(SortGroupBy);
 
-       if (from->useOp)
-               newnode->useOp = pstrdup(from->useOp);
+       Node_Copy(from, newnode, useOp);
        Node_Copy(from, newnode, node);
 
        return newnode;
 }
 
+static Alias *
+_copyAlias(Alias *from)
+{
+       Alias      *newnode = makeNode(Alias);
+
+       if (from->aliasname)
+               newnode->aliasname = pstrdup(from->aliasname);
+       Node_Copy(from, newnode, colnames);
+
+       return newnode;
+}
+
 static RangeVar *
 _copyRangeVar(RangeVar *from)
 {
        RangeVar   *newnode = makeNode(RangeVar);
 
+       if (from->catalogname)
+               newnode->catalogname = pstrdup(from->catalogname);
+       if (from->schemaname)
+               newnode->schemaname = pstrdup(from->schemaname);
        if (from->relname)
                newnode->relname = pstrdup(from->relname);
-       newnode->inh = from->inh;
-       Node_Copy(from, newnode, name);
+       newnode->inhOpt = from->inhOpt;
+       newnode->istemp = from->istemp;
+       Node_Copy(from, newnode, alias);
 
        return newnode;
 }
@@ -1574,10 +1691,21 @@ _copyRangeVar(RangeVar *from)
 static RangeSubselect *
 _copyRangeSubselect(RangeSubselect *from)
 {
-       RangeSubselect   *newnode = makeNode(RangeSubselect);
+       RangeSubselect *newnode = makeNode(RangeSubselect);
 
        Node_Copy(from, newnode, subquery);
-       Node_Copy(from, newnode, name);
+       Node_Copy(from, newnode, alias);
+
+       return newnode;
+}
+
+static RangeFunction *
+_copyRangeFunction(RangeFunction *from)
+{
+       RangeFunction   *newnode = makeNode(RangeFunction);
+
+       Node_Copy(from, newnode, funccallnode);
+       Node_Copy(from, newnode, alias);
 
        return newnode;
 }
@@ -1596,13 +1724,13 @@ _copyTypeCast(TypeCast *from)
 static IndexElem *
 _copyIndexElem(IndexElem *from)
 {
-       IndexElem   *newnode = makeNode(IndexElem);
+       IndexElem  *newnode = makeNode(IndexElem);
 
        if (from->name)
                newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, funcname);
        Node_Copy(from, newnode, args);
-       if (from->class)
-               newnode->class = pstrdup(from->class);
+       Node_Copy(from, newnode, opclass);
 
        return newnode;
 }
@@ -1610,13 +1738,12 @@ _copyIndexElem(IndexElem *from)
 static ColumnDef *
 _copyColumnDef(ColumnDef *from)
 {
-       ColumnDef   *newnode = makeNode(ColumnDef);
+       ColumnDef  *newnode = makeNode(ColumnDef);
 
        if (from->colname)
                newnode->colname = pstrdup(from->colname);
        Node_Copy(from, newnode, typename);
        newnode->is_not_null = from->is_not_null;
-       newnode->is_sequence = from->is_sequence;
        Node_Copy(from, newnode, raw_default);
        if (from->cooked_default)
                newnode->cooked_default = pstrdup(from->cooked_default);
@@ -1628,7 +1755,7 @@ _copyColumnDef(ColumnDef *from)
 static Constraint *
 _copyConstraint(Constraint *from)
 {
-       Constraint   *newnode = makeNode(Constraint);
+       Constraint *newnode = makeNode(Constraint);
 
        newnode->contype = from->contype;
        if (from->name)
@@ -1644,7 +1771,7 @@ _copyConstraint(Constraint *from)
 static DefElem *
 _copyDefElem(DefElem *from)
 {
-       DefElem   *newnode = makeNode(DefElem);
+       DefElem    *newnode = makeNode(DefElem);
 
        if (from->defname)
                newnode->defname = pstrdup(from->defname);
@@ -1661,37 +1788,36 @@ _copyQuery(Query *from)
        newnode->commandType = from->commandType;
        Node_Copy(from, newnode, utilityStmt);
        newnode->resultRelation = from->resultRelation;
-       if (from->into)
-               newnode->into = pstrdup(from->into);
+       Node_Copy(from, newnode, into);
        newnode->isPortal = from->isPortal;
        newnode->isBinary = from->isBinary;
-       newnode->isTemp = from->isTemp;
-       newnode->unionall = from->unionall;
        newnode->hasAggs = from->hasAggs;
        newnode->hasSubLinks = from->hasSubLinks;
+       newnode->originalQuery = from->originalQuery;
 
        Node_Copy(from, newnode, rtable);
        Node_Copy(from, newnode, jointree);
 
+       newnode->rowMarks = listCopy(from->rowMarks);
+
        Node_Copy(from, newnode, targetList);
-       Node_Copy(from, newnode, qual);
-       Node_Copy(from, newnode, rowMark);
 
-       Node_Copy(from, newnode, distinctClause);
-       Node_Copy(from, newnode, sortClause);
        Node_Copy(from, newnode, groupClause);
        Node_Copy(from, newnode, havingQual);
-
-       /* why is intersectClause missing? */
-       Node_Copy(from, newnode, unionClause);
+       Node_Copy(from, newnode, distinctClause);
+       Node_Copy(from, newnode, sortClause);
 
        Node_Copy(from, newnode, limitOffset);
        Node_Copy(from, newnode, limitCount);
 
+       Node_Copy(from, newnode, setOperations);
+
+       newnode->resultRelations = listCopy(from->resultRelations);
+
        /*
         * We do not copy the planner internal fields: base_rel_list,
-        * join_rel_list, equi_key_list, query_pathkeys. Not entirely clear if
-        * this is right?
+        * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. Not
+        * entirely clear if this is right?
         */
 
        return newnode;
@@ -1701,20 +1827,11 @@ static InsertStmt *
 _copyInsertStmt(InsertStmt *from)
 {
        InsertStmt *newnode = makeNode(InsertStmt);
-       
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
-       Node_Copy(from, newnode, distinctClause);
+
+       Node_Copy(from, newnode, relation);
        Node_Copy(from, newnode, cols);
        Node_Copy(from, newnode, targetList);
-       Node_Copy(from, newnode, fromClause);
-       Node_Copy(from, newnode, whereClause);
-       Node_Copy(from, newnode, groupClause);
-       Node_Copy(from, newnode, havingClause);
-       Node_Copy(from, newnode, unionClause);
-       newnode->unionall = from->unionall;
-       Node_Copy(from, newnode, intersectClause);
-       Node_Copy(from, newnode, forUpdate);
+       Node_Copy(from, newnode, selectStmt);
 
        return newnode;
 }
@@ -1723,11 +1840,9 @@ static DeleteStmt *
 _copyDeleteStmt(DeleteStmt *from)
 {
        DeleteStmt *newnode = makeNode(DeleteStmt);
-       
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+
+       Node_Copy(from, newnode, relation);
        Node_Copy(from, newnode, whereClause);
-       newnode->inh = from->inh;
 
        return newnode;
 }
@@ -1736,13 +1851,11 @@ static UpdateStmt *
 _copyUpdateStmt(UpdateStmt *from)
 {
        UpdateStmt *newnode = makeNode(UpdateStmt);
-       
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+
+       Node_Copy(from, newnode, relation);
        Node_Copy(from, newnode, targetList);
        Node_Copy(from, newnode, whereClause);
        Node_Copy(from, newnode, fromClause);
-       newnode->inh = from->inh;
 
        return newnode;
 }
@@ -1751,27 +1864,40 @@ static SelectStmt *
 _copySelectStmt(SelectStmt *from)
 {
        SelectStmt *newnode = makeNode(SelectStmt);
-       
+
        Node_Copy(from, newnode, distinctClause);
-       if (from->into)
-               newnode->into = pstrdup(from->into);
+       Node_Copy(from, newnode, into);
+       Node_Copy(from, newnode, intoColNames);
        Node_Copy(from, newnode, targetList);
        Node_Copy(from, newnode, fromClause);
        Node_Copy(from, newnode, whereClause);
        Node_Copy(from, newnode, groupClause);
        Node_Copy(from, newnode, havingClause);
-       Node_Copy(from, newnode, intersectClause);
-       Node_Copy(from, newnode, exceptClause);
-       Node_Copy(from, newnode, unionClause);
        Node_Copy(from, newnode, sortClause);
        if (from->portalname)
                newnode->portalname = pstrdup(from->portalname);
        newnode->binary = from->binary;
-       newnode->istemp = from->istemp;
-       newnode->unionall = from->unionall;
        Node_Copy(from, newnode, limitOffset);
        Node_Copy(from, newnode, limitCount);
        Node_Copy(from, newnode, forUpdate);
+       newnode->op = from->op;
+       newnode->all = from->all;
+       Node_Copy(from, newnode, larg);
+       Node_Copy(from, newnode, rarg);
+
+       return newnode;
+}
+
+static SetOperationStmt *
+_copySetOperationStmt(SetOperationStmt *from)
+{
+       SetOperationStmt *newnode = makeNode(SetOperationStmt);
+
+       newnode->op = from->op;
+       newnode->all = from->all;
+       Node_Copy(from, newnode, larg);
+       Node_Copy(from, newnode, rarg);
+       newnode->colTypes = listCopy(from->colTypes);
 
        return newnode;
 }
@@ -1780,11 +1906,9 @@ static AlterTableStmt *
 _copyAlterTableStmt(AlterTableStmt *from)
 {
        AlterTableStmt *newnode = makeNode(AlterTableStmt);
-       
+
        newnode->subtype = from->subtype;
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
-       newnode->inh = from->inh;
+       Node_Copy(from, newnode, relation);
        if (from->name)
                newnode->name = pstrdup(from->name);
        Node_Copy(from, newnode, def);
@@ -1793,22 +1917,53 @@ _copyAlterTableStmt(AlterTableStmt *from)
        return newnode;
 }
 
-static ChangeACLStmt *
-_copyChangeACLStmt(ChangeACLStmt *from)
+static GrantStmt *
+_copyGrantStmt(GrantStmt *from)
 {
-       ChangeACLStmt *newnode = makeNode(ChangeACLStmt);
-       
-       if (from->aclitem)
-       {
-               newnode->aclitem = (struct AclItem *) palloc(sizeof(struct AclItem));
-               memcpy(newnode->aclitem, from->aclitem, sizeof(struct AclItem));
-       }
-       newnode->modechg = from->modechg;
-       Node_Copy(from, newnode, relNames);
+       GrantStmt  *newnode = makeNode(GrantStmt);
+
+       newnode->is_grant = from->is_grant;
+       newnode->objtype = from->objtype;
+       Node_Copy(from, newnode, objects);
+       newnode->privileges = listCopy(from->privileges);
+       Node_Copy(from, newnode, grantees);
+
+       return newnode;
+}
+
+static PrivGrantee *
+_copyPrivGrantee(PrivGrantee *from)
+{
+       PrivGrantee *newnode = makeNode(PrivGrantee);
+
+       if (from->username)
+               newnode->username = pstrdup(from->username);
+       if (from->groupname)
+               newnode->groupname = pstrdup(from->groupname);
 
        return newnode;
 }
 
+static FuncWithArgs *
+_copyFuncWithArgs(FuncWithArgs *from)
+{
+       FuncWithArgs *newnode = makeNode(FuncWithArgs);
+
+       Node_Copy(from, newnode, funcname);
+       Node_Copy(from, newnode, funcargs);
+
+       return newnode;
+}
+
+static InsertDefault *
+_copyInsertDefault(InsertDefault *from)
+{
+       InsertDefault *newnode = makeNode(InsertDefault);
+
+       return newnode;
+}
+
+
 static ClosePortalStmt *
 _copyClosePortalStmt(ClosePortalStmt *from)
 {
@@ -1824,9 +1979,8 @@ static ClusterStmt *
 _copyClusterStmt(ClusterStmt *from)
 {
        ClusterStmt *newnode = makeNode(ClusterStmt);
-       
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+
+       Node_Copy(from, newnode, relation);
        if (from->indexname)
                newnode->indexname = pstrdup(from->indexname);
 
@@ -1836,19 +1990,13 @@ _copyClusterStmt(ClusterStmt *from)
 static CopyStmt *
 _copyCopyStmt(CopyStmt *from)
 {
-       CopyStmt *newnode = makeNode(CopyStmt);
-       
-       newnode->binary = from->binary;
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
-       newnode->oids = from->oids;
-       newnode->direction = from->direction;
+       CopyStmt   *newnode = makeNode(CopyStmt);
+
+       Node_Copy(from, newnode, relation);
+       newnode->is_from = from->is_from;
        if (from->filename)
                newnode->filename = pstrdup(from->filename);
-       if (from->delimiter)
-               newnode->delimiter = pstrdup(from->delimiter);
-       if (from->null_print)
-               newnode->null_print = pstrdup(from->null_print);
+       Node_Copy(from, newnode, options);
 
        return newnode;
 }
@@ -1857,25 +2005,12 @@ static CreateStmt *
 _copyCreateStmt(CreateStmt *from)
 {
        CreateStmt *newnode = makeNode(CreateStmt);
-       
-       newnode->istemp = from->istemp;
-       newnode->relname = pstrdup(from->relname);
+
+       Node_Copy(from, newnode, relation);
        Node_Copy(from, newnode, tableElts);
-       Node_Copy(from, newnode, inhRelnames);
+       Node_Copy(from, newnode, inhRelations);
        Node_Copy(from, newnode, constraints);
-
-       return newnode;
-}
-
-static VersionStmt *
-_copyVersionStmt(VersionStmt *from)
-{
-       VersionStmt *newnode = makeNode(VersionStmt);
-       
-       newnode->relname = pstrdup(from->relname);
-       newnode->direction = from->direction;
-       newnode->fromRelname = pstrdup(from->fromRelname);
-       newnode->date = pstrdup(from->date);
+       newnode->hasoids = from->hasoids;
 
        return newnode;
 }
@@ -1884,9 +2019,9 @@ static DefineStmt *
 _copyDefineStmt(DefineStmt *from)
 {
        DefineStmt *newnode = makeNode(DefineStmt);
-       
+
        newnode->defType = from->defType;
-       newnode->defname = pstrdup(from->defname);
+       Node_Copy(from, newnode, defnames);
        Node_Copy(from, newnode, definition);
 
        return newnode;
@@ -1895,10 +2030,11 @@ _copyDefineStmt(DefineStmt *from)
 static DropStmt *
 _copyDropStmt(DropStmt *from)
 {
-       DropStmt *newnode = makeNode(DropStmt);
-       
-       Node_Copy(from, newnode, relNames);
-       newnode->sequence = from->sequence;
+       DropStmt   *newnode = makeNode(DropStmt);
+
+       Node_Copy(from, newnode, objects);
+       newnode->removeType = from->removeType;
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -1908,7 +2044,7 @@ _copyTruncateStmt(TruncateStmt *from)
 {
        TruncateStmt *newnode = makeNode(TruncateStmt);
 
-       newnode->relName = pstrdup(from->relName);
+       Node_Copy(from, newnode, relation);
 
        return newnode;
 }
@@ -1917,25 +2053,12 @@ static CommentStmt *
 _copyCommentStmt(CommentStmt *from)
 {
        CommentStmt *newnode = makeNode(CommentStmt);
-       
-       newnode->objtype = from->objtype;
-       newnode->objname = pstrdup(from->objname);
-       if (from->objproperty)
-         newnode->objproperty = pstrdup(from->objproperty);
-       Node_Copy(from, newnode, objlist);
-       newnode->comment = pstrdup(from->comment);
-
-       return newnode;
-}
 
-static ExtendStmt *
-_copyExtendStmt(ExtendStmt *from)
-{
-       ExtendStmt *newnode = makeNode(ExtendStmt);
-       
-       newnode->idxname = pstrdup(from->idxname);
-       Node_Copy(from, newnode, whereClause);
-       Node_Copy(from, newnode, rangetable);
+       newnode->objtype = from->objtype;
+       Node_Copy(from, newnode, objname);
+       Node_Copy(from, newnode, objargs);
+       if (from->comment)
+               newnode->comment = pstrdup(from->comment);
 
        return newnode;
 }
@@ -1943,8 +2066,8 @@ _copyExtendStmt(ExtendStmt *from)
 static FetchStmt *
 _copyFetchStmt(FetchStmt *from)
 {
-       FetchStmt *newnode = makeNode(FetchStmt);
-       
+       FetchStmt  *newnode = makeNode(FetchStmt);
+
        newnode->direction = from->direction;
        newnode->howMany = from->howMany;
        newnode->portalname = pstrdup(from->portalname);
@@ -1956,13 +2079,12 @@ _copyFetchStmt(FetchStmt *from)
 static IndexStmt *
 _copyIndexStmt(IndexStmt *from)
 {
-       IndexStmt *newnode = makeNode(IndexStmt);
-       
+       IndexStmt  *newnode = makeNode(IndexStmt);
+
        newnode->idxname = pstrdup(from->idxname);
-       newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, relation);
        newnode->accessMethod = pstrdup(from->accessMethod);
        Node_Copy(from, newnode, indexParams);
-       Node_Copy(from, newnode, withClause);
        Node_Copy(from, newnode, whereClause);
        Node_Copy(from, newnode, rangetable);
        newnode->unique = from->unique;
@@ -1971,17 +2093,17 @@ _copyIndexStmt(IndexStmt *from)
        return newnode;
 }
 
-static ProcedureStmt *
-_copyProcedureStmt(ProcedureStmt *from)
+static CreateFunctionStmt *
+_copyCreateFunctionStmt(CreateFunctionStmt *from)
 {
-       ProcedureStmt *newnode = makeNode(ProcedureStmt);
-       
-       newnode->funcname = pstrdup(from->funcname);
-       Node_Copy(from, newnode, defArgs);
+       CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
+
+       newnode->replace = from->replace;
+       Node_Copy(from, newnode, funcname);
+       Node_Copy(from, newnode, argTypes);
        Node_Copy(from, newnode, returnType);
+       Node_Copy(from, newnode, options);
        Node_Copy(from, newnode, withClause);
-       Node_Copy(from, newnode, as);
-       newnode->language = pstrdup(from->language);
 
        return newnode;
 }
@@ -1990,9 +2112,10 @@ static RemoveAggrStmt *
 _copyRemoveAggrStmt(RemoveAggrStmt *from)
 {
        RemoveAggrStmt *newnode = makeNode(RemoveAggrStmt);
-       
-       newnode->aggname = pstrdup(from->aggname);
-       newnode->aggtype = pstrdup(from->aggtype);
+
+       Node_Copy(from, newnode, aggname);
+       Node_Copy(from, newnode, aggtype);
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2001,9 +2124,10 @@ static RemoveFuncStmt *
 _copyRemoveFuncStmt(RemoveFuncStmt *from)
 {
        RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
-       
-       newnode->funcname = pstrdup(from->funcname);
+
+       Node_Copy(from, newnode, funcname);
        Node_Copy(from, newnode, args);
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2012,20 +2136,10 @@ static RemoveOperStmt *
 _copyRemoveOperStmt(RemoveOperStmt *from)
 {
        RemoveOperStmt *newnode = makeNode(RemoveOperStmt);
-       
-       newnode->opname = pstrdup(from->opname);
-       Node_Copy(from, newnode, args);
-
-       return newnode;
-}
 
-static RemoveStmt *
-_copyRemoveStmt(RemoveStmt *from)
-{
-       RemoveStmt *newnode = makeNode(RemoveStmt);
-       
-       newnode->removeType = from->removeType;
-       newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, opname);
+       Node_Copy(from, newnode, args);
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2034,13 +2148,13 @@ static RenameStmt *
 _copyRenameStmt(RenameStmt *from)
 {
        RenameStmt *newnode = makeNode(RenameStmt);
-       
-       newnode->relname = pstrdup(from->relname);
-       newnode->inh = from->inh;
-       if (from->column)
-               newnode->column = pstrdup(from->column);
+
+       Node_Copy(from, newnode, relation);
+       if (from->oldname)
+               newnode->oldname = pstrdup(from->oldname);
        if (from->newname)
                newnode->newname = pstrdup(from->newname);
+       newnode->renameType = from->renameType;
 
        return newnode;
 }
@@ -2048,12 +2162,12 @@ _copyRenameStmt(RenameStmt *from)
 static RuleStmt *
 _copyRuleStmt(RuleStmt *from)
 {
-       RuleStmt *newnode = makeNode(RuleStmt);
-       
+       RuleStmt   *newnode = makeNode(RuleStmt);
+
+       Node_Copy(from, newnode, relation);
        newnode->rulename = pstrdup(from->rulename);
        Node_Copy(from, newnode, whereClause);
        newnode->event = from->event;
-       Node_Copy(from, newnode, object);
        newnode->instead = from->instead;
        Node_Copy(from, newnode, actions);
 
@@ -2065,8 +2179,7 @@ _copyNotifyStmt(NotifyStmt *from)
 {
        NotifyStmt *newnode = makeNode(NotifyStmt);
 
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, relation);
 
        return newnode;
 }
@@ -2076,8 +2189,7 @@ _copyListenStmt(ListenStmt *from)
 {
        ListenStmt *newnode = makeNode(ListenStmt);
 
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, relation);
 
        return newnode;
 }
@@ -2087,8 +2199,7 @@ _copyUnlistenStmt(UnlistenStmt *from)
 {
        UnlistenStmt *newnode = makeNode(UnlistenStmt);
 
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, relation);
 
        return newnode;
 }
@@ -2108,8 +2219,7 @@ _copyViewStmt(ViewStmt *from)
 {
        ViewStmt   *newnode = makeNode(ViewStmt);
 
-       if (from->viewname)
-               newnode->viewname = pstrdup(from->viewname);
+       Node_Copy(from, newnode, view);
        Node_Copy(from, newnode, aliases);
        Node_Copy(from, newnode, query);
 
@@ -2127,16 +2237,40 @@ _copyLoadStmt(LoadStmt *from)
        return newnode;
 }
 
+static CreateDomainStmt *
+_copyCreateDomainStmt(CreateDomainStmt *from)
+{
+       CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
+
+       Node_Copy(from, newnode, domainname);
+       Node_Copy(from, newnode, typename);
+       Node_Copy(from, newnode, constraints);
+
+       return newnode;
+}
+
 static CreatedbStmt *
 _copyCreatedbStmt(CreatedbStmt *from)
 {
-       CreatedbStmt   *newnode = makeNode(CreatedbStmt);
+       CreatedbStmt *newnode = makeNode(CreatedbStmt);
+
+       if (from->dbname)
+               newnode->dbname = pstrdup(from->dbname);
+       Node_Copy(from, newnode, options);
+
+       return newnode;
+}
+
+static AlterDatabaseSetStmt *
+_copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
+{
+       AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
 
        if (from->dbname)
                newnode->dbname = pstrdup(from->dbname);
-       if (from->dbpath)
-               newnode->dbpath = pstrdup(from->dbpath);
-       newnode->encoding = from->encoding;
+       if (from->variable)
+               newnode->variable = pstrdup(from->variable);
+       Node_Copy(from, newnode, value);
 
        return newnode;
 }
@@ -2144,7 +2278,7 @@ _copyCreatedbStmt(CreatedbStmt *from)
 static DropdbStmt *
 _copyDropdbStmt(DropdbStmt *from)
 {
-       DropdbStmt   *newnode = makeNode(DropdbStmt);
+       DropdbStmt *newnode = makeNode(DropdbStmt);
 
        if (from->dbname)
                newnode->dbname = pstrdup(from->dbname);
@@ -2155,13 +2289,15 @@ _copyDropdbStmt(DropdbStmt *from)
 static VacuumStmt *
 _copyVacuumStmt(VacuumStmt *from)
 {
-       VacuumStmt   *newnode = makeNode(VacuumStmt);
+       VacuumStmt *newnode = makeNode(VacuumStmt);
 
-       newnode->verbose = from->verbose;
+       newnode->vacuum = from->vacuum;
+       newnode->full = from->full;
        newnode->analyze = from->analyze;
-       if (from->vacrel)
-               newnode->vacrel = pstrdup(from->vacrel);
-       Node_Copy(from, newnode, va_spec);
+       newnode->freeze = from->freeze;
+       newnode->verbose = from->verbose;
+       Node_Copy(from, newnode, relation);
+       Node_Copy(from, newnode, va_cols);
 
        return newnode;
 }
@@ -2169,10 +2305,11 @@ _copyVacuumStmt(VacuumStmt *from)
 static ExplainStmt *
 _copyExplainStmt(ExplainStmt *from)
 {
-       ExplainStmt   *newnode = makeNode(ExplainStmt);
+       ExplainStmt *newnode = makeNode(ExplainStmt);
 
        Node_Copy(from, newnode, query);
        newnode->verbose = from->verbose;
+       newnode->analyze = from->analyze;
 
        return newnode;
 }
@@ -2180,10 +2317,9 @@ _copyExplainStmt(ExplainStmt *from)
 static CreateSeqStmt *
 _copyCreateSeqStmt(CreateSeqStmt *from)
 {
-       CreateSeqStmt   *newnode = makeNode(CreateSeqStmt);
+       CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
 
-       if (from->seqname)
-               newnode->seqname = pstrdup(from->seqname);
+       Node_Copy(from, newnode, sequence);
        Node_Copy(from, newnode, options);
 
        return newnode;
@@ -2196,8 +2332,8 @@ _copyVariableSetStmt(VariableSetStmt *from)
 
        if (from->name)
                newnode->name = pstrdup(from->name);
-       if (from->value)
-               newnode->value = pstrdup(from->value);
+       Node_Copy(from, newnode, args);
+       newnode->is_local = from->is_local;
 
        return newnode;
 }
@@ -2231,10 +2367,8 @@ _copyCreateTrigStmt(CreateTrigStmt *from)
 
        if (from->trigname)
                newnode->trigname = pstrdup(from->trigname);
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
-       if (from->funcname)
-               newnode->funcname = pstrdup(from->funcname);
+       Node_Copy(from, newnode, relation);
+       Node_Copy(from, newnode, funcname);
        Node_Copy(from, newnode, args);
        newnode->before = from->before;
        newnode->row = from->row;
@@ -2243,27 +2377,28 @@ _copyCreateTrigStmt(CreateTrigStmt *from)
                newnode->lang = pstrdup(from->lang);
        if (from->text)
                newnode->text = pstrdup(from->text);
+
        Node_Copy(from, newnode, attr);
        if (from->when)
                newnode->when = pstrdup(from->when);
        newnode->isconstraint = from->isconstraint;
        newnode->deferrable = from->deferrable;
        newnode->initdeferred = from->initdeferred;
-       if (from->constrrelname)
-               newnode->constrrelname = pstrdup(from->constrrelname);
+       Node_Copy(from, newnode, constrrel);
 
        return newnode;
 }
 
-static DropTrigStmt *
-_copyDropTrigStmt(DropTrigStmt *from)
+static DropPropertyStmt *
+_copyDropPropertyStmt(DropPropertyStmt *from)
 {
-       DropTrigStmt *newnode = makeNode(DropTrigStmt);
+       DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
 
-       if (from->trigname)
-               newnode->trigname = pstrdup(from->trigname);
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, relation);
+       if (from->property)
+               newnode->property = pstrdup(from->property);
+       newnode->removeType = from->removeType;
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2275,8 +2410,8 @@ _copyCreatePLangStmt(CreatePLangStmt *from)
 
        if (from->plname)
                newnode->plname = pstrdup(from->plname);
-       if (from->plhandler)
-               newnode->plhandler = pstrdup(from->plhandler);
+       Node_Copy(from, newnode, plhandler);
+       Node_Copy(from, newnode, plvalidator);
        if (from->plcompiler)
                newnode->plcompiler = pstrdup(from->plcompiler);
        newnode->pltrusted = from->pltrusted;
@@ -2291,6 +2426,7 @@ _copyDropPLangStmt(DropPLangStmt *from)
 
        if (from->plname)
                newnode->plname = pstrdup(from->plname);
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2302,14 +2438,7 @@ _copyCreateUserStmt(CreateUserStmt *from)
 
        if (from->user)
                newnode->user = pstrdup(from->user);
-       if (from->password)
-               newnode->password = pstrdup(from->password);
-       newnode->sysid = from->sysid;
-       newnode->createdb = from->createdb;
-       newnode->createuser = from->createuser;
-       Node_Copy(from, newnode, groupElts);
-       if (from->validUntil)
-               newnode->validUntil = pstrdup(from->validUntil);
+       Node_Copy(from, newnode, options);
 
        return newnode;
 }
@@ -2321,12 +2450,21 @@ _copyAlterUserStmt(AlterUserStmt *from)
 
        if (from->user)
                newnode->user = pstrdup(from->user);
-       if (from->password)
-               newnode->password = pstrdup(from->password);
-       newnode->createdb = from->createdb;
-       newnode->createuser = from->createuser;
-       if (from->validUntil)
-               newnode->validUntil = pstrdup(from->validUntil);
+       Node_Copy(from, newnode, options);
+
+       return newnode;
+}
+
+static AlterUserSetStmt *
+_copyAlterUserSetStmt(AlterUserSetStmt *from)
+{
+       AlterUserSetStmt *newnode = makeNode(AlterUserSetStmt);
+
+       if (from->user)
+               newnode->user = pstrdup(from->user);
+       if (from->variable)
+               newnode->variable = pstrdup(from->variable);
+       Node_Copy(from, newnode, value);
 
        return newnode;
 }
@@ -2346,8 +2484,8 @@ _copyLockStmt(LockStmt *from)
 {
        LockStmt   *newnode = makeNode(LockStmt);
 
-       if (from->relname)
-               newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, relations);
+
        newnode->mode = from->mode;
 
        return newnode;
@@ -2356,7 +2494,7 @@ _copyLockStmt(LockStmt *from)
 static ConstraintsSetStmt *
 _copyConstraintsSetStmt(ConstraintsSetStmt *from)
 {
-       ConstraintsSetStmt   *newnode = makeNode(ConstraintsSetStmt);
+       ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
 
        Node_Copy(from, newnode, constraints);
        newnode->deferred = from->deferred;
@@ -2367,12 +2505,11 @@ _copyConstraintsSetStmt(ConstraintsSetStmt *from)
 static CreateGroupStmt *
 _copyCreateGroupStmt(CreateGroupStmt *from)
 {
-       CreateGroupStmt   *newnode = makeNode(CreateGroupStmt);
+       CreateGroupStmt *newnode = makeNode(CreateGroupStmt);
 
        if (from->name)
                newnode->name = pstrdup(from->name);
-       newnode->sysid = from->sysid;
-       Node_Copy(from, newnode, initUsers);
+       Node_Copy(from, newnode, options);
 
        return newnode;
 }
@@ -2380,12 +2517,11 @@ _copyCreateGroupStmt(CreateGroupStmt *from)
 static AlterGroupStmt *
 _copyAlterGroupStmt(AlterGroupStmt *from)
 {
-       AlterGroupStmt   *newnode = makeNode(AlterGroupStmt);
+       AlterGroupStmt *newnode = makeNode(AlterGroupStmt);
 
        if (from->name)
                newnode->name = pstrdup(from->name);
        newnode->action = from->action;
-       newnode->sysid = from->sysid;
        Node_Copy(from, newnode, listUsers);
 
        return newnode;
@@ -2394,7 +2530,7 @@ _copyAlterGroupStmt(AlterGroupStmt *from)
 static DropGroupStmt *
 _copyDropGroupStmt(DropGroupStmt *from)
 {
-       DropGroupStmt   *newnode = makeNode(DropGroupStmt);
+       DropGroupStmt *newnode = makeNode(DropGroupStmt);
 
        if (from->name)
                newnode->name = pstrdup(from->name);
@@ -2405,9 +2541,10 @@ _copyDropGroupStmt(DropGroupStmt *from)
 static ReindexStmt *
 _copyReindexStmt(ReindexStmt *from)
 {
-       ReindexStmt   *newnode = makeNode(ReindexStmt);
+       ReindexStmt *newnode = makeNode(ReindexStmt);
 
        newnode->reindexType = from->reindexType;
+       Node_Copy(from, newnode, relation);
        if (from->name)
                newnode->name = pstrdup(from->name);
        newnode->force = from->force;
@@ -2416,12 +2553,15 @@ _copyReindexStmt(ReindexStmt *from)
        return newnode;
 }
 
-static SetSessionStmt *
-_copySetSessionStmt(SetSessionStmt *from)
+static CreateSchemaStmt *
+_copyCreateSchemaStmt(CreateSchemaStmt *from)
 {
-       SetSessionStmt   *newnode = makeNode(SetSessionStmt);
+       CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
 
-       Node_Copy(from, newnode, args);
+       newnode->schemaname = pstrdup(from->schemaname);
+       if (from->authid)
+               newnode->authid = pstrdup(from->authid);
+       Node_Copy(from, newnode, schemaElts);
 
        return newnode;
 }
@@ -2445,6 +2585,7 @@ _copyValue(Value *from)
                        break;
                case T_Float:
                case T_String:
+               case T_BitString:
                        newnode->val.str = pstrdup(from->val.str);
                        break;
                default:
@@ -2468,7 +2609,6 @@ copyObject(void *from)
 
        switch (nodeTag(from))
        {
-
                        /*
                         * PLAN NODES
                         */
@@ -2493,6 +2633,12 @@ copyObject(void *from)
                case T_TidScan:
                        retval = _copyTidScan(from);
                        break;
+               case T_SubqueryScan:
+                       retval = _copySubqueryScan(from);
+                       break;
+               case T_FunctionScan:
+                       retval = _copyFunctionScan(from);
+                       break;
                case T_Join:
                        retval = _copyJoin(from);
                        break;
@@ -2520,6 +2666,12 @@ copyObject(void *from)
                case T_Unique:
                        retval = _copyUnique(from);
                        break;
+               case T_SetOp:
+                       retval = _copySetOp(from);
+                       break;
+               case T_Limit:
+                       retval = _copyLimit(from);
+                       break;
                case T_Hash:
                        retval = _copyHash(from);
                        break;
@@ -2563,9 +2715,6 @@ copyObject(void *from)
                case T_ArrayRef:
                        retval = _copyArrayRef(from);
                        break;
-               case T_Iter:
-                       retval = _copyIter(from);
-                       break;
                case T_FieldSelect:
                        retval = _copyFieldSelect(from);
                        break;
@@ -2575,6 +2724,9 @@ copyObject(void *from)
                case T_RangeTblRef:
                        retval = _copyRangeTblRef(from);
                        break;
+               case T_FromExpr:
+                       retval = _copyFromExpr(from);
+                       break;
                case T_JoinExpr:
                        retval = _copyJoinExpr(from);
                        break;
@@ -2594,6 +2746,9 @@ copyObject(void *from)
                case T_TidPath:
                        retval = _copyTidPath(from);
                        break;
+               case T_AppendPath:
+                       retval = _copyAppendPath(from);
+                       break;
                case T_NestPath:
                        retval = _copyNestPath(from);
                        break;
@@ -2625,6 +2780,7 @@ copyObject(void *from)
                case T_Integer:
                case T_Float:
                case T_String:
+               case T_BitString:
                        retval = _copyValue(from);
                        break;
                case T_List:
@@ -2635,12 +2791,12 @@ copyObject(void *from)
 
                                /* rather ugly coding for speed... */
                                /* Note the input list cannot be NIL if we got here. */
-                               nl = lcons(copyObject(lfirst(list)), NIL);
+                               nl = makeList1(copyObject(lfirst(list)));
                                retval = nl;
 
                                foreach(l, lnext(list))
                                {
-                                       lnext(nl) = lcons(copyObject(lfirst(l)), NIL);
+                                       lnext(nl) = makeList1(copyObject(lfirst(l)));
                                        nl = lnext(nl);
                                }
                        }
@@ -2664,11 +2820,14 @@ copyObject(void *from)
                case T_SelectStmt:
                        retval = _copySelectStmt(from);
                        break;
+               case T_SetOperationStmt:
+                       retval = _copySetOperationStmt(from);
+                       break;
                case T_AlterTableStmt:
                        retval = _copyAlterTableStmt(from);
                        break;
-               case T_ChangeACLStmt:
-                       retval = _copyChangeACLStmt(from);
+               case T_GrantStmt:
+                       retval = _copyGrantStmt(from);
                        break;
                case T_ClosePortalStmt:
                        retval = _copyClosePortalStmt(from);
@@ -2682,9 +2841,6 @@ copyObject(void *from)
                case T_CreateStmt:
                        retval = _copyCreateStmt(from);
                        break;
-               case T_VersionStmt:
-                       retval = _copyVersionStmt(from);
-                       break;
                case T_DefineStmt:
                        retval = _copyDefineStmt(from);
                        break;
@@ -2697,17 +2853,14 @@ copyObject(void *from)
                case T_CommentStmt:
                        retval = _copyCommentStmt(from);
                        break;
-               case T_ExtendStmt:
-                       retval = _copyExtendStmt(from);
-                       break;
                case T_FetchStmt:
                        retval = _copyFetchStmt(from);
                        break;
                case T_IndexStmt:
                        retval = _copyIndexStmt(from);
                        break;
-               case T_ProcedureStmt:
-                       retval = _copyProcedureStmt(from);
+               case T_CreateFunctionStmt:
+                       retval = _copyCreateFunctionStmt(from);
                        break;
                case T_RemoveAggrStmt:
                        retval = _copyRemoveAggrStmt(from);
@@ -2718,9 +2871,6 @@ copyObject(void *from)
                case T_RemoveOperStmt:
                        retval = _copyRemoveOperStmt(from);
                        break;
-               case T_RemoveStmt:
-                       retval = _copyRemoveStmt(from);
-                       break;
                case T_RenameStmt:
                        retval = _copyRenameStmt(from);
                        break;
@@ -2745,9 +2895,15 @@ copyObject(void *from)
                case T_LoadStmt:
                        retval = _copyLoadStmt(from);
                        break;
+               case T_CreateDomainStmt:
+                       retval = _copyCreateDomainStmt(from);
+                       break;
                case T_CreatedbStmt:
                        retval = _copyCreatedbStmt(from);
                        break;
+               case T_AlterDatabaseSetStmt:
+                       retval = _copyAlterDatabaseSetStmt(from);
+                       break;
                case T_DropdbStmt:
                        retval = _copyDropdbStmt(from);
                        break;
@@ -2772,8 +2928,8 @@ copyObject(void *from)
                case T_CreateTrigStmt:
                        retval = _copyCreateTrigStmt(from);
                        break;
-               case T_DropTrigStmt:
-                       retval = _copyDropTrigStmt(from);
+               case T_DropPropertyStmt:
+                       retval = _copyDropPropertyStmt(from);
                        break;
                case T_CreatePLangStmt:
                        retval = _copyCreatePLangStmt(from);
@@ -2787,6 +2943,9 @@ copyObject(void *from)
                case T_AlterUserStmt:
                        retval = _copyAlterUserStmt(from);
                        break;
+               case T_AlterUserSetStmt:
+                       retval = _copyAlterUserSetStmt(from);
+                       break;
                case T_DropUserStmt:
                        retval = _copyDropUserStmt(from);
                        break;
@@ -2808,22 +2967,25 @@ copyObject(void *from)
                case T_ReindexStmt:
                        retval = _copyReindexStmt(from);
                        break;
-               case T_SetSessionStmt:
-                       retval = _copySetSessionStmt(from);
+               case T_CheckPointStmt:
+                       retval = (void *) makeNode(CheckPointStmt);
+                       break;
+               case T_CreateSchemaStmt:
+                       retval = _copyCreateSchemaStmt(from);
                        break;
 
                case T_A_Expr:
                        retval = _copyAExpr(from);
                        break;
-               case T_Attr:
-                       retval = _copyAttr(from);
+               case T_ColumnRef:
+                       retval = _copyColumnRef(from);
+                       break;
+               case T_ParamRef:
+                       retval = _copyParamRef(from);
                        break;
                case T_A_Const:
                        retval = _copyAConst(from);
                        break;
-               case T_ParamNo:
-                       retval = _copyParamNo(from);
-                       break;
                case T_Ident:
                        retval = _copyIdent(from);
                        break;
@@ -2833,6 +2995,9 @@ copyObject(void *from)
                case T_A_Indices:
                        retval = _copyAIndices(from);
                        break;
+               case T_ExprFieldSelect:
+                       retval = _copyExprFieldSelect(from);
+                       break;
                case T_ResTarget:
                        retval = _copyResTarget(from);
                        break;
@@ -2842,12 +3007,18 @@ copyObject(void *from)
                case T_SortGroupBy:
                        retval = _copySortGroupBy(from);
                        break;
+               case T_Alias:
+                       retval = _copyAlias(from);
+                       break;
                case T_RangeVar:
                        retval = _copyRangeVar(from);
                        break;
                case T_RangeSubselect:
                        retval = _copyRangeSubselect(from);
                        break;
+               case T_RangeFunction:
+                       retval = _copyRangeFunction(from);
+                       break;
                case T_TypeName:
                        retval = _copyTypeName(from);
                        break;
@@ -2881,12 +3052,24 @@ copyObject(void *from)
                case T_CaseWhen:
                        retval = _copyCaseWhen(from);
                        break;
-               case T_RowMark:
-                       retval = _copyRowMark(from);
+               case T_NullTest:
+                       retval = _copyNullTest(from);
+                       break;
+               case T_BooleanTest:
+                       retval = _copyBooleanTest(from);
                        break;
                case T_FkConstraint:
                        retval = _copyFkConstraint(from);
                        break;
+               case T_PrivGrantee:
+                       retval = _copyPrivGrantee(from);
+                       break;
+               case T_FuncWithArgs:
+                       retval = _copyFuncWithArgs(from);
+                       break;
+               case T_InsertDefault:
+                       retval = _copyInsertDefault(from);
+                       break;
 
                default:
                        elog(ERROR, "copyObject: don't know how to copy node type %d",