Search Postgresql Archives

Re: unique index for periods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gerhard Heift <ml-postgresql-20081012-3518@xxxxxxxxx> writes:
> I try to create an unique index for a (time)period, and my goal is to
> prevent two overlapping periods in a row.

> To use the btree index I added a compare function:

>    return
>       CASE
>          WHEN $1.next <= $2.first THEN -1
>          WHEN $2.next <= $1.first THEN 1
>          ELSE 0
>       END;

This does not work as a btree compare function, because it fails to
satisfy the basic requirements of a total order.  In particular it
doesn't satisfy the transitive law that A=B and B=C must imply A=C.

I don't believe it is possible to use a btree index for this purpose,
because there just isn't a way to express "overlaps" as a total order.
It'd be really nice to have uniqueness support in gist indexes someday
...

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux