]> granicus.if.org Git - postgresql/commitdiff
Remove Ident nodetype in favor of using String nodes; this fixes some
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 19 Aug 2002 15:08:47 +0000 (15:08 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 19 Aug 2002 15:08:47 +0000 (15:08 +0000)
latent wrong-struct-type bugs and makes the coding style more uniform,
since the majority of places working with lists of column names were
already using Strings not Idents.  While at it, remove vestigial
support for Stream node type, and otherwise-unreferenced nodes.h entries
for T_TupleCount and T_BaseNode.
NB: full recompile is recommended due to changes of Node type numbers.
This shouldn't force an initdb though.

src/backend/commands/copy.c
src/backend/commands/tablecmds.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/parser/parse_target.c
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/nodes/relation.h

index afe08a74a697639ddf095b8d64eda12810fe7734..2751fe01d9e5ae26cb05e9ce10f03f3381f49e23 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.164 2002/08/19 00:40:14 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.165 2002/08/19 15:08:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1513,7 +1513,7 @@ CopyGetAttnums(Relation rel, List *attnamelist)
 
                foreach(l, attnamelist)
                {
-                       char       *name = ((Ident *) lfirst(l))->name;
+                       char       *name = strVal(lfirst(l));
                        int                     attnum;
 
                        /* Lookup column name, elog on failure */
index 72ecd6d0ce4e1c83c3d9fbd56fd411ab67a47bc7..c6e8d686d41e61ea44e9b3ba82f02a08bc6913e3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.29 2002/08/15 16:36:02 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.30 2002/08/19 15:08:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2677,17 +2677,17 @@ validateForeignKeyConstraint(FkConstraint *fkconstraint,
        count = 4;
        foreach(list, fkconstraint->fk_attrs)
        {
-               Ident      *fk_at = lfirst(list);
+               char       *fk_at = strVal(lfirst(list));
 
-               trig.tgargs[count] = fk_at->name;
+               trig.tgargs[count] = fk_at;
                count += 2;
        }
        count = 5;
        foreach(list, fkconstraint->pk_attrs)
        {
-               Ident      *pk_at = lfirst(list);
+               char       *pk_at = strVal(lfirst(list));
 
-               trig.tgargs[count] = pk_at->name;
+               trig.tgargs[count] = pk_at;
                count += 2;
        }
        trig.tgnargs = count - 1;
@@ -2746,13 +2746,13 @@ createForeignKeyConstraint(Relation rel, Relation pkrel,
        i = 0;
        foreach(l, fkconstraint->fk_attrs)
        {
-               Ident *id = (Ident *) lfirst(l);
+               char *id = strVal(lfirst(l));
                AttrNumber      attno;
 
-               attno = get_attnum(RelationGetRelid(rel), id->name);
+               attno = get_attnum(RelationGetRelid(rel), id);
                if (attno == InvalidAttrNumber)
                        elog(ERROR, "Relation \"%s\" has no column \"%s\"",
-                                RelationGetRelationName(rel), id->name);
+                                RelationGetRelationName(rel), id);
                fkattr[i++] = attno;
        }
 
@@ -2762,13 +2762,13 @@ createForeignKeyConstraint(Relation rel, Relation pkrel,
        i = 0;
        foreach(l, fkconstraint->pk_attrs)
        {
-               Ident *id = (Ident *) lfirst(l);
+               char *id = strVal(lfirst(l));
                AttrNumber      attno;
 
-               attno = get_attnum(RelationGetRelid(pkrel), id->name);
+               attno = get_attnum(RelationGetRelid(pkrel), id);
                if (attno == InvalidAttrNumber)
                        elog(ERROR, "Relation \"%s\" has no column \"%s\"",
-                                RelationGetRelationName(pkrel), id->name);
+                                RelationGetRelationName(pkrel), id);
                pkattr[i++] = attno;
        }
 
@@ -2804,7 +2804,6 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint,
        CreateTrigStmt *fk_trigger;
        List       *fk_attr;
        List       *pk_attr;
-       Ident      *id;
        ObjectAddress trigobj,
                                constrobj;
 
@@ -2867,12 +2866,8 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint,
 
        while (fk_attr != NIL)
        {
-               id = (Ident *) lfirst(fk_attr);
-               fk_trigger->args = lappend(fk_trigger->args, makeString(id->name));
-
-               id = (Ident *) lfirst(pk_attr);
-               fk_trigger->args = lappend(fk_trigger->args, makeString(id->name));
-
+               fk_trigger->args = lappend(fk_trigger->args, lfirst(fk_attr));
+               fk_trigger->args = lappend(fk_trigger->args, lfirst(pk_attr));
                fk_attr = lnext(fk_attr);
                pk_attr = lnext(pk_attr);
        }
@@ -2942,12 +2937,8 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint,
        pk_attr = fkconstraint->pk_attrs;
        while (fk_attr != NIL)
        {
-               id = (Ident *) lfirst(fk_attr);
-               fk_trigger->args = lappend(fk_trigger->args, makeString(id->name));
-
-               id = (Ident *) lfirst(pk_attr);
-               fk_trigger->args = lappend(fk_trigger->args, makeString(id->name));
-
+               fk_trigger->args = lappend(fk_trigger->args, lfirst(fk_attr));
+               fk_trigger->args = lappend(fk_trigger->args, lfirst(pk_attr));
                fk_attr = lnext(fk_attr);
                pk_attr = lnext(pk_attr);
        }
@@ -3017,12 +3008,8 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint,
        pk_attr = fkconstraint->pk_attrs;
        while (fk_attr != NIL)
        {
-               id = (Ident *) lfirst(fk_attr);
-               fk_trigger->args = lappend(fk_trigger->args, makeString(id->name));
-
-               id = (Ident *) lfirst(pk_attr);
-               fk_trigger->args = lappend(fk_trigger->args, makeString(id->name));
-
+               fk_trigger->args = lappend(fk_trigger->args, lfirst(fk_attr));
+               fk_trigger->args = lappend(fk_trigger->args, lfirst(pk_attr));
                fk_attr = lnext(fk_attr);
                pk_attr = lnext(pk_attr);
        }
index 59bc689523511359fab2c95d3836d3bb59383bb4..4153bb73af8a7b391f1415c1f1c9e6de9a0020d4 100644 (file)
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.203 2002/08/19 00:40:14 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.204 2002/08/19 15:08:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1435,28 +1435,6 @@ _copyJoinInfo(JoinInfo *from)
        return newnode;
 }
 
-static Stream *
-_copyStream(Stream *from)
-{
-       Stream     *newnode = makeNode(Stream);
-
-       newnode->pathptr = from->pathptr;
-       newnode->cinfo = from->cinfo;
-       newnode->clausetype = from->clausetype;
-
-       newnode->upstream = (StreamPtr) NULL;           /* only copy nodes
-                                                                                                * downwards! */
-       Node_Copy(from, newnode, downstream);
-       if (newnode->downstream)
-               ((Stream *) newnode->downstream)->upstream = (Stream *) newnode;
-
-       newnode->groupup = from->groupup;
-       newnode->groupcost = from->groupcost;
-       newnode->groupsel = from->groupsel;
-
-       return newnode;
-}
-
 /* ****************************************************************
  *                                     parsenodes.h copy functions
  * ****************************************************************
@@ -1593,16 +1571,6 @@ _copyAConst(A_Const *from)
        return newnode;
 }
 
-static Ident *
-_copyIdent(Ident *from)
-{
-       Ident      *newnode = makeNode(Ident);
-
-       newnode->name = pstrdup(from->name);
-
-       return newnode;
-}
-
 static FuncCall *
 _copyFuncCall(FuncCall *from)
 {
@@ -2890,9 +2858,6 @@ copyObject(void *from)
                case T_JoinInfo:
                        retval = _copyJoinInfo(from);
                        break;
-               case T_Stream:
-                       retval = _copyStream(from);
-                       break;
                case T_IndexOptInfo:
                        retval = _copyIndexOptInfo(from);
                        break;
@@ -3131,9 +3096,6 @@ copyObject(void *from)
                case T_A_Const:
                        retval = _copyAConst(from);
                        break;
-               case T_Ident:
-                       retval = _copyIdent(from);
-                       break;
                case T_FuncCall:
                        retval = _copyFuncCall(from);
                        break;
index 60b6d2d3b160a6ed5cef52419af35366a2db64fa..9990a04622980f845cf210be68ca6f59c4a31a50 100644 (file)
@@ -20,7 +20,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.152 2002/08/19 00:40:14 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.153 2002/08/19 15:08:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -543,26 +543,6 @@ _equalJoinInfo(JoinInfo *a, JoinInfo *b)
        return true;
 }
 
-static bool
-_equalStream(Stream *a, Stream *b)
-{
-       if (a->clausetype != b->clausetype)
-               return false;
-       if (a->groupup != b->groupup)
-               return false;
-       if (a->groupcost != b->groupcost)
-               return false;
-       if (a->groupsel != b->groupsel)
-               return false;
-       if (!equal(a->pathptr, b->pathptr))
-               return false;
-       if (!equal(a->cinfo, b->cinfo))
-               return false;
-       if (!equal(a->upstream, b->upstream))
-               return false;
-       return equal(a->downstream, b->downstream);
-}
-
 /*
  * Stuff from parsenodes.h
  */
@@ -1556,15 +1536,6 @@ _equalAConst(A_Const *a, A_Const *b)
        return true;
 }
 
-static bool
-_equalIdent(Ident *a, Ident *b)
-{
-       if (!equalstr(a->name, b->name))
-               return false;
-
-       return true;
-}
-
 static bool
 _equalFuncCall(FuncCall *a, FuncCall *b)
 {
@@ -2045,9 +2016,6 @@ equal(void *a, void *b)
                case T_JoinInfo:
                        retval = _equalJoinInfo(a, b);
                        break;
-               case T_Stream:
-                       retval = _equalStream(a, b);
-                       break;
                case T_TidPath:
                        retval = _equalTidPath(a, b);
                        break;
@@ -2290,9 +2258,6 @@ equal(void *a, void *b)
                case T_A_Const:
                        retval = _equalAConst(a, b);
                        break;
-               case T_Ident:
-                       retval = _equalIdent(a, b);
-                       break;
                case T_FuncCall:
                        retval = _equalFuncCall(a, b);
                        break;
index 70419cb9ace93ad73e5099464830a5434f6b7867..1a610b7c7c0a04e7bc97381b11fccc845ade0770 100644 (file)
@@ -5,7 +5,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.167 2002/08/10 20:44:48 momjian Exp $
+ *     $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.168 2002/08/19 15:08:46 tgl Exp $
  *
  * NOTES
  *       Every (plan) node in POSTGRES has an associated "out" routine which
@@ -1257,24 +1257,6 @@ _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
        }
 }
 
-static void
-_outStream(StringInfo str, Stream *node)
-{
-       appendStringInfo(str,
-         " STREAM :pathptr @ %p :cinfo @ %p :clausetype %p :upstream @ %p ",
-                                        node->pathptr,
-                                        node->cinfo,
-                                        node->clausetype,
-                                        node->upstream);
-
-       appendStringInfo(str,
-                        " :downstream @ %p :groupup %d :groupcost %f :groupsel %f ",
-                                        node->downstream,
-                                        node->groupup,
-                                        node->groupcost,
-                                        node->groupsel);
-}
-
 static void
 _outAExpr(StringInfo str, A_Expr *node)
 {
@@ -1371,13 +1353,6 @@ _outParamRef(StringInfo str, ParamRef *node)
        _outNode(str, node->indirection);
 }
 
-static void
-_outIdent(StringInfo str, Ident *node)
-{
-       appendStringInfo(str, " IDENT ");
-       _outToken(str, node->name);
-}
-
 static void
 _outAConst(StringInfo str, A_Const *node)
 {
@@ -1736,9 +1711,6 @@ _outNode(StringInfo str, void *obj)
                        case T_JoinInfo:
                                _outJoinInfo(str, obj);
                                break;
-                       case T_Stream:
-                               _outStream(str, obj);
-                               break;
                        case T_A_Expr:
                                _outAExpr(str, obj);
                                break;
@@ -1751,9 +1723,6 @@ _outNode(StringInfo str, void *obj)
                        case T_ParamRef:
                                _outParamRef(str, obj);
                                break;
-                       case T_Ident:
-                               _outIdent(str, obj);
-                               break;
                        case T_A_Const:
                                _outAConst(str, obj);
                                break;
index e3d8ce070bc4f2530174897bff414a255a995af4..94a367885e34fe700a276acff540adfd9cc73672 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.240 2002/08/02 18:15:06 tgl Exp $
+ *     $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.241 2002/08/19 15:08:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -238,17 +238,14 @@ transformStmt(ParseState *pstate, Node *parseTree,
                                        {
                                                TargetEntry *te = (TargetEntry *) lfirst(targetList);
                                                Resdom     *rd;
-                                               Ident      *id;
 
                                                Assert(IsA(te, TargetEntry));
                                                rd = te->resdom;
                                                Assert(IsA(rd, Resdom));
-                                               if (rd->resjunk)                /* junk columns don't get
-                                                                                                * aliases */
+                                               /* junk columns don't get aliases */
+                                               if (rd->resjunk)
                                                        continue;
-                                               id = (Ident *) lfirst(aliaslist);
-                                               Assert(IsA(id, Ident));
-                                               rd->resname = pstrdup(id->name);
+                                               rd->resname = pstrdup(strVal(lfirst(aliaslist)));
                                                aliaslist = lnext(aliaslist);
                                                if (aliaslist == NIL)
                                                        break;          /* done assigning aliases */
@@ -788,7 +785,6 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
        bool            saw_nullable;
        Constraint *constraint;
        List       *clist;
-       Ident      *key;
 
        cxt->columns = lappend(cxt->columns, column);
 
@@ -901,17 +897,14 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
 
                /*
                 * If this column constraint is a FOREIGN KEY constraint, then we
-                * fill in the current attributes name and throw it into the list
+                * fill in the current attribute's name and throw it into the list
                 * of FK constraints to be processed later.
                 */
                if (IsA(constraint, FkConstraint))
                {
                        FkConstraint *fkconstraint = (FkConstraint *) constraint;
-                       Ident      *id = makeNode(Ident);
-
-                       id->name = column->colname;
-                       fkconstraint->fk_attrs = makeList1(id);
 
+                       fkconstraint->fk_attrs = makeList1(makeString(column->colname));
                        cxt->fkconstraints = lappend(cxt->fkconstraints, fkconstraint);
                        continue;
                }
@@ -923,7 +916,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
                        case CONSTR_NULL:
                                if (saw_nullable && column->is_not_null)
                                        elog(ERROR, "%s/(NOT) NULL conflicting declaration for '%s.%s'",
-                                                cxt->stmtType, (cxt->relation)->relname, column->colname);
+                                                cxt->stmtType, cxt->relation->relname, column->colname);
                                column->is_not_null = FALSE;
                                saw_nullable = true;
                                break;
@@ -931,7 +924,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
                        case CONSTR_NOTNULL:
                                if (saw_nullable && !column->is_not_null)
                                        elog(ERROR, "%s/(NOT) NULL conflicting declaration for '%s.%s'",
-                                                cxt->stmtType, (cxt->relation)->relname, column->colname);
+                                                cxt->stmtType, cxt->relation->relname, column->colname);
                                column->is_not_null = TRUE;
                                saw_nullable = true;
                                break;
@@ -939,42 +932,34 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
                        case CONSTR_DEFAULT:
                                if (column->raw_default != NULL)
                                        elog(ERROR, "%s/DEFAULT multiple values specified for '%s.%s'",
-                                                cxt->stmtType, (cxt->relation)->relname, column->colname);
+                                                cxt->stmtType, cxt->relation->relname, column->colname);
                                column->raw_default = constraint->raw_expr;
                                Assert(constraint->cooked_expr == NULL);
                                break;
 
                        case CONSTR_PRIMARY:
                                if (constraint->name == NULL)
-                                       constraint->name = makeObjectName((cxt->relation)->relname,
+                                       constraint->name = makeObjectName(cxt->relation->relname,
                                                                                                          NULL,
                                                                                                          "pkey");
                                if (constraint->keys == NIL)
-                               {
-                                       key = makeNode(Ident);
-                                       key->name = pstrdup(column->colname);
-                                       constraint->keys = makeList1(key);
-                               }
+                                       constraint->keys = makeList1(makeString(column->colname));
                                cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
                                break;
 
                        case CONSTR_UNIQUE:
                                if (constraint->name == NULL)
-                                       constraint->name = makeObjectName((cxt->relation)->relname,
+                                       constraint->name = makeObjectName(cxt->relation->relname,
                                                                                                          column->colname,
                                                                                                          "key");
                                if (constraint->keys == NIL)
-                               {
-                                       key = makeNode(Ident);
-                                       key->name = pstrdup(column->colname);
-                                       constraint->keys = makeList1(key);
-                               }
+                                       constraint->keys = makeList1(makeString(column->colname));
                                cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
                                break;
 
                        case CONSTR_CHECK:
                                if (constraint->name == NULL)
-                                       constraint->name = makeObjectName((cxt->relation)->relname,
+                                       constraint->name = makeObjectName(cxt->relation->relname,
                                                                                                          column->colname,
                                                                                                          NULL);
                                cxt->ckconstraints = lappend(cxt->ckconstraints, constraint);
@@ -1002,7 +987,7 @@ transformTableConstraint(ParseState *pstate, CreateStmtContext *cxt,
        {
                case CONSTR_PRIMARY:
                        if (constraint->name == NULL)
-                               constraint->name = makeObjectName((cxt->relation)->relname,
+                               constraint->name = makeObjectName(cxt->relation->relname,
                                                                                                  NULL,
                                                                                                  "pkey");
                        cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
@@ -1069,7 +1054,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                 relationHasPrimaryKey(cxt->relOid)))
                                elog(ERROR, "%s / PRIMARY KEY multiple primary keys"
                                         " for table '%s' are not allowed",
-                                        cxt->stmtType, (cxt->relation)->relname);
+                                        cxt->stmtType, cxt->relation->relname);
                        cxt->pkey = index;
                }
                index->isconstraint = true;
@@ -1077,7 +1062,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
                if (constraint->name != NULL)
                        index->idxname = pstrdup(constraint->name);
                else if (constraint->contype == CONSTR_PRIMARY)
-                       index->idxname = makeObjectName((cxt->relation)->relname, NULL, "pkey");
+                       index->idxname = makeObjectName(cxt->relation->relname, NULL, "pkey");
                else
                        index->idxname = NULL;          /* will set it later */
 
@@ -1092,16 +1077,15 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
                 */
                foreach(keys, constraint->keys)
                {
-                       Ident      *key = (Ident *) lfirst(keys);
+                       char       *key = strVal(lfirst(keys));
                        bool            found = false;
 
-                       Assert(IsA(key, Ident));
                        column = NULL;
                        foreach(columns, cxt->columns)
                        {
                                column = lfirst(columns);
                                Assert(IsA(column, ColumnDef));
-                               if (strcmp(column->colname, key->name) == 0)
+                               if (strcmp(column->colname, key) == 0)
                                {
                                        found = true;
                                        break;
@@ -1113,7 +1097,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                if (constraint->contype == CONSTR_PRIMARY)
                                        column->is_not_null = TRUE;
                        }
-                       else if (SystemAttributeByName(key->name, cxt->hasoids) != NULL)
+                       else if (SystemAttributeByName(key, cxt->hasoids) != NULL)
                        {
                                /*
                                 * column will be a system column in the new table, so
@@ -1145,7 +1129,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
 
                                                if (inhattr->attisdropped)
                                                        continue;
-                                               if (strcmp(key->name, inhname) == 0)
+                                               if (strcmp(key, inhname) == 0)
                                                {
                                                        found = true;
 
@@ -1180,7 +1164,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                /* ALTER TABLE case: does column already exist? */
                                HeapTuple       atttuple;
 
-                               atttuple = SearchSysCacheAttName(cxt->relOid, key->name);
+                               atttuple = SearchSysCacheAttName(cxt->relOid, key);
                                if (HeapTupleIsValid(atttuple))
                                {
                                        found = true;
@@ -1192,28 +1176,28 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                        if (constraint->contype == CONSTR_PRIMARY &&
                                                !((Form_pg_attribute) GETSTRUCT(atttuple))->attnotnull)
                                                elog(ERROR, "Existing attribute \"%s\" cannot be a PRIMARY KEY because it is not marked NOT NULL",
-                                                        key->name);
+                                                        key);
                                        ReleaseSysCache(atttuple);
                                }
                        }
 
                        if (!found)
                                elog(ERROR, "%s: column \"%s\" named in key does not exist",
-                                        cxt->stmtType, key->name);
+                                        cxt->stmtType, key);
 
                        /* Check for PRIMARY KEY(foo, foo) */
                        foreach(columns, index->indexParams)
                        {
                                iparam = (IndexElem *) lfirst(columns);
-                               if (iparam->name && strcmp(key->name, iparam->name) == 0)
+                               if (iparam->name && strcmp(key, iparam->name) == 0)
                                        elog(ERROR, "%s: column \"%s\" appears twice in %s constraint",
-                                                cxt->stmtType, key->name,
+                                                cxt->stmtType, key,
                                                 index->primary ? "PRIMARY KEY" : "UNIQUE");
                        }
 
                        /* OK, add it to the index definition */
                        iparam = makeNode(IndexElem);
-                       iparam->name = pstrdup(key->name);
+                       iparam->name = pstrdup(key);
                        iparam->funcname = NIL;
                        iparam->args = NIL;
                        iparam->opclass = NIL;
@@ -1338,13 +1322,12 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt)
                attnum = 0;
                foreach(fkattrs, fkconstraint->fk_attrs)
                {
-                       Ident      *fkattr = lfirst(fkattrs);
+                       char       *fkattr = strVal(lfirst(fkattrs));
 
                        if (attnum >= INDEX_MAX_KEYS)
                                elog(ERROR, "Can only have %d keys in a foreign key",
                                         INDEX_MAX_KEYS);
-                       fktypoid[attnum++] = transformFkeyGetColType(cxt,
-                                                                                                                fkattr->name);
+                       fktypoid[attnum++] = transformFkeyGetColType(cxt, fkattr);
                }
 
                /*
@@ -1353,7 +1336,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt)
                 */
                if (fkconstraint->pk_attrs == NIL)
                {
-                       if (strcmp(fkconstraint->pktable->relname, (cxt->relation)->relname) != 0)
+                       if (strcmp(fkconstraint->pktable->relname, cxt->relation->relname) != 0)
                                transformFkeyGetPrimaryKey(fkconstraint, pktypoid);
                        else if (cxt->pkey != NULL)
                        {
@@ -1364,17 +1347,16 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                foreach(attr, cxt->pkey->indexParams)
                                {
                                        IndexElem  *ielem = lfirst(attr);
-                                       Ident      *pkattr = (Ident *) makeNode(Ident);
+                                       char       *iname = ielem->name;
 
-                                       Assert(ielem->name); /* no func index here */
-                                       pkattr->name = pstrdup(ielem->name);
+                                       Assert(iname); /* no func index here */
                                        fkconstraint->pk_attrs = lappend(fkconstraint->pk_attrs,
-                                                                                                        pkattr);
+                                                                                                        makeString(iname));
                                        if (attnum >= INDEX_MAX_KEYS)
                                                elog(ERROR, "Can only have %d keys in a foreign key",
                                                         INDEX_MAX_KEYS);
                                        pktypoid[attnum++] = transformFkeyGetColType(cxt,
-                                                                                                                       ielem->name);
+                                                                                                                                iname);
                                }
                        }
                        else
@@ -1390,7 +1372,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt)
                else
                {
                        /* Validate the specified referenced key list */
-                       if (strcmp(fkconstraint->pktable->relname, (cxt->relation)->relname) != 0)
+                       if (strcmp(fkconstraint->pktable->relname, cxt->relation->relname) != 0)
                                transformFkeyCheckAttrs(fkconstraint, pktypoid);
                        else
                        {
@@ -1411,7 +1393,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                        attnum = 0;
                                        foreach(pkattrs, fkconstraint->pk_attrs)
                                        {
-                                               Ident      *pkattr = lfirst(pkattrs);
+                                               char       *pkattr = strVal(lfirst(pkattrs));
                                                List       *indparms;
 
                                                found = false;
@@ -1420,7 +1402,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                                        IndexElem  *indparm = lfirst(indparms);
 
                                                        if (indparm->name &&
-                                                               strcmp(indparm->name, pkattr->name) == 0)
+                                                               strcmp(indparm->name, pkattr) == 0)
                                                        {
                                                                found = true;
                                                                break;
@@ -1432,7 +1414,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt)
                                                        elog(ERROR, "Can only have %d keys in a foreign key",
                                                                 INDEX_MAX_KEYS);
                                                pktypoid[attnum++] = transformFkeyGetColType(cxt,
-                                                                                                                  pkattr->name);
+                                                                                                                                        pkattr);
                                        }
                                        if (found)
                                                break;
@@ -2621,7 +2603,7 @@ transformFkeyCheckAttrs(FkConstraint *fkconstraint, Oid *pktypoid)
 
                                foreach(attrl, fkconstraint->pk_attrs)
                                {
-                                       Ident      *attr = lfirst(attrl);
+                                       char       *attrname = strVal(lfirst(attrl));
 
                                        found = false;
                                        for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0; i++)
@@ -2629,7 +2611,7 @@ transformFkeyCheckAttrs(FkConstraint *fkconstraint, Oid *pktypoid)
                                                int                     pkattno = indexStruct->indkey[i];
 
                                                if (namestrcmp(attnumAttName(pkrel, pkattno),
-                                                                          attr->name) == 0)
+                                                                          attrname) == 0)
                                                {
                                                        pktypoid[attnum++] = attnumTypeId(pkrel, pkattno);
                                                        found = true;
@@ -2720,12 +2702,10 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint, Oid *pktypoid)
        for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0; i++)
        {
                int                     pkattno = indexStruct->indkey[i];
-               Ident      *pkattr = makeNode(Ident);
 
-               pkattr->name = pstrdup(NameStr(*attnumAttName(pkrel, pkattno)));
                pktypoid[attnum++] = attnumTypeId(pkrel, pkattno);
-
-               fkconstraint->pk_attrs = lappend(fkconstraint->pk_attrs, pkattr);
+               fkconstraint->pk_attrs = lappend(fkconstraint->pk_attrs,
+                                                                                makeString(pstrdup(NameStr(*attnumAttName(pkrel, pkattno)))));
        }
 
        ReleaseSysCache(indexTuple);
index a56f7d41b99b30a3df9740d8340f30ce3108f46f..80aa372f9c572f21faf6685010506a10ffddfa54 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.359 2002/08/15 16:36:03 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.360 2002/08/19 15:08:47 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -1724,9 +1724,7 @@ columnList:
 
 columnElem: ColId
                                {
-                                       Ident *id = makeNode(Ident);
-                                       id->name = $1;
-                                       $$ = (Node *)id;
+                                       $$ = (Node *) makeString($1);
                                }
                ;
 
index 6f5b5bab90b8bd1e23244d260647c2bbc4d39e32..26983c48cf1a00bfdfaf82c8e305072bf83bb085 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.87 2002/08/08 01:44:31 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.88 2002/08/19 15:08:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -501,9 +501,6 @@ FigureColnameInternal(Node *node, char **name)
 
        switch (nodeTag(node))
        {
-               case T_Ident:
-                       *name = ((Ident *) node)->name;
-                       return 2;
                case T_ColumnRef:
                        {
                                char     *cname = strVal(llast(((ColumnRef *) node)->fields));
index 0e3922ec37ade569950520726be8be1b556f3838..f3437ce4cbf66adf1df958b2e9799aac0217292f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodes.h,v 1.115 2002/08/15 16:36:07 momjian Exp $
+ * $Id: nodes.h,v 1.116 2002/08/19 15:08:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -85,7 +85,6 @@ typedef enum NodeTag
        T_PathKeyItem,
        T_RestrictInfo,
        T_JoinInfo,
-       T_Stream,
        T_IndexOptInfo,
 
        /*
@@ -93,13 +92,11 @@ typedef enum NodeTag
         */
        T_IndexInfo = 300,
        T_ResultRelInfo,
-       T_TupleCount,
        T_TupleTableSlot,
        T_ExprContext,
        T_ProjectionInfo,
        T_JunkFilter,
        T_EState,
-       T_BaseNode,
        T_CommonState,
        T_ResultState,
        T_AppendState,
@@ -207,7 +204,6 @@ typedef enum NodeTag
        T_A_Expr = 700,
        T_ColumnRef,
        T_ParamRef,
-       T_Ident,
        T_A_Const,
        T_FuncCall,
        T_A_Indices,
index 14d4126bbed9d4ceea06826933d1b5ea068df167..ecf59f30c10536dd695c737e50bffd08b52d8c7b 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parsenodes.h,v 1.200 2002/08/19 00:40:15 tgl Exp $
+ * $Id: parsenodes.h,v 1.201 2002/08/19 15:08:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -287,17 +287,6 @@ typedef struct ColumnDef
        RangeVar   *support;            /* supporting relation, if any */
 } ColumnDef;
 
-/*
- * Ident -
- *       an unqualified identifier.  This is currently used only in the context
- *       of column name lists.
- */
-typedef struct Ident
-{
-       NodeTag         type;
-       char       *name;                       /* its name */
-} Ident;
-
 /*
  * FuncCall - a function or aggregate invocation
  *
@@ -869,7 +858,8 @@ typedef struct CopyStmt
 {
        NodeTag         type;
        RangeVar   *relation;           /* the relation to copy */
-       List       *attlist;            /* List of Ident nodes, or NIL for all */
+       List       *attlist;            /* List of column names (as Strings),
+                                                                * or NIL for all columns */
        bool            is_from;                /* TO or FROM */
        char       *filename;           /* if NULL, use stdin/stdout */
        List       *options;            /* List of DefElem nodes */
@@ -936,7 +926,7 @@ typedef struct Constraint
        char       *name;                       /* name, or NULL if unnamed */
        Node       *raw_expr;           /* expr, as untransformed parse tree */
        char       *cooked_expr;        /* expr, as nodeToString representation */
-       List       *keys;                       /* Ident nodes naming referenced column(s) */
+       List       *keys;                       /* String nodes naming referenced column(s) */
 } Constraint;
 
 /* ----------
index 8715ad36c586d8be70fa22177f5373dadcf2bacb..26c465fd03740c488994823e578fa753da1d426a 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: relation.h,v 1.65 2002/06/20 20:29:51 momjian Exp $
+ * $Id: relation.h,v 1.66 2002/08/19 15:08:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -603,42 +603,4 @@ typedef struct JoinInfo
        List       *jinfo_restrictinfo;         /* relevant RestrictInfos */
 } JoinInfo;
 
-/*
- *     Stream:
- *     A stream represents a root-to-leaf path in a plan tree (i.e. a tree of
- *     JoinPaths and Paths).  The stream includes pointers to all Path nodes,
- *     as well as to any clauses that reside above Path nodes. This structure
- *     is used to make Path nodes and clauses look similar, so that Predicate
- *     Migration can run.
- *
- *     XXX currently, Predicate Migration is dead code, and so is this node type.
- *     Probably should remove support for it.
- *
- *     pathptr -- pointer to the current path node
- *     cinfo -- if NULL, this stream node referes to the path node.
- *                       Otherwise this is a pointer to the current clause.
- *     clausetype -- whether cinfo is in loc_restrictinfo or pathinfo in the
- *                       path node (XXX this is now used only by dead code, which is
- *                       good because the distinction no longer exists...)
- *     upstream -- linked list pointer upwards
- *     downstream -- ditto, downwards
- *     groupup -- whether or not this node is in a group with the node upstream
- *     groupcost -- total cost of the group that node is in
- *     groupsel -- total selectivity of the group that node is in
- */
-typedef struct Stream *StreamPtr;
-
-typedef struct Stream
-{
-       NodeTag         type;
-       Path       *pathptr;
-       RestrictInfo *cinfo;
-       int                *clausetype;
-       StreamPtr       upstream;
-       StreamPtr       downstream;
-       bool            groupup;
-       Cost            groupcost;
-       Selectivity groupsel;
-} Stream;
-
 #endif   /* RELATION_H */