xref: /PHP-7.0/ext/mysqli/tests/bug54221.phpt (revision d903915f)
1--TEST--
2Bug #54221 mysqli::get_warnings segfault when used in multi queries
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--INI--
9mysqli.max_links = 1
10mysqli.allow_persistent = Off
11mysqli.max_persistent = 0
12mysqli.reconnect = Off
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--EXPECTF--
45Warning: :
46Warning: 1050: Table 't54221' already exists
47done!
48