johannes                Mon Feb 16 17:25:37 2009 UTC

  Modified files:              
    /php-src/ext/mysqlnd        mysqlnd.c mysqlnd.h mysqlnd_priv.h 
                                mysqlnd_ps.c mysqlnd_ps_codec.c 
  Log:
  - Improve mysqlnd's internal method registration
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.c?r1=1.37&r2=1.38&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.c
diff -u php-src/ext/mysqlnd/mysqlnd.c:1.37 php-src/ext/mysqlnd/mysqlnd.c:1.38
--- php-src/ext/mysqlnd/mysqlnd.c:1.37  Wed Dec 31 11:12:33 2008
+++ php-src/ext/mysqlnd/mysqlnd.c       Mon Feb 16 17:25:37 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.c,v 1.37 2008/12/31 11:12:33 sebastian Exp $ */
+/* $Id: mysqlnd.c,v 1.38 2009/02/16 17:25:37 johannes Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -68,19 +68,7 @@
 
 static enum_func_status mysqlnd_send_close(MYSQLND * conn TSRMLS_DC);
 
-
-/* {{{ mysqlnd_library_init */
-void mysqlnd_library_init(TSRMLS_D)
-{
-       if (mysqlnd_library_initted == FALSE) {
-               mysqlnd_library_initted = TRUE;
-               _mysqlnd_init_ps_subsystem();
-               /* Should be calloc, as mnd_calloc will reference LOCK_access*/
-               mysqlnd_stats_init(&mysqlnd_global_stats);
-       }
-}
-/* }}} */
-
+static struct st_mysqlnd_conn_methods *mysqlnd_conn_methods;
 
 /* {{{ mysqlnd_library_end */
 void mysqlnd_library_end(TSRMLS_D)
@@ -2125,7 +2113,6 @@
 
 MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC);
 
-
 MYSQLND_CLASS_METHODS_START(mysqlnd_conn)
        MYSQLND_METHOD(mysqlnd_conn, escape_string),
        MYSQLND_METHOD(mysqlnd_conn, set_charset),
@@ -2196,7 +2183,7 @@
        SET_ERROR_AFF_ROWS(ret);
        ret->persistent = persistent;
 
-       ret->m = & mysqlnd_mysqlnd_conn_methods;
+       ret->m = mysqlnd_conn_methods;
        ret->m->get_reference(ret TSRMLS_CC);
 
 #ifdef MYSQLND_THREADED
@@ -2212,6 +2199,32 @@
 }
 /* }}} */
 
+/* {{{ mysqlnd_library_init */
+void mysqlnd_library_init(TSRMLS_D)
+{
+       if (mysqlnd_library_initted == FALSE) {
+               mysqlnd_library_initted = TRUE;
+               mysqlnd_conn_methods = 
&MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_conn);
+               _mysqlnd_init_ps_subsystem();
+               /* Should be calloc, as mnd_calloc will reference LOCK_access*/
+               mysqlnd_stats_init(&mysqlnd_global_stats);
+       }
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_get_methods */
+PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods()
+{
+       return mysqlnd_conn_methods;
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_set_methods */
+PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods)
+{
+       mysqlnd_conn_methods = methods;
+}
+/* }}} */
 
 /*
  * Local variables:
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.h?r1=1.24&r2=1.25&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.h
diff -u php-src/ext/mysqlnd/mysqlnd.h:1.24 php-src/ext/mysqlnd/mysqlnd.h:1.25
--- php-src/ext/mysqlnd/mysqlnd.h:1.24  Wed Dec 31 11:12:33 2008
+++ php-src/ext/mysqlnd/mysqlnd.h       Mon Feb 16 17:25:37 2009
@@ -18,12 +18,12 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.h,v 1.24 2008/12/31 11:12:33 sebastian Exp $ */
+/* $Id: mysqlnd.h,v 1.25 2009/02/16 17:25:37 johannes Exp $ */
 
 #ifndef MYSQLND_H
 #define MYSQLND_H
 
-#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 1.24 $"
+#define MYSQLND_VERSION "mysqlnd 5.0.5-dev - 081106 - $Revision: 1.25 $"
 #define MYSQLND_VERSION_ID 50005
 
 /* This forces inlining of some accessor functions */
@@ -67,6 +67,13 @@
 void mysqlnd_library_init(TSRMLS_D);
 void mysqlnd_library_end(TSRMLS_D);
 
+PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods();
+PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods);
+
+PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods();
+PHPAPI void mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods);
+
+
 #define mysqlnd_restart_psession(conn, cache) 
_mysqlnd_restart_psession((conn), (cache) TSRMLS_CC)
 PHPAPI void _mysqlnd_restart_psession(MYSQLND *conn, MYSQLND_THD_ZVAL_PCACHE 
*cache TSRMLS_DC);
 #define mysqlnd_end_psession(conn) _mysqlnd_end_psession((conn) TSRMLS_CC)
@@ -354,7 +361,9 @@
 void                           mysqlnd_qcache_put(MYSQLND_QCACHE * const 
cache, char * query, size_t query_len,
                                                                           
MYSQLND_RES_BUFFERED * const result, MYSQLND_RES_METADATA * const meta);
 
-
+/* double check the class name to avoid naming conflicts when using these: */
+#define MYSQLND_METHOD(class, method) php_##class##_##method##_pub
+#define MYSQLND_METHOD_PRIVATE(class, method) php_##class##_##method##_priv
 
 ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
        zend_bool               collect_statistics;
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_priv.h?r1=1.19&r2=1.20&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_priv.h
diff -u php-src/ext/mysqlnd/mysqlnd_priv.h:1.19 
php-src/ext/mysqlnd/mysqlnd_priv.h:1.20
--- php-src/ext/mysqlnd/mysqlnd_priv.h:1.19     Wed Dec 31 11:12:33 2008
+++ php-src/ext/mysqlnd/mysqlnd_priv.h  Mon Feb 16 17:25:37 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_priv.h,v 1.19 2008/12/31 11:12:33 sebastian Exp $ */
+/* $Id: mysqlnd_priv.h,v 1.20 2009/02/16 17:25:37 johannes Exp $ */
 
 #ifndef MYSQLND_PRIV_H
 #define MYSQLND_PRIV_H
@@ -49,12 +49,10 @@
 #define pestrndup(s, length, persistent) 
((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
 #endif
 
-
+#define MYSQLND_CLASS_METHOD_TABLE_NAME(class) mysqlnd_##class##_methods
 #define MYSQLND_CLASS_METHODS_START(class) static \
-                                                                        struct 
st_##class##_methods mysqlnd_##class##_methods = {
+                                                                        struct 
st_##class##_methods MYSQLND_CLASS_METHOD_TABLE_NAME(class) = {
 #define MYSQLND_CLASS_METHODS_END                              }               
                                         
-#define MYSQLND_METHOD(class, method)                  
php_##class##_##method##_pub
-#define MYSQLND_METHOD_PRIVATE(class, method)  php_##class##_##method##_priv
 
 #if PHP_MAJOR_VERSION < 6
 #define mysqlnd_array_init(arg, field_count) \
@@ -170,7 +168,9 @@
 enum_func_status mysqlnd_handle_local_infile(MYSQLND *conn, const char 
*filename, zend_bool *is_warning TSRMLS_DC);
 
 
+
 void _mysqlnd_init_ps_subsystem();/* This one is private, 
mysqlnd_library_init() will call it */
+void _mysqlnd_init_ps_fetch_subsystem();
 
 void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
                                                                unsigned int 
pack_len, zend_uchar **row, zend_bool as_unicode,
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_ps.c?r1=1.26&r2=1.27&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_ps.c
diff -u php-src/ext/mysqlnd/mysqlnd_ps.c:1.26 
php-src/ext/mysqlnd/mysqlnd_ps.c:1.27
--- php-src/ext/mysqlnd/mysqlnd_ps.c:1.26       Wed Dec 31 11:12:33 2008
+++ php-src/ext/mysqlnd/mysqlnd_ps.c    Mon Feb 16 17:25:37 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_ps.c,v 1.26 2008/12/31 11:12:33 sebastian Exp $ */
+/* $Id: mysqlnd_ps.c,v 1.27 2009/02/16 17:25:37 johannes Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -35,6 +35,8 @@
 const char * const mysqlnd_not_bound_as_blob = "Can't send long data for 
non-string/non-binary data types";
 const char * const mysqlnd_stmt_not_prepared = "Statement not prepared";
 
+static struct st_mysqlnd_stmt_methods *mysqlnd_stmt_methods;
+
 /* Exported by mysqlnd.c */
 enum_func_status mysqlnd_simple_command(MYSQLND *conn, enum 
php_mysqlnd_server_command command,
                                                                                
const char * const arg, size_t arg_len,
@@ -2080,8 +2082,7 @@
 /* }}} */
 
 
-static
-struct st_mysqlnd_stmt_methods mysqlnd_stmt_methods = {
+MYSQLND_CLASS_METHODS_START(mysqlnd_stmt)
        MYSQLND_METHOD(mysqlnd_stmt, prepare),
        MYSQLND_METHOD(mysqlnd_stmt, execute),
        MYSQLND_METHOD(mysqlnd_stmt, use_result),
@@ -2123,7 +2124,7 @@
 
        MYSQLND_METHOD(mysqlnd_stmt, attr_get),
        MYSQLND_METHOD(mysqlnd_stmt, attr_set), 
-};
+MYSQLND_CLASS_METHODS_END;
 
 
 /* {{{ _mysqlnd_stmt_init */
@@ -2134,7 +2135,7 @@
        DBG_ENTER("_mysqlnd_stmt_init");
        DBG_INF_FMT("stmt=%p", stmt); 
 
-       stmt->m = &mysqlnd_stmt_methods;
+       stmt->m = mysqlnd_stmt_methods;
        stmt->state = MYSQLND_STMT_INITTED;
        stmt->execute_cmd_buffer.length = 4096;
        stmt->execute_cmd_buffer.buffer = 
mnd_emalloc(stmt->execute_cmd_buffer.length);
@@ -2172,6 +2173,28 @@
 }
 /* }}} */
 
+/* {{{ _mysqlnd_init_ps_subsystem */
+void _mysqlnd_init_ps_subsystem()
+{
+       mysqlnd_stmt_methods = &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_stmt);
+       _mysqlnd_init_ps_fetch_subsystem();
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_get_methods */
+PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods()
+{
+       return mysqlnd_stmt_methods;
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_set_methods */
+PHPAPI void mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods)
+{
+       mysqlnd_stmt_methods = methods;
+}
+/* }}} */
+
 
 /*
  * Local variables:
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_ps_codec.c?r1=1.14&r2=1.15&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_ps_codec.c
diff -u php-src/ext/mysqlnd/mysqlnd_ps_codec.c:1.14 
php-src/ext/mysqlnd/mysqlnd_ps_codec.c:1.15
--- php-src/ext/mysqlnd/mysqlnd_ps_codec.c:1.14 Wed Dec 31 11:12:33 2008
+++ php-src/ext/mysqlnd/mysqlnd_ps_codec.c      Mon Feb 16 17:25:37 2009
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_ps_codec.c,v 1.14 2008/12/31 11:12:33 sebastian Exp $ */
+/* $Id: mysqlnd_ps_codec.c,v 1.15 2009/02/16 17:25:37 johannes Exp $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -433,8 +433,8 @@
 /* }}} */
 
 
-/* {{{ _mysqlnd_init_ps_subsystem */
-void _mysqlnd_init_ps_subsystem()
+/* {{{ _mysqlnd_init_ps_fetch_subsystem */
+void _mysqlnd_init_ps_fetch_subsystem()
 {
        memset(mysqlnd_ps_fetch_functions, 0, 
sizeof(mysqlnd_ps_fetch_functions));
        mysqlnd_ps_fetch_functions[MYSQL_TYPE_NULL].func                = 
ps_fetch_null;

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

Reply via email to