Skip to content

Commit 15a2c86

Browse files
mysqli_reap_async_query error reporting (php#7629)
1 parent 425e70c commit 15a2c86

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

ext/mysqli/mysqli_nonapi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ PHP_FUNCTION(mysqli_reap_async_query)
957957
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
958958

959959
if (FAIL == mysqlnd_reap_async_query(mysql->mysql)) {
960+
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
960961
RETURN_FALSE;
961962
}
962963

@@ -978,8 +979,7 @@ PHP_FUNCTION(mysqli_reap_async_query)
978979
}
979980

980981
if (!result) {
981-
php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql),
982-
"%s", mysql_error(mysql->mysql));
982+
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
983983
RETURN_FALSE;
984984
}
985985

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
mysqli_reap_async_query() error reporting
3+
--EXTENSIONS--
4+
mysqli
5+
--SKIPIF--
6+
<?php
7+
require_once 'skipifconnectfailure.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
require_once "connect.inc";
12+
13+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
14+
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
15+
16+
$link->query(')', MYSQLI_ASYNC | MYSQLI_USE_RESULT);
17+
$reads = $errors = $rejects = [$link];
18+
mysqli::poll($reads, $errors, $rejects, 1);
19+
$link = $reads[0];
20+
21+
try {
22+
$rs = $link->reap_async_query();
23+
} catch (mysqli_sql_exception $exception) {
24+
echo $exception->getMessage() . "\n";
25+
}
26+
27+
print "done!";
28+
?>
29+
--EXPECT--
30+
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
31+
done!

0 commit comments

Comments
 (0)