aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-04-02 21:05:32 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-04-02 21:05:32 +0000
commitb066d9e4bc34bf1159d6ec4f459cd2a24426510d (patch)
treee19c1114943f9271b7d27b20a00ce714f424da4a /src
parent27a4f06adee023d9172abaf128e35e3cc068108a (diff)
downloadpostgresql-b066d9e4bc34bf1159d6ec4f459cd2a24426510d.tar.gz
postgresql-b066d9e4bc34bf1159d6ec4f459cd2a24426510d.zip
Clean up some code that had gotten a bit ugly through repeated revisions.
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/analyze.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 75f4f65d78a..2330bf18d43 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.297 2004/01/23 02:13:12 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.298 2004/04/02 21:05:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -506,7 +506,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
List *sub_namespace;
List *icolumns;
List *attrnos;
- List *attnos;
+ List *icols; /* to become ListCell */
+ List *attnos; /* to become ListCell */
List *tl;
qry->commandType = CMD_INSERT;
@@ -665,39 +666,35 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
/*
* Prepare columns for assignment to target table.
*/
+ icols = icolumns;
attnos = attrnos;
- /* cannot use foreach here because of possible lremove */
- tl = qry->targetList;
- while (tl)
+ foreach(tl, qry->targetList)
{
TargetEntry *tle = (TargetEntry *) lfirst(tl);
ResTarget *col;
- /* must advance tl before lremove possibly pfree's it */
- tl = lnext(tl);
-
- if (icolumns == NIL || attnos == NIL)
+ if (icols == NIL || attnos == NIL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("INSERT has more expressions than target columns")));
- col = (ResTarget *) lfirst(icolumns);
+ col = (ResTarget *) lfirst(icols);
Assert(IsA(col, ResTarget));
Assert(!tle->resdom->resjunk);
updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
col->indirection);
- icolumns = lnext(icolumns);
+ icols = lnext(icols);
attnos = lnext(attnos);
}
/*
* Ensure that the targetlist has the same number of entries that were
* present in the columns list. Don't do the check unless an explicit
- * columns list was given, though. statements.
+ * columns list was given, though.
*/
- if (stmt->cols != NIL && (icolumns != NIL || attnos != NIL))
+ if (stmt->cols != NIL && (icols != NIL || attnos != NIL))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("INSERT has more target columns than expressions")));