From: | Elvis Pranskevichus <elprans(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #15458: pg_typeof inconsistency on negative integer constant limits |
Date: | 2018-10-24 20:58:13 |
Message-ID: | 7428706.JDTFIi69Ek@hammer.magicstack.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Wednesday, October 24, 2018 4:54:32 PM EDT Andres Freund wrote:
> 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(at)gmail(dot)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.
Ah, you're right. Sorry for the noise.
Elvis
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Banck | 2018-10-24 23:00:29 | Re: BUG #15448: server process (PID 22656) was terminated by exception 0xC0000005 |
Previous Message | Andres Freund | 2018-10-24 20:54:32 | Re: BUG #15458: pg_typeof inconsistency on negative integer constant limits |