xref: /PHP-8.1/ext/mysqli/tests/bug54221.phpt (revision b5a14e6c)
1--TEST--
2Bug #54221 mysqli::get_warnings segfault when used in multi queries
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--INI--
10mysqli.max_links = 1
11mysqli.allow_persistent = Off
12mysqli.max_persistent = 0
13mysqli.reconnect = Off
14--FILE--
15<?php
16    include ("connect.inc");
17
18    $link = mysqli_init();
19    if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
20        printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
21    }
22
23    $create = "CREATE TEMPORARY TABLE IF NOT EXISTS t54221(a int)";
24
25    $query = "$create;$create;$create;";
26    if ($link->multi_query($query)) {
27        do {
28            $sth = $link->store_result();
29
30            if ($link->warning_count) {
31                $warnings = $link->get_warnings();
32                if ($warnings) {
33                    do {
34                        echo "Warning: ".$warnings->errno.": ".$warnings->message."\n";
35                    } while ($warnings->next());
36                }
37            }
38        } while ($link->more_results() && $link->next_result());
39    }
40
41    mysqli_close($link);
42
43    print "done!";
44?>
45--EXPECT--
46Warning: 1050: Table 't54221' already exists
47done!
48