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..22fb70979650d --- /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 $e) { +} +$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