[GENERAL] referential integrity constraints not checked inside PL/pgSQL functions?

2004-05-13 Thread Christian Rank
Hello, I came across the following problem with integrity constraints and PL/pgSQL (PostgreSQL version used: 7.4.2): I defined the following tables, constraints and data: create table a (n integer); create table b (n integer); alter table a add primary key (n);

Re: [GENERAL] referential integrity constraints not checked inside PL/pgSQL functions?

2004-05-13 Thread Patrick Welche
On Thu, May 13, 2004 at 11:41:24AM +0200, Christian Rank wrote: create function f () returns void as ' begin delete from a; delete from b; return; end; ' language plpgsql; I would expect that select f(); yields an error message

Re: [GENERAL] referential integrity constraints not checked inside PL/pgSQL functions?

2004-05-13 Thread Christopher Browne
Supposing you drop the delete from b; from the function, you'll find that the function fails with much the same error message you had before. Evidently that foreign key check gets _deferred_ in the context of the stored procedure. It is indeed checked; just not at the point you expect it to be