Re: referential integrity without trigger

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Alexander Presber <aljoscha(at)weisshuhn(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: referential integrity without trigger
Date: 2006-02-09 18:38:32
Message-ID: 20060209103717.D84979@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 9 Feb 2006, Alexander Presber wrote:

> Hello everybody,
>
> Assuming I want to empty and refill table A (with roughly the same
> content, preferrably in one transaction) and don't want to completely
> empty a dependent table B but still keep referential integrity after
> the commit.
>
> Without disabling A's on-delete-trigger B will be be emptied on
> commit, even when I inserted exactly the same data into A that I
> deleted an instant before. That is because the trigger gets called on
> commit, no matter if the deleted rows have "reappeared".
>
> If I disable the trigger, My referential integrity is most likely
> corrupted.
> Is there a clever, general scheme to "recheck" and enforce foreign
> key contraints, after the responsible triggers have been disabled and
> reenabled?

Probably the easiest way to do these things is to drop the constraint
before, do stuff and re-add the constraint since that will check the
constraint at the add constraint time.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Florian Weimer 2006-02-09 18:46:16 Re: Debian Packages For PostgreSQL
Previous Message Harald Fuchs 2006-02-09 18:30:12 Re: referential integrity without trigger