Re: BUG #15458: pg_typeof inconsistency on negative integer constantlimits
От
Andres Freund
Тема
Re: BUG #15458: pg_typeof inconsistency on negative integer constantlimits
Дата
Msg-id
20181024205432.yh2jswtvbhl3x536@alap3.anarazel.de
Ответ на
BUG #15458: pg_typeof inconsistency on negative integer constantlimits (PG Bug reporting form)
Список
Дерево обсуждения
BUG #15458: pg_typeof inconsistency on negative integer constantlimits PG Bug reporting form <noreply@postgresql.org>
Re: BUG #15458: pg_typeof inconsistency on negative integer constantlimits Andres Freund <andres@anarazel.de>
Re: BUG #15458: pg_typeof inconsistency on negative integer constant limits Elvis Pranskevichus <elprans@gmail.com>
Re: BUG #15458: pg_typeof inconsistency on negative integer constantlimits Fabien COELHO <coelho@cri.ensmp.fr>
Re: BUG #15458: pg_typeof inconsistency on negative integer constantlimits Andres Freund <andres@anarazel.de>
Re: BUG #15458: pg_typeof inconsistency on negative integer constant limits Tom Lane <tgl@sss.pgh.pa.us>
Hi, On 2018-10-24 20:47:21 +0000, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 15458 > Logged by: Elvis Pranskevichus > Email address: elprans@gmail.com > PostgreSQL version: 11.0 > Operating system: x86_64-pc-linux-gnu > Description: > > There seems to be an inconsistency in how the parser and the integer input > functions interpret the integers at the negative limit (-2 ^ 31 and -2 ^ > 63): > > > SELECT pg_typeof(-2147483648); > > pg_typeof > ----------- > integer > (1 row) > > But: > > SELECT -2147483648::integer; > ERROR: integer out of range > > The same issue applies to int8 as well. > > PG_INT32_MIN is explicitly defined as -(2 ^ 31 - 1), and it seems > inconsistent that the parser does not respect that when determining the > type of numeric constants. It's just a precedence issue. :: binds with higher precedence, so the above is actually -(2147483648::integer), rather than (-2147483648)::integer. Therefore you get an overflow. Greetings, Andres Freund
В списке pgsql-bugs по дате отправления
От: PG Bug reporting form
Дата:
От: Elvis Pranskevichus
Дата: