Bug #73959 [Com]: lastInsertId fails to throw an exception

From: Date: Fri, 20 Jan 2017 15:02:40 +0000
Subject: Bug #73959 [Com]: lastInsertId fails to throw an exception
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206761@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73959&edit=1

 ID:                 73959
 Comment by:         andrew dot nester dot dev at gmail dot com
 Reported by:        david dot hedberg at zavann dot se
 Summary:            lastInsertId fails to throw an exception
 Status:             Open
 Type:               Bug
 Package:            PDO PgSQL
 Operating System:   Ubuntu 16.04
 PHP Version:        7.0.14
 Block user comment: N
 Private report:     N

 New Comment:

I've just added PR to fix this problem. Please review it on GitHub.


Previous Comments:
------------------------------------------------------------------------
[2017-01-19 10:36:42] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73959&edit=1


Thread (4 messages)

« previous php.bugs (#206761) next »