BUG #3627: Triple FK with ON DELETE SET NULL makes DELETE fail - Mailing list pgsql-bugs

From Pedro Gimeno
Subject BUG #3627: Triple FK with ON DELETE SET NULL makes DELETE fail
Date
Msg-id 200709232215.l8NMFcpg038592@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #3627: Triple FK with ON DELETE SET NULL makes DELETE fail  ("Heikki Linnakangas" <heikki@enterprisedb.com>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      3627
Logged by:          Pedro Gimeno
Email address:      pgsql-001@personal.formauri.es
PostgreSQL version: 8.2.4
Operating system:   Linux (Debian stable + backports)
Description:        Triple FK with ON DELETE SET NULL makes DELETE fail
Details:

In the following script:

-- begin script
create database test1;
\c test1

create table t1 (id integer not null primary key);

create table t2 (id integer not null primary key,
  f1 integer references t1(id) on delete set null,
  f2 integer references t1(id) on delete set null,
  f3 integer references t1(id) on delete set null);

insert into t1 values (1);
insert into t1 values (2);
insert into t2 values (3,1,1,1);
insert into t2 values (4,2,2,2);
delete from t1 where id=1;
-- end script

the last delete results in the following error:

ERROR: insert or update on table "t2" violates foreign key constraint
"t2_f3_fkey"
DETAIL: Key (f3)=(1) is not present in table "t1".
CONTEXT: SQL statement "UPDATE ONLY "public"."t2" SET "f2" = NULL WHERE "f2"
= $1"

-- Pedro Gimeno

pgsql-bugs by date:

Previous
From: Herouth Maoz
Date:
Subject: Re: BUG #3616: PgAdminIII crashes on copy operation
Next
From: "Pedro Gimeno"
Date:
Subject: BUG #3628: Wrong schema picked