Re: Last ID Problem
От | Tom Lane |
---|---|
Тема | Re: Last ID Problem |
Дата | |
Msg-id | 10519.1107237380@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Last ID Problem (Michael Fuhr <mike@fuhr.org>) |
Ответы |
Re: Last ID Problem
|
Список | pgsql-novice |
Michael Fuhr <mike@fuhr.org> writes: > On Mon, Jan 31, 2005 at 08:55:22PM -0500, Mitch Pirtle wrote: >> 'Common', unfortunately, is relative; and in this matter might only >> apply to ADOdb ;-) > The world's bigger than a couple of PHP modules :-) Calling currval() > after an INSERT is a common way to get the sequence value when using > PostgreSQL, regardless of the programming language or API being > used. His point stands though: if you are accessing Postgres through some kind of connection-pooling software, currval() cannot be trusted across transaction boundaries, since the pool code might give your connection to someone else. In this situation the nextval-before-insert paradigm is the only way. (But in most of the applications I can think of, your uses of currval subsequent to an INSERT ought to be in the same transaction as the insert, so are perfectly safe. If your connection pooler takes control away from you within a transaction block, you need a less broken pooler...) regards, tom lane
В списке pgsql-novice по дате отправления: