Skip to content

PDO MySQL: Normalize handling of empty stored procedure result set #6497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions ext/pdo_mysql/mysql_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,6 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
PDO_DBG_RETURN(0);
}

if (!mysqlnd_stmt_more_results(S->stmt)) {
/*
MySQL gives us n + 1 result sets for
CALL proc() and n result sets returned by the proc itself.
Result set n + 1 is about the procedure call itself.
As the PDO emulation does not return it, we skip it as well
*/
PDO_DBG_RETURN(0);
}

/* TODO - this code is stolen from execute() - see above */
if (S->result) {
mysql_free_result(S->result);
Expand Down
10 changes: 8 additions & 2 deletions ext/pdo_mysql/tests/bug_39858.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ if ($version < 50000)
die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
$matches[1], $matches[2], $matches[3], $version));
?>
--XFAIL--
nextRowset() problem with stored proc & emulation mode & mysqlnd
--FILE--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
Expand Down Expand Up @@ -79,13 +77,17 @@ array(1) {
string(1) "4"
}
}
array(0) {
}
array(1) {
[0]=>
array(1) {
["2 * 2"]=>
string(1) "4"
}
}
array(0) {
}
Native Prepared Statements...
array(1) {
[0]=>
Expand All @@ -94,11 +96,15 @@ array(1) {
string(1) "4"
}
}
array(0) {
}
array(1) {
[0]=>
array(1) {
["2 * 2"]=>
string(1) "4"
}
}
array(0) {
}
done!
4 changes: 2 additions & 2 deletions ext/pdo_mysql/tests/bug_41997.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
PDO MySQL Bug #41997 (stored procedure call returning single rowset blocks future queries)
--XFAIL--
nextRowset() problem with stored proc & emulation mode & mysqlnd
--SKIPIF--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
Expand Down Expand Up @@ -46,6 +44,8 @@ array(1) {
string(1) "1"
}
}
array(0) {
}
array(3) {
[0]=>
string(5) "00000"
Expand Down
50 changes: 40 additions & 10 deletions ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,12 @@ MySQLPDOTest::skip();
),
);
do {
$tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($tmp != $expected) {
printf("[004] Expecting %s got %s\n",
var_export($expected, true), var_export($tmp, true));
}
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
} while ($stmt->nextRowset());

$stmt->execute();
do {
$tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($tmp != $expected) {
printf("[005] Expecting %s got %s\n",
var_export($expected, true), var_export($tmp, true));
}
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
} while ($stmt->nextRowset());

}
Expand Down Expand Up @@ -124,4 +116,42 @@ array(1) {
string(3) "%se"
}
}
array(1) {
[0]=>
array(6) {
["z"]=>
NULL
["a"]=>
string(0) ""
["b"]=>
string(1) " "
["c"]=>
string(0) ""
["d"]=>
string(2) " d"
["e"]=>
string(2) " e"
}
}
array(0) {
}
array(1) {
[0]=>
array(6) {
["z"]=>
NULL
["a"]=>
string(0) ""
["b"]=>
string(1) " "
["c"]=>
string(0) ""
["d"]=>
string(2) " d"
["e"]=>
string(2) " e"
}
}
array(0) {
}
done!
8 changes: 8 additions & 0 deletions ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)
array(3) {
[0]=>
Expand Down Expand Up @@ -173,6 +175,8 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)

Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'INSERT INTO test (id, label) VALUES (99, 'x')' at line 1 in %s on line %d
Expand Down Expand Up @@ -219,6 +223,8 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)
array(3) {
[0]=>
Expand Down Expand Up @@ -260,6 +266,8 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)
string(5) "00000"
done!
10 changes: 8 additions & 2 deletions ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
MySQL PDOStatement->nextRowSet()
--XFAIL--
nextRowset() problem with stored proc & emulation mode & mysqlnd
--SKIPIF--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
Expand Down Expand Up @@ -159,6 +157,8 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)
array(1) {
[0]=>
Expand Down Expand Up @@ -208,6 +208,8 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)
Native PS...
array(1) {
Expand Down Expand Up @@ -258,6 +260,8 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)
array(1) {
[0]=>
Expand Down Expand Up @@ -307,5 +311,7 @@ array(3) {
string(1) "a"
}
}
array(0) {
}
bool(false)
done!