diff --git a/NEWS b/NEWS index 82b0bee72da..970e8d7fc58 100644 --- a/NEWS +++ b/NEWS @@ -91,6 +91,10 @@ PHP NEWS (Adam Baratz) . Fixed bug #73396 (bigint columns are returned as strings). (Adam Baratz) +- PDO_PgSQL: + . Fixed bug #73959 (lastInsertId fails to throw an exception for wrong + sequence name). (andrewnester) + - posix: . Fixed bug #71219 (configure script incorrectly checks for ttyname_r). (atoh) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 045d32e7e51..52a9b8f285e 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 00000000000..c04b4acd52c --- /dev/null +++ b/ext/pdo_pgsql/tests/bug73959.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #73959 (lastInsertId fails to throw an exception) +--SKIPIF-- + +--FILE-- +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