diff options
author | Joe Watkins <krakjoe@php.net> | 2017-01-20 20:12:03 +0000 |
---|---|---|
committer | Joe Watkins <krakjoe@php.net> | 2017-01-20 20:12:30 +0000 |
commit | 0877839469a40b3aec0639d25be2fad62225a8b6 (patch) | |
tree | 8a9076e24a1ab550748227648dbd60bf8db6fcf3 /ext/pdo_pgsql | |
parent | fa45f64bd87b62f655e6d99c1a088efa5772b5fe (diff) | |
parent | d6feb2edbdc95b2db1ec09f011595de0204b2fa1 (diff) | |
download | php-git-0877839469a40b3aec0639d25be2fad62225a8b6.tar.gz |
Merge branch 'PHP-7.1'
* PHP-7.1:
Fixed #73959 - lastInsertId fails to throw an exception in pdsql
Diffstat (limited to 'ext/pdo_pgsql')
-rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 1 | ||||
-rw-r--r-- | ext/pdo_pgsql/tests/bug73959.phpt | 27 |
2 files changed, 27 insertions, 1 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 045d32e7e5..52a9b8f285 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -379,7 +379,6 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t * *len = PQgetlength(res, 0, 0); } else { pdo_pgsql_error(dbh, status, pdo_pgsql_sqlstate(res)); - *len = spprintf(&id, 0, ZEND_LONG_FMT, (zend_long) H->pgoid); } if (res) { diff --git a/ext/pdo_pgsql/tests/bug73959.phpt b/ext/pdo_pgsql/tests/bug73959.phpt new file mode 100644 index 0000000000..c04b4acd52 --- /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 |