johannes                Thu Jun 25 19:03:52 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/mysqlnd        mysqlnd.h mysqlnd_block_alloc.c 
                                mysqlnd_block_alloc.h mysqlnd_debug.c 
                                mysqlnd_enum_n_def.h mysqlnd_palloc.c 
                                mysqlnd_ps.c mysqlnd_result.c 
                                mysqlnd_statistics.c mysqlnd_structs.h 
                                mysqlnd_wireprotocol.c php_mysqlnd.c 
  Log:
  Revert mysqlnd to RC3 state after issues with pconnects
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.h?r1=1.3.2.26&r2=1.3.2.27&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.h
diff -u php-src/ext/mysqlnd/mysqlnd.h:1.3.2.26 
php-src/ext/mysqlnd/mysqlnd.h:1.3.2.27
--- php-src/ext/mysqlnd/mysqlnd.h:1.3.2.26      Wed Jun 17 16:22:13 2009
+++ php-src/ext/mysqlnd/mysqlnd.h       Thu Jun 25 19:03:51 2009
@@ -18,13 +18,13 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.h,v 1.3.2.26 2009/06/17 16:22:13 andrey Exp $ */
+/* $Id: mysqlnd.h,v 1.3.2.27 2009/06/25 19:03:51 johannes Exp $ */
 
 #ifndef MYSQLND_H
 #define MYSQLND_H
 
-#define MYSQLND_VERSION "mysqlnd/PHP " PHP_VERSION " $Revision: 1.3.2.26 $"
-#define MYSQLND_VERSION_ID PHP_VERSION_ID
+#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $"
+#define MYSQLND_VERSION_ID 50005
 
 /* This forces inlining of some accessor functions */
 #define MYSQLND_USE_OPTIMISATIONS 1
@@ -318,9 +318,11 @@
 PHPAPI void                                             
_mysqlnd_palloc_rshutdown(MYSQLND_THD_ZVAL_PCACHE * cache TSRMLS_DC);
 
 
+#define mysqlnd_palloc_init_thd_cache(cache)                   
_mysqlnd_palloc_init_thd_cache((cache) TSRMLS_CC)
 #define mysqlnd_palloc_free_thd_cache_reference(cache) 
_mysqlnd_palloc_free_thd_cache_reference((cache) TSRMLS_CC)
 #define mysqlnd_palloc_get_thd_cache_reference(cache)  
_mysqlnd_palloc_get_thd_cache_reference((cache) TSRMLS_CC)
 
+PHPAPI MYSQLND_THD_ZVAL_PCACHE*        
_mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC);
 MYSQLND_THD_ZVAL_PCACHE*               
_mysqlnd_palloc_get_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE * const cache 
TSRMLS_DC);
 PHPAPI void                                            
_mysqlnd_palloc_free_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE **cache 
TSRMLS_DC);
 
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_block_alloc.c?r1=1.1.2.8&r2=1.1.2.9&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_block_alloc.c
diff -u php-src/ext/mysqlnd/mysqlnd_block_alloc.c:1.1.2.8 
php-src/ext/mysqlnd/mysqlnd_block_alloc.c:1.1.2.9
--- php-src/ext/mysqlnd/mysqlnd_block_alloc.c:1.1.2.8   Wed Jun 17 16:22:13 2009
+++ php-src/ext/mysqlnd/mysqlnd_block_alloc.c   Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_block_alloc.c,v 1.1.2.8 2009/06/17 16:22:13 andrey Exp $ */
+/* $Id: mysqlnd_block_alloc.c,v 1.1.2.9 2009/06/25 19:03:51 johannes Exp $ */
 
 #include "php.h"
 #include "mysqlnd.h"
@@ -35,7 +35,7 @@
        DBG_ENTER("mysqlnd_mempool_dtor");
        for (i = 0; i < pool->free_chunk_list_elements; i++) {
                MYSQLND_MEMORY_POOL_CHUNK * chunk = pool->free_chunk_list[i];
-               mysqlnd_mempool_free_chunk(chunk, FALSE TSRMLS_CC);
+               chunk->free_chunk(chunk, FALSE TSRMLS_CC);
        }
        
        DBG_VOID_RETURN;
@@ -44,14 +44,11 @@
 
 
 /* {{{ mysqlnd_mempool_free_chunk */
-void
+static void
 mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, zend_bool 
cache_it TSRMLS_DC)
 {
        MYSQLND_MEMORY_POOL * pool = chunk->pool;
        DBG_ENTER("mysqlnd_mempool_free_chunk");
-       if (!chunk) {
-               DBG_VOID_RETURN;
-       }
        if (chunk->from_pool) {
                /* Try to back-off and guess if this is the last block 
allocated */
                if (chunk->ptr == (pool->arena + (pool->arena_size - 
pool->free_size - chunk->size))) {
@@ -78,7 +75,7 @@
 
 
 /* {{{ mysqlnd_mempool_resize_chunk */
-void
+static void
 mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int 
size TSRMLS_DC)
 {
        DBG_ENTER("mysqlnd_mempool_resize_chunk");
@@ -138,6 +135,8 @@
                chunk = mnd_malloc(sizeof(MYSQLND_MEMORY_POOL_CHUNK));
        }
 
+       chunk->free_chunk = mysqlnd_mempool_free_chunk;
+       chunk->resize_chunk = mysqlnd_mempool_resize_chunk;
        chunk->size = size;
        /*
          Should not go over MYSQLND_MAX_PACKET_SIZE, since we
@@ -184,12 +183,10 @@
 mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool TSRMLS_DC)
 {
        DBG_ENTER("mysqlnd_mempool_destroy");
-       if (pool) {
-               /* mnd_free will reference LOCK_access and might crash, 
depending on the caller...*/
-               mysqlnd_mempool_free_contents(pool TSRMLS_CC);
-               mnd_free(pool->arena);
-               mnd_free(pool);
-       }
+       /* mnd_free will reference LOCK_access and might crash, depending on 
the caller...*/
+       mysqlnd_mempool_free_contents(pool TSRMLS_CC);
+       mnd_free(pool->arena);
+       mnd_free(pool);
        DBG_VOID_RETURN;
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_block_alloc.h?r1=1.1.2.3&r2=1.1.2.4&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_block_alloc.h
diff -u php-src/ext/mysqlnd/mysqlnd_block_alloc.h:1.1.2.3 
php-src/ext/mysqlnd/mysqlnd_block_alloc.h:1.1.2.4
--- php-src/ext/mysqlnd/mysqlnd_block_alloc.h:1.1.2.3   Tue Jun 16 09:15:38 2009
+++ php-src/ext/mysqlnd/mysqlnd_block_alloc.h   Thu Jun 25 19:03:51 2009
@@ -18,16 +18,13 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_block_alloc.h,v 1.1.2.3 2009/06/16 09:15:38 andrey Exp $ */
+/* $Id: mysqlnd_block_alloc.h,v 1.1.2.4 2009/06/25 19:03:51 johannes Exp $ */
 
 #ifndef MYSQLND_BLOCK_ALLOC_H
 #define MYSQLND_BLOCK_ALLOC_H
 
 MYSQLND_MEMORY_POOL *  mysqlnd_mempool_create(size_t arena_size TSRMLS_DC);
 void                                   
mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool TSRMLS_DC);
-void                                   
mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int 
size TSRMLS_DC);
-void                                   
mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, zend_bool 
cache_it TSRMLS_DC);
-
 
 #endif /* MYSQLND_BLOCK_ALLOC_H */
 
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_debug.c?r1=1.1.2.17&r2=1.1.2.18&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_debug.c
diff -u php-src/ext/mysqlnd/mysqlnd_debug.c:1.1.2.17 
php-src/ext/mysqlnd/mysqlnd_debug.c:1.1.2.18
--- php-src/ext/mysqlnd/mysqlnd_debug.c:1.1.2.17        Tue Jun 16 13:07:14 2009
+++ php-src/ext/mysqlnd/mysqlnd_debug.c Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_debug.c,v 1.1.2.17 2009/06/16 13:07:14 andrey Exp $ */
+/* $Id: mysqlnd_debug.c,v 1.1.2.18 2009/06/25 19:03:51 johannes Exp $ */
 
 #include "php.h"
 #include "mysqlnd.h"
@@ -830,9 +830,6 @@
 void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
 {
        DBG_ENTER(mysqlnd_efree_name);
-       if (!ptr) {
-               DBG_VOID_RETURN;
-       }
 #ifdef MYSQLND_THREADED
        if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
                DBG_RETURN(_mysqlnd_pefree(ptr, 1 TSRMLS_CC ZEND_FILE_LINE_CC 
ZEND_FILE_LINE_EMPTY_CC));
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_enum_n_def.h?r1=1.2.2.14&r2=1.2.2.15&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_enum_n_def.h
diff -u php-src/ext/mysqlnd/mysqlnd_enum_n_def.h:1.2.2.14 
php-src/ext/mysqlnd/mysqlnd_enum_n_def.h:1.2.2.15
--- php-src/ext/mysqlnd/mysqlnd_enum_n_def.h:1.2.2.14   Fri Jun 12 13:24:57 2009
+++ php-src/ext/mysqlnd/mysqlnd_enum_n_def.h    Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_enum_n_def.h,v 1.2.2.14 2009/06/12 13:24:57 andrey Exp $ */
+/* $Id: mysqlnd_enum_n_def.h,v 1.2.2.15 2009/06/25 19:03:51 johannes Exp $ */
 #ifndef MYSQLND_ENUM_N_DEF_H
 #define MYSQLND_ENUM_N_DEF_H
 
@@ -142,6 +142,7 @@
        MYSQLND_OPT_NET_READ_BUFFER_SIZE = 203,
 } enum_mysqlnd_option;
 
+
 typedef enum mysqlnd_field_types
 {
        MYSQL_TYPE_DECIMAL,
@@ -176,6 +177,7 @@
 /* Please update this if there is a new type after MYSQL_TYPE_GEOMETRY */
 #define MYSQL_TYPE_LAST                MYSQL_TYPE_GEOMETRY
 
+
 typedef enum mysqlnd_server_option
 {
        MYSQL_OPTION_MULTI_STATEMENTS_ON,
@@ -239,6 +241,7 @@
 /* see mysqlnd_charset.c for more information */
 #define MYSQLND_BINARY_CHARSET_NR      63
 
+
 /*
           /-----> CONN_CLOSE  <---------------\
          |           ^                         \
@@ -258,6 +261,7 @@
        CONN_QUIT_SENT, /* object is "destroyed" at this stage */
 } enum_mysqlnd_connection_state;
 
+
 typedef enum mysqlnd_stmt_state
 {
        MYSQLND_STMT_INITTED = 0,
@@ -268,11 +272,13 @@
        MYSQLND_STMT_USER_FETCHING, /* fetch_row_buff or fetch_row_unbuf */
 } enum_mysqlnd_stmt_state;
 
+
 typedef enum param_bind_flags
 {
        MYSQLND_PARAM_BIND_BLOB_USED = 1
 } enum_param_bind_flags;
 
+
 /* PS */
 enum mysqlnd_stmt_attr
 {
@@ -280,6 +286,7 @@
        STMT_ATTR_CURSOR_TYPE,
        STMT_ATTR_PREFETCH_ROWS
 };
+
 enum myslqnd_cursor_type
 {
        CURSOR_TYPE_NO_CURSOR= 0,
@@ -287,6 +294,7 @@
        CURSOR_TYPE_FOR_UPDATE= 2,
        CURSOR_TYPE_SCROLLABLE= 4
 };
+
 typedef enum mysqlnd_connection_close_type
 {
        MYSQLND_CLOSE_EXPLICIT = 0,
@@ -295,6 +303,7 @@
        MYSQLND_CLOSE_LAST      /* for checking, should always be last */
 } enum_connection_close_type;
 
+
 typedef enum mysqlnd_collected_stats
 {
        STAT_BYTES_SENT,
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_palloc.c?r1=1.2.2.19&r2=1.2.2.20&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_palloc.c
diff -u php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.19 
php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.20
--- php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.19       Tue Jun 16 07:53:35 2009
+++ php-src/ext/mysqlnd/mysqlnd_palloc.c        Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_palloc.c,v 1.2.2.19 2009/06/16 07:53:35 andrey Exp $ */
+/* $Id: mysqlnd_palloc.c,v 1.2.2.20 2009/06/25 19:03:51 johannes Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_priv.h"
@@ -82,7 +82,6 @@
 
 
 /* {{{ mysqlnd_palloc_get_cache_reference */
-static inline
 MYSQLND_ZVAL_PCACHE* mysqlnd_palloc_get_cache_reference(MYSQLND_ZVAL_PCACHE * 
const cache)
 {
        if (cache) {
@@ -95,20 +94,6 @@
 /* }}} */
 
 
-/* {{{ mysqlnd_palloc_release_cache_reference */
-static inline
-MYSQLND_ZVAL_PCACHE* 
mysqlnd_palloc_release_cache_reference(MYSQLND_ZVAL_PCACHE * const cache)
-{
-       if (cache) {
-               LOCK_PCACHE(cache);
-               cache->references--;
-               UNLOCK_PCACHE(cache);
-       }
-       return cache;
-}
-/* }}} */
-
-
 /* {{{ mysqlnd_palloc_free_cache */
 /*
   As this call will happen on MSHUTDOWN(), then we don't need to copy the 
zvals with
@@ -137,9 +122,9 @@
 
 
 /* {{{ _mysqlnd_palloc_init_thd_cache */
-MYSQLND_THD_ZVAL_PCACHE* mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * 
const cache TSRMLS_DC)
+PHPAPI MYSQLND_THD_ZVAL_PCACHE* 
_mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC)
 {
-       MYSQLND_THD_ZVAL_PCACHE *ret = mnd_ecalloc(1, 
sizeof(MYSQLND_THD_ZVAL_PCACHE));
+       MYSQLND_THD_ZVAL_PCACHE *ret = calloc(1, 
sizeof(MYSQLND_THD_ZVAL_PCACHE));
        DBG_ENTER("_mysqlnd_palloc_init_thd_cache");
        DBG_INF_FMT("ret = %p", ret);
        
@@ -161,7 +146,7 @@
        ret->references = 1;
 
        /* 1. Initialize the GC list */
-       ret->gc_list.ptr_line = mnd_ecalloc(cache->max_items, 
sizeof(mysqlnd_zval *));
+       ret->gc_list.ptr_line = calloc(cache->max_items, sizeof(mysqlnd_zval 
*));
        /* Backward and forward looping is possible */
        ret->gc_list.last_added = ret->gc_list.ptr_line;
        ret->gc_list.canary1 = (void*)0xCAFE;
@@ -178,18 +163,17 @@
 {
        DBG_ENTER("_mysqlnd_palloc_get_thd_cache_reference");
        if (cache) {
+               ++cache->references;
                DBG_INF_FMT("cache=%p new_refc=%d gc_list.canary1=%p 
gc_list.canary2=%p",
                                        cache, cache->references, 
cache->gc_list.canary1, cache->gc_list.canary2);
                mysqlnd_palloc_get_cache_reference(cache->parent);
-               /* No concurrency here, we are in the same thread */
-               ++cache->references;
        }
        DBG_RETURN(cache);
 }
 /* }}} */
 
 
-/* {{{ mysqlnd_palloc_free_thd_cache */
+/* {{{ mysqlnd_palloc_free_cache */
 /*
   As this call will happen on MSHUTDOWN(), then we don't need to copy the 
zvals with
   copy_ctor but scrap what they point to with zval_dtor() and then just free 
our
@@ -233,8 +217,8 @@
                UNLOCK_PCACHE(global_cache);
 
        }
-       mnd_efree(thd_cache->gc_list.ptr_line);
-       mnd_efree(thd_cache);
+       mnd_free(thd_cache->gc_list.ptr_line);
+       mnd_free(thd_cache);
 
        DBG_VOID_RETURN;
 }
@@ -246,7 +230,7 @@
 {
        DBG_ENTER("_mysqlnd_palloc_free_thd_cache_reference");
        if (*cache) {
-               mysqlnd_palloc_release_cache_reference((*cache)->parent);
+               --(*cache)->parent->references;
                DBG_INF_FMT("cache=%p references_left=%d canary1=%p canary2=%p",
                                        *cache, (*cache)->references, 
(*cache)->gc_list.canary1, (*cache)->gc_list.canary2);
 
@@ -413,9 +397,6 @@
 {
        MYSQLND_ZVAL_PCACHE *cache;
        DBG_ENTER("mysqlnd_palloc_zval_ptr_dtor");
-       if (!*zv) {
-               DBG_VOID_RETURN;
-       }
        if (thd_cache) {
                DBG_INF_FMT("cache=%p parent_block=%p last_in_block=%p *zv=%p 
refc=%d type=%d ",
                                        thd_cache,
@@ -547,7 +528,7 @@
 /* {{{ _mysqlnd_palloc_rinit */
 PHPAPI MYSQLND_THD_ZVAL_PCACHE * _mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * 
cache TSRMLS_DC)
 {
-       return mysqlnd_palloc_init_thd_cache(cache TSRMLS_CC);
+       return mysqlnd_palloc_init_thd_cache(cache);
 }
 /* }}} */
 
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_ps.c?r1=1.3.2.29&r2=1.3.2.30&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_ps.c
diff -u php-src/ext/mysqlnd/mysqlnd_ps.c:1.3.2.29 
php-src/ext/mysqlnd/mysqlnd_ps.c:1.3.2.30
--- php-src/ext/mysqlnd/mysqlnd_ps.c:1.3.2.29   Tue Jun 16 18:00:00 2009
+++ php-src/ext/mysqlnd/mysqlnd_ps.c    Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_ps.c,v 1.3.2.29 2009/06/16 18:00:00 andrey Exp $ */
+/* $Id: mysqlnd_ps.c,v 1.3.2.30 2009/06/25 19:03:51 johannes Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -871,7 +871,7 @@
                                                        
result->meta->fields[i].max_length = Z_STRLEN_P(data);
                                                }
                                                stmt->result_bind[i].zv->value 
= data->value;
-                                               /* copied data, thus also the 
ownership. Thus null data */
+                                               // copied data, thus also the 
ownership. Thus null data
                                                ZVAL_NULL(data);
                                        }
                                }
@@ -885,7 +885,7 @@
                          the bound variables. Thus we need to do part of what 
it does or Zend will
                          report leaks.
                        */
-                       mysqlnd_mempool_free_chunk(row_packet->row_buffer, TRUE 
TSRMLS_CC);
+                       
row_packet->row_buffer->free_chunk(row_packet->row_buffer, TRUE TSRMLS_CC);
                        row_packet->row_buffer = NULL;
                }
        } else if (ret == FAIL) {
@@ -1047,7 +1047,7 @@
                                                        
result->meta->fields[i].max_length = Z_STRLEN_P(data);
                                                }
                                                stmt->result_bind[i].zv->value 
= data->value;
-                                               /* copied data, thus also the 
ownership. Thus null data */
+                                               // copied data, thus also the 
ownership. Thus null data
                                                ZVAL_NULL(data);
                                        }
                                }
@@ -1060,13 +1060,13 @@
                          the bound variables. Thus we need to do part of what 
it does or Zend will
                          report leaks.
                        */
-                       mysqlnd_mempool_free_chunk(row_packet->row_buffer, TRUE 
TSRMLS_CC);
+                       
row_packet->row_buffer->free_chunk(row_packet->row_buffer, TRUE TSRMLS_CC);
                        row_packet->row_buffer = NULL;
                }
                /* We asked for one row, the next one should be EOF, eat it */
                ret = PACKET_READ(row_packet, result->conn);
                if (row_packet->row_buffer) {
-                       mysqlnd_mempool_free_chunk(row_packet->row_buffer, TRUE 
TSRMLS_CC);
+                       
row_packet->row_buffer->free_chunk(row_packet->row_buffer, TRUE TSRMLS_CC);
                        row_packet->row_buffer = NULL;
                }
                MYSQLND_INC_CONN_STATISTIC(&stmt->conn->stats, 
STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR);
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_result.c?r1=1.4.2.33&r2=1.4.2.34&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_result.c
diff -u php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.33 
php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.34
--- php-src/ext/mysqlnd/mysqlnd_result.c:1.4.2.33       Tue Jun 23 14:15:28 2009
+++ php-src/ext/mysqlnd/mysqlnd_result.c        Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.c,v 1.4.2.33 2009/06/23 14:15:28 dsp Exp $ */
+/* $Id: mysqlnd_result.c,v 1.4.2.34 2009/06/25 19:03:51 johannes Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -30,9 +30,6 @@
 #include "mysqlnd_debug.h"
 #include "ext/standard/basic_functions.h"
 
-#define START_FREEING_AFTER_X_ROWS 10
-static void mysqlnd_buffered_free_previous_row(MYSQLND_RES *result, int which 
TSRMLS_DC);
-
 #define MYSQLND_SILENT
 
 #ifdef MYSQLND_THREADED
@@ -104,18 +101,11 @@
        unsigned int field_count = result->meta->field_count;
        unsigned int row_count = result->stored_data->row_count;
        DBG_ENTER("mysqlnd_res_initialize_result_set_rest");
-       DBG_INF_FMT("before heap=%lu real=%lu", zend_memory_usage(FALSE 
TSRMLS_CC), zend_memory_usage(TRUE TSRMLS_CC));
 
        if (!data_cursor || row_count == result->stored_data->initialized_rows) 
{
                DBG_VOID_RETURN;
        }
        while ((data_cursor - data_begin) < (row_count * field_count)) {
-               if (START_FREEING_AFTER_X_ROWS < ((data_cursor - data_begin) / 
result->field_count)) {
-                       zval **orig_data_cursor = 
result->stored_data->data_cursor;
-                       result->stored_data->data_cursor = data_cursor;
-                       mysqlnd_buffered_free_previous_row(result, 
START_FREEING_AFTER_X_ROWS TSRMLS_CC);
-                       result->stored_data->data_cursor = orig_data_cursor;
-               }
                if (NULL == data_cursor[0]) {
                        result->stored_data->initialized_rows++;
                        result->m.row_decoder(
@@ -140,7 +130,6 @@
                }
                data_cursor += field_count;
        }
-       DBG_INF_FMT("after heap=%lu real=%lu", zend_memory_usage(FALSE 
TSRMLS_CC), zend_memory_usage(TRUE TSRMLS_CC));
        DBG_VOID_RETURN;
 }
 /* }}} */
@@ -188,7 +177,7 @@
        if (unbuf->last_row_buffer) {
                DBG_INF("Freeing last row buffer");
                /* Nothing points to this buffer now, free it */
-               mysqlnd_mempool_free_chunk(unbuf->last_row_buffer, TRUE 
TSRMLS_CC);
+               unbuf->last_row_buffer->free_chunk(unbuf->last_row_buffer, TRUE 
TSRMLS_CC);
                unbuf->last_row_buffer = NULL;
        }
 
@@ -197,59 +186,6 @@
 /* }}} */
 
 
-/* {{{ mysqlnd_buffered_free_previous_row */
-static
-void mysqlnd_buffered_free_previous_row(MYSQLND_RES *result, int which 
TSRMLS_DC)
-{
-       return;
-#ifdef JOHANNES_0
-       /* optimization currently disabled as this breaks fetching data with
-          more than START_FREEING_AFTER_X_ROWS rows */
-
-       MYSQLND_RES_BUFFERED * set = result->stored_data;
-
-       DBG_ENTER("mysqlnd_buffered_free_previous_row");
-
-       if (!set) {
-               DBG_VOID_RETURN;
-       }
-
-       DBG_INF_FMT("which=%d result->field_count=%d data=%p data_cursor=%p", 
which, result->field_count, set->data, set->data_cursor);
-       if (set->data_cursor && ((set->data_cursor - (which * 
result->field_count) ) >= set->data)) {
-               unsigned int i, ctor_called_count = 0;
-               zend_bool copy_ctor_called;
-               MYSQLND_STATS *global_stats = result->conn? 
&result->conn->stats:NULL;
-               zval **current_row = set->data_cursor - (which * 
result->field_count);
-
-               DBG_INF_FMT("%u columns to free", result->field_count);
-               for (i = 0; i < result->field_count; i++) {
-                       if (current_row[i]) {
-                               mysqlnd_palloc_zval_ptr_dtor(&(current_row[i]),
-                                                                               
         result->zval_cache, result->type,
-                                                                               
         &copy_ctor_called TSRMLS_CC);
-                               if (copy_ctor_called) {
-                                       ctor_called_count++;
-                               }
-                               current_row[i] = NULL;
-                       }
-               }
-               DBG_INF_FMT("copy_ctor_called_count=%u", ctor_called_count);
-               /* By using value3 macros we hold a mutex only once, there is 
no value2 */
-               MYSQLND_INC_CONN_STATISTIC_W_VALUE3(global_stats,
-                                                                               
        STAT_COPY_ON_WRITE_PERFORMED,
-                                                                               
        ctor_called_count,
-                                                                               
        STAT_COPY_ON_WRITE_SAVED,
-                                                                               
        result->field_count - ctor_called_count,
-                                                                               
        STAT_COPY_ON_WRITE_PERFORMED, 0);
-       }
-
-       DBG_VOID_RETURN;
-#endif
-}
-/* }}} */
-
-
-
 /* {{{ mysqlnd_free_buffered_data */
 void mysqlnd_free_buffered_data(MYSQLND_RES *result TSRMLS_DC)
 {
@@ -269,20 +205,21 @@
 
                for (col = field_count - 1; col >= 0; --col) {
                        zend_bool copy_ctor_called;
-                       if (current_row[col] != NULL) {
-                               
mysqlnd_palloc_zval_ptr_dtor(&(current_row[col]), zval_cache,
+                       if (current_row[0] == NULL) {
+                               break;/* row that was never initialized */
+                       }
+                       mysqlnd_palloc_zval_ptr_dtor(&(current_row[col]), 
zval_cache,
                                                                                
 result->type, &copy_ctor_called TSRMLS_CC);
 #if MYSQLND_DEBUG_MEMORY
-                               DBG_INF_FMT("Copy_ctor_called=%d", 
copy_ctor_called);
+                       DBG_INF_FMT("Copy_ctor_called=%d", copy_ctor_called);
 #endif
-                               MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? 
STAT_COPY_ON_WRITE_PERFORMED:
-                                                                               
                                           STAT_COPY_ON_WRITE_SAVED);
-                       }
+                       MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? 
STAT_COPY_ON_WRITE_PERFORMED:
+                                                                               
                                   STAT_COPY_ON_WRITE_SAVED);
                }
 #if MYSQLND_DEBUG_MEMORY
                DBG_INF("Freeing current_row & current_buffer");
 #endif
-               mysqlnd_mempool_free_chunk(current_buffer, TRUE TSRMLS_CC);
+               current_buffer->free_chunk(current_buffer, TRUE TSRMLS_CC);
        }
        DBG_INF("Freeing data & row_buffer");
        if (set->data) {
@@ -360,7 +297,7 @@
 #endif
                        pefree(current_row, set->persistent);
                }
-               mysqlnd_mempool_free_chunk(current_buffer, TRUE TSRMLS_CC);
+               current_buffer->free_chunk(current_buffer, TRUE TSRMLS_CC);
        }
        DBG_INF("Freeing data & row_buffer");
        pefree(set->data, set->persistent);
@@ -1162,10 +1099,6 @@
                zval **current_row = set->data_cursor;
                MYSQLND_FIELD *field = result->meta->fields;
                struct mysqlnd_field_hash_key *zend_hash_key = 
result->meta->zend_hash_keys;
-               DBG_INF_FMT("row_num=%u", (set->data_cursor - set->data) / 
result->meta->field_count);
-               if (START_FREEING_AFTER_X_ROWS < ((set->data_cursor - 
set->data) / result->field_count)) {
-                       mysqlnd_buffered_free_previous_row(result, 
START_FREEING_AFTER_X_ROWS TSRMLS_CC);
-               }
 
                if (NULL == current_row[0]) {
                        uint64_t row_num = (set->data_cursor - set->data) / 
result->meta->field_count;
@@ -1915,7 +1848,6 @@
 
        DBG_ENTER("mysqlnd_res::fetch_into");
        DBG_INF_FMT("flags=%u mysqlnd_extension=%d", flags, extension);
-       DBG_INF_FMT("memory in use: heap_size=%lu real_size=%u", 
zend_memory_usage(FALSE TSRMLS_CC), zend_memory_usage(TRUE TSRMLS_CC));
 
        if (!result->m.fetch_row) {
                RETVAL_NULL();
@@ -1927,7 +1859,7 @@
        */
        mysqlnd_array_init(return_value, mysqlnd_num_fields(result) * 2);
        if (FAIL == result->m.fetch_row(result, (void *)return_value, flags, 
&fetched_anything TSRMLS_CC)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while 
reading/decoding a row");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while 
reading a row");
                RETVAL_FALSE;
        } else if (fetched_anything == FALSE) {
                zval_dtor(return_value);
@@ -1945,7 +1877,6 @@
          return_value is IS_NULL for no more data and an array for data. Thus 
it's ok
          to return here.
        */
-       DBG_INF_FMT("returning: heap_size=%lu real_size=%u", 
zend_memory_usage(FALSE TSRMLS_CC), zend_memory_usage(TRUE TSRMLS_CC));
        DBG_VOID_RETURN;
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_statistics.c?r1=1.2.2.11&r2=1.2.2.12&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_statistics.c
diff -u php-src/ext/mysqlnd/mysqlnd_statistics.c:1.2.2.11 
php-src/ext/mysqlnd/mysqlnd_statistics.c:1.2.2.12
--- php-src/ext/mysqlnd/mysqlnd_statistics.c:1.2.2.11   Fri Jun 12 13:24:57 2009
+++ php-src/ext/mysqlnd/mysqlnd_statistics.c    Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_statistics.c,v 1.2.2.11 2009/06/12 13:24:57 andrey Exp $ */
+/* $Id: mysqlnd_statistics.c,v 1.2.2.12 2009/06/25 19:03:51 johannes Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_priv.h"
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_structs.h?r1=1.2.2.20&r2=1.2.2.21&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_structs.h
diff -u php-src/ext/mysqlnd/mysqlnd_structs.h:1.2.2.20 
php-src/ext/mysqlnd/mysqlnd_structs.h:1.2.2.21
--- php-src/ext/mysqlnd/mysqlnd_structs.h:1.2.2.20      Tue Jun 16 09:15:38 2009
+++ php-src/ext/mysqlnd/mysqlnd_structs.h       Thu Jun 25 19:03:51 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_structs.h,v 1.2.2.20 2009/06/16 09:15:38 andrey Exp $ */
+/* $Id: mysqlnd_structs.h,v 1.2.2.21 2009/06/25 19:03:51 johannes Exp $ */
 
 #ifndef MYSQLND_STRUCTS_H
 #define MYSQLND_STRUCTS_H
@@ -45,10 +45,12 @@
 
 struct st_mysqlnd_memory_pool_chunk
 {
-       uint32_t                        app;
+       uint64_t                        app;
        MYSQLND_MEMORY_POOL *pool;
        zend_uchar                      *ptr;
-       uint32_t                        size;
+       unsigned int                            size;
+       void                            
(*resize_chunk)(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size TSRMLS_DC);
+       void                            (*free_chunk)(MYSQLND_MEMORY_POOL_CHUNK 
* chunk, zend_bool cache_it TSRMLS_DC);
        zend_bool                       from_pool;
 };
 
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_wireprotocol.c?r1=1.4.2.31&r2=1.4.2.32&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_wireprotocol.c
diff -u php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.4.2.31 
php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.4.2.32
--- php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.4.2.31 Tue Jun 16 09:15:38 2009
+++ php-src/ext/mysqlnd/mysqlnd_wireprotocol.c  Thu Jun 25 19:03:52 2009
@@ -42,6 +42,7 @@
 #define MYSQLND_DUMP_HEADER_N_BODY2
 #define MYSQLND_DUMP_HEADER_N_BODY_FULL2
 
+
 #define        PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_size, 
packet_type_as_text, packet_type) \
        { \
                if (FAIL == mysqlnd_read_header((conn), &((packet)->header) 
TSRMLS_CC)) {\
@@ -69,6 +70,7 @@
                                                                                
        1); \
        }
 
+
 extern mysqlnd_packet_methods packet_methods[];
 
 static const char *unknown_sqlstate= "HY000";
@@ -610,7 +612,7 @@
        /* pad2 */
        p+= 13;
 
-       if ((size_t)(p - buf) < packet->header.size) {
+       if (p - buf < packet->header.size) {
                /* scramble_buf is split into two parts */
                memcpy(packet->scramble_buf + SCRAMBLE_LENGTH_323,
                                p, SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323);
@@ -624,7 +626,7 @@
        DBG_INF_FMT("server_capabilities=%d charset_no=%d server_status=%d",
                                packet->server_capabilities, 
packet->charset_no, packet->server_status);
 
-       if ((size_t)(p - begin) > packet->header.size) {
+       if (p - begin > packet->header.size) {
                DBG_ERR_FMT("GREET packet %d bytes shorter than expected", p - 
begin - packet->header.size);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet 
"MYSQLND_SZ_T_SPEC" bytes shorter than expected",
                                                 p - begin - 
packet->header.size);
@@ -809,7 +811,7 @@
        p+= 2;
 
        /* There is a message */
-       if (packet->header.size > (size_t) (p - buf) && (i = 
php_mysqlnd_net_field_length(&p))) {
+       if (packet->header.size > p - buf && (i = 
php_mysqlnd_net_field_length(&p))) {
                packet->message = pestrndup((char *)p, MIN(i, sizeof(buf) - (p 
- buf)), conn->persistent);
                packet->message_len = i;
        } else {
@@ -820,7 +822,7 @@
                                packet->affected_rows, packet->last_insert_id, 
packet->server_status,
                                packet->warning_count);
 
-       if ((size_t)(p - begin) > packet->header.size) {
+       if (p - begin > packet->header.size) {
                DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - 
begin - packet->header.size);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "OK packet 
"MYSQLND_SZ_T_SPEC" bytes shorter than expected",
                                                 p - begin - 
packet->header.size);
@@ -893,7 +895,7 @@
                packet->server_status = 0;
        }
 
-       if ((size_t)(p - begin) > packet->header.size) {
+       if (p - begin > packet->header.size) {
                DBG_ERR_FMT("EOF packet %d bytes shorter than expected", p - 
begin - packet->header.size);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "EOF packet 
"MYSQLND_SZ_T_SPEC" bytes shorter than expected",
                                                 p - begin - 
packet->header.size);
@@ -1043,7 +1045,7 @@
                        packet->warning_count = uint2korr(p);
                        p+=2;
                        /* Check for additional textual data */
-                       if (packet->header.size  > (size_t) (p - buf) && (len = 
php_mysqlnd_net_field_length(&p))) {
+                       if (packet->header.size  > (p - buf) && (len = 
php_mysqlnd_net_field_length(&p))) {
                                packet->info_or_local_file = mnd_pemalloc(len + 
1, conn->persistent);
                                memcpy(packet->info_or_local_file, p, len);
                                packet->info_or_local_file[len] = '\0';
@@ -1058,7 +1060,7 @@
                        /* Result set */
                        break;
        }
-       if ((size_t)(p - begin) > packet->header.size) {
+       if (p - begin > packet->header.size) {
                DBG_ERR_FMT("RSET_HEADER packet %d bytes shorter than 
expected", p - begin - packet->header.size);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet 
"MYSQLND_SZ_T_SPEC" bytes shorter than expected",
                                                 p - begin - 
packet->header.size);
@@ -1186,7 +1188,7 @@
          NULL_LENGTH (0xFB) comes from COM_FIELD_LIST when the default value 
is NULL.
          Otherwise the string is length encoded.
        */
-       if (packet->header.size > (size_t)(p - buf) &&
+       if (packet->header.size > (p - buf) &&
                (len = php_mysqlnd_net_field_length(&p)) &&
                len != MYSQLND_NULL_LENGTH)
        {
@@ -1198,7 +1200,7 @@
                p += len;
        }
 
-       if ((size_t)(p - begin) > packet->header.size) {
+       if (p - begin > packet->header.size) {
                DBG_ERR_FMT("RSET field packet %d bytes shorter than expected", 
p - begin - packet->header.size);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set field 
packet "MYSQLND_SZ_T_SPEC" bytes "
                                                "shorter than expected", p - 
begin - packet->header.size);
@@ -1326,7 +1328,7 @@
                          We need a trailing \0 for the last string, in case of 
text-mode,
                          to be able to implement read-only variables.
                        */
-                       mysqlnd_mempool_resize_chunk((*buffer), *data_size + 1 
TSRMLS_CC);
+                       (*buffer)->resize_chunk((*buffer), *data_size + 1 
TSRMLS_CC);
                        /* The position could have changed, recalculate */
                        p = (*buffer)->ptr + (*data_size - header.size);
                }
@@ -1342,8 +1344,8 @@
                        break;
                }
        }
-       if (ret == FAIL && (*buffer)) {
-               mysqlnd_mempool_free_chunk(*buffer, TRUE TSRMLS_CC);
+       if (ret == FAIL) {
+               (*buffer)->free_chunk((*buffer), TRUE TSRMLS_CC);
                *buffer = NULL;
        }
        *data_size -= prealloc_more_bytes;
@@ -1361,10 +1363,8 @@
        zend_uchar *null_ptr, bit;
        zval **current_field, **end_field, **start_field;
        zend_bool as_unicode = conn->options.numeric_and_datetime_as_unicode;
-#ifdef USE_ZVAL_CACHE
        zend_bool allocated;
-       void *obj = NULL;
-#endif
+       void *obj;
 
        DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
 
@@ -1826,7 +1826,7 @@
        DBG_ENTER("php_mysqlnd_rowp_free_mem");
        p = (php_mysql_packet_row *) _packet;
        if (p->row_buffer) {
-               mysqlnd_mempool_free_chunk(p->row_buffer, TRUE TSRMLS_CC);
+               p->row_buffer->free_chunk(p->row_buffer, TRUE TSRMLS_CC);
                p->row_buffer = NULL;
        }
        DBG_INF_FMT("alloca=%d persistent=%d", (int)alloca, 
(int)p->header.persistent);
@@ -1944,7 +1944,7 @@
        DBG_INF_FMT("Prepare packet read: stmt_id=%d fields=%d params=%d",
                                packet->stmt_id, packet->field_count, 
packet->param_count);
 
-       if ((size_t) (p - begin) > packet->header.size) {
+       if (p - begin > packet->header.size) {
                DBG_ERR_FMT("PREPARE packet %d bytes shorter than expected", p 
- begin - packet->header.size);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "PREPARE packet 
"MYSQLND_SZ_T_SPEC" bytes shorter than expected",
                                                 p - begin - 
packet->header.size);
@@ -2004,7 +2004,7 @@
                                                                                
 packet->error_info.sqlstate
                                                                                
 TSRMLS_CC);
        }
-       if ((size_t)(p - begin) > packet->header.size) {
+       if (p - begin > packet->header.size) {
                DBG_ERR_FMT("CHANGE_USER packet %d bytes shorter than 
expected", p - begin - packet->header.size);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "CHANGE_USER packet 
"MYSQLND_SZ_T_SPEC" bytes shorter than expected",
                                                 p - begin - 
packet->header.size);
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/php_mysqlnd.c?r1=1.1.2.10&r2=1.1.2.11&diff_format=u
Index: php-src/ext/mysqlnd/php_mysqlnd.c
diff -u php-src/ext/mysqlnd/php_mysqlnd.c:1.1.2.10 
php-src/ext/mysqlnd/php_mysqlnd.c:1.1.2.11
--- php-src/ext/mysqlnd/php_mysqlnd.c:1.1.2.10  Thu Jun 11 08:30:08 2009
+++ php-src/ext/mysqlnd/php_mysqlnd.c   Thu Jun 25 19:03:52 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_mysqlnd.c,v 1.1.2.10 2009/06/11 08:30:08 andrey Exp $ */
+/* $Id: php_mysqlnd.c,v 1.1.2.11 2009/06/25 19:03:52 johannes Exp $ */
 #include "php.h"
 #include "php_ini.h"
 #include "mysqlnd.h"
@@ -46,13 +46,13 @@
 
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
        while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values),
-               (void **)&values_entry, &pos_values) == SUCCESS) {
+                                                                               
(void **)&values_entry, &pos_values) == SUCCESS) {
+               TSRMLS_FETCH();
                zstr    string_key;
                uint    string_key_len;
                ulong   num_key;
                int     s_len;
                char    *s = NULL;
-               TSRMLS_FETCH();
 
                zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, 
&string_key_len, &num_key, 0, &pos_values);
 

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

Reply via email to