Re: apparent RI bug

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: chester c young <chestercyoung(at)yahoo(dot)com>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: apparent RI bug
Date: 2008-04-03 17:31:19
Message-ID: 20080403102340.B14656@megazone.bigpanda.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 2 Apr 2008, chester c young wrote:

> it appears I have a broken RI in my db.
>
> call_individual.clh_id references call_household.clh_id
>
> \d call_individual
> ...
> Foreign-key constraints:
> "call_individual_clh_id_fkey" FOREIGN KEY (clh_id) REFERENCES
> call_household(clh_id) ON DELETE CASCADE
>
> however:
> development=# select clh_id from call_individual cli where not exists(
> select 1 from call_household clh where clh.clh_id=cli.clh_id );
> clh_id
> --------
> 14691
>
> should not matter, but call_individual has a pre-delete trigger that
> simply raises an exception to prevent deletions:
> raise exception 'calls may not be deleted';

Yeah, that looks pretty broken. Can you reproduce this from a clean start
repeatedly or is this a one off? Do you ever turn off triggers, perhaps by
modifying the pg_class row's reltriggers (I'd guess the answer is no, but
it'd be good to make sure)?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Shane Ambler 2008-04-03 17:35:31 Re: connections between servers
Previous Message Marcin Krawczyk 2008-04-03 17:00:26 connections between servers