On Wed, Mar 03, 2004 at 06:27:07PM -0500, Tom Lane wrote:
> Steve Atkins <steve(at)blighty(dot)com> writes:
> >> test=> select -2147483648::int;
> >> ERROR: integer out of range
> There is no bug here. You are mistakenly assuming that the above
> select (-2147483648)::int;
> But actually the :: operator binds more tightly than unary minus,
> so Postgres reads it as
> select -(2147483648::int);
> and quite rightly fails to convert the int8 literal to int.
> If you write it with the correct parenthesization it works:
> regression=# select -2147483648::int;
> ERROR: integer out of range
> regression=# select (-2147483648)::int;
OK... That makes sense if the parser has no support for negative
constants, but it doesn't seem like intuitive behaviour.
BTW, the original issue that led to this was:
db=>CREATE function t(integer) RETURNS integer AS '
' LANGUAGE 'plpgsql';
db=> select t(-2147483648);
ERROR: function t(bigint) does not exist
Which again makes sense considering the way the parser works, but
still seems to violate the principle of least surprise.
In response to
pgsql-bugs by date
|Next:||From: PostgreSQL Bugs List||Date: 2004-03-04 02:08:47|
|Subject: BUG #1091: Localization in EUC_TW Can't decode Big5 0xFA40--0xFEF0.|
|Previous:||From: Tom Lane||Date: 2004-03-03 23:27:07|
|Subject: Re: Integer parsing bug? |