Skip to content

Commit d26069a

Browse files
Prevent mysqli::next_result from reporting errors from previous calls (#7304)
1 parent 1fa26ec commit d26069a

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
next_result reports errors from previous calls
3+
--EXTENSIONS--
4+
mysqli
5+
--SKIPIF--
6+
<?php
7+
require_once 'skipifconnectfailure.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
12+
require_once __DIR__ . '/connect.inc';
13+
14+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
15+
16+
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
17+
18+
try {
19+
$mysqli->query("Syntax Error");
20+
} catch (mysqli_sql_exception $e) {
21+
}
22+
$mysqli->next_result();
23+
24+
print "done!";
25+
26+
?>
27+
--EXPECTF--
28+
done!

ext/mysqli/tests/mysqli_report.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,10 @@ Warning: mysqli_rollback(): (%s/%d): Commands out of sync; you can't run this co
331331

332332
Warning: mysqli_stmt_prepare(): (%s/%d): Commands out of sync; you can't run this command now in %s on line %d
333333

334-
Warning: mysqli_next_result(): (%s/%d): Commands out of sync; you can't run this command now in %s on line %d
335-
336334
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
337335

338336
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
339337

340-
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
341-
342338
Warning: mysqli_stmt_attr_set(): (%s/%d): Not implemented in %s on line %d
343339

344340
Warning: mysqli_kill(): processid should have positive value in %s on line %d

ext/mysqlnd/mysqlnd_connection.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,13 +1481,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, next_result)(MYSQLND_CONN_DATA * const conn)
14811481
DBG_ENTER("mysqlnd_conn_data::next_result");
14821482
DBG_INF_FMT("conn=%llu", conn->thread_id);
14831483

1484+
SET_EMPTY_ERROR(conn->error_info);
1485+
14841486
if (PASS == conn->m->local_tx_start(conn, this_func)) {
14851487
do {
14861488
if (GET_CONNECTION_STATE(&conn->state) != CONN_NEXT_RESULT_PENDING) {
14871489
break;
14881490
}
14891491

1490-
SET_EMPTY_ERROR(conn->error_info);
14911492
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
14921493
/*
14931494
We are sure that there is a result set, since conn->state is set accordingly

0 commit comments

Comments
 (0)