Re: Disable and enable of table and column constraints

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christopher Browne <cbbrowne(at)ca(dot)afilias(dot)info>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Disable and enable of table and column constraints
Date: 2009-09-10 20:24:15
Message-ID: 4AA9606F.2070200@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9/10/2009 11:06 AM, Tom Lane wrote:
> Christopher Browne <cbbrowne(at)ca(dot)afilias(dot)info> writes:
>> With the ALTER TABLE DISABLE TRIGGER functionality added in 8.3, we
>> already have the ability to do this with foreign key constraints.
>
> That "feature" is a crock that should not be extended, because it
> leaves it entirely on the user's shoulders whether the constraint
> is actually true when the system thinks it is. What is being discussed
> here is ways to incrementally add real, proven-valid constraints.
>
> (Indeed, given the thought that's being given to having the planner
> assume that FK constraints hold, I rather think that we need to
> reconsider ALTER DISABLE TRIGGER.)

The feature was originally intended to be a clean way of avoiding
interferences of triggers and/or foreign keys with replication systems
that work on the user level (like Bucardo, Londiste and Slony). The only
way to break foreign keys in that scenario is to replicate a referencing
table without replicating the corresponding PK table.

Note that Slony-I currently does apply updates in a fashion that would
actually make checking of foreign keys on the replica possible, but does
need the ability to disable regular user triggers. But for some future
version of Slony, we may need to change that and apply changes within
one replication group (SYNC) out of order with respect to multiple
tables. Which means that Slony would need at least some mechanism to
disable user triggers and force all foreign key constraints to be
deferred, whether they are declared deferrable or not.

Jan

--
Anyone who trades liberty for security deserves neither
liberty nor security. -- Benjamin Franklin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2009-09-10 20:32:58 Re: RfD: more powerful "any" types
Previous Message Pavel Stehule 2009-09-10 20:23:25 Re: RfD: more powerful "any" types