com php-src: Fixed #73959 - lastInsertId fails to throw an exception in pdsql: NEWS ext/pdo_pgsql/pgsql_driver.c ext/pdo_pgsq l/tests/bug73959.phpt

From: Date: Fri, 20 Jan 2017 20:10:55 +0000
Subject: com php-src: Fixed #73959 - lastInsertId fails to throw an exception in pdsql: NEWS ext/pdo_pgsql/pgsql_driver.c ext/pdo_pgsq l/tests/bug73959.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96817@lists.php.net to get a copy of this message
Commit: 21ac79e94bd0335bf885b807e09c4d86d75d776a Author: andrewnester <andrew.nester.dev@gmail.com> Fri, 20 Jan 2017 21:39:45 +0300 Committer: Joe Watkins <krakjoe@php.net> Fri, 20 Jan 2017 20:10:55 +0000 Parents: 2e3d68ed1ba9097d1b8ac64c2a5af7004faa2796 Branches: PHP-7..0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=21ac79e94bd0335bf885b807e09c4d86d75d776a Log: Fixed #73959 - lastInsertId fails to throw an exception in pdsql Bugs: https://bugs.php.net/73959 Changed paths: M NEWS M ext/pdo_pgsql/pgsql_driver.c A ext/pdo_pgsql/tests/bug73959.phpt Diff: diff --git a/NEWS b/NEWS index 5087d56..2c403eb 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,10 @@ PHP NEWS - PDO_Firebird: . Implemented FR #72583 (All data are fetched as strings). (Dorin Marcoci) +- PDO_PgSQL: + . Fixed bug #73959 (lastInsertId fails to throw an exception for wrong + sequence name). (andrewnester) + - Phar: . Fixed bug #70417 (PharData::compress() doesn't close temp file). (cmb) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 7e2c97d..b04cade 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -391,7 +391,6 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t * (void)PQexec(H->server, "ROLLBACK TO SAVEPOINT _php_lastid_savepoint"); } pdo_pgsql_error(dbh, status, pdo_pgsql_sqlstate(res)); - *len = spprintf(&id, 0, ZEND_LONG_FMT, (zend_long) H->pgoid); } if (savepoint) { diff --git a/ext/pdo_pgsql/tests/bug73959.phpt b/ext/pdo_pgsql/tests/bug73959.phpt new file mode 100644 index 0000000..c04b4ac --- /dev/null +++ b/ext/pdo_pgsql/tests/bug73959.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #73959 (lastInsertId fails to throw an exception) +--SKIPIF-- +<?php +if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); +require dirname(__FILE__) . '/../../.../ext/pdo/tests/pdo_test.inc'; +require dirname(__FILE__) . '/config.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; +require dirname(__FILE__) .. '/config.inc'; +$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); +$db->setAttribute(PDO::ATTR_PERSISTENT, false); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true); + +try { + $db->lastInsertId('nonexistent_seq'); + echo "Error: No exception thrown"; +} catch (PDOException $e) { + echo "Success: Exception thrown"; +} +?> +--EXPECT-- +Success: Exception thrown

« previous php.cvs (#96817) next »