public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: [email protected] <[email protected]>
To: [email protected] <[email protected]>
Subject: Re: BUG #19472: CAST(-32768::SMALLINT AS REAL) fails with "SMALLINT out of range" but -32768 is valid SMALLINT value
Date: Wed, 6 May 2026 05:53:58 -0700
Message-ID: <CAKFQuwY95Rsw=P4a+=NJijCTY=+AmV2W7OEF2T14BiQo4S9i4w@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Wednesday, May 6, 2026, PG Bug reporting form <[email protected]>
wrote:
> The following bug has been logged on the website:
>
> Bug reference: 19472
> Logged by: Pisces Mar.
> Email address: [email protected]
> PostgreSQL version: 17.6
> Operating system: x86_64-windows
> Description:
>
> Issue Description:
> When casting -32768 to SMALLINT and then to REAL using the :: operator,
> PostgreSQL throws an error "smallint out of range", even though -32768 is a
> valid value within the SMALLINT range (-32768 to +32767).
>
> Workaround:
> Use parentheses: SELECT CAST((-32768) :: SMALLINT AS REAL);
> Or use standard CAST syntax: SELECT CAST(-32768 AS SMALLINT);
>
These aren’t really workarounds; this is just how you need to write the
expression given our long-established and not going to change operator
precedence and literal syntax parsing rules.
David J.
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: BUG #19472: CAST(-32768::SMALLINT AS REAL) fails with "SMALLINT out of range" but -32768 is valid SMALLINT value
In-Reply-To: <CAKFQuwY95Rsw=P4a+=NJijCTY=+AmV2W7OEF2T14BiQo4S9i4w@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox