PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2 » Bug #9106

More accurate sequence name

Details

Request #9106More accurate sequence name
Submitted2006-10-20 13:13 UTC
Frommcraig at leadehealth dot com
Assignedquipo
StatusClosed
PackageMDB2
PHP Version4.4.3
OSlinux
Roadmaps(Not assigned)

Comments

[2006-10-20 13:13 UTC] mcraig at leadehealth dot com

Description:
------------
This request is for the driver to do a little more introspection in getSequenceName in order to return a more accurate sequence name. For instance, right now it does not check the tableInfo for SERIAL sequences created by PostgreSQL. It just returns something like "<table>_seq", whereas it should have the ability to look for a column definition containing "nextval(.*)". Through something:

// pgsql.php / override getSequenceName
function getSequenceName($sqn)
{
$ti = $this->reverse->tableInfo($sqn);
... grab the col & parse the nextval();
if($found) return $seqnname;

return parent::getSequenceName($sqn);
}

Expected result:
----------------
For example, I use DB_DataObject to access a table called "enrollment" with a sequence called "enrollment_id_seq" that was created by Postgres.

My current version of DB_DataObject (via DB, actually) creates and returns a seqeuence named "enrollment_seq" so that when non-PHP programs access the table and use the real sequence there are id collisions.

It would be great if MDB could return the real sequence to avoid these collisions.

[2006-11-02 13:55 UTC] mcraig at leadehealth dot com

pg_get_serial_sequence does not seem to be included by default on the latest gentoo postgres 7.4.13, though it is in version 8.

Also it still requires introspection to know exactly which column is expected to be the serial column.