xref: /PHP-8.4/ext/pdo_mysql/tests/bug76815.phpt (revision 4bb75d56)
1--TEST--
2Bug #76815: PDOStatement cannot be GCed/closeCursor-ed when a PROCEDURE resultset SIGNAL
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once __DIR__ . '/inc/mysql_pdo_test.inc';
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13
14$pdo = MySQLPDOTest::factory();
15$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
16
17$func = 'bug76815_pdo_mysql_f';
18$procedure = 'bug76815_pdo_mysql_p';
19
20$pdo->query("CREATE FUNCTION {$func}() RETURNS VARCHAR(5) DETERMINISTIC BEGIN RETURN 'x12345'; END");
21$pdo->query("CREATE PROCEDURE {$procedure}() BEGIN SELECT {$func}(); END");
22
23$st = $pdo->prepare("CALL {$procedure}()");
24try {
25    $st->execute();
26} catch (PDOException $ex) {
27    echo $ex->getMessage(), "\n";
28}
29unset($st);
30echo "Ok.\n";
31?>
32--CLEAN--
33<?php
34require_once __DIR__ . '/inc/mysql_pdo_test.inc';
35$pdo = MySQLPDOTest::factory();
36$pdo->query('DROP FUNCTION IF EXISTS bug76815_pdo_mysql_f');
37$pdo->query('DROP PROCEDURE IF EXISTS bug76815_pdo_mysql_p');
38?>
39--EXPECT--
40SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'bug76815_pdo_mysql_f()' at row 1
41Ok.
42