xref: /PHP-8.1/ext/pdo_mysql/tests/bug76815.phpt (revision b5a14e6c)
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__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
13
14$pdo = MySQLPDOTest::factory();
15$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
16
17$pdo->query('DROP FUNCTION IF EXISTS tst');
18$pdo->query('DROP PROCEDURE IF EXISTS tst2');
19$pdo->query('CREATE FUNCTION tst() RETURNS VARCHAR(5) DETERMINISTIC BEGIN RETURN \'x12345\'; END');
20$pdo->query('CREATE PROCEDURE tst2() BEGIN SELECT tst(); END');
21
22$st = $pdo->prepare('CALL tst2()');
23try {
24    $st->execute();
25} catch (PDOException $ex) {
26    echo $ex->getMessage(), "\n";
27}
28unset($st);
29echo "Ok.\n";
30
31?>
32--CLEAN--
33<?php
34require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
35$pdo = MySQLPDOTest::factory();
36$pdo->query('DROP FUNCTION IF EXISTS tst');
37$pdo->query('DROP PROCEDURE IF EXISTS tst2');
38?>
39--EXPECT--
40SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'tst()' at row 1
41Ok.
42