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

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Chris Lexvold <lexvold(at)telsasoft(dot)com>
Subject: SELECT x'00000000F'::int leading zeros causes "integer out of range"
Date: 2017-02-24 19:02:48
Message-ID: 20170224190248.GA26240@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is this expected behavior ?

This works:

ts=# SELECT x'0000000F'::int;
int4|15

.. but an additional leading zero causes it to fail:

ts=# SELECT x'00000000F'::int;
ERROR: 22003: integer out of range
LOCATION: bittoint4, varbit.c:1575

|/* Check that the bit string is not too long */
|if (VARBITLEN(arg) > sizeof(result) * BITS_PER_BYTE)
| ereport(ERROR,
| (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
| errmsg("integer out of range")));

Justin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-02-24 19:13:06 Re: SELECT x'00000000F'::int leading zeros causes "integer out of range"
Previous Message kbrannen 2017-02-24 18:03:36 Re: Postgres HA