Re: [Patch] DB_DataObject and Postgres INSERT race condition obtaining last key
| From: | Alexey Borzov | Date: | Wed, 18 Oct 2006 09:32:19 +0000 |
| Subject: | Re: [Patch] DB_DataObject and Postgres INSERT race condition obtaining last key | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-44624@lists.php.net to get a copy of this message | ||
Hi,
Matt Craig wrote:
I have related question about the attached patch. The patch is for DataObject to get currval from the real "serial" postgres sequence instead of DB-created sequences, as long as the key is marked with a nextval(). Is there a more efficient was to find the key? And Justin mentioned that getting the sequences corrected in DB itself is a preferrable fix, but pretending we don't have the skill or time to fix DB, too, how should DataObject handle the difficulties passed on to it from DB? (Namely, that it always uses sequences named "<table>_seq".)Two not-quite-related points: 1) PostgreSQL 8.1 has a built-in lastval() function that returns the last value produced by any sequence in current session. In other words, it works just like MySQL's last_insert_id() or whatever it is called. 2) DB does offer means to customize sequence names: $dbh->setOption('seqname_format', 'whatever_%s_you_like');