From: | "Joel Jacobson" <joel(at)compiler(dot)org> |
---|---|
To: | "Isaac Morland" <isaac(dot)morland(at)gmail(dot)com> |
Cc: | "Mark Dilger" <mark(dot)dilger(at)enterprisedb(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Postgres hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Jeff Davis" <pgsql(at)j-davis(dot)com> |
Subject: | Re: [PATCH] Support empty ranges with bounds information |
Date: | 2021-03-04 18:05:09 |
Message-ID: | 527d7f28-8508-404b-b3b0-3314ca3d11bc@www.fastmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Mar 4, 2021, at 16:21, Isaac Morland wrote:
> On Thu, 4 Mar 2021 at 01:25, Joel Jacobson <joel(at)compiler(dot)org> wrote:
>
>> __
>> Suggestion #1: Use [] as the canonical form for discrete types.
>> This would allow creating ranges for all values for discrete types.
>
> I won't reiterate here, but there are fundamental reasons why [) is definitely the right default and canonical form.
It would be interesting to hear the reasons.
For discrete types, there are only exact values, there is nothing in between two adjacent discrete values.
So if we mean a range covering only the integer 5, why can't we just say [5,5] which simply means "5"?
Why is it necessary to express it as [5,6) which I interpret as the much more complex "all integers from 5 up until just before the integer 6".
We know for sure nothing can exist after 5 before 6, it's void, so why is it necessary to be explicit about including this space which we know can't contain any values?
For discrete types, we wouldn't even need the inclusive/exclusive features at all.
>
> In any case, you can create a range containing the last value:
>
> odyssey=> select 2147483647 <@ int4range (0, null);
> ?column?
> ----------
> t
> (1 row)
>
> odyssey=>
>
> It does seem reasonable to me to change it so that specifying the last value as the right end with ] would use a null endpoint instead of producing an error when it tries to increment the bound.
Neat hack, thanks.
/Joel
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-03-04 18:11:19 | Re: Increase value of OUTER_VAR |
Previous Message | Andres Freund | 2021-03-04 17:56:50 | Re: buildfarm windows checks / tap tests on windows |