From 1bdc780d30450593c1289845e95e9749ff38181a Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Wed, 16 Feb 2011 16:36:33 +0000 Subject: [PATCH] fixed a problem in mysqlnd. 0 was always as num_rows returned for unbuffered sets (text protocol and PS). --- NEWS | 4 ++++ ext/mysqli/tests/mysqli_stmt_num_rows.phpt | 4 ++-- ext/mysqlnd/mysqlnd_result.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index cef3f418f7..49b929ec41 100644 --- a/NEWS +++ b/NEWS @@ -87,6 +87,10 @@ . Fixed bug #53963 (Ensure error_code is always set during some failed decodings). (Scott) +- mysqlnd + . Fixed problem with always returning 0 as num_rows for unbuffered sets. + (Andrey, Ulf) + - MySQL Improved extension: . Added 'db' and 'catalog' keys to the field fetching functions (FR #39847). (Kalle) diff --git a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt index 0a21bb5471..af81ca4e8a 100644 --- a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt +++ b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt @@ -82,8 +82,8 @@ require_once('skipifconnectfailure.inc'); $i++; } while (mysqli_stmt_fetch($stmt)); - if (0 !== ($tmp = mysqli_stmt_num_rows($stmt))) - printf("[54] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (7 !== ($tmp = mysqli_stmt_num_rows($stmt))) + printf("[54] Expecting int/7, got %s/%s\n", gettype($tmp), $tmp); } else { printf("[055] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 2979e56667..947e788635 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -1401,7 +1401,7 @@ static uint64_t MYSQLND_METHOD(mysqlnd_res, num_rows)(const MYSQLND_RES * const result TSRMLS_DC) { /* Be compatible with libmysql. We count row_count, but will return 0 */ - return result->stored_data? result->stored_data->row_count:0; + return result->stored_data? result->stored_data->row_count:(result->unbuf && result->unbuf->eof_reached? result->unbuf->row_count:0); } /* }}} */ -- 2.40.0