Commit d63e05a6 authored by Tom Lane's avatar Tom Lane

Improve error message wording in unary_op_error() --- suggest that

problem could be lack of parentheses.  This addresses cases like
X UserOp UserOp Y, which will be parsed as (X UserOp) UserOp Y,
whereas what likely was wanted was X UserOp (UserOp Y).
parent f91dd788
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.37 2000/03/11 23:17:47 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.38 2000/03/18 19:53:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -703,18 +703,14 @@ op_error(char *op, Oid arg1, Oid arg2) ...@@ -703,18 +703,14 @@ op_error(char *op, Oid arg1, Oid arg2)
if (typeidIsValid(arg1)) if (typeidIsValid(arg1))
tp1 = typeidType(arg1); tp1 = typeidType(arg1);
else else
{
elog(ERROR, "Left hand side of operator '%s' has an unknown type" elog(ERROR, "Left hand side of operator '%s' has an unknown type"
"\n\tProbably a bad attribute name", op); "\n\tProbably a bad attribute name", op);
}
if (typeidIsValid(arg2)) if (typeidIsValid(arg2))
tp2 = typeidType(arg2); tp2 = typeidType(arg2);
else else
{
elog(ERROR, "Right hand side of operator %s has an unknown type" elog(ERROR, "Right hand side of operator %s has an unknown type"
"\n\tProbably a bad attribute name", op); "\n\tProbably a bad attribute name", op);
}
elog(ERROR, "Unable to identify an operator '%s' for types '%s' and '%s'" elog(ERROR, "Unable to identify an operator '%s' for types '%s' and '%s'"
"\n\tYou will have to retype this query using an explicit cast", "\n\tYou will have to retype this query using an explicit cast",
...@@ -741,7 +737,7 @@ unary_op_error(char *op, Oid arg, bool is_left_op) ...@@ -741,7 +737,7 @@ unary_op_error(char *op, Oid arg, bool is_left_op)
} }
elog(ERROR, "Unable to identify a %s operator '%s' for type '%s'" elog(ERROR, "Unable to identify a %s operator '%s' for type '%s'"
"\n\tYou will have to retype this query using an explicit cast", "\n\tYou may need to add parentheses or an explicit cast",
(is_left_op ? "left" : "right"), (is_left_op ? "left" : "right"),
op, typeTypeName(tp1)); op, typeTypeName(tp1));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment