xref: /php-src/ext/mysqli/tests/gh9841.phpt (revision 7e5171d1)
1--TEST--
2Bug GH-9841 (mysqli_query throws warning despite using silenced error mode)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require_once 'connect.inc';
13
14mysqli_report(MYSQLI_REPORT_OFF);
15
16$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
17
18$mysqli->query("SELECT (
19        SELECT 1 AS val
20        UNION ALL
21        SELECT 2
22    ) FROM dual");
23
24$mysqli->query("SELECT (
25        SELECT 1 AS val
26        UNION ALL
27        SELECT 2
28    ) FROM dual", MYSQLI_ASYNC);
29$mysqli->reap_async_query();
30
31$mysqli->real_query("SELECT (
32    SELECT 1 AS val
33    UNION ALL
34    SELECT 2
35) FROM dual");
36new mysqli_result($mysqli);
37
38// now make sure the errors are thrown when not using silent mode
39mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
40
41try {
42    $mysqli->query("SELECT (
43        SELECT 1 AS val
44        UNION ALL
45        SELECT 2
46    ) FROM dual");
47} catch (mysqli_sql_exception $e) {
48    echo $e->getMessage()."\n";
49}
50
51$mysqli->query("SELECT (
52    SELECT 1 AS val
53    UNION ALL
54    SELECT 2
55) FROM dual", MYSQLI_ASYNC);
56try {
57    $mysqli->reap_async_query();
58} catch (mysqli_sql_exception $e) {
59    echo $e->getMessage()."\n";
60}
61
62$mysqli->real_query("SELECT (
63    SELECT 1 AS val
64    UNION ALL
65    SELECT 2
66) FROM dual");
67try {
68    new mysqli_result($mysqli);
69} catch (mysqli_sql_exception $e) {
70    echo $e->getMessage()."\n";
71}
72
73print "done!";
74?>
75--EXPECTF--
76Subquery returns more than 1 row
77Subquery returns more than 1 row
78Subquery returns more than 1 row
79done!
80