Re: [Patch] DB_DataObject and Postgres INSERT race conditionobtaininglast key

From: Date: Wed, 18 Oct 2006 07:23:02 +0000
Subject: Re: [Patch] DB_DataObject and Postgres INSERT race conditionobtaininglast key
References: 1 2 3 4 5 6 7  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-44616@lists.php.net to get a copy of this message
Lukas Kahwe Smith wrote: > Alan Knowles wrote: >> the issue is slightly different from the original thread. >> not knowing MDB2, you may have solved it. but here goes the summary: >> >> DataObjects needs to know the sequence name for a table, so it can fetch >> the last inserted id. >> >> in the old PEAR::DB world, it called getSequenceKey($table), which >> usually just returned the tablename, reformatted with %s_seq (from what >> I remember). >> >> However, in the brave new world of MDB2, The hope is that >> getSequenceKey($table) would actually use something like tableInfo(), >> look at the flags, and return the 'real' sequence key', as defined by >> nextval() etc. > > You are talking about finding a nextval() trigger on a column? > I think it would be wiser to let users configure that, no? Yes, probably a good idea. > > Anyways if you do the following you should already get this information: > $mdb2->reverse->tableInfo($table_name); Yes, they point was to put the code to extract that into MDB/postgres driver, rather than weighing down the more generic layers. Something like pgsql.php / override getSequenceName function getSequenceName($sqn, $col = false) { if ($col == false) { return parent::getSequenceName($sqn); } $ti = $this->reverse->tableInfo($sqn); ... grab the col & parse the nextval(); } Regards Alan > > regards, > Lukas >

« previous php.pear.dev (#44616) next »