andrey          Thu May 28 11:47:48 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/mysqlnd        mysqlnd.h mysqlnd_debug.c mysqlnd_result.c 
  Log:
  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.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.h?r1=1.3.2.22&r2=1.3.2.23&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.h
diff -u php-src/ext/mysqlnd/mysqlnd.h:1.3.2.22 
php-src/ext/mysqlnd/mysqlnd.h:1.3.2.23
--- php-src/ext/mysqlnd/mysqlnd.h:1.3.2.22      Mon Feb 16 17:26:43 2009
+++ php-src/ext/mysqlnd/mysqlnd.h       Thu May 28 11:47:48 2009
@@ -18,12 +18,12 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.h,v 1.3.2.22 2009/02/16 17:26:43 johannes Exp $ */
+/* $Id: mysqlnd.h,v 1.3.2.23 2009/05/28 11:47:48 andrey Exp $ */
 
 #ifndef MYSQLND_H
 #define MYSQLND_H
 
-#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.22 $"
+#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.23 $"
 #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.1.2.15&r2=1.1.2.16&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_debug.c
diff -u php-src/ext/mysqlnd/mysqlnd_debug.c:1.1.2.15 
php-src/ext/mysqlnd/mysqlnd_debug.c:1.1.2.16
--- php-src/ext/mysqlnd/mysqlnd_debug.c:1.1.2.15        Mon Mar 30 16:52:33 2009
+++ php-src/ext/mysqlnd/mysqlnd_debug.c Thu May 28 11:47:48 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_debug.c,v 1.1.2.15 2009/03/30 16:52:33 felipe Exp $ */
+/* $Id: mysqlnd_debug.c,v 1.1.2.16 2009/05/28 11:47:48 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.4.2.26&r2=1.4.2.27&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_result.c
diff -u php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.26 
php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.27
--- php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.26       Mon Mar 30 16:52:33 2009
+++ php-src/ext/mysqlnd/mysqlnd_result.c        Thu May 28 11:47:48 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.c,v 1.4.2.26 2009/03/30 16:52:33 felipe Exp $ */
+/* $Id: mysqlnd_result.c,v 1.4.2.27 2009/05/28 11:47:48 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