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

Patrick Welche <prlw1@newn.cam.ac.uk>

From: Patrick Welche <prlw1@newn.cam.ac.uk>
To: Christian Rank <christian.rank@rz.uni-passau.de>
Cc: pgsql-general@postgresql.org
Date: 2004-05-13T10:26:34Z
Lists: pgsql-general
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 about constraint violation when executing
> 'delete from a;'.

Off the top of my head, the constraints would be checked when the
transaction ends, i.e., after both the "delete from a" and "delete from b"
happened. Split into 2 transactions?

Cheers,

Patrick