referential integrity

From: Ian Turner <vectro(at)pipeline(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: referential integrity
Date: 2000-09-01 00:44:05
Message-ID: Pine.LNX.4.21.0008311743550.695-100000@crafter.house
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It seems that cascading across multiple tables does not work
correctly, when combining different action types. For example, given:

CREATE TABLE a (anum Integer PRIMARY KEY);
CREATE TABLE b (bnum Integer PRIMARY KEY,
anum Integer REFERENCES a ON DELETE CASCADE);
CREATE TABLE c (cnum Integer PRIMARY KEY,
bnum Integer REFERENCES b ON DELETE CASCADE,
anum Integer REFERENCES a ON DELETE SET NULL);

INSERT INTO a (anum) VALUES (1);
INSERT INTO b (bnum, anum) VALUES (1,1);
INSERT INTO c (cnum, bnum, anum) VALUES (1,1,1);

This passes without an error:

delete from b where bnum = 1;
delete from a where anum = 1;

but this fails:

delete from a where anum = 1;

with this error:

ERROR: <unnamed> referential integrity violation - key referenced from c
not found in b

Got any ideas? :o

Ian Turner
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE5rvvXfn9ub9ZE1xoRAqEkAJ0aFgzuoaK23xdnzsE7ADGrCYErRQCfbEjy
X/J9RlqAPHOwnHGlQHTmFRE=
=BgK8
-----END PGP SIGNATURE-----

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ian Turner 2000-09-01 00:47:00 Re: POSTGRESQL vs. ORACLE 8i &Sybase & Interbase etc
Previous Message Chris 2000-08-31 22:41:09 Re: INHERITANCE