pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Elvis Pranskevichus <elprans@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15458: pg_typeof inconsistency on negative integer constant limits
Date: Wed, 24 Oct 2018 16:58:13 -0400
Message-ID: <7428706.JDTFIi69Ek@hammer.magicstack.net> (raw)
In-Reply-To: <20181024205432.yh2jswtvbhl3x536@alap3.anarazel.de>
References: <15458-632e422e26e19786@postgresql.org>
	<20181024205432.yh2jswtvbhl3x536@alap3.anarazel.de>

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@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.

Ah, you're right.  Sorry for the noise.


                              Elvis






view thread (6+ messages)  latest in thread

Message-ID: <7428706.JDTFIi69Ek@hammer.magicstack.net>
Permalink:  ../7428706.JDTFIi69Ek@hammer.magicstack.net/
Also on:    postgresql.org/message-id/7428706.JDTFIi69Ek@hammer.magicstack.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: elprans@gmail.com, andres@anarazel.de
  Subject: Re: BUG #15458: pg_typeof inconsistency on negative integer constant limits
  In-Reply-To: <7428706.JDTFIi69Ek@hammer.magicstack.net>
  References: <15458-632e422e26e19786@postgresql.org> <20181024205432.yh2jswtvbhl3x536@alap3.anarazel.de> <7428706.JDTFIi69Ek@hammer.magicstack.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox