Re: "two time periods with only an endpoint in common do not overlap" ???

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: "two time periods with only an endpoint in common do not overlap" ???
Date: 2021-10-16 05:23:51
Message-ID: 1031323.1634361831@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron <ronljohnsonjr(at)gmail(dot)com> writes:
> OP refers to the OVERLAP operator (is it an operator), not the tsrange()
> function.

Indeed. SQL92 defines OVERLAP thus:

6) The result of the <overlaps predicate> is the result of the
following expression:

( S1 > S2 AND NOT ( S1 >= T2 AND T1 >= T2 ) )
OR
( S2 > S1 AND NOT ( S2 >= T1 AND T2 >= T1 ) )
OR
( S1 = S2 AND ( T1 <> T2 OR T1 = T2 ) )

where S1 is the smaller of the first range's endpoints and T1 is the
larger; similarly S2/T2 are the smaller/larger of the second range's.
(I gloss over the question of what to do with NULL endpoints; but the
apparent redundancies in the above seem to be meant to define what
happens with NULLs.)

I submit that our description using half-open ranges is clearer than
the spec's. Nonetheless, they're equivalent.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-10-16 05:41:58 Re: "two time periods with only an endpoint in common do not overlap" ???
Previous Message Ron 2021-10-16 04:54:27 Re: "two time periods with only an endpoint in common do not overlap" ???