OSDN Git Service

copyObject() and equal() now know about all parse-time node types,
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 11 Aug 2000 23:45:35 +0000 (23:45 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 11 Aug 2000 23:45:35 +0000 (23:45 +0000)
including utility statements.  Still can't copy or compare executor
state, but at present that doesn't seem to be necessary.  This makes
it possible to execute most (all?) utility statements in plpgsql.
Had to change parsetree representation of CreateTrigStmt so that it
contained only legal Nodes, and not bare string constants.

src/backend/commands/trigger.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/tcop/postgres.c

index a03f140..4a63094 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.75 2000/08/03 19:19:18 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.76 2000/08/11 23:45:28 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -212,7 +212,7 @@ CreateTrigger(CreateTrigStmt *stmt)
 
                foreach(le, stmt->args)
                {
-                       char       *ar = (char *) lfirst(le);
+                       char       *ar = ((Value*) lfirst(le))->val.str;
 
                        len += strlen(ar) + 4;
                        for (; *ar; ar++)
@@ -222,10 +222,10 @@ CreateTrigger(CreateTrigStmt *stmt)
                        }
                }
                args = (char *) palloc(len + 1);
-               args[0] = 0;
+               args[0] = '\0';
                foreach(le, stmt->args)
                {
-                       char       *s = (char *) lfirst(le);
+                       char       *s = ((Value*) lfirst(le))->val.str;
                        char       *d = args + strlen(args);
 
                        while (*s)
@@ -234,8 +234,7 @@ CreateTrigger(CreateTrigStmt *stmt)
                                        *d++ = '\\';
                                *d++ = *s++;
                        }
-                       *d = 0;
-                       strcat(args, "\\000");
+                       strcpy(d, "\\000");
                }
                values[Anum_pg_trigger_tgnargs - 1] = Int16GetDatum(nargs);
                values[Anum_pg_trigger_tgargs - 1] = DirectFunctionCall1(byteain,
index 33b630c..7270d31 100644 (file)
  * out, we avoid needing to write copy/compare routines for all the
  * different executor state node types.
  *
- * Another class of nodes not currently handled is nodes that appear
- * only in "raw" parsetrees (gram.y output not yet analyzed by the parser).
- * Perhaps some day that will need to be supported.
- *
  *
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.119 2000/08/08 15:41:23 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.120 2000/08/11 23:45:31 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,6 +24,7 @@
 
 #include "optimizer/clauses.h"
 #include "optimizer/planmain.h"
+#include "utils/acl.h"
 
 
 /*
@@ -91,10 +88,10 @@ CopyPlanFields(Plan *from, Plan *newnode)
        newnode->plan_rows = from->plan_rows;
        newnode->plan_width = from->plan_width;
        /* state is NOT copied */
-       newnode->targetlist = copyObject(from->targetlist);
-       newnode->qual = copyObject(from->qual);
-       newnode->lefttree = copyObject(from->lefttree);
-       newnode->righttree = copyObject(from->righttree);
+       Node_Copy(from, newnode, targetlist);
+       Node_Copy(from, newnode, qual);
+       Node_Copy(from, newnode, lefttree);
+       Node_Copy(from, newnode, righttree);
        newnode->extParam = listCopy(from->extParam);
        newnode->locParam = listCopy(from->locParam);
        newnode->chgParam = listCopy(from->chgParam);
@@ -513,6 +510,20 @@ _copyGroupClause(GroupClause *from)
        return newnode;
 }
 
+static JoinExpr *
+_copyJoinExpr(JoinExpr *from)
+{
+       JoinExpr *newnode = makeNode(JoinExpr);
+
+       newnode->jointype = from->jointype;
+       newnode->isNatural = from->isNatural;
+       Node_Copy(from, newnode, larg);
+       Node_Copy(from, newnode, rarg);
+       Node_Copy(from, newnode, alias);
+       Node_Copy(from, newnode, quals);
+
+       return newnode;
+}
 
 /* ----------------
  *             _copyUnique
@@ -1381,6 +1392,26 @@ _copyRowMark(RowMark *from)
        return newnode;
 }
 
+static FkConstraint *
+_copyFkConstraint(FkConstraint *from)
+{
+       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, fk_attrs);
+       Node_Copy(from, newnode, pk_attrs);
+       if (from->match_type)
+               newnode->match_type = pstrdup(from->match_type);
+       newnode->actions = from->actions;
+       newnode->deferrable = from->deferrable;
+       newnode->initdeferred = from->initdeferred;
+       
+       return newnode;
+}
+
 static SortClause *
 _copySortClause(SortClause *from)
 {
@@ -1392,6 +1423,20 @@ _copySortClause(SortClause *from)
        return newnode;
 }
 
+static A_Expr *
+_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, lexpr);
+       Node_Copy(from, newnode, rexpr);
+
+       return newnode;
+}
+
 static A_Const *
 _copyAConst(A_Const *from)
 {
@@ -1403,6 +1448,69 @@ _copyAConst(A_Const *from)
        return newnode;
 }
 
+static ParamNo *
+_copyParamNo(ParamNo *from)
+{
+       ParamNo    *newnode = makeNode(ParamNo);
+
+       newnode->number = from->number;
+       Node_Copy(from, newnode, typename);
+       Node_Copy(from, newnode, indirection);
+
+       return newnode;
+}
+
+static Ident *
+_copyIdent(Ident *from)
+{
+       Ident    *newnode = makeNode(Ident);
+
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, indirection);
+       newnode->isRel = from->isRel;
+
+       return newnode;
+}
+
+static FuncCall *
+_copyFuncCall(FuncCall *from)
+{
+       FuncCall    *newnode = makeNode(FuncCall);
+
+       if (from->funcname)
+               newnode->funcname = pstrdup(from->funcname);
+       Node_Copy(from, newnode, args);
+       newnode->agg_star = from->agg_star;
+       newnode->agg_distinct = from->agg_distinct;
+
+       return newnode;
+}
+
+static A_Indices *
+_copyAIndices(A_Indices *from)
+{
+       A_Indices    *newnode = makeNode(A_Indices);
+
+       Node_Copy(from, newnode, lidx);
+       Node_Copy(from, newnode, uidx);
+
+       return newnode;
+}
+
+static ResTarget *
+_copyResTarget(ResTarget *from)
+{
+       ResTarget    *newnode = makeNode(ResTarget);
+
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, indirection);
+       Node_Copy(from, newnode, val);
+
+       return newnode;
+}
+
 static TypeName *
 _copyTypeName(TypeName *from)
 {
@@ -1418,6 +1526,41 @@ _copyTypeName(TypeName *from)
        return newnode;
 }
 
+static RelExpr *
+_copyRelExpr(RelExpr *from)
+{
+       RelExpr   *newnode = makeNode(RelExpr);
+
+       if (from->relname)
+               newnode->relname = pstrdup(from->relname);
+       newnode->inh = from->inh;
+
+       return newnode;
+}
+
+static SortGroupBy *
+_copySortGroupBy(SortGroupBy *from)
+{
+       SortGroupBy   *newnode = makeNode(SortGroupBy);
+
+       if (from->useOp)
+               newnode->useOp = pstrdup(from->useOp);
+       Node_Copy(from, newnode, node);
+
+       return newnode;
+}
+
+static RangeVar *
+_copyRangeVar(RangeVar *from)
+{
+       RangeVar   *newnode = makeNode(RangeVar);
+
+       Node_Copy(from, newnode, relExpr);
+       Node_Copy(from, newnode, name);
+
+       return newnode;
+}
+
 static TypeCast *
 _copyTypeCast(TypeCast *from)
 {
@@ -1429,6 +1572,66 @@ _copyTypeCast(TypeCast *from)
        return newnode;
 }
 
+static IndexElem *
+_copyIndexElem(IndexElem *from)
+{
+       IndexElem   *newnode = makeNode(IndexElem);
+
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, args);
+       if (from->class)
+               newnode->class = pstrdup(from->class);
+
+       return newnode;
+}
+
+static ColumnDef *
+_copyColumnDef(ColumnDef *from)
+{
+       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);
+       Node_Copy(from, newnode, constraints);
+
+       return newnode;
+}
+
+static Constraint *
+_copyConstraint(Constraint *from)
+{
+       Constraint   *newnode = makeNode(Constraint);
+
+       newnode->contype = from->contype;
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, raw_expr);
+       if (from->cooked_expr)
+               newnode->cooked_expr = pstrdup(from->cooked_expr);
+       Node_Copy(from, newnode, keys);
+
+       return newnode;
+}
+
+static DefElem *
+_copyDefElem(DefElem *from)
+{
+       DefElem   *newnode = makeNode(DefElem);
+
+       if (from->defname)
+               newnode->defname = pstrdup(from->defname);
+       Node_Copy(from, newnode, arg);
+
+       return newnode;
+}
+
 static Query *
 _copyQuery(Query *from)
 {
@@ -1471,6 +1674,118 @@ _copyQuery(Query *from)
        return newnode;
 }
 
+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, 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);
+
+       return newnode;
+}
+
+static DeleteStmt *
+_copyDeleteStmt(DeleteStmt *from)
+{
+       DeleteStmt *newnode = makeNode(DeleteStmt);
+       
+       if (from->relname)
+               newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, whereClause);
+       newnode->inh = from->inh;
+
+       return newnode;
+}
+
+static UpdateStmt *
+_copyUpdateStmt(UpdateStmt *from)
+{
+       UpdateStmt *newnode = makeNode(UpdateStmt);
+       
+       if (from->relname)
+               newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, targetList);
+       Node_Copy(from, newnode, whereClause);
+       Node_Copy(from, newnode, fromClause);
+       newnode->inh = from->inh;
+
+       return newnode;
+}
+
+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, 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);
+
+       return newnode;
+}
+
+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;
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+       Node_Copy(from, newnode, def);
+       newnode->behavior = from->behavior;
+
+       return newnode;
+}
+
+static ChangeACLStmt *
+_copyChangeACLStmt(ChangeACLStmt *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);
+
+       return newnode;
+}
+
 static ClosePortalStmt *
 _copyClosePortalStmt(ClosePortalStmt *from)
 {
@@ -1482,6 +1797,89 @@ _copyClosePortalStmt(ClosePortalStmt *from)
        return newnode;
 }
 
+static ClusterStmt *
+_copyClusterStmt(ClusterStmt *from)
+{
+       ClusterStmt *newnode = makeNode(ClusterStmt);
+       
+       if (from->relname)
+               newnode->relname = pstrdup(from->relname);
+       if (from->indexname)
+               newnode->indexname = pstrdup(from->indexname);
+
+       return newnode;
+}
+
+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;
+       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);
+
+       return newnode;
+}
+
+static CreateStmt *
+_copyCreateStmt(CreateStmt *from)
+{
+       CreateStmt *newnode = makeNode(CreateStmt);
+       
+       newnode->istemp = from->istemp;
+       newnode->relname = pstrdup(from->relname);
+       Node_Copy(from, newnode, tableElts);
+       Node_Copy(from, newnode, inhRelnames);
+       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);
+
+       return newnode;
+}
+
+static DefineStmt *
+_copyDefineStmt(DefineStmt *from)
+{
+       DefineStmt *newnode = makeNode(DefineStmt);
+       
+       newnode->defType = from->defType;
+       newnode->defname = pstrdup(from->defname);
+       Node_Copy(from, newnode, definition);
+
+       return newnode;
+}
+
+static DropStmt *
+_copyDropStmt(DropStmt *from)
+{
+       DropStmt *newnode = makeNode(DropStmt);
+       
+       Node_Copy(from, newnode, relNames);
+       newnode->sequence = from->sequence;
+
+       return newnode;
+}
+
 static TruncateStmt *
 _copyTruncateStmt(TruncateStmt *from)
 {
@@ -1492,6 +1890,152 @@ _copyTruncateStmt(TruncateStmt *from)
        return newnode;
 }
 
+static CommentStmt *
+_copyCommentStmt(CommentStmt *from)
+{
+       CommentStmt *newnode = makeNode(CommentStmt);
+       
+       newnode->objtype = from->objtype;
+       newnode->objname = pstrdup(from->objname);
+       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);
+
+       return newnode;
+}
+
+static FetchStmt *
+_copyFetchStmt(FetchStmt *from)
+{
+       FetchStmt *newnode = makeNode(FetchStmt);
+       
+       newnode->direction = from->direction;
+       newnode->howMany = from->howMany;
+       newnode->portalname = pstrdup(from->portalname);
+       newnode->ismove = from->ismove;
+
+       return newnode;
+}
+
+static IndexStmt *
+_copyIndexStmt(IndexStmt *from)
+{
+       IndexStmt *newnode = makeNode(IndexStmt);
+       
+       newnode->idxname = pstrdup(from->idxname);
+       newnode->relname = pstrdup(from->relname);
+       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;
+       newnode->primary = from->primary;
+
+       return newnode;
+}
+
+static ProcedureStmt *
+_copyProcedureStmt(ProcedureStmt *from)
+{
+       ProcedureStmt *newnode = makeNode(ProcedureStmt);
+       
+       newnode->funcname = pstrdup(from->funcname);
+       Node_Copy(from, newnode, defArgs);
+       Node_Copy(from, newnode, returnType);
+       Node_Copy(from, newnode, withClause);
+       Node_Copy(from, newnode, as);
+       newnode->language = pstrdup(from->language);
+
+       return newnode;
+}
+
+static RemoveAggrStmt *
+_copyRemoveAggrStmt(RemoveAggrStmt *from)
+{
+       RemoveAggrStmt *newnode = makeNode(RemoveAggrStmt);
+       
+       newnode->aggname = pstrdup(from->aggname);
+       newnode->aggtype = pstrdup(from->aggtype);
+
+       return newnode;
+}
+
+static RemoveFuncStmt *
+_copyRemoveFuncStmt(RemoveFuncStmt *from)
+{
+       RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
+       
+       newnode->funcname = pstrdup(from->funcname);
+       Node_Copy(from, newnode, args);
+
+       return newnode;
+}
+
+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);
+
+       return newnode;
+}
+
+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);
+       if (from->newname)
+               newnode->newname = pstrdup(from->newname);
+
+       return newnode;
+}
+
+static RuleStmt *
+_copyRuleStmt(RuleStmt *from)
+{
+       RuleStmt *newnode = makeNode(RuleStmt);
+       
+       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);
+
+       return newnode;
+}
+
 static NotifyStmt *
 _copyNotifyStmt(NotifyStmt *from)
 {
@@ -1535,6 +2079,19 @@ _copyTransactionStmt(TransactionStmt *from)
        return newnode;
 }
 
+static ViewStmt *
+_copyViewStmt(ViewStmt *from)
+{
+       ViewStmt   *newnode = makeNode(ViewStmt);
+
+       if (from->viewname)
+               newnode->viewname = pstrdup(from->viewname);
+       Node_Copy(from, newnode, aliases);
+       Node_Copy(from, newnode, query);
+
+       return newnode;
+}
+
 static LoadStmt *
 _copyLoadStmt(LoadStmt *from)
 {
@@ -1546,6 +2103,68 @@ _copyLoadStmt(LoadStmt *from)
        return newnode;
 }
 
+static CreatedbStmt *
+_copyCreatedbStmt(CreatedbStmt *from)
+{
+       CreatedbStmt   *newnode = makeNode(CreatedbStmt);
+
+       if (from->dbname)
+               newnode->dbname = pstrdup(from->dbname);
+       if (from->dbpath)
+               newnode->dbpath = pstrdup(from->dbpath);
+       newnode->encoding = from->encoding;
+
+       return newnode;
+}
+
+static DropdbStmt *
+_copyDropdbStmt(DropdbStmt *from)
+{
+       DropdbStmt   *newnode = makeNode(DropdbStmt);
+
+       if (from->dbname)
+               newnode->dbname = pstrdup(from->dbname);
+
+       return newnode;
+}
+
+static VacuumStmt *
+_copyVacuumStmt(VacuumStmt *from)
+{
+       VacuumStmt   *newnode = makeNode(VacuumStmt);
+
+       newnode->verbose = from->verbose;
+       newnode->analyze = from->analyze;
+       if (from->vacrel)
+               newnode->vacrel = pstrdup(from->vacrel);
+       Node_Copy(from, newnode, va_spec);
+
+       return newnode;
+}
+
+static ExplainStmt *
+_copyExplainStmt(ExplainStmt *from)
+{
+       ExplainStmt   *newnode = makeNode(ExplainStmt);
+
+       Node_Copy(from, newnode, query);
+       newnode->verbose = from->verbose;
+
+       return newnode;
+}
+
+static CreateSeqStmt *
+_copyCreateSeqStmt(CreateSeqStmt *from)
+{
+       CreateSeqStmt   *newnode = makeNode(CreateSeqStmt);
+
+       if (from->seqname)
+               newnode->seqname = pstrdup(from->seqname);
+       Node_Copy(from, newnode, options);
+
+       return newnode;
+}
+
 static VariableSetStmt *
 _copyVariableSetStmt(VariableSetStmt *from)
 {
@@ -1559,6 +2178,17 @@ _copyVariableSetStmt(VariableSetStmt *from)
        return newnode;
 }
 
+static VariableShowStmt *
+_copyVariableShowStmt(VariableShowStmt *from)
+{
+       VariableShowStmt *newnode = makeNode(VariableShowStmt);
+
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+
+       return newnode;
+}
+
 static VariableResetStmt *
 _copyVariableResetStmt(VariableResetStmt *from)
 {
@@ -1570,6 +2200,123 @@ _copyVariableResetStmt(VariableResetStmt *from)
        return newnode;
 }
 
+static CreateTrigStmt *
+_copyCreateTrigStmt(CreateTrigStmt *from)
+{
+       CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
+
+       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, args);
+       newnode->before = from->before;
+       newnode->row = from->row;
+       memcpy(newnode->actions, from->actions, sizeof(from->actions));
+       if (from->lang)
+               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);
+
+       return newnode;
+}
+
+static DropTrigStmt *
+_copyDropTrigStmt(DropTrigStmt *from)
+{
+       DropTrigStmt *newnode = makeNode(DropTrigStmt);
+
+       if (from->trigname)
+               newnode->trigname = pstrdup(from->trigname);
+       if (from->relname)
+               newnode->relname = pstrdup(from->relname);
+
+       return newnode;
+}
+
+static CreatePLangStmt *
+_copyCreatePLangStmt(CreatePLangStmt *from)
+{
+       CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
+
+       if (from->plname)
+               newnode->plname = pstrdup(from->plname);
+       if (from->plhandler)
+               newnode->plhandler = pstrdup(from->plhandler);
+       if (from->plcompiler)
+               newnode->plcompiler = pstrdup(from->plcompiler);
+       newnode->pltrusted = from->pltrusted;
+
+       return newnode;
+}
+
+static DropPLangStmt *
+_copyDropPLangStmt(DropPLangStmt *from)
+{
+       DropPLangStmt *newnode = makeNode(DropPLangStmt);
+
+       if (from->plname)
+               newnode->plname = pstrdup(from->plname);
+
+       return newnode;
+}
+
+static CreateUserStmt *
+_copyCreateUserStmt(CreateUserStmt *from)
+{
+       CreateUserStmt *newnode = makeNode(CreateUserStmt);
+
+       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);
+
+       return newnode;
+}
+
+static AlterUserStmt *
+_copyAlterUserStmt(AlterUserStmt *from)
+{
+       AlterUserStmt *newnode = makeNode(AlterUserStmt);
+
+       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);
+
+       return newnode;
+}
+
+static DropUserStmt *
+_copyDropUserStmt(DropUserStmt *from)
+{
+       DropUserStmt *newnode = makeNode(DropUserStmt);
+
+       Node_Copy(from, newnode, users);
+
+       return newnode;
+}
+
 static LockStmt *
 _copyLockStmt(LockStmt *from)
 {
@@ -1582,6 +2329,79 @@ _copyLockStmt(LockStmt *from)
        return newnode;
 }
 
+static ConstraintsSetStmt *
+_copyConstraintsSetStmt(ConstraintsSetStmt *from)
+{
+       ConstraintsSetStmt   *newnode = makeNode(ConstraintsSetStmt);
+
+       Node_Copy(from, newnode, constraints);
+       newnode->deferred = from->deferred;
+
+       return newnode;
+}
+
+static CreateGroupStmt *
+_copyCreateGroupStmt(CreateGroupStmt *from)
+{
+       CreateGroupStmt   *newnode = makeNode(CreateGroupStmt);
+
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+       newnode->sysid = from->sysid;
+       Node_Copy(from, newnode, initUsers);
+
+       return newnode;
+}
+
+static AlterGroupStmt *
+_copyAlterGroupStmt(AlterGroupStmt *from)
+{
+       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;
+}
+
+static DropGroupStmt *
+_copyDropGroupStmt(DropGroupStmt *from)
+{
+       DropGroupStmt   *newnode = makeNode(DropGroupStmt);
+
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+
+       return newnode;
+}
+
+static ReindexStmt *
+_copyReindexStmt(ReindexStmt *from)
+{
+       ReindexStmt   *newnode = makeNode(ReindexStmt);
+
+       newnode->reindexType = from->reindexType;
+       if (from->name)
+               newnode->name = pstrdup(from->name);
+       newnode->force = from->force;
+       newnode->all = from->all;
+
+       return newnode;
+}
+
+static SetSessionStmt *
+_copySetSessionStmt(SetSessionStmt *from)
+{
+       SetSessionStmt   *newnode = makeNode(SetSessionStmt);
+
+       Node_Copy(from, newnode, args);
+
+       return newnode;
+}
+
 
 /* ****************************************************************
  *                                     pg_list.h copy functions
@@ -1621,6 +2441,7 @@ copyObject(void *from)
 
        if (from == NULL)
                return NULL;
+
        switch (nodeTag(from))
        {
 
@@ -1801,12 +2622,81 @@ copyObject(void *from)
                case T_Query:
                        retval = _copyQuery(from);
                        break;
+               case T_InsertStmt:
+                       retval = _copyInsertStmt(from);
+                       break;
+               case T_DeleteStmt:
+                       retval = _copyDeleteStmt(from);
+                       break;
+               case T_UpdateStmt:
+                       retval = _copyUpdateStmt(from);
+                       break;
+               case T_SelectStmt:
+                       retval = _copySelectStmt(from);
+                       break;
+               case T_AlterTableStmt:
+                       retval = _copyAlterTableStmt(from);
+                       break;
+               case T_ChangeACLStmt:
+                       retval = _copyChangeACLStmt(from);
+                       break;
                case T_ClosePortalStmt:
                        retval = _copyClosePortalStmt(from);
                        break;
+               case T_ClusterStmt:
+                       retval = _copyClusterStmt(from);
+                       break;
+               case T_CopyStmt:
+                       retval = _copyCopyStmt(from);
+                       break;
+               case T_CreateStmt:
+                       retval = _copyCreateStmt(from);
+                       break;
+               case T_VersionStmt:
+                       retval = _copyVersionStmt(from);
+                       break;
+               case T_DefineStmt:
+                       retval = _copyDefineStmt(from);
+                       break;
+               case T_DropStmt:
+                       retval = _copyDropStmt(from);
+                       break;
                case T_TruncateStmt:
                        retval = _copyTruncateStmt(from);
                        break;
+               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);
+                       break;
+               case T_RemoveAggrStmt:
+                       retval = _copyRemoveAggrStmt(from);
+                       break;
+               case T_RemoveFuncStmt:
+                       retval = _copyRemoveFuncStmt(from);
+                       break;
+               case T_RemoveOperStmt:
+                       retval = _copyRemoveOperStmt(from);
+                       break;
+               case T_RemoveStmt:
+                       retval = _copyRemoveStmt(from);
+                       break;
+               case T_RenameStmt:
+                       retval = _copyRenameStmt(from);
+                       break;
+               case T_RuleStmt:
+                       retval = _copyRuleStmt(from);
+                       break;
                case T_NotifyStmt:
                        retval = _copyNotifyStmt(from);
                        break;
@@ -1819,31 +2709,130 @@ copyObject(void *from)
                case T_TransactionStmt:
                        retval = _copyTransactionStmt(from);
                        break;
+               case T_ViewStmt:
+                       retval = _copyViewStmt(from);
+                       break;
                case T_LoadStmt:
                        retval = _copyLoadStmt(from);
                        break;
+               case T_CreatedbStmt:
+                       retval = _copyCreatedbStmt(from);
+                       break;
+               case T_DropdbStmt:
+                       retval = _copyDropdbStmt(from);
+                       break;
+               case T_VacuumStmt:
+                       retval = _copyVacuumStmt(from);
+                       break;
+               case T_ExplainStmt:
+                       retval = _copyExplainStmt(from);
+                       break;
+               case T_CreateSeqStmt:
+                       retval = _copyCreateSeqStmt(from);
+                       break;
                case T_VariableSetStmt:
                        retval = _copyVariableSetStmt(from);
                        break;
+               case T_VariableShowStmt:
+                       retval = _copyVariableShowStmt(from);
+                       break;
                case T_VariableResetStmt:
                        retval = _copyVariableResetStmt(from);
                        break;
+               case T_CreateTrigStmt:
+                       retval = _copyCreateTrigStmt(from);
+                       break;
+               case T_DropTrigStmt:
+                       retval = _copyDropTrigStmt(from);
+                       break;
+               case T_CreatePLangStmt:
+                       retval = _copyCreatePLangStmt(from);
+                       break;
+               case T_DropPLangStmt:
+                       retval = _copyDropPLangStmt(from);
+                       break;
+               case T_CreateUserStmt:
+                       retval = _copyCreateUserStmt(from);
+                       break;
+               case T_AlterUserStmt:
+                       retval = _copyAlterUserStmt(from);
+                       break;
+               case T_DropUserStmt:
+                       retval = _copyDropUserStmt(from);
+                       break;
                case T_LockStmt:
                        retval = _copyLockStmt(from);
                        break;
+               case T_ConstraintsSetStmt:
+                       retval = _copyConstraintsSetStmt(from);
+                       break;
+               case T_CreateGroupStmt:
+                       retval = _copyCreateGroupStmt(from);
+                       break;
+               case T_AlterGroupStmt:
+                       retval = _copyAlterGroupStmt(from);
+                       break;
+               case T_DropGroupStmt:
+                       retval = _copyDropGroupStmt(from);
+                       break;
+               case T_ReindexStmt:
+                       retval = _copyReindexStmt(from);
+                       break;
+               case T_SetSessionStmt:
+                       retval = _copySetSessionStmt(from);
+                       break;
 
+               case T_A_Expr:
+                       retval = _copyAExpr(from);
+                       break;
                case T_Attr:
                        retval = _copyAttr(from);
                        break;
                case T_A_Const:
                        retval = _copyAConst(from);
                        break;
+               case T_ParamNo:
+                       retval = _copyParamNo(from);
+                       break;
+               case T_Ident:
+                       retval = _copyIdent(from);
+                       break;
+               case T_FuncCall:
+                       retval = _copyFuncCall(from);
+                       break;
+               case T_A_Indices:
+                       retval = _copyAIndices(from);
+                       break;
+               case T_ResTarget:
+                       retval = _copyResTarget(from);
+                       break;
                case T_TypeCast:
                        retval = _copyTypeCast(from);
                        break;
+               case T_RelExpr:
+                       retval = _copyRelExpr(from);
+                       break;
+               case T_SortGroupBy:
+                       retval = _copySortGroupBy(from);
+                       break;
+               case T_RangeVar:
+                       retval = _copyRangeVar(from);
+                       break;
                case T_TypeName:
                        retval = _copyTypeName(from);
                        break;
+               case T_IndexElem:
+                       retval = _copyIndexElem(from);
+                       break;
+               case T_ColumnDef:
+                       retval = _copyColumnDef(from);
+                       break;
+               case T_Constraint:
+                       retval = _copyConstraint(from);
+                       break;
+               case T_DefElem:
+                       retval = _copyDefElem(from);
+                       break;
                case T_TargetEntry:
                        retval = _copyTargetEntry(from);
                        break;
@@ -1856,6 +2845,9 @@ copyObject(void *from)
                case T_GroupClause:
                        retval = _copyGroupClause(from);
                        break;
+               case T_JoinExpr:
+                       retval = _copyJoinExpr(from);
+                       break;
                case T_CaseExpr:
                        retval = _copyCaseExpr(from);
                        break;
@@ -1865,6 +2857,9 @@ copyObject(void *from)
                case T_RowMark:
                        retval = _copyRowMark(from);
                        break;
+               case T_FkConstraint:
+                       retval = _copyFkConstraint(from);
+                       break;
 
                default:
                        elog(ERROR, "copyObject: don't know how to copy node type %d",
index 701e651..b059e5c 100644 (file)
  * need to be fixed someday, but presently there is no need to compare
  * plan trees.
  *
- * Another class of nodes not currently handled is nodes that appear
- * only in "raw" parsetrees (gram.y output not yet analyzed by the parser).
- * Perhaps some day that will need to be supported.
- *
  *
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.71 2000/08/08 15:41:24 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.72 2000/08/11 23:45:31 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "nodes/plannodes.h"
 #include "nodes/relation.h"
+#include "utils/acl.h"
 #include "utils/datum.h"
 
+
 static bool equali(List *a, List *b);
 
+/* Macro for comparing string fields that might be NULL */
+#define equalstr(a, b)  \
+       (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
+
 
 /*
  *     Stuff from primnodes.h
@@ -51,17 +53,8 @@ _equalResdom(Resdom *a, Resdom *b)
                return false;
        if (a->restypmod != b->restypmod)
                return false;
-       if (a->resname && b->resname)
-       {
-               if (strcmp(a->resname, b->resname) != 0)
-                       return false;
-       }
-       else
-       {
-               /* must both be null to be equal */
-               if (a->resname != b->resname)
-                       return false;
-       }
+       if (!equalstr(a->resname, b->resname))
+               return false;
        if (a->ressortgroupref != b->ressortgroupref)
                return false;
        if (a->reskey != b->reskey)
@@ -114,17 +107,6 @@ _equalExpr(Expr *a, Expr *b)
 }
 
 static bool
-_equalAttr(Attr *a, Attr *b)
-{
-       if (strcmp(a->relname, b->relname) != 0)
-               return false;
-       if (!equal(a->attrs, b->attrs))
-               return false;
-
-       return true;
-}
-
-static bool
 _equalVar(Var *a, Var *b)
 {
        if (a->varno != b->varno)
@@ -158,6 +140,9 @@ _equalOper(Oper *a, Oper *b)
         * logically derived from opno, and they may not be set yet depending
         * on how far along the node is in the parse/plan pipeline.
         *
+        * (Besides, op_fcache is executor state, which we don't check --- see
+        * notes at head of file.)
+        *
         * It's probably not really necessary to check opresulttype either...
         */
 
@@ -556,16 +541,8 @@ _equalQuery(Query *a, Query *b)
                return false;
        if (a->resultRelation != b->resultRelation)
                return false;
-       if (a->into && b->into)
-       {
-               if (strcmp(a->into, b->into) != 0)
-                       return false;
-       }
-       else
-       {
-               if (a->into != b->into)
-                       return false;
-       }
+       if (!equalstr(a->into, b->into))
+               return false;
        if (a->isPortal != b->isPortal)
                return false;
        if (a->isBinary != b->isBinary)
@@ -613,148 +590,1182 @@ _equalQuery(Query *a, Query *b)
 }
 
 static bool
-_equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
+_equalInsertStmt(InsertStmt *a, InsertStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (!equal(a->distinctClause, b->distinctClause))
+               return false;
+       if (!equal(a->cols, b->cols))
+               return false;
+       if (!equal(a->targetList, b->targetList))
+               return false;
+       if (!equal(a->fromClause, b->fromClause))
+               return false;
+       if (!equal(a->whereClause, b->whereClause))
+               return false;
+       if (!equal(a->groupClause, b->groupClause))
+               return false;
+       if (!equal(a->havingClause, b->havingClause))
+               return false;
+       if (!equal(a->unionClause, b->unionClause))
+               return false;
+       if (a->unionall != b->unionall)
+               return false;
+       if (!equal(a->intersectClause, b->intersectClause))
+               return false;
+       if (!equal(a->forUpdate, b->forUpdate))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (!equal(a->whereClause, b->whereClause))
+               return false;
+       if (a->inh != b->inh)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (!equal(a->targetList, b->targetList))
+               return false;
+       if (!equal(a->whereClause, b->whereClause))
+               return false;
+       if (!equal(a->fromClause, b->fromClause))
+               return false;
+       if (a->inh != b->inh)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalSelectStmt(SelectStmt *a, SelectStmt *b)
+{
+       if (!equal(a->distinctClause, b->distinctClause))
+               return false;
+       if (!equalstr(a->into, b->into))
+               return false;
+       if (!equal(a->targetList, b->targetList))
+               return false;
+       if (!equal(a->fromClause, b->fromClause))
+               return false;
+       if (!equal(a->whereClause, b->whereClause))
+               return false;
+       if (!equal(a->groupClause, b->groupClause))
+               return false;
+       if (!equal(a->havingClause, b->havingClause))
+               return false;
+       if (!equal(a->intersectClause, b->intersectClause))
+               return false;
+       if (!equal(a->exceptClause, b->exceptClause))
+               return false;
+       if (!equal(a->unionClause, b->unionClause))
+               return false;
+       if (!equal(a->sortClause, b->sortClause))
+               return false;
+       if (!equalstr(a->portalname, b->portalname))
+               return false;
+       if (a->binary != b->binary)
+               return false;
+       if (a->istemp != b->istemp)
+               return false;
+       if (a->unionall != b->unionall)
+               return false;
+       if (!equal(a->limitOffset, b->limitOffset))
+               return false;
+       if (!equal(a->limitCount, b->limitCount))
+               return false;
+       if (!equal(a->forUpdate, b->forUpdate))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
 {
-       if (a->relname && b->relname)
+       if (a->subtype != b->subtype)
+               return false;
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (a->inh != b->inh)
+               return false;
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (!equal(a->def, b->def))
+               return false;
+       if (a->behavior != b->behavior)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalChangeACLStmt(ChangeACLStmt *a, ChangeACLStmt *b)
+{
+       if (a->aclitem && b->aclitem)
        {
-               if (strcmp(a->relname, b->relname) != 0)
+               if (a->aclitem->ai_id != b->aclitem->ai_id)
+                       return false;
+               if (a->aclitem->ai_idtype != b->aclitem->ai_idtype)
+                       return false;
+               if (a->aclitem->ai_mode != b->aclitem->ai_mode)
                        return false;
        }
        else
        {
-               if (a->relname != b->relname)
-                       return false;
+               if (a->aclitem != b->aclitem)
+                       return false;           /* one NULL, one not */
        }
-       if (!equal(a->ref, b->ref))
-               return false;
-       if (a->relid != b->relid)
+       if (a->modechg != b->modechg)
                return false;
-       if (a->inh != b->inh)
+       if (!equal(a->relNames, b->relNames))
                return false;
-       if (a->inFromCl != b->inFromCl)
+
+       return true;
+}
+
+static bool
+_equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
+{
+       if (!equalstr(a->portalname, b->portalname))
                return false;
-       if (a->inJoinSet != b->inJoinSet)
+
+       return true;
+}
+
+static bool
+_equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
                return false;
-       if (a->skipAcl != b->skipAcl)
+       if (!equalstr(a->indexname, b->indexname))
                return false;
 
        return true;
 }
 
 static bool
-_equalSortClause(SortClause *a, SortClause *b)
+_equalCopyStmt(CopyStmt *a, CopyStmt *b)
 {
-       if (a->tleSortGroupRef != b->tleSortGroupRef)
+       if (a->binary != b->binary)
                return false;
-       if (a->sortop != b->sortop)
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (a->oids != b->oids)
+               return false;
+       if (a->direction != b->direction)
+               return false;
+       if (!equalstr(a->filename, b->filename))
+               return false;
+       if (!equalstr(a->delimiter, b->delimiter))
+               return false;
+       if (!equalstr(a->null_print, b->null_print))
                return false;
 
        return true;
 }
 
 static bool
-_equalRowMark(RowMark *a, RowMark *b)
+_equalCreateStmt(CreateStmt *a, CreateStmt *b)
 {
-       if (a->rti != b->rti)
+       if (a->istemp != b->istemp)
                return false;
-       if (a->info != b->info)
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (!equal(a->tableElts, b->tableElts))
+               return false;
+       if (!equal(a->inhRelnames, b->inhRelnames))
+               return false;
+       if (!equal(a->constraints, b->constraints))
                return false;
 
        return true;
 }
 
 static bool
-_equalTargetEntry(TargetEntry *a, TargetEntry *b)
+_equalVersionStmt(VersionStmt *a, VersionStmt *b)
 {
-       if (!equal(a->resdom, b->resdom))
+       if (!equalstr(a->relname, b->relname))
                return false;
-       if (!equal(a->fjoin, b->fjoin))
+       if (a->direction != b->direction)
                return false;
-       if (!equal(a->expr, b->expr))
+       if (!equalstr(a->fromRelname, b->fromRelname))
+               return false;
+       if (!equalstr(a->date, b->date))
                return false;
 
        return true;
 }
 
 static bool
-_equalCaseExpr(CaseExpr *a, CaseExpr *b)
+_equalDefineStmt(DefineStmt *a, DefineStmt *b)
 {
-       if (a->casetype != b->casetype)
+       if (a->defType != b->defType)
                return false;
-       if (!equal(a->arg, b->arg))
-               return false;
-       if (!equal(a->args, b->args))
+       if (!equalstr(a->defname, b->defname))
                return false;
-       if (!equal(a->defresult, b->defresult))
+       if (!equal(a->definition, b->definition))
                return false;
 
        return true;
 }
 
 static bool
-_equalCaseWhen(CaseWhen *a, CaseWhen *b)
+_equalDropStmt(DropStmt *a, DropStmt *b)
 {
-       if (!equal(a->expr, b->expr))
+       if (!equal(a->relNames, b->relNames))
                return false;
-       if (!equal(a->result, b->result))
+       if (a->sequence != b->sequence)
                return false;
 
        return true;
 }
 
-/*
- * Stuff from pg_list.h
- */
+static bool
+_equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
+{
+       if (!equalstr(a->relName, b->relName))
+               return false;
+
+       return true;
+}
 
 static bool
-_equalValue(Value *a, Value *b)
+_equalCommentStmt(CommentStmt *a, CommentStmt *b)
 {
-       if (a->type != b->type)
+       if (a->objtype != b->objtype)
+               return false;
+       if (!equalstr(a->objname, b->objname))
+               return false;
+       if (!equalstr(a->objproperty, b->objproperty))
+               return false;
+       if (!equal(a->objlist, b->objlist))
+               return false;
+       if (!equalstr(a->comment, b->comment))
                return false;
 
-       switch (a->type)
-       {
-               case T_Integer:
-                       return a->val.ival == b->val.ival;
-               case T_Float:
-               case T_String:
-                       return strcmp(a->val.str, b->val.str) == 0;
-               default:
-                       break;
-       }
+       return true;
+}
+
+static bool
+_equalExtendStmt(ExtendStmt *a, ExtendStmt *b)
+{
+       if (!equalstr(a->idxname, b->idxname))
+               return false;
+       if (!equal(a->whereClause, b->whereClause))
+               return false;
+       if (!equal(a->rangetable, b->rangetable))
+               return false;
 
        return true;
 }
 
-/*
- * equal
- *       returns whether two nodes are equal
- */
-bool
-equal(void *a, void *b)
+static bool
+_equalFetchStmt(FetchStmt *a, FetchStmt *b)
 {
-       bool            retval = false;
+       if (a->direction != b->direction)
+               return false;
+       if (a->howMany != b->howMany)
+               return false;
+       if (!equalstr(a->portalname, b->portalname))
+               return false;
+       if (a->ismove != b->ismove)
+               return false;
 
-       if (a == b)
-               return true;
+       return true;
+}
 
-       /*
-        * note that a!=b, so only one of them can be NULL
-        */
-       if (a == NULL || b == NULL)
+static bool
+_equalIndexStmt(IndexStmt *a, IndexStmt *b)
+{
+       if (!equalstr(a->idxname, b->idxname))
+               return false;
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (!equalstr(a->accessMethod, b->accessMethod))
+               return false;
+       if (!equal(a->indexParams, b->indexParams))
+               return false;
+       if (!equal(a->withClause, b->withClause))
+               return false;
+       if (!equal(a->whereClause, b->whereClause))
+               return false;
+       if (!equal(a->rangetable, b->rangetable))
+               return false;
+       if (a->unique != b->unique)
+               return false;
+       if (a->primary != b->primary)
                return false;
 
-       /*
-        * are they the same type of nodes?
-        */
-       if (nodeTag(a) != nodeTag(b))
+       return true;
+}
+
+static bool
+_equalProcedureStmt(ProcedureStmt *a, ProcedureStmt *b)
+{
+       if (!equalstr(a->funcname, b->funcname))
+               return false;
+       if (!equal(a->defArgs, b->defArgs))
+               return false;
+       if (!equal(a->returnType, b->returnType))
+               return false;
+       if (!equal(a->withClause, b->withClause))
+               return false;
+       if (!equal(a->as, b->as))
+               return false;
+       if (!equalstr(a->language, b->language))
                return false;
 
-       switch (nodeTag(a))
-       {
-               case T_SubPlan:
-                       retval = _equalSubPlan(a, b);
+       return true;
+}
+
+static bool
+_equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b)
+{
+       if (!equalstr(a->aggname, b->aggname))
+               return false;
+       if (!equalstr(a->aggtype, b->aggtype))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
+{
+       if (!equalstr(a->funcname, b->funcname))
+               return false;
+       if (!equal(a->args, b->args))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b)
+{
+       if (!equalstr(a->opname, b->opname))
+               return false;
+       if (!equal(a->args, b->args))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRemoveStmt(RemoveStmt *a, RemoveStmt *b)
+{
+       if (a->removeType != b->removeType)
+               return false;
+       if (!equalstr(a->name, b->name))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRenameStmt(RenameStmt *a, RenameStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (a->inh != b->inh)
+               return false;
+       if (!equalstr(a->column, b->column))
+               return false;
+       if (!equalstr(a->newname, b->newname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRuleStmt(RuleStmt *a, RuleStmt *b)
+{
+       if (!equalstr(a->rulename, b->rulename))
+               return false;
+       if (!equal(a->whereClause, b->whereClause))
+               return false;
+       if (a->event != b->event)
+               return false;
+       if (!equal(a->object, b->object))
+               return false;
+       if (a->instead != b->instead)
+               return false;
+       if (!equal(a->actions, b->actions))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalListenStmt(ListenStmt *a, ListenStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
+{
+       if (a->command != b->command)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalViewStmt(ViewStmt *a, ViewStmt *b)
+{
+       if (!equalstr(a->viewname, b->viewname))
+               return false;
+       if (!equal(a->aliases, b->aliases))
+               return false;
+       if (!equal(a->query, b->query))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalLoadStmt(LoadStmt *a, LoadStmt *b)
+{
+       if (!equalstr(a->filename, b->filename))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
+{
+       if (!equalstr(a->dbname, b->dbname))
+               return false;
+       if (!equalstr(a->dbpath, b->dbpath))
+               return false;
+       if (a->encoding != b->encoding)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
+{
+       if (!equalstr(a->dbname, b->dbname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
+{
+       if (a->verbose != b->verbose)
+               return false;
+       if (a->analyze != b->analyze)
+               return false;
+       if (!equalstr(a->vacrel, b->vacrel))
+               return false;
+       if (!equal(a->va_spec, b->va_spec))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
+{
+       if (!equal(a->query, b->query))
+               return false;
+       if (a->verbose != b->verbose)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
+{
+       if (!equalstr(a->seqname, b->seqname))
+               return false;
+       if (!equal(a->options, b->options))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (!equalstr(a->value, b->value))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
+{
+       if (!equalstr(a->trigname, b->trigname))
+               return false;
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (!equalstr(a->funcname, b->funcname))
+               return false;
+       if (!equal(a->args, b->args))
+               return false;
+       if (a->before != b->before)
+               return false;
+       if (a->row != b->row)
+               return false;
+       if (strcmp(a->actions, b->actions) != 0)
+               return false;
+       if (!equalstr(a->lang, b->lang))
+               return false;
+       if (!equalstr(a->text, b->text))
+               return false;
+       if (!equal(a->attr, b->attr))
+               return false;
+       if (!equalstr(a->when, b->when))
+               return false;
+       if (a->isconstraint != b->isconstraint)
+               return false;
+       if (a->deferrable != b->deferrable)
+               return false;
+       if (a->initdeferred != b->initdeferred)
+               return false;
+       if (!equalstr(a->constrrelname, b->constrrelname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalDropTrigStmt(DropTrigStmt *a, DropTrigStmt *b)
+{
+       if (!equalstr(a->trigname, b->trigname))
+               return false;
+       if (!equalstr(a->relname, b->relname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
+{
+       if (!equalstr(a->plname, b->plname))
+               return false;
+       if (!equalstr(a->plhandler, b->plhandler))
+               return false;
+       if (!equalstr(a->plcompiler, b->plcompiler))
+               return false;
+       if (a->pltrusted != b->pltrusted)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
+{
+       if (!equalstr(a->plname, b->plname))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCreateUserStmt(CreateUserStmt *a, CreateUserStmt *b)
+{
+       if (!equalstr(a->user, b->user))
+               return false;
+       if (!equalstr(a->password, b->password))
+               return false;
+       if (a->sysid != b->sysid)
+               return false;
+       if (a->createdb != b->createdb)
+               return false;
+       if (a->createuser != b->createuser)
+               return false;
+       if (!equal(a->groupElts, b->groupElts))
+               return false;
+       if (!equalstr(a->validUntil, b->validUntil))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalAlterUserStmt(AlterUserStmt *a, AlterUserStmt *b)
+{
+       if (!equalstr(a->user, b->user))
+               return false;
+       if (!equalstr(a->password, b->password))
+               return false;
+       if (a->createdb != b->createdb)
+               return false;
+       if (a->createuser != b->createuser)
+               return false;
+       if (!equalstr(a->validUntil, b->validUntil))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalDropUserStmt(DropUserStmt *a, DropUserStmt *b)
+{
+       if (!equal(a->users, b->users))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalLockStmt(LockStmt *a, LockStmt *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (a->mode != b->mode)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
+{
+       if (!equal(a->constraints, b->constraints))
+               return false;
+       if (a->deferred != b->deferred)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCreateGroupStmt(CreateGroupStmt *a, CreateGroupStmt *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (a->sysid != b->sysid)
+               return false;
+       if (!equal(a->initUsers, b->initUsers))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalAlterGroupStmt(AlterGroupStmt *a, AlterGroupStmt *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (a->action != b->action)
+               return false;
+       if (a->sysid != b->sysid)
+               return false;
+       if (!equal(a->listUsers, b->listUsers))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalDropGroupStmt(DropGroupStmt *a, DropGroupStmt *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
+{
+       if (a->reindexType != b->reindexType)
+               return false;
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (a->force != b->force)
+               return false;
+       if (a->all != b->all)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalSetSessionStmt(SetSessionStmt *a, SetSessionStmt *b)
+{
+       if (!equal(a->args, b->args))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalAExpr(A_Expr *a, A_Expr *b)
+{
+       if (a->oper != b->oper)
+               return false;
+       if (!equalstr(a->opname, b->opname))
+               return false;
+       if (!equal(a->lexpr, b->lexpr))
+               return false;
+       if (!equal(a->rexpr, b->rexpr))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalAttr(Attr *a, Attr *b)
+{
+       if (strcmp(a->relname, b->relname) != 0)
+               return false;
+       if (!equal(a->paramNo, b->paramNo))
+               return false;
+       if (!equal(a->attrs, b->attrs))
+               return false;
+       if (!equal(a->indirection, b->indirection))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalAConst(A_Const *a, A_Const *b)
+{
+       if (!equal(&a->val, &b->val))
+               return false;
+       if (!equal(a->typename, b->typename))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalParamNo(ParamNo *a, ParamNo *b)
+{
+       if (a->number != b->number)
+               return false;
+       if (!equal(a->typename, b->typename))
+               return false;
+       if (!equal(a->indirection, b->indirection))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalIdent(Ident *a, Ident *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (!equal(a->indirection, b->indirection))
+               return false;
+       if (a->isRel != b->isRel)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalFuncCall(FuncCall *a, FuncCall *b)
+{
+       if (!equalstr(a->funcname, b->funcname))
+               return false;
+       if (!equal(a->args, b->args))
+               return false;
+       if (a->agg_star != b->agg_star)
+               return false;
+       if (a->agg_distinct != b->agg_distinct)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalAIndices(A_Indices *a, A_Indices *b)
+{
+       if (!equal(a->lidx, b->lidx))
+               return false;
+       if (!equal(a->uidx, b->uidx))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalResTarget(ResTarget *a, ResTarget *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (!equal(a->indirection, b->indirection))
+               return false;
+       if (!equal(a->val, b->val))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalTypeCast(TypeCast *a, TypeCast *b)
+{
+       if (!equal(a->arg, b->arg))
+               return false;
+       if (!equal(a->typename, b->typename))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRelExpr(RelExpr *a, RelExpr *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (a->inh != b->inh)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalSortGroupBy(SortGroupBy *a, SortGroupBy *b)
+{
+       if (!equalstr(a->useOp, b->useOp))
+               return false;
+       if (!equal(a->node, b->node))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRangeVar(RangeVar *a, RangeVar *b)
+{
+       if (!equal(a->relExpr, b->relExpr))
+               return false;
+       if (!equal(a->name, b->name))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalTypeName(TypeName *a, TypeName *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (a->timezone != b->timezone)
+               return false;
+       if (a->setof != b->setof)
+               return false;
+       if (a->typmod != b->typmod)
+               return false;
+       if (!equal(a->arrayBounds, b->arrayBounds))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalIndexElem(IndexElem *a, IndexElem *b)
+{
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (!equal(a->args, b->args))
+               return false;
+       if (!equalstr(a->class, b->class))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalColumnDef(ColumnDef *a, ColumnDef *b)
+{
+       if (!equalstr(a->colname, b->colname))
+               return false;
+       if (!equal(a->typename, b->typename))
+               return false;
+       if (a->is_not_null != b->is_not_null)
+               return false;
+       if (a->is_sequence != b->is_sequence)
+               return false;
+       if (!equal(a->raw_default, b->raw_default))
+               return false;
+       if (!equalstr(a->cooked_default, b->cooked_default))
+               return false;
+       if (!equal(a->constraints, b->constraints))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalConstraint(Constraint *a, Constraint *b)
+{
+       if (a->contype != b->contype)
+               return false;
+       if (!equalstr(a->name, b->name))
+               return false;
+       if (!equal(a->raw_expr, b->raw_expr))
+               return false;
+       if (!equalstr(a->cooked_expr, b->cooked_expr))
+               return false;
+       if (!equal(a->keys, b->keys))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalDefElem(DefElem *a, DefElem *b)
+{
+       if (!equalstr(a->defname, b->defname))
+               return false;
+       if (!equal(a->arg, b->arg))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalTargetEntry(TargetEntry *a, TargetEntry *b)
+{
+       if (!equal(a->resdom, b->resdom))
+               return false;
+       if (!equal(a->fjoin, b->fjoin))
+               return false;
+       if (!equal(a->expr, b->expr))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
+{
+       if (!equalstr(a->relname, b->relname))
+               return false;
+       if (!equal(a->ref, b->ref))
+               return false;
+       /* XXX what about eref? */
+       if (a->relid != b->relid)
+               return false;
+       if (a->inh != b->inh)
+               return false;
+       if (a->inFromCl != b->inFromCl)
+               return false;
+       if (a->inJoinSet != b->inJoinSet)
+               return false;
+       if (a->skipAcl != b->skipAcl)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalSortClause(SortClause *a, SortClause *b)
+{
+       if (a->tleSortGroupRef != b->tleSortGroupRef)
+               return false;
+       if (a->sortop != b->sortop)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalRowMark(RowMark *a, RowMark *b)
+{
+       if (a->rti != b->rti)
+               return false;
+       if (a->info != b->info)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalJoinExpr(JoinExpr *a, JoinExpr *b)
+{
+       if (a->jointype != b->jointype)
+               return false;
+       if (a->isNatural != b->isNatural)
+               return false;
+       if (!equal(a->larg, b->larg))
+               return false;
+       if (!equal(a->rarg, b->rarg))
+               return false;
+       if (!equal(a->alias, b->alias))
+               return false;
+       if (!equal(a->quals, b->quals))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalFkConstraint(FkConstraint *a, FkConstraint *b)
+{
+       if (!equalstr(a->constr_name, b->constr_name))
+               return false;
+       if (!equalstr(a->pktable_name, b->pktable_name))
+               return false;
+       if (!equal(a->fk_attrs, b->fk_attrs))
+               return false;
+       if (!equal(a->pk_attrs, b->pk_attrs))
+               return false;
+       if (!equalstr(a->match_type, b->match_type))
+               return false;
+       if (a->actions != b->actions)
+               return false;
+       if (a->deferrable != b->deferrable)
+               return false;
+       if (a->initdeferred != b->initdeferred)
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCaseExpr(CaseExpr *a, CaseExpr *b)
+{
+       if (a->casetype != b->casetype)
+               return false;
+       if (!equal(a->arg, b->arg))
+               return false;
+       if (!equal(a->args, b->args))
+               return false;
+       if (!equal(a->defresult, b->defresult))
+               return false;
+
+       return true;
+}
+
+static bool
+_equalCaseWhen(CaseWhen *a, CaseWhen *b)
+{
+       if (!equal(a->expr, b->expr))
+               return false;
+       if (!equal(a->result, b->result))
+               return false;
+
+       return true;
+}
+
+/*
+ * Stuff from pg_list.h
+ */
+
+static bool
+_equalValue(Value *a, Value *b)
+{
+       if (a->type != b->type)
+               return false;
+
+       switch (a->type)
+       {
+               case T_Integer:
+                       return a->val.ival == b->val.ival;
+               case T_Float:
+               case T_String:
+                       return strcmp(a->val.str, b->val.str) == 0;
+               default:
+                       break;
+       }
+
+       return true;
+}
+
+/*
+ * equal
+ *       returns whether two nodes are equal
+ */
+bool
+equal(void *a, void *b)
+{
+       bool            retval = false;
+
+       if (a == b)
+               return true;
+
+       /*
+        * note that a!=b, so only one of them can be NULL
+        */
+       if (a == NULL || b == NULL)
+               return false;
+
+       /*
+        * are they the same type of nodes?
+        */
+       if (nodeTag(a) != nodeTag(b))
+               return false;
+
+       switch (nodeTag(a))
+       {
+               case T_SubPlan:
+                       retval = _equalSubPlan(a, b);
                        break;
+
                case T_Resdom:
                        retval = _equalResdom(a, b);
                        break;
@@ -785,18 +1796,19 @@ equal(void *a, void *b)
                case T_Func:
                        retval = _equalFunc(a, b);
                        break;
+               case T_FieldSelect:
+                       retval = _equalFieldSelect(a, b);
+                       break;
                case T_ArrayRef:
                        retval = _equalArrayRef(a, b);
                        break;
                case T_Iter:
                        retval = _equalIter(a, b);
                        break;
-               case T_FieldSelect:
-                       retval = _equalFieldSelect(a, b);
-                       break;
                case T_RelabelType:
                        retval = _equalRelabelType(a, b);
                        break;
+
                case T_RelOptInfo:
                        retval = _equalRelOptInfo(a, b);
                        break;
@@ -833,12 +1845,11 @@ equal(void *a, void *b)
                case T_IndexOptInfo:
                        retval = _equalIndexOptInfo(a, b);
                        break;
+
                case T_EState:
                        retval = _equalEState(a, b);
                        break;
-               case T_Attr:
-                       retval = _equalAttr(a, b);
-                       break;
+
                case T_List:
                        {
                                List       *la = (List *) a;
@@ -865,9 +1876,221 @@ equal(void *a, void *b)
                case T_String:
                        retval = _equalValue(a, b);
                        break;
+
                case T_Query:
                        retval = _equalQuery(a, b);
                        break;
+               case T_InsertStmt:
+                       retval = _equalInsertStmt(a, b);
+                       break;
+               case T_DeleteStmt:
+                       retval = _equalDeleteStmt(a, b);
+                       break;
+               case T_UpdateStmt:
+                       retval = _equalUpdateStmt(a, b);
+                       break;
+               case T_SelectStmt:
+                       retval = _equalSelectStmt(a, b);
+                       break;
+               case T_AlterTableStmt:
+                       retval = _equalAlterTableStmt(a, b);
+                       break;
+               case T_ChangeACLStmt:
+                       retval = _equalChangeACLStmt(a, b);
+                       break;
+               case T_ClosePortalStmt:
+                       retval = _equalClosePortalStmt(a, b);
+                       break;
+               case T_ClusterStmt:
+                       retval = _equalClusterStmt(a, b);
+                       break;
+               case T_CopyStmt:
+                       retval = _equalCopyStmt(a, b);
+                       break;
+               case T_CreateStmt:
+                       retval = _equalCreateStmt(a, b);
+                       break;
+               case T_VersionStmt:
+                       retval = _equalVersionStmt(a, b);
+                       break;
+               case T_DefineStmt:
+                       retval = _equalDefineStmt(a, b);
+                       break;
+               case T_DropStmt:
+                       retval = _equalDropStmt(a, b);
+                       break;
+               case T_TruncateStmt:
+                       retval = _equalTruncateStmt(a, b);
+                       break;
+               case T_CommentStmt:
+                       retval = _equalCommentStmt(a, b);
+                       break;
+               case T_ExtendStmt:
+                       retval = _equalExtendStmt(a, b);
+                       break;
+               case T_FetchStmt:
+                       retval = _equalFetchStmt(a, b);
+                       break;
+               case T_IndexStmt:
+                       retval = _equalIndexStmt(a, b);
+                       break;
+               case T_ProcedureStmt:
+                       retval = _equalProcedureStmt(a, b);
+                       break;
+               case T_RemoveAggrStmt:
+                       retval = _equalRemoveAggrStmt(a, b);
+                       break;
+               case T_RemoveFuncStmt:
+                       retval = _equalRemoveFuncStmt(a, b);
+                       break;
+               case T_RemoveOperStmt:
+                       retval = _equalRemoveOperStmt(a, b);
+                       break;
+               case T_RemoveStmt:
+                       retval = _equalRemoveStmt(a, b);
+                       break;
+               case T_RenameStmt:
+                       retval = _equalRenameStmt(a, b);
+                       break;
+               case T_RuleStmt:
+                       retval = _equalRuleStmt(a, b);
+                       break;
+               case T_NotifyStmt:
+                       retval = _equalNotifyStmt(a, b);
+                       break;
+               case T_ListenStmt:
+                       retval = _equalListenStmt(a, b);
+                       break;
+               case T_UnlistenStmt:
+                       retval = _equalUnlistenStmt(a, b);
+                       break;
+               case T_TransactionStmt:
+                       retval = _equalTransactionStmt(a, b);
+                       break;
+               case T_ViewStmt:
+                       retval = _equalViewStmt(a, b);
+                       break;
+               case T_LoadStmt:
+                       retval = _equalLoadStmt(a, b);
+                       break;
+               case T_CreatedbStmt:
+                       retval = _equalCreatedbStmt(a, b);
+                       break;
+               case T_DropdbStmt:
+                       retval = _equalDropdbStmt(a, b);
+                       break;
+               case T_VacuumStmt:
+                       retval = _equalVacuumStmt(a, b);
+                       break;
+               case T_ExplainStmt:
+                       retval = _equalExplainStmt(a, b);
+                       break;
+               case T_CreateSeqStmt:
+                       retval = _equalCreateSeqStmt(a, b);
+                       break;
+               case T_VariableSetStmt:
+                       retval = _equalVariableSetStmt(a, b);
+                       break;
+               case T_VariableShowStmt:
+                       retval = _equalVariableShowStmt(a, b);
+                       break;
+               case T_VariableResetStmt:
+                       retval = _equalVariableResetStmt(a, b);
+                       break;
+               case T_CreateTrigStmt:
+                       retval = _equalCreateTrigStmt(a, b);
+                       break;
+               case T_DropTrigStmt:
+                       retval = _equalDropTrigStmt(a, b);
+                       break;
+               case T_CreatePLangStmt:
+                       retval = _equalCreatePLangStmt(a, b);
+                       break;
+               case T_DropPLangStmt:
+                       retval = _equalDropPLangStmt(a, b);
+                       break;
+               case T_CreateUserStmt:
+                       retval = _equalCreateUserStmt(a, b);
+                       break;
+               case T_AlterUserStmt:
+                       retval = _equalAlterUserStmt(a, b);
+                       break;
+               case T_DropUserStmt:
+                       retval = _equalDropUserStmt(a, b);
+                       break;
+               case T_LockStmt:
+                       retval = _equalLockStmt(a, b);
+                       break;
+               case T_ConstraintsSetStmt:
+                       retval = _equalConstraintsSetStmt(a, b);
+                       break;
+               case T_CreateGroupStmt:
+                       retval = _equalCreateGroupStmt(a, b);
+                       break;
+               case T_AlterGroupStmt:
+                       retval = _equalAlterGroupStmt(a, b);
+                       break;
+               case T_DropGroupStmt:
+                       retval = _equalDropGroupStmt(a, b);
+                       break;
+               case T_ReindexStmt:
+                       retval = _equalReindexStmt(a, b);
+                       break;
+               case T_SetSessionStmt:
+                       retval = _equalSetSessionStmt(a, b);
+                       break;
+
+               case T_A_Expr:
+                       retval = _equalAExpr(a, b);
+                       break;
+               case T_Attr:
+                       retval = _equalAttr(a, b);
+                       break;
+               case T_A_Const:
+                       retval = _equalAConst(a, b);
+                       break;
+               case T_ParamNo:
+                       retval = _equalParamNo(a, b);
+                       break;
+               case T_Ident:
+                       retval = _equalIdent(a, b);
+                       break;
+               case T_FuncCall:
+                       retval = _equalFuncCall(a, b);
+                       break;
+               case T_A_Indices:
+                       retval = _equalAIndices(a, b);
+                       break;
+               case T_ResTarget:
+                       retval = _equalResTarget(a, b);
+                       break;
+               case T_TypeCast:
+                       retval = _equalTypeCast(a, b);
+                       break;
+               case T_RelExpr:
+                       retval = _equalRelExpr(a, b);
+                       break;
+               case T_SortGroupBy:
+                       retval = _equalSortGroupBy(a, b);
+                       break;
+               case T_RangeVar:
+                       retval = _equalRangeVar(a, b);
+                       break;
+               case T_TypeName:
+                       retval = _equalTypeName(a, b);
+                       break;
+               case T_IndexElem:
+                       retval = _equalIndexElem(a, b);
+                       break;
+               case T_ColumnDef:
+                       retval = _equalColumnDef(a, b);
+                       break;
+               case T_Constraint:
+                       retval = _equalConstraint(a, b);
+                       break;
+               case T_DefElem:
+                       retval = _equalDefElem(a, b);
+                       break;
                case T_TargetEntry:
                        retval = _equalTargetEntry(a, b);
                        break;
@@ -881,6 +2104,9 @@ equal(void *a, void *b)
                        /* GroupClause is equivalent to SortClause */
                        retval = _equalSortClause(a, b);
                        break;
+               case T_JoinExpr:
+                       retval = _equalJoinExpr(a, b);
+                       break;
                case T_CaseExpr:
                        retval = _equalCaseExpr(a, b);
                        break;
@@ -890,6 +2116,9 @@ equal(void *a, void *b)
                case T_RowMark:
                        retval = _equalRowMark(a, b);
                        break;
+               case T_FkConstraint:
+                       retval = _equalFkConstraint(a, b);
+                       break;
 
                default:
                        elog(NOTICE, "equal: don't know whether nodes of type %d are equal",
index 09f90fe..be6009f 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $Id: analyze.c,v 1.153 2000/08/08 15:42:04 tgl Exp $
+ *     $Id: analyze.c,v 1.154 2000/08/11 23:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1112,13 +1112,13 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 
                        fk_trigger->args = NIL;
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->constr_name);
+                                                                          makeString(fkconstraint->constr_name));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          stmt->relname);
+                                                                          makeString(stmt->relname));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->pktable_name);
+                                                                          makeString(fkconstraint->pktable_name));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->match_type);
+                                                                          makeString(fkconstraint->match_type));
                        fk_attr = fkconstraint->fk_attrs;
                        pk_attr = fkconstraint->pk_attrs;
                        if (length(fk_attr) != length(pk_attr))
@@ -1130,10 +1130,12 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
                        while (fk_attr != NIL)
                        {
                                id = (Ident *) lfirst(fk_attr);
-                               fk_trigger->args = lappend(fk_trigger->args, id->name);
+                               fk_trigger->args = lappend(fk_trigger->args,
+                                                                                  makeString(id->name));
 
                                id = (Ident *) lfirst(pk_attr);
-                               fk_trigger->args = lappend(fk_trigger->args, id->name);
+                               fk_trigger->args = lappend(fk_trigger->args,
+                                                                                  makeString(id->name));
 
                                fk_attr = lnext(fk_attr);
                                pk_attr = lnext(pk_attr);
@@ -1189,22 +1191,24 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 
                        fk_trigger->args = NIL;
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->constr_name);
+                                                                          makeString(fkconstraint->constr_name));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          stmt->relname);
+                                                                          makeString(stmt->relname));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->pktable_name);
+                                                                          makeString(fkconstraint->pktable_name));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->match_type);
+                                                                          makeString(fkconstraint->match_type));
                        fk_attr = fkconstraint->fk_attrs;
                        pk_attr = fkconstraint->pk_attrs;
                        while (fk_attr != NIL)
                        {
                                id = (Ident *) lfirst(fk_attr);
-                               fk_trigger->args = lappend(fk_trigger->args, id->name);
+                               fk_trigger->args = lappend(fk_trigger->args,
+                                                                                  makeString(id->name));
 
                                id = (Ident *) lfirst(pk_attr);
-                               fk_trigger->args = lappend(fk_trigger->args, id->name);
+                               fk_trigger->args = lappend(fk_trigger->args,
+                                                                                  makeString(id->name));
 
                                fk_attr = lnext(fk_attr);
                                pk_attr = lnext(pk_attr);
@@ -1260,22 +1264,24 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
 
                        fk_trigger->args = NIL;
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->constr_name);
+                                                                          makeString(fkconstraint->constr_name));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          stmt->relname);
+                                                                          makeString(stmt->relname));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->pktable_name);
+                                                                          makeString(fkconstraint->pktable_name));
                        fk_trigger->args = lappend(fk_trigger->args,
-                                                                          fkconstraint->match_type);
+                                                                          makeString(fkconstraint->match_type));
                        fk_attr = fkconstraint->fk_attrs;
                        pk_attr = fkconstraint->pk_attrs;
                        while (fk_attr != NIL)
                        {
                                id = (Ident *) lfirst(fk_attr);
-                               fk_trigger->args = lappend(fk_trigger->args, id->name);
+                               fk_trigger->args = lappend(fk_trigger->args,
+                                                                                  makeString(id->name));
 
                                id = (Ident *) lfirst(pk_attr);
-                               fk_trigger->args = lappend(fk_trigger->args, id->name);
+                               fk_trigger->args = lappend(fk_trigger->args,
+                                                                                  makeString(id->name));
 
                                fk_attr = lnext(fk_attr);
                                pk_attr = lnext(pk_attr);
@@ -1662,13 +1668,13 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
 
                                fk_trigger->args = NIL;
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->constr_name);
+                                                                                  makeString(fkconstraint->constr_name));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  stmt->relname);
+                                                                                  makeString(stmt->relname));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->pktable_name);
+                                                                                  makeString(fkconstraint->pktable_name));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->match_type);
+                                                                                  makeString(fkconstraint->match_type));
                                fk_attr = fkconstraint->fk_attrs;
                                pk_attr = fkconstraint->pk_attrs;
                                if (length(fk_attr) != length(pk_attr))
@@ -1680,10 +1686,12 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
                                while (fk_attr != NIL)
                                {
                                        id = (Ident *) lfirst(fk_attr);
-                                       fk_trigger->args = lappend(fk_trigger->args, id->name);
+                                       fk_trigger->args = lappend(fk_trigger->args,
+                                                                                          makeString(id->name));
 
                                        id = (Ident *) lfirst(pk_attr);
-                                       fk_trigger->args = lappend(fk_trigger->args, id->name);
+                                       fk_trigger->args = lappend(fk_trigger->args,
+                                                                                          makeString(id->name));
 
                                        fk_attr = lnext(fk_attr);
                                        pk_attr = lnext(pk_attr);
@@ -1737,22 +1745,24 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
 
                                fk_trigger->args = NIL;
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->constr_name);
+                                                                                  makeString(fkconstraint->constr_name));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  stmt->relname);
+                                                                                  makeString(stmt->relname));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->pktable_name);
+                                                                                  makeString(fkconstraint->pktable_name));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->match_type);
+                                                                                  makeString(fkconstraint->match_type));
                                fk_attr = fkconstraint->fk_attrs;
                                pk_attr = fkconstraint->pk_attrs;
                                while (fk_attr != NIL)
                                {
                                        id = (Ident *) lfirst(fk_attr);
-                                       fk_trigger->args = lappend(fk_trigger->args, id->name);
+                                       fk_trigger->args = lappend(fk_trigger->args,
+                                                                                          makeString(id->name));
 
                                        id = (Ident *) lfirst(pk_attr);
-                                       fk_trigger->args = lappend(fk_trigger->args, id->name);
+                                       fk_trigger->args = lappend(fk_trigger->args,
+                                                                                          makeString(id->name));
 
                                        fk_attr = lnext(fk_attr);
                                        pk_attr = lnext(pk_attr);
@@ -1806,22 +1816,24 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
 
                                fk_trigger->args = NIL;
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->constr_name);
+                                                                                  makeString(fkconstraint->constr_name));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  stmt->relname);
+                                                                                  makeString(stmt->relname));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->pktable_name);
+                                                                                  makeString(fkconstraint->pktable_name));
                                fk_trigger->args = lappend(fk_trigger->args,
-                                                                                  fkconstraint->match_type);
+                                                                                  makeString(fkconstraint->match_type));
                                fk_attr = fkconstraint->fk_attrs;
                                pk_attr = fkconstraint->pk_attrs;
                                while (fk_attr != NIL)
                                {
                                        id = (Ident *) lfirst(fk_attr);
-                                       fk_trigger->args = lappend(fk_trigger->args, id->name);
+                                       fk_trigger->args = lappend(fk_trigger->args,
+                                                                                          makeString(id->name));
 
                                        id = (Ident *) lfirst(pk_attr);
-                                       fk_trigger->args = lappend(fk_trigger->args, id->name);
+                                       fk_trigger->args = lappend(fk_trigger->args,
+                                                                                          makeString(id->name));
 
                                        fk_attr = lnext(fk_attr);
                                        pk_attr = lnext(pk_attr);
index 2ec136a..276afb8 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.184 2000/08/07 20:16:13 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.185 2000/08/11 23:45:27 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -158,7 +158,8 @@ static void doNegateFloat(Value *v);
 
 %type <str>            OptConstrFromTable
 
-%type <str>            TriggerEvents, TriggerFuncArg
+%type <str>            TriggerEvents
+%type <value>  TriggerFuncArg
 
 %type <str>            relation_name, copy_file_name, copy_delimiter, copy_null, def_name,
                database_name, access_method_clause, access_method, attr_name,
@@ -1792,11 +1793,20 @@ TriggerFuncArg:  ICONST
                                {
                                        char buf[64];
                                        sprintf (buf, "%d", $1);
-                                       $$ = pstrdup(buf);
+                                       $$ = makeString(pstrdup(buf));
+                               }
+                       | FCONST
+                               {
+                                       $$ = makeString($1);
+                               }
+                       | Sconst
+                               {
+                                       $$ = makeString($1);
+                               }
+                       | ColId
+                               {
+                                       $$ = makeString($1);
                                }
-                       | FCONST                                                {  $$ = $1; }
-                       | Sconst                                                {  $$ = $1; }
-                       | ColId                                                 {  $$ = $1; }
                ;
 
 OptConstrFromTable:                    /* Empty */
index e87492f..1c9095d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.170 2000/07/17 03:05:14 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.171 2000/08/11 23:45:35 tgl Exp $
  *
  * NOTES
  *       this is the "main" module of the postgres backend and
@@ -417,21 +417,13 @@ pg_parse_and_rewrite(char *query_string,  /* string to execute */
         * trees.  The present (bizarre) implementation of UNION/INTERSECT/EXCEPT
         * doesn't run analysis of the second and later subqueries until rewrite,
         * so we'd get false failures on these queries if we did it beforehand.
-        *
-        * Currently, copyObject doesn't know about most of the utility query
-        * types, so suppress the check until that can be fixed... it should
-        * be fixed, though.
         */
-       if (querytree_list &&
-               ((Query *) lfirst(querytree_list))->commandType != CMD_UTILITY)
-       {
-               new_list = (List *) copyObject(querytree_list);
-               /* This checks both copyObject() and the equal() routines... */
-               if (! equal(new_list, querytree_list))
-                       elog(NOTICE, "pg_parse_and_rewrite: copyObject failed on parse tree");
-               else
-                       querytree_list = new_list;
-       }
+       new_list = (List *) copyObject(querytree_list);
+       /* This checks both copyObject() and the equal() routines... */
+       if (! equal(new_list, querytree_list))
+               elog(NOTICE, "pg_parse_and_rewrite: copyObject failed on parse tree");
+       else
+               querytree_list = new_list;
 #endif
 
        if (Debug_print_rewritten)
@@ -1412,7 +1404,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
        if (!IsUnderPostmaster)
        {
                puts("\nPOSTGRES backend interactive interface ");
-               puts("$Revision: 1.170 $ $Date: 2000/07/17 03:05:14 $\n");
+               puts("$Revision: 1.171 $ $Date: 2000/08/11 23:45:35 $\n");
        }
 
        /*