Thread: BUG #6192: Incorrect result from operator "overlaps"

BUG #6192: Incorrect result from operator "overlaps"

From
"Incorrect result from operator "overlaps""
Date:
The following bug has been logged online:

Bug reference:      6192
Logged by:          Incorrect result from operator "overlaps"
Email address:      wolfmoon@o2.pl
PostgreSQL version: 9.0.4
Operating system:   Debian/Sid
Description:        Incorrect result from operator "overlaps"
Details:

SELECT ('2011-08-31'::date,'2011-08-31'::date) overlaps
('2011-08-1'::date,'2011-08-31'::date);
Returns false, should return true.

SELECT ('2011-08-31'::date,'2011-08-31'::date) overlaps
('2011-08-1'::date,'2011-09-1'::date);
Returns true, as it should.

SELECT ('2011-08-31'::date,'2011-08-31'::date) overlaps
('2011-08-31'::date,'2011-09-1'::date);
Returns true, as it should.

Tested in versions 8.3.14, 8.4.7 and 9.0.4.

Re: BUG #6192: Incorrect result from operator "overlaps"

From
Vik Reykja
Date:
On Thu, Sep 1, 2011 at 10:27, Incorrect result from operator <wolfmoon@o2.pl
> wrote:

>
> SELECT ('2011-08-31'::date,'2011-08-31'::date) overlaps
> ('2011-08-1'::date,'2011-08-31'::date);
> Returns false, should return true.
>

According to the documentation, it should return false.

"Each time period is considered to represent the half-open interval start <=
time < end, unless start and end are equal in which case it represents that
single time instant. This means for instance that two time periods with only
an endpoint in common do not overlap."

http://www.postgresql.org/docs/current/static/functions-datetime.html

Re: BUG #6192: Incorrect result from operator "overlaps"

From
Tom Lane
Date:
"Incorrect result from operator "overlaps"" <wolfmoon@o2.pl> writes:
> SELECT ('2011-08-31'::date,'2011-08-31'::date) overlaps
> ('2011-08-1'::date,'2011-08-31'::date);
> Returns false, should return true.

This is correct per SQL standard.  The spec is written such that an
interval is considered half-open, ie ['2011-08-01', '2011-08-31').
So that does not overlap the point '2011-08-31'.

            regards, tom lane