Re: Need help writing exclusion constraint

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Need help writing exclusion constraint
Date: 2011-01-18 19:31:01
Message-ID: 1295379061.22206.21.camel@jdavis-ux.asterdata.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2011-01-15 at 21:32 +0100, Tomas Vondra wrote:
> > ALTER TABLE event ADD CONSTRAINT event_overlap
> > CHECK(overlap_at_dest(destination_id, starts, ends));
>
> There's a race condition

...

> One way to fix this is locking

I do not recommend locking. In fact, the primary reason that exclusion
constraints exist is to prevent unnecessary locking for problems exactly
like this.

I included some links in my other reply that demonstrate how to avoid
that excessive locking while still being safe from race conditions.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-01-18 19:34:23 Re: Getting a sample data set.
Previous Message Jeff Davis 2011-01-18 19:29:09 Re: Need help writing exclusion constraint