| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | 1243111560(at)qq(dot)com |
| Subject: | BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX |
| Date: | 2026-10-18 11:59:47 |
| Message-ID: | 19769-36a284b9d245c7bf@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19769
Logged by: Zhs
Email address: 1243111560(at)qq(dot)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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-10-18 13:58:03 | BUG #19770: CREATE TABLE (LIKE ...) PARTITION BY copies a NO INHERIT not-null constraint; NULLs then go into par |
| Previous Message | Nitin Motiani | 2026-10-18 06:15:28 | Re: BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses |