Apparent referential integrity bug in PL/pgSQL

From: Brian Blaha <bblaha(at)umr(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Apparent referential integrity bug in PL/pgSQL
Date: 2002-10-18 07:15:32
Message-ID: 3DAFB514.7080002@umr.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a function that operates on two tables A and B, such that B has a
foreign key on A, as follows:
INSERT INTO A (...) several times
INSERT INTO B (...) several times, with foreign keys pointing to the new
members of A
DELETE FROM A (...), possibly including some of the newly added members

Even though B's foreign key is defined ON DELETE CASCADE, I get a
referential integrity
violation when I run this function. If instead, I comment out the DELETE
statement, start a
transaction block, run the function, run the DELETE statement, and end
the transaction, no
errors occur. To run those statements with one function call, I need to
split the INSERTs and
DELETEs into separate functions, and call them separately from a third
function. I am using
version 7.2.2. Has this been corrected in the beta versions or can
someone confirm this for me?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Brian Blaha 2002-10-18 07:19:50 UPDATE: Apparent referential integrity bug in PL/pgSQL
Previous Message Josh Berkus 2002-10-18 05:27:14 Re: Can I create working trigger on view