From 4c53c7f9e785a5121919196ea3eb306e7fd50b4f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 8 Dec 2020 14:28:18 +0100 Subject: [PATCH] Normalize handling of empty SP result set --- ext/pdo_mysql/mysql_statement.c | 10 ---- ext/pdo_mysql/tests/bug_39858.phpt | 10 +++- ext/pdo_mysql/tests/bug_41997.phpt | 4 +- .../tests/pdo_mysql_attr_oracle_nulls.phpt | 50 +++++++++++++++---- .../pdo_mysql_multi_stmt_nextrowset.phpt | 8 +++ .../tests/pdo_mysql_stmt_nextrowset.phpt | 10 +++- 6 files changed, 66 insertions(+), 26 deletions(-) diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 0d1cd348c7a59..452fa8b124d13 100644 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -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); diff --git a/ext/pdo_mysql/tests/bug_39858.phpt b/ext/pdo_mysql/tests/bug_39858.phpt index e33415eb675a9..d421d31a38ab1 100644 --- a/ext/pdo_mysql/tests/bug_39858.phpt +++ b/ext/pdo_mysql/tests/bug_39858.phpt @@ -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-- array(1) { @@ -86,6 +86,8 @@ array(1) { string(1) "4" } } +array(0) { +} Native Prepared Statements... array(1) { [0]=> @@ -94,6 +96,8 @@ array(1) { string(1) "4" } } +array(0) { +} array(1) { [0]=> array(1) { @@ -101,4 +105,6 @@ array(1) { string(1) "4" } } +array(0) { +} done! diff --git a/ext/pdo_mysql/tests/bug_41997.phpt b/ext/pdo_mysql/tests/bug_41997.phpt index 7ce2e810d43ee..769080f86a228 100644 --- a/ext/pdo_mysql/tests/bug_41997.phpt +++ b/ext/pdo_mysql/tests/bug_41997.phpt @@ -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-- string(5) "00000" diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt index 6d922a037def8..71bdf99ea77cb 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt @@ -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()); } @@ -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! diff --git a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt index e17a233109791..a65fd2eed2ef1 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt @@ -132,6 +132,8 @@ array(3) { string(1) "a" } } +array(0) { +} bool(false) array(3) { [0]=> @@ -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 @@ -219,6 +223,8 @@ array(3) { string(1) "a" } } +array(0) { +} bool(false) array(3) { [0]=> @@ -260,6 +266,8 @@ array(3) { string(1) "a" } } +array(0) { +} bool(false) string(5) "00000" done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt index eac4b9e4d80af..91a4615a52be0 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt @@ -1,7 +1,5 @@ --TEST-- MySQL PDOStatement->nextRowSet() ---XFAIL-- -nextRowset() problem with stored proc & emulation mode & mysqlnd --SKIPIF-- @@ -208,6 +208,8 @@ array(3) { string(1) "a" } } +array(0) { +} bool(false) Native PS... array(1) { @@ -258,6 +260,8 @@ array(3) { string(1) "a" } } +array(0) { +} bool(false) array(1) { [0]=> @@ -307,5 +311,7 @@ array(3) { string(1) "a" } } +array(0) { +} bool(false) done!