1--TEST--
2Error in multi query
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11
12require_once __DIR__ . '/connect.inc';
13
14mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
15
16$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
17
18$mysqli->multi_query("SELECT 1; SELECT 2; Syntax Error");
19
20try {
21    do {
22        if ($res = $mysqli->store_result()) {
23            var_dump($res->fetch_all(MYSQLI_ASSOC));
24            $res->free();
25        }
26    } while ($mysqli->more_results() && $mysqli->next_result());
27} catch (mysqli_sql_exception $e) {
28    echo $e->getMessage(), "\n";
29}
30
31$mysqli->query("DROP PROCEDURE IF EXISTS p");
32$mysqli->query('CREATE PROCEDURE p() READS SQL DATA BEGIN SELECT 1; SELECT foobar FROM table_that_does_not_exist; END;');
33
34$stmt = $mysqli->prepare("CALL p()");
35$stmt->execute();
36
37try {
38    do {
39        $stmt->bind_result($num);
40        while ($stmt->fetch()) {
41            echo "num = $num\n";
42        }
43    } while ($stmt->more_results() && $stmt->next_result());
44} catch (mysqli_sql_exception $e) {
45    echo $e->getMessage(), "\n";
46}
47
48$mysqli->query("DROP PROCEDURE IF EXISTS p");
49
50?>
51--EXPECTF--
52array(1) {
53  [0]=>
54  array(1) {
55    [1]=>
56    string(1) "1"
57  }
58}
59array(1) {
60  [0]=>
61  array(1) {
62    [2]=>
63    string(1) "2"
64  }
65}
66You have an error in your SQL syntax; %s
67num = 1
68Table '%s.table_that_does_not_exist' doesn't exist
69