From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 1243111560@qq.com
Subject: BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX
Date: Sun, 18 Oct 2026 11:59:47 +0000
Message-ID: <19769-36a284b9d245c7bf@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19769
Logged by: Zhs
Email address: 1243111560@qq.com
PostgreSQL version: 14.24
Operating system: Windows x64
Description:
Reproduced on PostgreSQL 14.24 and PostgreSQL 14.20 on Windows x64.
The following call fails, even though both bounds are valid bigint values
and the requested range represents the singleton set containing the maximum
bigint value (9223372036854775807).
An equivalent representation over the bigint domain can be constructed with
an unbounded upper bound: [9223372036854775807,). This control range
contains BIGINT_MAX and does not contain BIGINT_MAX - 1.
The PostgreSQL range documentation describes int8range as a discrete range
type whose canonical form is lower-inclusive and upper-exclusive ([)). Based
on this behavior, I expected the singleton range to be accepted and
represented equivalently rather than raising an out-of-range error.
How to repeat
SELECT version();
-- This raises an error:
SELECT int8range(
'9223372036854775807'::bigint,
'9223372036854775807'::bigint,
'[]'
);
-- Control: this succeeds and represents the same set over bigint values.
SELECT
int8range('9223372036854775807'::bigint, NULL, '[)') AS control_range,
int8range('9223372036854775807'::bigint, NULL, '[)')
@> '9223372036854775807'::bigint AS contains_max,
int8range('9223372036854775807'::bigint, NULL, '[)')
@> '9223372036854775806'::bigint AS contains_max_minus_one;
Actual result
The first int8range() call fails with:
ERROR: bigint out of range
SQLSTATE: 22003
The control query succeeds and returns:
control_range: [9223372036854775807,)
contains_max: true
contains_max_minus_one: false
Expected result
The first call should succeed and return a range equivalent to the singleton
set {9223372036854775807}. The control range demonstrates an equivalent
representation over the bigint domain.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, 1243111560@qq.com
Subject: Re: BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX
In-Reply-To: <19769-36a284b9d245c7bf@postgresql.org>
References: <19769-36a284b9d245c7bf@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox