diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index b4f80f6df38..b905426eeae 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -957,6 +957,7 @@ PHP_FUNCTION(mysqli_reap_async_query) MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); if (FAIL == mysqlnd_reap_async_query(mysql->mysql)) { + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } @@ -978,8 +979,7 @@ PHP_FUNCTION(mysqli_reap_async_query) } if (!result) { - php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql), - "%s", mysql_error(mysql->mysql)); + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } diff --git a/ext/mysqli/tests/mysqli_reap_async_query_error.phpt b/ext/mysqli/tests/mysqli_reap_async_query_error.phpt new file mode 100644 index 00000000000..d5672ba1776 --- /dev/null +++ b/ext/mysqli/tests/mysqli_reap_async_query_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +mysqli_reap_async_query() error reporting +--EXTENSIONS-- +mysqli +--SKIPIF-- + +--FILE-- +query(')', MYSQLI_ASYNC | MYSQLI_USE_RESULT); +$reads = $errors = $rejects = [$link]; +mysqli::poll($reads, $errors, $rejects, 1); +$link = $reads[0]; + +try { + $rs = $link->reap_async_query(); +} catch (mysqli_sql_exception $exception) { + echo $exception->getMessage() . "\n"; +} + +print "done!"; +?> +--EXPECT-- +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 +done!