xref: /PHP-8.2/ext/mysqli/tests/gh12107.phpt (revision 0d21a8dc)
1--TEST--
2GH-12107 (When running a stored procedure (that returns a result set) twice, PHP crashes)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11require_once 'connect.inc';
12
13$mysqli = new mysqli("$host:$port", $user, $passwd, $db);
14
15$sql = <<<SQL
16CREATE PROCEDURE `gh12107`()
17BEGIN
18    SELECT "hello world";
19END;
20SQL;
21$mysqli->query($sql);
22
23echo "Start or run 1\n";
24$stmt = $mysqli->prepare("call `gh12107`()");
25$stmt->execute();
26$stmt->bind_result($output);
27var_dump($stmt->fetch());
28var_dump($output);
29unset($output);
30echo "End of run 1\n";
31
32echo "Start or run 2\n";
33$stmt->execute();
34$stmt->bind_result($output);
35var_dump($stmt->fetch());
36var_dump($output);
37echo "End of run 2\n";
38
39?>
40--CLEAN--
41<?php
42require_once 'connect.inc';
43if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
44   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
45
46if (!mysqli_query($link, "DROP PROCEDURE IF EXISTS gh12107"))
47    printf("[c002] Cannot drop procedure, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
48
49mysqli_close($link);
50?>
51--EXPECT--
52Start or run 1
53bool(true)
54string(11) "hello world"
55End of run 1
56Start or run 2
57bool(true)
58string(11) "hello world"
59End of run 2
60