collision in serial numbers after INSERT?

Поиск
Список
Период
Сортировка
Искать
От
lawpoop@gmail.com
Тема
collision in serial numbers after INSERT?
Дата
Msg-id
1180630007.363398.62400@m36g2000hse.googlegroups.com
Список
Дерево обсуждения
collision in serial numbers after INSERT? lawpoop@gmail.com
Re: collision in serial numbers after INSERT? Bill Moran <wmoran@potentialtech.com>
Re: collision in serial numbers after INSERT? Steve Lefevre <lefevre.10@osu.edu>
Re: collision in serial numbers after INSERT? Bill Moran <wmoran@potentialtech.com>
Re: collision in serial numbers after INSERT? PFC <lists@peufeu.com>
Re: collision in serial numbers after INSERT? "Ian Harding" <harding.ian@gmail.com>
Re: collision in serial numbers after INSERT? Michael Glaesemann <grzm@seespotcode.net>
Re: collision in serial numbers after INSERT? Tom Lane <tgl@sss.pgh.pa.us>
Re: collision in serial numbers after INSERT? Michael Glaesemann <grzm@seespotcode.net>
Hello all -

I'm working on a site with PHP and Postgres, coming from a MySQL
background.

I was looking for an equivalent to the mysql_insert_id() function, and
a site recommended this:

function postg_insert_id($tablename, $fieldname)
{
 global connection_id;
 $result=pg_exec($connection_id, "SELECT last_value FROM ${tablename}_
${fieldname}_seq");
 $seq_array=pg_fetch_row($result, 0);
 return $seq_array[0];
}

It relies on pg's sequencing ability.

However, I wondered, if I were in an environment where there were many
concurrent inserts, would it be possible that I didn't get the serial
number of the insert that *I* just did? That if I do an insert, and
several inserts happen after mine, wouldn't I get the id of the latest
row, which is several inserts after mine?

I don't think this would be a problem in our environment, but I am
just wondering.

В списке pgsql-general по дате отправления
От: Dudás József
Дата:
От: stig erikson
Дата:
FAQ