Re: Getting the OID of inserted row in a rule
От | Michael Fuhr |
---|---|
Тема | Re: Getting the OID of inserted row in a rule |
Дата | |
Msg-id | 20040922155922.GA12629@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Re: Getting the OID of inserted row in a rule (Bradley Kieser <brad@kieser.net>) |
Ответы |
Re: Getting the OID of inserted row in a rule
|
Список | pgsql-admin |
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. -- Michael Fuhr http://www.fuhr.org/~mfuhr/
В списке pgsql-admin по дате отправления: