From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Larry White <ljw1001(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: transactions, functions, foreign keys |
Date: | 2004-12-15 17:33:57 |
Message-ID: | 20041215173357.GA21321@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Dec 15, 2004 at 11:53:55AM -0500, Larry White wrote:
> I have a function that calls other functions. These other functions
> are inserting rows and return the primary key for the inserted row.
> Some of the tables are related in a way that they have a foreign key
> reference to a table that was updated in a previous step.
>
> Here's an example in psuedocode
>
> create function foo() AS '
> begin
> select into key1 bar1( a, b);
> select into key2 bar2,(e, f, key1);
> etc...
> end
> '
>
> The call to bar2 uses the key from the call to bar1. The table
> updated in bar2 has a foreign key constraint referencing the key1
> column from bar1, but the bar1 transaction hasn't been committed.
> Thus - a foreign key violation exception. (That's the part I should
> have seen coming.)
Have you actually seen this problem? I don't know if PostgreSQL's
visibility rules have changed, but I just tested what you describe
in 7.4.6 and 8.0.0rc1 and it works. What version of PostgreSQL are
you using? Could you post a complete example that exhibits the
problem?
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2004-12-15 17:35:34 | Re: Threading with non-shared libraries |
Previous Message | Terry Lee Tucker | 2004-12-15 17:11:34 | Re: transactions, functions, foreign keys |