diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-09 14:04:30 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-09 14:04:30 +0100 |
commit | 23193e89e4cf3a503473a912154f2c8c9b92ee93 (patch) | |
tree | 830b66a8e1cd2e5e0d9c06131376c6f213862b02 | |
parent | 71b5f1446e45fd4ab9255fd3287cebeceaf45be3 (diff) | |
download | php-git-23193e89e4cf3a503473a912154f2c8c9b92ee93.tar.gz |
PDO MySQL: Handle error during closeCursor()
-rw-r--r-- | ext/pdo_mysql/mysql_statement.c | 3 | ||||
-rw-r--r-- | ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index e82cc6ddcc..7d0988b384 100644 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -899,7 +899,8 @@ static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt) /* {{{ */ while (mysql_more_results(S->H->server)) { MYSQL_RES *res; if (mysql_next_result(S->H->server) != 0) { - break; + pdo_mysql_error_stmt(stmt); + PDO_DBG_RETURN(0); } res = mysql_store_result(S->H->server); if (res) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt b/ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt new file mode 100644 index 0000000000..1f9421fe8a --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Error during closeCursor() of multi query +--SKIPIF-- +<?php +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); +MySQLPDOTest::skip(); +?> +--FILE-- +<?php +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); +$db = MySQLPDOTest::factory(); + +$stmt = $db->query('SELECT 1; SELECT x FROM does_not_exist'); +var_dump($stmt->fetchAll()); +var_dump($stmt->closeCursor()); +?> +--EXPECTF-- +array(1) { + [0]=> + array(2) { + [1]=> + string(1) "1" + [0]=> + string(1) "1" + } +} + +Warning: PDOStatement::closeCursor(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.does_not_exist' doesn't exist in %s on line %d +bool(false) |