Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/02/17 08:39, John McKown wrote:
On Fri, Feb 24, 2017 at 1:25 PM, David G. Johnston <david.g.johnston@xxxxxxxxx <mailto:david.g.johnston@xxxxxxxxx>>wrote:

    On Friday, February 24, 2017, Tom Lane <tgl@xxxxxxxxxxxxx
    <mailto:tgl@xxxxxxxxxxxxx>> wrote:

        Justin Pryzby <pryzby@xxxxxxxxxxxxx> 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.​

[...]

I think the latter would be a good idea!

Cheers,
Gavin


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux