Re: Integer parsing bug?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Integer parsing bug?
Дата
Msg-id 19111.1078356427@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Integer parsing bug?  (Steve Atkins <steve@blighty.com>)
Ответы Re: Integer parsing bug?  (Steve Atkins <steve@blighty.com>)
Список pgsql-bugs
Steve Atkins <steve@blighty.com> writes:
>> test=> select -2147483648::int;
>> ERROR:  integer out of range

There is no bug here.  You are mistakenly assuming that the above
represents
    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;
    int4
-------------
 -2147483648
(1 row)


            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Suresh Babu.A.G"
Дата:
Сообщение: Re: BUG #1090: initdb does not work
Следующее
От: Steve Atkins
Дата:
Сообщение: Re: Integer parsing bug?