pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX
2+ messages / 2 participants
[nested] [flat]

* BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX
@ 2026-10-18 11:59 PG Bug reporting form <noreply@postgresql.org>
  2026-10-19 16:44 ` Re: BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2026-10-18 11:59 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: 1243111560@qq.com

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.








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX
  2026-10-18 11:59 BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX PG Bug reporting form <noreply@postgresql.org>
@ 2026-10-19 16:44 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-10-19 16:44 UTC (permalink / raw)
  To: 1243111560@qq.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> 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).

The same thing happens with int4range:

regression=# select '[2147483647,2147483647]'::int4range;
ERROR:  integer out of range

and with other range types.

> 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.

I think your expectation is mistaken.  The documentation is quite
clear that we normalize [x,y] to [x,y+1).

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-10-19 16:44 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-18 11:59 BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX PG Bug reporting form <noreply@postgresql.org>
2026-10-19 16:44 ` Tom Lane <tgl@sss.pgh.pa.us>

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