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