pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedapparent RI bug
7+ messages / 2 participants
[nested] [flat]
* apparent RI bug
@ 2008-04-02 17:42 chester c young <chestercyoung@yahoo.com>
2008-04-03 17:31 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 1 reply; 7+ messages in thread
From: chester c young @ 2008-04-02 17:42 UTC (permalink / raw)
To: pgsql-sql
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';
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: apparent RI bug
2008-04-02 17:42 apparent RI bug chester c young <chestercyoung@yahoo.com>
@ 2008-04-03 17:31 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 18:13 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
0 siblings, 1 reply; 7+ messages in thread
From: Stephan Szabo @ 2008-04-03 17:31 UTC (permalink / raw)
To: chester c young <chestercyoung@yahoo.com>; +Cc: 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)?
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: apparent RI bug
2008-04-02 17:42 apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 17:31 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
@ 2008-04-03 18:13 ` chester c young <chestercyoung@yahoo.com>
2008-04-03 18:33 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 1 reply; 7+ messages in thread
From: chester c young @ 2008-04-03 18:13 UTC (permalink / raw)
To: Stephan Szabo <sszabo@megazone.bigpanda.com>; +Cc: pgsql-sql
Stephan Szabo <sszabo@megazone.bigpanda.com> wrote:
> On Wed, 2 Apr 2008, chester c young wrote:
>
> > it appears I have a broken RI in my db.
> 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)?
only one error. unable to duplicate so far.
this is a development db - triggers are frequently dropped and created,
but I don't think ever concurrently with db activity.
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: apparent RI bug
2008-04-02 17:42 apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 17:31 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 18:13 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
@ 2008-04-03 18:33 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 20:16 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
0 siblings, 1 reply; 7+ messages in thread
From: Stephan Szabo @ 2008-04-03 18:33 UTC (permalink / raw)
To: chester c young <chestercyoung@yahoo.com>; +Cc: pgsql-sql
On Thu, 3 Apr 2008, chester c young wrote:
>
> Stephan Szabo <sszabo@megazone.bigpanda.com> wrote:
>
> > On Wed, 2 Apr 2008, chester c young wrote:
> >
> > > it appears I have a broken RI in my db.
>
> > 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)?
>
> only one error. unable to duplicate so far.
>
> this is a development db - triggers are frequently dropped and created,
> but I don't think ever concurrently with db activity.
Is it possible you ever had a before delete trigger that just did a return
NULL rather than raising an exception? IIRC, explicitly telling the
system to ignore the delete will work on the referential actions.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: apparent RI bug
2008-04-02 17:42 apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 17:31 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 18:13 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 18:33 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
@ 2008-04-03 20:16 ` chester c young <chestercyoung@yahoo.com>
2008-04-03 20:35 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 1 reply; 7+ messages in thread
From: chester c young @ 2008-04-03 20:16 UTC (permalink / raw)
To: Stephan Szabo <sszabo@megazone.bigpanda.com>; +Cc: pgsql-sql
--- Stephan Szabo <sszabo@megazone.bigpanda.com> wrote:
> Is it possible you ever had a before delete trigger that just did a
> return
> NULL rather than raising an exception? IIRC, explicitly telling the
> system to ignore the delete will work on the referential actions.
yes, it is possible, for example, a function without a body or without
a "return old".
are you saying this would override the RI constraint? if so, is this
by design?
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: apparent RI bug
2008-04-02 17:42 apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 17:31 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 18:13 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 18:33 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 20:16 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
@ 2008-04-03 20:35 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-04 01:53 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
0 siblings, 1 reply; 7+ messages in thread
From: Stephan Szabo @ 2008-04-03 20:35 UTC (permalink / raw)
To: chester c young <chestercyoung@yahoo.com>; +Cc: pgsql-sql
On Thu, 3 Apr 2008, chester c young wrote:
> --- Stephan Szabo <sszabo@megazone.bigpanda.com> wrote:
>
> > Is it possible you ever had a before delete trigger that just did a
> > return
> > NULL rather than raising an exception? IIRC, explicitly telling the
> > system to ignore the delete will work on the referential actions.
>
> yes, it is possible, for example, a function without a body or without
> a "return old".
>
> are you saying this would override the RI constraint?
If it returned something that would have prevented the delete without an
error, yes.
> if so, is this by design?
It's basically an ongoing question (without concensus AFAIK) about whether
a rule or trigger should be allowed to stop the referential action and
what should happen if it does.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: apparent RI bug
2008-04-02 17:42 apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 17:31 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 18:13 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 18:33 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 20:16 ` Re: apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 20:35 ` Re: apparent RI bug Stephan Szabo <sszabo@megazone.bigpanda.com>
@ 2008-04-04 01:53 ` chester c young <chestercyoung@yahoo.com>
0 siblings, 0 replies; 7+ messages in thread
From: chester c young @ 2008-04-04 01:53 UTC (permalink / raw)
To: Stephan Szabo <sszabo@megazone.bigpanda.com>; +Cc: pgsql-sql
--- Stephan Szabo <sszabo@megazone.bigpanda.com> wrote:
> > is it is possible, for example, a function without a body or
> without a "return old".
> >
> > are you saying this would override the RI constraint?
>
> If it returned something that would have prevented the delete without
> an error, yes.
this is very good news that there is a reason why the RI did not work,
which is to say, RI not working randomly is very frightening
> > if so, is this by design?
>
> It's basically an ongoing question (without concensus AFAIK) about
> whether
> a rule or trigger should be allowed to stop the referential action
> and
> what should happen if it does.
in my opinion the most important thing is that it's documented.
btw, cheers! you're my hero of the week!!
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2008-04-04 01:53 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-04-02 17:42 apparent RI bug chester c young <chestercyoung@yahoo.com>
2008-04-03 17:31 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 18:13 ` chester c young <chestercyoung@yahoo.com>
2008-04-03 18:33 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-03 20:16 ` chester c young <chestercyoung@yahoo.com>
2008-04-03 20:35 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2008-04-04 01:53 ` chester c young <chestercyoung@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox