Re: SELECT x'00000000F'::int leading zeros causes "integer out of range"

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(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:25:34
Message-ID: CAKFQuwaF9wkNeZ=C1mnKwyC60m9_Z5bSAVQLjXui5=dkvFxAmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday, February 24, 2017, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Justin Pryzby <pryzby(at)telsasoft(dot)com <javascript:;>> 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".
>
>
IME The error message itself is to blame here - we are checking for a
malformed (too many characters) integer varbit representation but then
reporting that the we somehow got a valid integer but that it is "out of
range".

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John McKown 2017-02-24 19:39:18 Re: SELECT x'00000000F'::int leading zeros causes "integer out of range"
Previous Message Melvin Davidson 2017-02-24 19:17:15 Re: SELECT x'00000000F'::int leading zeros causes "integer out of range"