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