Re: Constraint exclusion with box and integer - Mailing list pgsql-general

From Jeff Davis
Subject Re: Constraint exclusion with box and integer
Date
Msg-id 1295644315.23146.4.camel@jdavis-ux.asterdata.local
Whole thread Raw
In response to Constraint exclusion with box and integer  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Responses Re: Constraint exclusion with box and integer  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List pgsql-general
On Fri, 2011-01-21 at 18:36 +0000, Daniele Varrazzo wrote:
> => alter table commission_rate add constraint check_overlapping
> exclude using gist (payer_id with =, box( point(extract(epoch from
> start_date), extract(epoch from start_date)),
> point(coalesce(extract(epoch from end_date), 'infinity'),
> coalesce(extract(epoch from end_date),'infinity') ) ) with &&);
> ERROR:  data type integer has no default operator class for access method "gist"
> HINT:  You must specify an operator class for the index or define a
> default operator class for the data type.
>
> Can I build a constraint check using both a box (for the range) and an
> integer (for a fkey) or should I go back to the classic trigger + lock
> solution?

Install btree_gist, and this should work.

Exclusion constraints are enforced with an index, and an index can only
have one index access method (btree, gist, etc.). So you need to have
one index access method that works for both "=" on integers and "&&" on
boxes.

There's no hope of making a btree work for "&&" on boxes, so we need to
make gist work for "=" on integers.

Regards,
    Jeff Davis


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Large object corruption during 'piped' pg_restore
Next
From: MargaretGillon@chromalloy.com
Date:
Subject: Re: pg_dumpall backup script w. ftp ; pgpass file ; after upgrade to Ubuntu 10.4 (lucid) and Postgresql 9.0.2