mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
Deliver better error message when a relation name is used in an expression.
Per report from Ian Barwick.
This commit is contained in:
parent
6c08905d4c
commit
a8a820668a
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.137 2002/12/12 20:35:13 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.138 2002/12/27 20:06:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -934,6 +934,7 @@ exprType(Node *expr)
|
|||||||
if (!qtree || !IsA(qtree, Query))
|
if (!qtree || !IsA(qtree, Query))
|
||||||
elog(ERROR, "exprType: Cannot get type for untransformed sublink");
|
elog(ERROR, "exprType: Cannot get type for untransformed sublink");
|
||||||
tent = (TargetEntry *) lfirst(qtree->targetList);
|
tent = (TargetEntry *) lfirst(qtree->targetList);
|
||||||
|
Assert(IsA(tent, TargetEntry));
|
||||||
type = tent->resdom->restype;
|
type = tent->resdom->restype;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -967,6 +968,16 @@ exprType(Node *expr)
|
|||||||
case T_ConstraintTestValue:
|
case T_ConstraintTestValue:
|
||||||
type = ((ConstraintTestValue *) expr)->typeId;
|
type = ((ConstraintTestValue *) expr)->typeId;
|
||||||
break;
|
break;
|
||||||
|
case T_RangeVar:
|
||||||
|
/*
|
||||||
|
* If someone uses a bare relation name in an expression,
|
||||||
|
* we will likely first notice a problem here (see comments in
|
||||||
|
* transformColumnRef()). Issue an appropriate error message.
|
||||||
|
*/
|
||||||
|
elog(ERROR, "Relation reference \"%s\" cannot be used in an expression",
|
||||||
|
((RangeVar *) expr)->relname);
|
||||||
|
type = InvalidOid; /* keep compiler quiet */
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
elog(ERROR, "exprType: Do not know how to get type for %d node",
|
elog(ERROR, "exprType: Do not know how to get type for %d node",
|
||||||
nodeTag(expr));
|
nodeTag(expr));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user