mirror of
https://github.com/php/php-src.git
synced 2026-03-29 03:32:20 +02:00
- Improve mysqlnd's internal method registration
This commit is contained in:
@@ -68,19 +68,7 @@ static zend_bool mysqlnd_library_initted = FALSE;
|
||||
|
||||
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_METHOD(mysqlnd_conn, get_connection_stats)(const MYSQLND * const conn,
|
||||
|
||||
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 @@ PHPAPI MYSQLND *_mysqlnd_init(zend_bool persistent TSRMLS_DC)
|
||||
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 @@ PHPAPI MYSQLND *_mysqlnd_init(zend_bool persistent TSRMLS_DC)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ 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:
|
||||
|
||||
@@ -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 @@ MYSQLND_RES * mysqlnd_qcache_get(MYSQLND_QCACHE * const cache, const char * qu
|
||||
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;
|
||||
|
||||
@@ -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 @@ extern const char * const mysqlnd_server_gone;
|
||||
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,
|
||||
|
||||
@@ -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 @@ MYSQLND_METHOD(mysqlnd_stmt, dtor)(MYSQLND_STMT * const stmt, zend_bool implicit
|
||||
/* }}} */
|
||||
|
||||
|
||||
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 @@ struct st_mysqlnd_stmt_methods mysqlnd_stmt_methods = {
|
||||
|
||||
MYSQLND_METHOD(mysqlnd_stmt, attr_get),
|
||||
MYSQLND_METHOD(mysqlnd_stmt, attr_set),
|
||||
};
|
||||
MYSQLND_CLASS_METHODS_END;
|
||||
|
||||
|
||||
/* {{{ _mysqlnd_stmt_init */
|
||||
@@ -2134,7 +2135,7 @@ MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC)
|
||||
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_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ _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:
|
||||
|
||||
@@ -433,8 +433,8 @@ void ps_fetch_bit(zval *zv, const MYSQLND_FIELD * const field,
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ _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;
|
||||
|
||||
Reference in New Issue
Block a user