From: | Melvin Davidson <melvin6925(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Chris Lexvold <lexvold(at)telsasoft(dot)com> |
Subject: | Re: SELECT x'00000000F'::int leading zeros causes "integer out of range" |
Date: | 2017-02-24 19:17:15 |
Message-ID: | CANu8Fiw=cBcEdOA4VtXieDY4bswmUyWF7xmA+pgg7QyHp_XwHA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Feb 24, 2017 at 2:13 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Justin Pryzby <pryzby(at)telsasoft(dot)com> writes:
> > Is this expected behavior ?
> > ts=# SELECT x'00000000F'::int;
> > ERROR: 22003: integer out of range
> > LOCATION: bittoint4, varbit.c:1575
>
> Yes. The provided operation is "convert a bitstring of up to 32 bits
> to an integer". It's not "guess whether it's okay to throw away some
> bits to make an integer".
>
> As an example, even if you think it's obvious that it would be okay
> to convert that bitstring to "15", would it be all right to convert
> x'FFFFFFFFF' to "-1" ?
>
> regards, tom lane
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
In addition to what Tom said
SELECT x'00000000F'::bigint;
works just fine.
IOW, int = 4 bytes, while bigint = 8 bytes.
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2017-02-24 19:25:34 | Re: SELECT x'00000000F'::int leading zeros causes "integer out of range" |
Previous Message | Tom Lane | 2017-02-24 19:13:06 | Re: SELECT x'00000000F'::int leading zeros causes "integer out of range" |