Re: Confusion about the range types - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Confusion about the range types
Date
Msg-id 3452152.1673107986@sss.pgh.pa.us
Whole thread Raw
In response to Confusion about the range types  (Dino Maric <dinom@hey.com>)
Responses Re: Confusion about the range types  (Dino Maric <dinom@hey.com>)
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: Dino Maric
Date:
Subject: Confusion about the range types
Next
From: Dino Maric
Date:
Subject: Re: Confusion about the range types