Re: Ranges for well-ordered types

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Michael Glaesemann <grzm(at)seespotcode(dot)net>
Cc: Ian Caulfield <ian(dot)caulfield(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Ranges for well-ordered types
Date: 2006-06-10 17:39:30
Message-ID: EB6C7C08-A436-4BC3-AF79-ECD76DCB14A1@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Jun 11, 2006, at 2:34 , Michael Glaesemann wrote:

>
> On Jun 11, 2006, at 0:54 , Ian Caulfield wrote:
>
>> I've done similar date range things by creating a composite type
>> consisting of the lower and upper bounds, and then implementing a
>> btree opclass where the comparator returns 0 if two ranges overlap
>> - this allows a current btree index to enforce non-overlapping
>> ranges, and allows indexed lookup of which range contains a
>> particular value.
>
> As Tom already pointed out, this method leads to problems with
> btree indexes. I haven't heavily tested my own implementation
> (below), but it only returns 0 for equality, which is what btree
> expects. All other possible relationships between two ranges have a
> well-defined result of -1 or 1. I believe this should be enough to
> prevent any transitivity issues with btree.

Of course, this method doesn't provide the non-overlapping
constraint. That still needs to be handled by a constraint trigger.

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-06-10 17:48:24 Re: [PATCHES] ADD/DROP INHERITS
Previous Message Michael Glaesemann 2006-06-10 17:34:31 Re: Ranges for well-ordered types