xref: /PHP-8.2/ext/mysqli/tests/bug54221.phpt (revision 21ca8c43)
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
13--FILE--
14<?php
15    include ("connect.inc");
16
17    $link = mysqli_init();
18    if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
19        printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
20    }
21
22    $create = "CREATE TEMPORARY TABLE IF NOT EXISTS t54221(a int)";
23
24    $query = "$create;$create;$create;";
25    if ($link->multi_query($query)) {
26        do {
27            $sth = $link->store_result();
28
29            if ($link->warning_count) {
30                $warnings = $link->get_warnings();
31                if ($warnings) {
32                    do {
33                        echo "Warning: ".$warnings->errno.": ".$warnings->message."\n";
34                    } while ($warnings->next());
35                }
36            }
37        } while ($link->more_results() && $link->next_result());
38    }
39
40    mysqli_close($link);
41
42    print "done!";
43?>
44--EXPECT--
45Warning: 1050: Table 't54221' already exists
46done!
47