Re: Getting the OID of inserted row in a rule

From: Bradley Kieser <brad(at)kieser(dot)net>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Getting the OID of inserted row in a rule
Date: 2004-09-22 16:15:40
Message-ID: 4151A52C.5030500@kieser.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Ah!
I didn't know that!
Michael, thank you so much! No, I don't have anything sharing these
sessions, they are rules in the back end so they should (unless someone
tells me differently) AFAIK be in their own threads.

Top man!

Brad

Michael Fuhr wrote:

>On Wed, Sep 22, 2004 at 04:30:06PM +0100, Bradley Kieser wrote:
>
>
>>Michael Fuhr wrote:
>>
>>
>>
>>>CREATE RULE v_ins AS ON INSERT TO v DO INSTEAD (
>>>INSERT INTO a (xxx) VALUES (NEW.xxx);
>>>INSERT INTO b (col1, col2, col3) VALUES (NEW.col1, NEW.col2,
>>>currval('a_id_seq'))
>>>);
>>>
>>>
>>But what if another insert happens in the mean time? Then the sequence
>>would have advanced that the data will be scrambled. |Given that this
>>could be a very active dataset, that situation is almost certain to occur.
>>
>>
>
>currval() returns the last value returned by nextval() in *this session*.
>
>http://www.postgresql.org/docs/7.4/static/functions-sequence.html
>http://www.postgresql.org/docs/faqs/FAQ.html#4.15.3
>
>Do you have multiple processes or threads sharing the same connection?
>Perhaps one of the developers can comment on the possibility of a race
>condition in that case.
>
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Gaetano Mendola 2004-09-22 16:43:11 Re: Important Question.
Previous Message Gaetano Mendola 2004-09-22 16:11:38 Re: Getting the OID of inserted row in a rule