andrey          Thu May 28 11:47:15 2009 UTC

  Modified files:              
    /php-src/ext/mysqlnd        mysqlnd.h mysqlnd_debug.c mysqlnd_result.c 
  Log:
  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.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.h?r1=1.25&r2=1.26&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.h
diff -u php-src/ext/mysqlnd/mysqlnd.h:1.25 php-src/ext/mysqlnd/mysqlnd.h:1.26
--- php-src/ext/mysqlnd/mysqlnd.h:1.25  Mon Feb 16 17:25:37 2009
+++ php-src/ext/mysqlnd/mysqlnd.h       Thu May 28 11:47:15 2009
@@ -18,12 +18,12 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.h,v 1.25 2009/02/16 17:25:37 johannes Exp $ */
+/* $Id: mysqlnd.h,v 1.26 2009/05/28 11:47:15 andrey Exp $ */
 
 #ifndef MYSQLND_H
 #define MYSQLND_H
 
-#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 1.25 $"
+#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 1.26 $"
 #define MYSQLND_VERSION_ID 50005
 
 /* This forces inlining of some accessor functions */
@@ -158,8 +158,8 @@
 #define mysqlnd_field_seek(result, ofs)                        
(result)->m.seek_field((result), (ofs))
 #define mysqlnd_field_tell(result)                             
((result)->meta? (result)->meta->current_field:0)
 #define mysqlnd_fetch_field(result)                            
(result)->m.fetch_field((result) TSRMLS_CC)
-#define mysqlnd_fetch_field_direct(result,fnr) ((result)->meta? 
&((result)->meta->fields[(fnr)]):NULL)
-#define mysqlnd_fetch_fields(result)                   ((result)->meta? 
(result)->meta->fields: NULL)
+#define mysqlnd_fetch_field_direct(result,fnr) 
(result)->m.fetch_field_direct((result), (fnr) TSRMLS_CC)
+#define mysqlnd_fetch_fields(result)                   
(result)->m.fetch_fields((result) TSRMLS_CC)
 
 /* mysqlnd metadata */
 #define mysqlnd_get_client_info()              MYSQLND_VERSION
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_debug.c?r1=1.14&r2=1.15&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_debug.c
diff -u php-src/ext/mysqlnd/mysqlnd_debug.c:1.14 
php-src/ext/mysqlnd/mysqlnd_debug.c:1.15
--- php-src/ext/mysqlnd/mysqlnd_debug.c:1.14    Mon Mar 30 13:53:35 2009
+++ php-src/ext/mysqlnd/mysqlnd_debug.c Thu May 28 11:47:15 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_debug.c,v 1.14 2009/03/30 13:53:35 johannes Exp $ */
+/* $Id: mysqlnd_debug.c,v 1.15 2009/05/28 11:47:15 andrey Exp $ */
 
 #include "php.h"
 #include "mysqlnd.h"
@@ -815,7 +815,7 @@
        if (persistent == FALSE) {
                DBG_INF_FMT("after : %lu", zend_memory_usage(persistent 
TSRMLS_CC));
        }
-       MYSQLND_INC_GLOBAL_STATISTIC(persistent? 
STAT_MEM_EREALLOC_COUNT:STAT_MEM_REALLOC_COUNT);
+       MYSQLND_INC_GLOBAL_STATISTIC(persistent? 
STAT_MEM_REALLOC_COUNT:STAT_MEM_EREALLOC_COUNT);
        if (MYSQLND_G(collect_memory_statistics)) {
                enum mysqlnd_collected_stats s1 = persistent? 
STAT_MEM_REALLOC_COUNT:STAT_MEM_EREALLOC_COUNT;
                enum mysqlnd_collected_stats s2 = persistent? 
STAT_MEM_REALLOC_AMMOUNT:STAT_MEM_EREALLOC_AMMOUNT;
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_result.c?r1=1.30&r2=1.31&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_result.c
diff -u php-src/ext/mysqlnd/mysqlnd_result.c:1.30 
php-src/ext/mysqlnd/mysqlnd_result.c:1.31
--- php-src/ext/mysqlnd/mysqlnd_result.c:1.30   Fri Mar 27 19:28:26 2009
+++ php-src/ext/mysqlnd/mysqlnd_result.c        Thu May 28 11:47:15 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.c,v 1.30 2009/03/27 19:28:26 felipe Exp $ */
+/* $Id: mysqlnd_result.c,v 1.31 2009/05/28 11:47:15 andrey Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -1736,6 +1736,16 @@
 {
        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 @@
 {
        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);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to