diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-19 15:08:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-19 15:08:47 +0000 |
commit | 6ebc90b0455ffe9dc0bcaf85185b2746008003f6 (patch) | |
tree | ac89e57df60a93047eb69e28074556c0c9acdb6f | |
parent | 10b374aecfb50365eeb93e3434a77729d7a89541 (diff) | |
download | postgresql-6ebc90b0455ffe9dc0bcaf85185b2746008003f6.tar.gz postgresql-6ebc90b0455ffe9dc0bcaf85185b2746008003f6.zip |
Remove Ident nodetype in favor of using String nodes; this fixes some
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.
-rw-r--r-- | src/backend/commands/copy.c | 4 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 47 | ||||
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 40 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 37 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 33 | ||||
-rw-r--r-- | src/backend/parser/analyze.c | 104 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 6 | ||||
-rw-r--r-- | src/backend/parser/parse_target.c | 5 | ||||
-rw-r--r-- | src/include/nodes/nodes.h | 6 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 18 | ||||
-rw-r--r-- | src/include/nodes/relation.h | 40 |
11 files changed, 73 insertions, 267 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index afe08a74a69..2751fe01d9e 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -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 */ diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 72ecd6d0ce4..c6e8d686d41 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -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); } diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 59bc6895235..4153bb73af8 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -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; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 60b6d2d3b16..9990a046229 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -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 */ @@ -1557,15 +1537,6 @@ _equalAConst(A_Const *a, A_Const *b) } static bool -_equalIdent(Ident *a, Ident *b) -{ - if (!equalstr(a->name, b->name)) - return false; - - return true; -} - -static bool _equalFuncCall(FuncCall *a, FuncCall *b) { if (!equal(a->funcname, b->funcname)) @@ -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; diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 70419cb9ace..1a610b7c7c0 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -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 @@ -1258,24 +1258,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) { appendStringInfo(str, " AEXPR "); @@ -1372,13 +1354,6 @@ _outParamRef(StringInfo str, ParamRef *node) } static void -_outIdent(StringInfo str, Ident *node) -{ - appendStringInfo(str, " IDENT "); - _outToken(str, node->name); -} - -static void _outAConst(StringInfo str, A_Const *node) { appendStringInfo(str, "CONST "); @@ -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; diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index e3d8ce070bc..94a367885e3 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -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); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index a56f7d41b99..80aa372f9c5 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -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); } ; diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 6f5b5bab90b..26983c48cf1 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -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)); diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 0e3922ec37a..f3437ce4cbf 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -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, diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 14d4126bbed..ecf59f30c10 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -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 $ * *------------------------------------------------------------------------- */ @@ -288,17 +288,6 @@ typedef struct ColumnDef } 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 * * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct @@ -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; /* ---------- diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 8715ad36c58..26c465fd037 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -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 */ |