Skip site navigation (1) Skip section navigation (2)

Re: Foreign key constaint can be broken

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Kazemier <mark(dot)kazemier(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Foreign key constaint can be broken
Date: 2010-01-26 15:59:17
Message-ID: 9906.1264521557@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Mark Kazemier <mark(dot)kazemier(at)gmail(dot)com> writes:
> I found a way to break a foreign key constraint in PostgreSQL
> [ ie, make a rule that defeats an ON DELETE CASCADE operation ]

This isn't a bug, it's just the way things work.  Rules (and triggers)
apply to the commands that implement foreign key updates, so a poorly
written rule can make those queries do the wrong thing.  The rule can
make your regular queries do the wrong thing too, so it's not like you'd
be fine if it were done some other way.  There are a number of real
applications that would be broken if rules/triggers *didn't* apply to
FK queries --- for example, using a trigger to implement logging --- so
we've concluded this is the most useful way for it to be done.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: andrew neillDate: 2010-01-26 16:52:55
Subject: BUG #5296: crash when two 'add column' diagrams are open
Previous:From: Kevin GrittnerDate: 2010-01-26 14:55:10
Subject: Re: BUG #5284: Postgres CPU 100% and worker took too long to start; cancelled... Systemdown

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group