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