summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_result.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2009-05-28 11:47:48 +0000
committerAndrey Hristov <andrey@php.net>2009-05-28 11:47:48 +0000
commit6c4e8fa4f9f804a636c3d5772e15388f441a21c6 (patch)
treebcba6c85174b29f4317f08cccea00ddb9e3a2268 /ext/mysqlnd/mysqlnd_result.c
parent90a8a7f857836f7aad7b871a5b8969b1294f412f (diff)
downloadphp-git-6c4e8fa4f9f804a636c3d5772e15388f441a21c6.tar.gz
MFH:
Fix a bug with mysqlnd_fetch_field(_direct()). With mysqlnd the optimised function was called, which however, doesn't respect that during store the raw data is not unpacked, to be lazy. The data is unpacked to zvals later, during every row fetch. However, this way max_length won't be calculated correctly. So, if a mysqlnd_fetch_field(_direct) call comes we need to unpack everything and then calculate max_length...and that is expensive, defies our lazy unpacking optimisation.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_result.c')
-rw-r--r--ext/mysqlnd/mysqlnd_result.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index e2c8c2c0af..f791fd0fb5 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -1736,6 +1736,16 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field)(MYSQLND_RES * const result TSRMLS_DC)
{
DBG_ENTER("mysqlnd_res::fetch_field");
if (result->meta) {
+ /*
+ We optimize the result set, so we don't convert all the data from raw buffer format to
+ zval arrays during store. In the case someone doesn't read all the lines this will
+ save time. However, when a metadata call is done, we need to calculate max_length.
+ We don't have control whether max_length will be used, unfortunately. Otherwise we
+ could have been able to skip that step.
+ Well, if the mysqli API switches from returning stdClass to class like mysqli_field_metadata,
+ then we can have max_length as dynamic property, which will be calculated during runtime and
+ not during mysqli_fetch_field() time.
+ */
if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
/* we have to initialize the rest to get the updated max length */
mysqlnd_res_initialize_result_set_rest(result TSRMLS_CC);
@@ -1754,6 +1764,16 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field_direct)(MYSQLND_RES * const result,
{
DBG_ENTER("mysqlnd_res::fetch_field_direct");
if (result->meta) {
+ /*
+ We optimize the result set, so we don't convert all the data from raw buffer format to
+ zval arrays during store. In the case someone doesn't read all the lines this will
+ save time. However, when a metadata call is done, we need to calculate max_length.
+ We don't have control whether max_length will be used, unfortunately. Otherwise we
+ could have been able to skip that step.
+ Well, if the mysqli API switches from returning stdClass to class like mysqli_field_metadata,
+ then we can have max_length as dynamic property, which will be calculated during runtime and
+ not during mysqli_fetch_field_direct() time.
+ */
if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
/* we have to initialized the rest to get the updated max length */
mysqlnd_res_initialize_result_set_rest(result TSRMLS_CC);