| From: | Max Khon <mkhon(at)swsoft(dot)com> |
|---|---|
| To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: ON DELETE CASCADE with multiple paths |
| Date: | 2007-05-21 08:55:04 |
| Message-ID: | 46515E68.9040806@swsoft.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Stephan Szabo wrote:
> On Thu, 17 May 2007, Tom Lane wrote:
>
>> Max Khon <mkhon(at)swsoft(dot)com> writes:
>>> "delete from foo" fails:
>>> ERROR: update or delete on table "bar" violates foreign key constraint
>>> "foobar_fk0" on table "foobar"
>>> SQL state: 23503
>>> Detail: Key (bar_id)=(1) is still referenced from table "foobar".
>>> Context: SQL statement "DELETE FROM ONLY "public"."bar" WHERE "foo_id" = $1"
>> I see no bug here. There is no guarantee about the order in which
>> constraints are applied.
>
> Except that SQL92 at least does seem to say in 11.8 that "All rows that
> are marked for deletion are effectively deleted at the end of the
> SQL-statement, prior to the checking of any integrity constraints." I
> think that likely makes our behavior wrong, but I'm not really sure how to
> get there from what we have now.
Is it sufficient to execute ON DELETE CASCADE and ON DELETE SET
NULL/DEFAULT triggers before other triggers?
Attached patch solves the problem for me.
--
Max Khon
PEM Platform Team Leader
SWsoft, Inc.
E-mail: mkhon(at)swsoft(dot)com
Web Site: http://swsoft.com/
| Attachment | Content-Type | Size |
|---|---|---|
| patch-src-backend-commands-trigger.c | text/plain | 1.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zdenek Kotala | 2007-05-21 11:46:41 | Re: BUG #3291: Query tool not returning all results |
| Previous Message | Tom Lane | 2007-05-20 17:45:55 | Re: Fwd: Bug#425125: postgresql-8.1: localhost does not work for unix sockets in ~/.pgpass |