From c7f10efabc6632e891923e2f03cc1d4302254666 Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Fri, 18 Jun 2010 17:25:41 +0000 Subject: [PATCH] Fix for bug #52115 mysqli_result::fetch_all returns null, not an empty array --- ext/mysqli/tests/mysqli_fetch_all.phpt | 6 ++++-- ext/mysqlnd/mysqlnd_result.c | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ext/mysqli/tests/mysqli_fetch_all.phpt b/ext/mysqli/tests/mysqli_fetch_all.phpt index 122f8cd8f1..63b6ad2848 100644 --- a/ext/mysqli/tests/mysqli_fetch_all.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all.phpt @@ -383,7 +383,8 @@ array(2) { } } [011] -NULL +array(0) { +} [013] array(2) { [0]=> @@ -402,7 +403,8 @@ array(2) { } } [016] -NULL +array(0) { +} [017] array(1) { [0]=> diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 7769018d51..539cfbce2d 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -1568,16 +1568,17 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, unsigned int flags, DBG_INF_FMT("flags=%u", flags); /* mysqlnd_res::fetch_all works with buffered resultsets only */ - if (!set || - !set->row_count || !set->data_cursor || - set->data_cursor >= set->data + set->row_count) - { + if (result->unbuf || (!result->unbuf && !set)) { RETVAL_NULL(); DBG_VOID_RETURN; - } + } mysqlnd_array_init(return_value, (unsigned int) set->row_count); + if (!set->row_count || !set->data_cursor || set->data_cursor >= set->data + set->row_count) { + DBG_VOID_RETURN; + } + while (set->data_cursor && (set->data_cursor - set->data) < (set->row_count * result->meta->field_count)) { -- 2.40.0