Skip to content

Commit c22f1d4

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed bug #63185
2 parents 75d7e60 + bd72e4a commit c22f1d4

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

ext/pdo_mysql/mysql_statement.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
355355
PDO_DBG_RETURN(0);
356356
}
357357
if (mysqlnd_stmt_next_result(S->stmt)) {
358+
pdo_mysql_error_stmt(stmt);
358359
PDO_DBG_RETURN(0);
359360
}
360361

ext/pdo_mysql/tests/bug63185.phpt

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
--TEST--
2+
Bug #63185: nextRowset() ignores MySQL errors with native prepared statements
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
6+
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
7+
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8+
MySQLPDOTest::skip();
9+
?>
10+
--FILE--
11+
<?php
12+
require_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->exec('DROP PROCEDURE IF EXISTS test_procedure_error_at_second');
18+
$pdo->exec('CREATE PROCEDURE test_procedure_error_at_second ()
19+
BEGIN
20+
SELECT "x" as foo;
21+
SELECT * FROM no_such_table;
22+
END');
23+
24+
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
25+
$st = $pdo->query('CALL test_procedure_error_at_second()');
26+
var_dump($st->fetchAll());
27+
try {
28+
var_dump($st->nextRowset());
29+
} catch (PDOException $e) {
30+
echo $e->getMessage(), "\n";
31+
}
32+
unset($st);
33+
34+
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
35+
$st = $pdo->query('CALL test_procedure_error_at_second()');
36+
var_dump($st->fetchAll());
37+
try {
38+
var_dump($st->nextRowset());
39+
} catch (PDOException $e) {
40+
echo $e->getMessage(), "\n";
41+
}
42+
var_dump($st->fetchAll());
43+
44+
?>
45+
--EXPECTF--
46+
array(1) {
47+
[0]=>
48+
array(2) {
49+
["foo"]=>
50+
string(1) "x"
51+
[0]=>
52+
string(1) "x"
53+
}
54+
}
55+
SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.no_such_table' doesn't exist
56+
array(1) {
57+
[0]=>
58+
array(2) {
59+
["foo"]=>
60+
string(1) "x"
61+
[0]=>
62+
string(1) "x"
63+
}
64+
}
65+
SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.no_such_table' doesn't exist
66+
array(0) {
67+
}

0 commit comments

Comments
 (0)