Re: [INTERFACES] locking on database updates

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [INTERFACES] locking on database updates
Дата
Msg-id 23996.944589573@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [INTERFACES] locking on database updates  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
Ответы Re: [INTERFACES] locking on database updates  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
Список pgsql-interfaces
"Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu> writes:
> create table foo (bar serial, baz text);
> insert into foo (baz) values ('wooble');
> select currval('foo_bar_seq');

I don't think this is safe in a multi-client environment;
what if someone else inserts at about the same time?

Better to doselect nextval('foo_bar_seq');insert into foo values (just-retrieved-value, 'wooble');
which is safer and probably marginally faster (since the
sequence object is touched only once, not twice).
        regards, tom lane


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [INTERFACES] locking on database updates
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [INTERFACES] Deleting duplicate records