xref: /PHP-8.1/ext/mysqli/tests/bug77935.phpt (revision 970d659d)
1--TEST--
2Bug #77935: Crash in mysqlnd_fetch_stmt_row_cursor when calling an SP with a cursor
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8if (!$IS_MYSQLND) {
9    die("skip mysqlnd only test");
10}
11?>
12--FILE--
13<?php
14require_once(__DIR__ . '/connect.inc');
15
16mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
17$db = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
18$db->query('DROP PROCEDURE IF EXISTS testSp');
19$db->query(<<<'SQL'
20CREATE
21    PROCEDURE `testSp`()
22	BEGIN
23		DECLARE `cur` CURSOR FOR SELECT 1;
24		OPEN `cur`;
25		CLOSE `cur`;
26		SELECT 1;
27	END;
28SQL);
29
30$stmt = $db->prepare("CALL testSp()");
31$stmt->execute();
32$result = $stmt->get_result();
33while ($row = $result->fetch_assoc()) {
34    var_dump($row);
35}
36
37?>
38--CLEAN--
39<?php
40require_once 'connect.inc';
41$link = new mysqli($host, $user, $passwd, $db, $port, $socket);
42$link->query('DROP PROCEDURE IF EXISTS testSp');
43$link->close();
44?>
45--EXPECT--
46array(1) {
47  [1]=>
48  int(1)
49}
50