php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72633 Postgres PDO lastInsertId() should work without specifying a sequence
Submitted: 2016-07-20 18:00 UTC Modified: 2016-07-27 21:51 UTC
From: zippy1981 at gmail dot com Assigned: ab
Status: Closed Package: PDO PgSQL
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID:
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
16 + 8 = ?
Subscribe to this entry?

 
 [2016-07-20 18:00 UTC] zippy1981 at gmail dot com
Description:
------------
The code here shows that CURRVAL() is used to get the last id of a named sequence but if NULL is passed, NULL is returned.

https://github.com/php/php-src/blob/php-7.0.9/ext/pdo_pgsql/pgsql_driver.c#L360

However, as of postgres 8.3, the LASTVAL() function has been available to get the last sequence in a session of any sequence. Postgres 8.2 EOL was in 2011.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-20 18:49 UTC] zippy1981 at gmail dot com
-Summary: lastInsertId() should work without specifying a sequence +Summary: Postgres PDO lastInsertId() should work without specifying a sequence
 [2016-07-20 18:49 UTC] zippy1981 at gmail dot com
Changed title
 [2016-07-27 21:51 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2016-07-27 21:51 UTC] ab@php.net
Implemented via https://github.com/php/php-src/pull/2014

Thanks.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Wed Aug 16 23:01:35 2017 UTC