xref: /PHP-8.3/ext/mysqli/tests/bug77935.phpt (revision a21edc52)
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';
8?>
9--FILE--
10<?php
11require_once __DIR__ . '/connect.inc';
12
13mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
14$db = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
15$db->query('DROP PROCEDURE IF EXISTS testSp');
16$db->query(<<<'SQL'
17CREATE
18    PROCEDURE `testSp`()
19	BEGIN
20		DECLARE `cur` CURSOR FOR SELECT 1;
21		OPEN `cur`;
22		CLOSE `cur`;
23		SELECT 1;
24	END;
25SQL);
26
27$stmt = $db->prepare("CALL testSp()");
28$stmt->execute();
29$result = $stmt->get_result();
30while ($row = $result->fetch_assoc()) {
31    var_dump($row);
32}
33
34?>
35--CLEAN--
36<?php
37require_once 'connect.inc';
38$link = new mysqli($host, $user, $passwd, $db, $port, $socket);
39$link->query('DROP PROCEDURE IF EXISTS testSp');
40$link->close();
41?>
42--EXPECT--
43array(1) {
44  [1]=>
45  int(1)
46}
47