pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@postgresql.org
Cc: binoternary@gmail.com
Subject: BUG #14986: -2147483648 is minimum value of integer but -2147483648::integer fails (out of range).
Date: Wed, 20 Dec 2017 12:20:32 +0000
Message-ID: <20171220122032.25740.1219@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      14986
Logged by:          Indrek Loolaid
Email address:      binoternary@gmail.com
PostgreSQL version: 10.1
Operating system:   Ubuntu 16.04.3 LTS
Description:        

Documentation in
https://www.postgresql.org/docs/current/static/datatype-numeric.html states
that the range for integer type is -2147483648 to +2147483647.

However casting the minimum value literal with :: syntax to integer fails
(ERROR:  integer out of range).

postgres=# select version();
                                                    version                 
                                   
----------------------------------------------------------------------------------------------------------------
 PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609, 64-bit
(1 row)


postgres=# select -2147483648::integer;
ERROR:  integer out of range

postgres=# select cast(-2147483648 as integer);
    int4     
-------------
 -2147483648
(1 row)

postgres=# select (select -2147483648)::integer;
  ?column?   
-------------
 -2147483648
(1 row)


The expected outome is that the first query returns the same result as the
other two.
Bigint and smallint types have the same issue.



view thread (8+ messages)  latest in thread

Message-ID: <20171220122032.25740.1219@wrigleys.postgresql.org>
Permalink:  ../20171220122032.25740.1219@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20171220122032.25740.1219@wrigleys.postgresql.org

 · 

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: noreply@postgresql.org, binoternary@gmail.com
  Subject: Re: BUG #14986: -2147483648 is minimum value of integer but -2147483648::integer fails (out of range).
  In-Reply-To: <20171220122032.25740.1219@wrigleys.postgresql.org>
  References: <20171220122032.25740.1219@wrigleys.postgresql.org>

* 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