mirror of
https://github.com/postgres/postgres.git
synced 2025-05-11 05:41:32 +03:00
Clean up some code that had gotten a bit ugly through repeated revisions.
This commit is contained in:
parent
27a4f06ade
commit
b066d9e4bc
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 *sub_namespace;
|
||||||
List *icolumns;
|
List *icolumns;
|
||||||
List *attrnos;
|
List *attrnos;
|
||||||
List *attnos;
|
List *icols; /* to become ListCell */
|
||||||
|
List *attnos; /* to become ListCell */
|
||||||
List *tl;
|
List *tl;
|
||||||
|
|
||||||
qry->commandType = CMD_INSERT;
|
qry->commandType = CMD_INSERT;
|
||||||
@ -665,39 +666,35 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
|
|||||||
/*
|
/*
|
||||||
* Prepare columns for assignment to target table.
|
* Prepare columns for assignment to target table.
|
||||||
*/
|
*/
|
||||||
|
icols = icolumns;
|
||||||
attnos = attrnos;
|
attnos = attrnos;
|
||||||
/* cannot use foreach here because of possible lremove */
|
foreach(tl, qry->targetList)
|
||||||
tl = qry->targetList;
|
|
||||||
while (tl)
|
|
||||||
{
|
{
|
||||||
TargetEntry *tle = (TargetEntry *) lfirst(tl);
|
TargetEntry *tle = (TargetEntry *) lfirst(tl);
|
||||||
ResTarget *col;
|
ResTarget *col;
|
||||||
|
|
||||||
/* must advance tl before lremove possibly pfree's it */
|
if (icols == NIL || attnos == NIL)
|
||||||
tl = lnext(tl);
|
|
||||||
|
|
||||||
if (icolumns == NIL || attnos == NIL)
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
errmsg("INSERT has more expressions than target columns")));
|
errmsg("INSERT has more expressions than target columns")));
|
||||||
|
|
||||||
col = (ResTarget *) lfirst(icolumns);
|
col = (ResTarget *) lfirst(icols);
|
||||||
Assert(IsA(col, ResTarget));
|
Assert(IsA(col, ResTarget));
|
||||||
|
|
||||||
Assert(!tle->resdom->resjunk);
|
Assert(!tle->resdom->resjunk);
|
||||||
updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
|
updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
|
||||||
col->indirection);
|
col->indirection);
|
||||||
|
|
||||||
icolumns = lnext(icolumns);
|
icols = lnext(icols);
|
||||||
attnos = lnext(attnos);
|
attnos = lnext(attnos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure that the targetlist has the same number of entries that were
|
* 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
|
* 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,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
errmsg("INSERT has more target columns than expressions")));
|
errmsg("INSERT has more target columns than expressions")));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user