Re: Bug with int2

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Feng Tian <ftian(at)vitessedata(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug with int2
Date: 2016-02-17 03:46:25
Message-ID: CAB7nPqTkExBp3FE5wBhhoH6QiQ0Cx-GgqcuzZm+SXgxocq6XxA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 17, 2016 at 12:27 PM, Feng Tian <ftian(at)vitessedata(dot)com> wrote:
> ftian=# select -32768::int2;
> ERROR: smallint out of range

But 32768 is not. You should just use parenthesis, a cast does not
take into account the minus sign here:
=# select (-32768)::int2;
int2
--------
-32768
(1 row)
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2016-02-17 03:54:00 Re: Bug with int2
Previous Message Tom Lane 2016-02-17 03:46:06 Re: Bug with int2