Skip to content

Prevent mysqli::next_result from reporting errors from previous calls #7304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ext/mysqli/tests/mysqli_next_result_no_repeat_error.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
next_result reports errors from previous calls
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php

require_once __DIR__ . '/connect.inc';

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);

try {
$mysqli->query("Syntax Error");
} catch (mysqli_sql_exception $e) {
}
$mysqli->next_result();

print "done!";

?>
--EXPECTF--
done!
4 changes: 0 additions & 4 deletions ext/mysqli/tests/mysqli_report.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ext/mysqlnd/mysqlnd_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down