php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73959 lastInsertId fails to throw an exception
Submitted: 2017-01-19 10:36 UTC Modified: -
From: david dot hedberg at zavann dot se Assigned:
Status: Closed Package: PDO PgSQL
PHP Version: 7.0.14 OS: Ubuntu 16.04
Private report: No CVE-ID: None
 [2017-01-19 10:36 UTC] david dot hedberg at zavann dot se
Description:
------------
Running PDO::lastInsertId() using a bad sequence name (not updated or nonexistent) no longer throws an exception after upgrading.

PostgreSQL server version is 9.5.5.

It works in 7.0.8-0ubuntu0.16.04.3, but fails in both 7.0.13-0ubuntu0.16.04.1 and 7.0.14-2+deb.sury.org~xenial+1.
 


Test script:
---------------
$pdo = new PDO(
    'pgsql:service=...', null, null,
    array(
        PDO::ATTR_PERSISTENT => false,
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::PGSQL_ATTR_DISABLE_PREPARES => true
    )
);

try {
    $pdo->lastInsertId('nonexistent_seq');
    echo "Error: No exception thrown";
} catch (PDOException $e) {
    echo "Success: Exception thrown";
}


Expected result:
----------------
Success: Exception thrown

Actual result:
--------------
Error: No exception thrown

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-20 15:02 UTC] andrew dot nester dot dev at gmail dot com
I've just added PR to fix this problem. Please review it on GitHub.
 [2017-01-20 20:12 UTC] krakjoe@php.net
Automatic comment on behalf of andrew.nester.dev@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=21ac79e94bd0335bf885b807e09c4d86d75d776a
Log: Fixed #73959 - lastInsertId fails to throw an exception in pdsql
 [2017-01-20 20:12 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 [2017-01-21 09:09 UTC] david dot hedberg at zavann dot se
Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC