From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dino Maric <dinom@hey.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Confusion about the range types
Date: Sat, 07 Jan 2023 11:13:06 -0500
Message-ID: <3452152.1673107986@sss.pgh.pa.us> (raw)
In-Reply-To: <d1bbdc3da826051cc37efc1094673a2357ace614@hey.com>
References: <d1bbdc3da826051cc37efc1094673a2357ace614@hey.com>
Dino Maric <dinom@hey.com> writes:
> When I insert range like this:
> INSERT INTO public.tests
> VALUES (int4range(7,8,'[]'))
> After when querying table my return value for this column is not [7,8]
> but it is [7,9).
> I found this behaviour confusing, because I want to insert 7-8 ranges
> (including upper value) and then present that range to a user.
This is the effect of canonicalization, as explained here:
https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-DISCRETE
If you don't like it you can make a range type with a different
canonicalization function, or no such function, but that might
have odd effects on the behavior of range comparison operators.
regards, tom lane
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: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, dinom@hey.com, pgsql-bugs@lists.postgresql.org
Subject: Re: Confusion about the range types
In-Reply-To: <3452152.1673107986@sss.pgh.pa.us>
* 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