mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Improve parser error location for cases where an INSERT or UPDATE command
supplies an expression that can't be coerced to the target column type. The code previously attempted to point at the target column name, which doesn't work at all in an INSERT with omitted column name list, and is also not remarkably helpful when the problem is buried somewhere in a long INSERT-multi-VALUES command. Make it point at the failed expression instead.
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.381 2008/10/06 15:15:22 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.382 2008/10/07 01:47:54 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -426,11 +426,15 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
|
||||
exprType((Node *) tle->expr) == UNKNOWNOID)
|
||||
expr = tle->expr;
|
||||
else
|
||||
expr = (Expr *) makeVar(rtr->rtindex,
|
||||
tle->resno,
|
||||
exprType((Node *) tle->expr),
|
||||
exprTypmod((Node *) tle->expr),
|
||||
0);
|
||||
{
|
||||
Var *var = makeVar(rtr->rtindex,
|
||||
tle->resno,
|
||||
exprType((Node *) tle->expr),
|
||||
exprTypmod((Node *) tle->expr),
|
||||
0);
|
||||
var->location = exprLocation((Node *) tle->expr);
|
||||
expr = (Expr *) var;
|
||||
}
|
||||
exprList = lappend(exprList, expr);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user