From 8d9da5aa51d706c1d7bc0884bad7c18b1522af24 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sun, 25 Jul 2021 01:02:52 +0100 Subject: [PATCH 1/2] Prevent next_result from reporting errors from previous calls --- .../mysqli_next_result_no_repeat_error.phpt | 28 +++++++++++++++++++ ext/mysqli/tests/mysqli_report.phpt | 4 --- ext/mysqlnd/mysqlnd_connection.c | 3 +- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt diff --git a/ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt b/ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt new file mode 100644 index 0000000000000..a2881e10ec7ce --- /dev/null +++ b/ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt @@ -0,0 +1,28 @@ +--TEST-- +next_result reports errors from previous calls +--EXTENSIONS-- +mysqli +--SKIPIF-- + +--FILE-- +query("Syntax Error"); +} catch (mysqli_sql_exception) { +} +$mysqli->next_result(); + +print "done!"; + +?> +--EXPECTF-- +done! diff --git a/ext/mysqli/tests/mysqli_report.phpt b/ext/mysqli/tests/mysqli_report.phpt index 7a343bdef8f10..75545fee4e573 100644 --- a/ext/mysqli/tests/mysqli_report.phpt +++ b/ext/mysqli/tests/mysqli_report.phpt @@ -331,14 +331,10 @@ Warning: mysqli_rollback(): (%s/%d): Commands out of sync; you can't run this co Warning: mysqli_stmt_prepare(): (%s/%d): Commands out of sync; you can't run this command now in %s on line %d -Warning: mysqli_next_result(): (%s/%d): Commands out of sync; you can't run this command now in %s on line %d - Warning: mysqli_next_result(): (%s/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_store_result(): (%s/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d -Warning: mysqli_next_result(): (%s/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d - Warning: mysqli_stmt_attr_set(): (%s/%d): Not implemented in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c index 5057746fffd73..889703886e358 100644 --- a/ext/mysqlnd/mysqlnd_connection.c +++ b/ext/mysqlnd/mysqlnd_connection.c @@ -1481,13 +1481,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, next_result)(MYSQLND_CONN_DATA * const conn) DBG_ENTER("mysqlnd_conn_data::next_result"); DBG_INF_FMT("conn=%llu", conn->thread_id); + SET_EMPTY_ERROR(conn->error_info); + if (PASS == conn->m->local_tx_start(conn, this_func)) { do { if (GET_CONNECTION_STATE(&conn->state) != CONN_NEXT_RESULT_PENDING) { break; } - SET_EMPTY_ERROR(conn->error_info); UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status); /* We are sure that there is a result set, since conn->state is set accordingly From ff63085418b3ff59a5bb54e422fecaa0e831d825 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sun, 25 Jul 2021 10:49:21 +0100 Subject: [PATCH 2/2] Add missing variable in the test --- ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt b/ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt index a2881e10ec7ce..22fb70979650d 100644 --- a/ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt +++ b/ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt @@ -17,7 +17,7 @@ $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); try { $mysqli->query("Syntax Error"); -} catch (mysqli_sql_exception) { +} catch (mysqli_sql_exception $e) { } $mysqli->next_result();