[rt.cpan.org #20696] last_insert_id() fails if schema is not in search_path
"John Supplee via RT" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.dbdpg |
|---|---|
| Message-ID | <[email protected]> |
Wed Jul 26 10:55:23 2006: Request 20696 was acted upon.
Transaction: Ticket created by jrsupplee
Queue: DBD-Pg
Subject: last_insert_id() fails if schema is not in search_path
Broken in: 1.49
Severity: Important
Owner: Nobody
Requestors: [email protected]
Status: new
Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=20696 >
The last_insert_id function fails if the table's schema name is not in
search_path. I have patched my version of Pg.pm (ver 1.49) which used
to look like this:
308: $sth = $dbh->prepare("SELECT currval(?)");
309: $sth->execute($sequence);
to look like this:
308: $sth = $dbh->prepare("SELECT currval(?)");
309: $sequence = "$schema.$sequence" if $schema;
310: $sth->execute($sequence);
Everything is fine now. I think this bug should be fixed because not
only is last_insert_id() broken tables whose schema is not in
search_path, but it is possible that last_insert_id() could return the
value for the wrong table if two schemas have tables with the same
name.
John Supplee