Skip to content

Commit bd093ad

Browse files
committed
Fixed bug #63185
1 parent a83cc03 commit bd093ad

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ PHP NEWS
3131
- PDO MySQL:
3232
. Fixed bug #80458 (PDOStatement::fetchAll() throws for upsert queries).
3333
(Kamil Tekiela)
34+
. Fixed bug #63185 (nextRowset() ignores MySQL errors with native prepared
35+
statements). (Nikita)
3436

3537
- Phpdbg:
3638
. Fixed bug #76813 (Access violation near NULL on source operand). (cmb)

ext/pdo_mysql/mysql_statement.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
357357
PDO_DBG_RETURN(0);
358358
}
359359
if (mysqlnd_stmt_next_result(S->stmt)) {
360+
pdo_mysql_error_stmt(stmt);
360361
PDO_DBG_RETURN(0);
361362
}
362363

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)