Re: [GENERAL] SELECT x'00000000F'::int leading zeros causes "integerout of range" - Mailing list pgsql-general

From John McKown
Subject Re: [GENERAL] SELECT x'00000000F'::int leading zeros causes "integerout of range"
Date
Msg-id CAAJSdjjQ=TWS+R3jeEvtXR-ZKxG-0Qew9rvjO7pOCYV85wtLNA@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] SELECT x'00000000F'::int leading zeros causes "integerout of range"  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: [GENERAL] SELECT x'00000000F'::int leading zeros causes "integerout of range"  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
List pgsql-general
On Fri, Feb 24, 2017 at 1:25 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Friday, February 24, 2017, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Justin Pryzby <pryzby@telsasoft.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".


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

​A better reply would be good. Another possibility is for the parser to remove unneeded leading zeros.​

 

David J.



--
"Irrigation of the land with seawater desalinated by fusion power is ancient. It's called 'rain'." -- Michael McClary, in alt.fusion

Maranatha! <><
John McKown

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: [GENERAL] SELECT x'00000000F'::int leading zeros causes "integerout of range"
Next
From: Gavin Flower
Date:
Subject: Re: [GENERAL] SELECT x'00000000F'::int leading zeros causes "integerout of range"