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 2c1e5b6..739161b 100644 (file)
  * different executor state node types.
  *
  *
- * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
+ * 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.173 2002/03/22 02:56:31 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.192 2002/07/01 15:27:51 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -310,6 +310,23 @@ _copySubqueryScan(SubqueryScan *from)
        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
@@ -323,7 +340,6 @@ CopyJoinFields(Join *from, Join *newnode)
 {
        newnode->jointype = from->jointype;
        Node_Copy(from, newnode, joinqual);
-       newnode->joinrti = from->joinrti;
        /* 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,
@@ -748,6 +764,7 @@ _copyOper(Oper *from)
        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;
 
@@ -836,7 +853,8 @@ _copyFunc(Func *from)
         * 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;
 
@@ -852,11 +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;
@@ -1088,7 +1102,7 @@ _copyRelOptInfo(RelOptInfo *from)
        Node_Copy(from, newnode, cheapest_total_path);
        newnode->pruneable = from->pruneable;
 
-       newnode->issubquery = from->issubquery;
+       newnode->rtekind = from->rtekind;
        Node_Copy(from, newnode, indexlist);
        newnode->pages = from->pages;
        newnode->tuples = from->tuples;
@@ -1421,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)
 {
@@ -1478,11 +1481,9 @@ _copyRangeTblEntry(RangeTblEntry *from)
        newnode->rtekind = from->rtekind;
        newnode->relid = from->relid;
        Node_Copy(from, newnode, subquery);
+       Node_Copy(from, newnode, funcexpr);
        newnode->jointype = from->jointype;
-       newnode->joincoltypes = listCopy(from->joincoltypes);
-       newnode->joincoltypmods = listCopy(from->joincoltypmods);
-       newnode->joinleftcols = listCopy(from->joinleftcols);
-       newnode->joinrightcols = listCopy(from->joinrightcols);
+       Node_Copy(from, newnode, joinaliasvars);
        Node_Copy(from, newnode, alias);
        Node_Copy(from, newnode, eref);
        newnode->inh = from->inh;
@@ -1530,8 +1531,7 @@ _copyAExpr(A_Expr *from)
        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);
 
@@ -1587,8 +1587,7 @@ _copyFuncCall(FuncCall *from)
 {
        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;
@@ -1637,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);
 
@@ -1652,8 +1652,7 @@ _copySortGroupBy(SortGroupBy *from)
 {
        SortGroupBy *newnode = makeNode(SortGroupBy);
 
-       if (from->useOp)
-               newnode->useOp = pstrdup(from->useOp);
+       Node_Copy(from, newnode, useOp);
        Node_Copy(from, newnode, node);
 
        return newnode;
@@ -1700,6 +1699,17 @@ _copyRangeSubselect(RangeSubselect *from)
        return newnode;
 }
 
+static RangeFunction *
+_copyRangeFunction(RangeFunction *from)
+{
+       RangeFunction   *newnode = makeNode(RangeFunction);
+
+       Node_Copy(from, newnode, funccallnode);
+       Node_Copy(from, newnode, alias);
+
+       return newnode;
+}
+
 static TypeCast *
 _copyTypeCast(TypeCast *from)
 {
@@ -1718,9 +1728,9 @@ _copyIndexElem(IndexElem *from)
 
        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;
 }
@@ -1939,13 +1949,21 @@ _copyFuncWithArgs(FuncWithArgs *from)
 {
        FuncWithArgs *newnode = makeNode(FuncWithArgs);
 
-       if (from->funcname)
-               newnode->funcname = pstrdup(from->funcname);
+       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)
 {
@@ -1974,16 +1992,11 @@ _copyCopyStmt(CopyStmt *from)
 {
        CopyStmt   *newnode = makeNode(CopyStmt);
 
-       newnode->binary = from->binary;
        Node_Copy(from, newnode, relation);
-       newnode->oids = from->oids;
-       newnode->direction = from->direction;
+       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;
 }
@@ -2008,7 +2021,7 @@ _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;
@@ -2042,13 +2055,10 @@ _copyCommentStmt(CommentStmt *from)
        CommentStmt *newnode = makeNode(CommentStmt);
 
        newnode->objtype = from->objtype;
-       if (from->objschema)
-               newnode->objschema = pstrdup(from->objschema);
-       newnode->objname = pstrdup(from->objname);
-       if (from->objproperty)
-               newnode->objproperty = pstrdup(from->objproperty);
-       Node_Copy(from, newnode, objlist);
-       newnode->comment = pstrdup(from->comment);
+       Node_Copy(from, newnode, objname);
+       Node_Copy(from, newnode, objargs);
+       if (from->comment)
+               newnode->comment = pstrdup(from->comment);
 
        return newnode;
 }
@@ -2083,18 +2093,17 @@ _copyIndexStmt(IndexStmt *from)
        return newnode;
 }
 
-static ProcedureStmt *
-_copyProcedureStmt(ProcedureStmt *from)
+static CreateFunctionStmt *
+_copyCreateFunctionStmt(CreateFunctionStmt *from)
 {
-       ProcedureStmt *newnode = makeNode(ProcedureStmt);
+       CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
 
        newnode->replace = from->replace;
-       newnode->funcname = pstrdup(from->funcname);
+       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;
 }
@@ -2104,8 +2113,9 @@ _copyRemoveAggrStmt(RemoveAggrStmt *from)
 {
        RemoveAggrStmt *newnode = makeNode(RemoveAggrStmt);
 
-       newnode->aggname = pstrdup(from->aggname);
+       Node_Copy(from, newnode, aggname);
        Node_Copy(from, newnode, aggtype);
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2115,8 +2125,9 @@ _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;
 }
@@ -2126,8 +2137,9 @@ _copyRemoveOperStmt(RemoveOperStmt *from)
 {
        RemoveOperStmt *newnode = makeNode(RemoveOperStmt);
 
-       newnode->opname = pstrdup(from->opname);
+       Node_Copy(from, newnode, opname);
        Node_Copy(from, newnode, args);
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2138,10 +2150,11 @@ _copyRenameStmt(RenameStmt *from)
        RenameStmt *newnode = makeNode(RenameStmt);
 
        Node_Copy(from, newnode, relation);
-       if (from->column)
-               newnode->column = pstrdup(from->column);
+       if (from->oldname)
+               newnode->oldname = pstrdup(from->oldname);
        if (from->newname)
                newnode->newname = pstrdup(from->newname);
+       newnode->renameType = from->renameType;
 
        return newnode;
 }
@@ -2229,8 +2242,7 @@ _copyCreateDomainStmt(CreateDomainStmt *from)
 {
        CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
 
-       if (from->domainname)
-               newnode->domainname = pstrdup(from->domainname);
+       Node_Copy(from, newnode, domainname);
        Node_Copy(from, newnode, typename);
        Node_Copy(from, newnode, constraints);
 
@@ -2244,13 +2256,7 @@ _copyCreatedbStmt(CreatedbStmt *from)
 
        if (from->dbname)
                newnode->dbname = pstrdup(from->dbname);
-       if (from->dbowner)
-               newnode->dbowner = pstrdup(from->dbowner);
-       if (from->dbpath)
-               newnode->dbpath = pstrdup(from->dbpath);
-       if (from->dbtemplate)
-               newnode->dbtemplate = pstrdup(from->dbtemplate);
-       newnode->encoding = from->encoding;
+       Node_Copy(from, newnode, options);
 
        return newnode;
 }
@@ -2327,6 +2333,7 @@ _copyVariableSetStmt(VariableSetStmt *from)
        if (from->name)
                newnode->name = pstrdup(from->name);
        Node_Copy(from, newnode, args);
+       newnode->is_local = from->is_local;
 
        return newnode;
 }
@@ -2361,8 +2368,7 @@ _copyCreateTrigStmt(CreateTrigStmt *from)
        if (from->trigname)
                newnode->trigname = pstrdup(from->trigname);
        Node_Copy(from, newnode, relation);
-       if (from->funcname)
-               newnode->funcname = pstrdup(from->funcname);
+       Node_Copy(from, newnode, funcname);
        Node_Copy(from, newnode, args);
        newnode->before = from->before;
        newnode->row = from->row;
@@ -2383,14 +2389,16 @@ _copyCreateTrigStmt(CreateTrigStmt *from)
        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);
        Node_Copy(from, newnode, relation);
+       if (from->property)
+               newnode->property = pstrdup(from->property);
+       newnode->removeType = from->removeType;
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2402,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;
@@ -2418,6 +2426,7 @@ _copyDropPLangStmt(DropPLangStmt *from)
 
        if (from->plname)
                newnode->plname = pstrdup(from->plname);
+       newnode->behavior = from->behavior;
 
        return newnode;
 }
@@ -2454,7 +2463,7 @@ _copyAlterUserSetStmt(AlterUserSetStmt *from)
        if (from->user)
                newnode->user = pstrdup(from->user);
        if (from->variable)
-               newnode->user = pstrdup(from->variable);
+               newnode->variable = pstrdup(from->variable);
        Node_Copy(from, newnode, value);
 
        return newnode;
@@ -2627,6 +2636,9 @@ copyObject(void *from)
                case T_SubqueryScan:
                        retval = _copySubqueryScan(from);
                        break;
+               case T_FunctionScan:
+                       retval = _copyFunctionScan(from);
+                       break;
                case T_Join:
                        retval = _copyJoin(from);
                        break;
@@ -2703,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;
@@ -2850,8 +2859,8 @@ copyObject(void *from)
                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);
@@ -2919,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);
@@ -3007,6 +3016,9 @@ copyObject(void *from)
                case T_RangeSubselect:
                        retval = _copyRangeSubselect(from);
                        break;
+               case T_RangeFunction:
+                       retval = _copyRangeFunction(from);
+                       break;
                case T_TypeName:
                        retval = _copyTypeName(from);
                        break;
@@ -3055,6 +3067,9 @@ copyObject(void *from)
                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",