Re: Why overlaps is not working - Mailing list pgsql-general

From Tom Lane
Subject Re: Why overlaps is not working
Date
Msg-id 6860.1163083106@sss.pgh.pa.us
Whole thread Raw
In response to Re: Why overlaps is not working  (Alban Hertroys <alban@magproductions.nl>)
List pgsql-general
Alban Hertroys <alban@magproductions.nl> writes:
> They're adjacent, they don't overlap. Check the documentation on
> OVERLAPS, I'm sure it's explicit about whether it is inclusive or
> exclusive (the latter apparently).

It's not very clear, but the spec defines (S1,T1) OVERLAPS (S2,T2)
as

              ( 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 ) )

(for the simple case where there are no nulls and S1 <= T1, S2 <= T2).
So it looks to me like the intervals are actually considered to be
half-open intervals [S1, T1).  Which is something that has its uses,
but it's a bit surprising compared to, say, BETWEEN.

If you don't like it, write your own comparison function ...

            regards, tom lane

pgsql-general by date:

Previous
From: Antonios Katsikadamos
Date:
Subject: posgres headers
Next
From: Adrian Klaver
Date:
Subject: Re: posgres headers