1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 06:21:12 +02:00

Moving extension specific code to php_mysqlnd.c as the old rule is.

This commit is contained in:
Andrey Hristov
2008-01-28 23:23:08 +00:00
parent ec34464024
commit d95c29d7f6
4 changed files with 9 additions and 224 deletions

View File

@@ -15,6 +15,7 @@ if (CHECK_LIB("ws2_32.lib", "mysqlnd")) {
"mysqlnd_result.c " +
"mysqlnd_result_meta.c " +
"mysqlnd_statistics.c " +
"mysqlnd_wireprotocol.c";
"mysqlnd_wireprotocol.c" +
"php_mysqlnd.c";
EXTENSION("mysqlnd", mysqlnd_source, false);
}

View File

@@ -8,7 +8,7 @@ if test "$PHP_MYSQLND_ENABLED" = "yes"; then
mysqlnd_ps.c mysqlnd_loaddata.c mysqlnd_palloc.c \
mysqlnd_ps_codec.c mysqlnd_statistics.c mysqlnd_qcache.c\
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
mysqlnd_block_alloc.c"
mysqlnd_block_alloc.c php_mysqlnd.c"
PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, no)
PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)

View File

@@ -28,10 +28,8 @@
#include "mysqlnd_charset.h"
#include "mysqlnd_debug.h"
#include "mysqlnd_block_alloc.h"
#include "php_ini.h"
#include "ext/standard/basic_functions.h"
#include "ext/standard/php_lcg.h"
#include "ext/standard/info.h"
/* the server doesn't support 4byte utf8, but let's make it forward compatible */
#define MYSQLND_MAX_ALLOWED_USER_LEN 256 /* 64 char * 4byte */
@@ -129,7 +127,6 @@ void * _mysqlnd_fetch_thread(void *arg)
/* {{{ mysqlnd_library_init */
static
void mysqlnd_library_init(TSRMLS_D)
{
if (mysqlnd_library_initted == FALSE) {
@@ -146,7 +143,6 @@ void mysqlnd_library_init(TSRMLS_D)
/* {{{ mysqlnd_library_end */
static
void mysqlnd_library_end(TSRMLS_D)
{
if (mysqlnd_library_initted == TRUE) {
@@ -2038,223 +2034,6 @@ PHPAPI MYSQLND *_mysqlnd_init(zend_bool persistent TSRMLS_DC)
/* }}} */
/* {{{ mysqlnd_functions[]
*
* Every user visible function must have an entry in mysqlnd_functions[].
*/
static zend_function_entry mysqlnd_functions[] = {
{NULL, NULL, NULL} /* Must be the last line in mysqlnd_functions[] */
};
/* }}} */
/* {{{ mysqlnd_minfo_print_hash */
#if PHP_MAJOR_VERSION >= 6
PHPAPI void mysqlnd_minfo_print_hash(zval *values)
{
zval **values_entry;
HashPosition pos_values;
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) {
TSRMLS_FETCH();
zstr string_key;
uint string_key_len;
ulong num_key;
char *s = NULL;
zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values);
convert_to_string(*values_entry);
if (UG(unicode)) {
int s_len;
if (zend_unicode_to_string(ZEND_U_CONVERTER(UG(runtime_encoding_conv)),
&s, &s_len, string_key.u, string_key_len TSRMLS_CC) == SUCCESS) {
php_info_print_table_row(2, s, Z_STRVAL_PP(values_entry));
}
if (s) {
mnd_efree(s);
}
} else {
php_info_print_table_row(2, string_key.s, Z_STRVAL_PP(values_entry));
}
zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values);
}
}
#else
void mysqlnd_minfo_print_hash(zval *values)
{
zval **values_entry;
HashPosition pos_values;
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) {
char *string_key;
uint string_key_len;
ulong num_key;
zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values);
convert_to_string(*values_entry);
php_info_print_table_row(2, string_key, Z_STRVAL_PP(values_entry));
zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values);
}
}
#endif
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(mysqlnd)
{
char buf[32];
zval values;
php_info_print_table_start();
php_info_print_table_header(2, "mysqlnd", "enabled");
php_info_print_table_row(2, "Version", mysqlnd_get_client_info());
/* Print client stats */
php_info_print_table_header(2, "Client statistics", "");
mysqlnd_get_client_stats(&values);
mysqlnd_minfo_print_hash(&values);
php_info_print_table_row(2, "Collecting statistics", MYSQLND_G(collect_statistics)? "Yes":"No");
php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");
snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_cmd_buffer_size));
php_info_print_table_row(2, "Command buffer size", buf);
snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size));
php_info_print_table_row(2, "Read buffer size", buf);
zval_dtor(&values);
php_info_print_table_end();
}
/* }}} */
ZEND_DECLARE_MODULE_GLOBALS(mysqlnd);
/* {{{ PHP_GINIT_FUNCTION
*/
static PHP_GINIT_FUNCTION(mysqlnd)
{
mysqlnd_globals->collect_statistics = TRUE;
mysqlnd_globals->collect_memory_statistics = FALSE;
mysqlnd_globals->debug = NULL; /* The actual string */
mysqlnd_globals->dbg = NULL; /* The DBG object*/
mysqlnd_globals->net_cmd_buffer_size = 2048;
mysqlnd_globals->net_read_buffer_size = 32768;
}
/* }}} */
/* {{{ PHP_INI_BEGIN
*/
PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("mysqlnd.collect_statistics", "1", PHP_INI_ALL, OnUpdateBool, collect_statistics, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_BOOLEAN("mysqlnd.collect_memory_statistics", "0", PHP_INI_SYSTEM, OnUpdateBool, collect_memory_statistics, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.debug", NULL, PHP_INI_SYSTEM, OnUpdateString, debug, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size", "2048", PHP_INI_ALL, OnUpdateLong, net_cmd_buffer_size, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.net_read_buffer_size", "32768",PHP_INI_ALL, OnUpdateLong, net_read_buffer_size, zend_mysqlnd_globals, mysqlnd_globals)
PHP_INI_END()
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
static PHP_MINIT_FUNCTION(mysqlnd)
{
REGISTER_INI_ENTRIES();
mysqlnd_library_init(TSRMLS_C);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
static PHP_MSHUTDOWN_FUNCTION(mysqlnd)
{
mysqlnd_library_end(TSRMLS_C);
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
/* }}} */
#if PHP_DEBUG
/* {{{ PHP_RINIT_FUNCTION
*/
static PHP_RINIT_FUNCTION(mysqlnd)
{
#ifdef PHP_DEBUG
if (MYSQLND_G(debug)) {
MYSQLND_DEBUG *dbg = mysqlnd_debug_init(TSRMLS_C);
if (!dbg) {
return FAILURE;
}
dbg->m->set_mode(dbg, MYSQLND_G(debug));
MYSQLND_G(dbg) = dbg;
}
#endif
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
static PHP_RSHUTDOWN_FUNCTION(mysqlnd)
{
#ifdef PHP_DEBUG
MYSQLND_DEBUG *dbg = MYSQLND_G(dbg);
DBG_ENTER("RSHUTDOWN");
if (dbg) {
dbg->m->close(dbg);
dbg->m->free_handle(dbg);
MYSQLND_G(dbg) = NULL;
}
#endif
return SUCCESS;
}
/* }}} */
#endif
/* {{{ mysqlnd_module_entry
*/
zend_module_entry mysqlnd_module_entry = {
STANDARD_MODULE_HEADER,
"mysqlnd",
mysqlnd_functions,
PHP_MINIT(mysqlnd),
PHP_MSHUTDOWN(mysqlnd),
#if PHP_DEBUG
PHP_RINIT(mysqlnd),
PHP_RSHUTDOWN(mysqlnd),
#else
NULL,
NULL,
#endif
PHP_MINFO(mysqlnd),
MYSQLND_VERSION,
PHP_MODULE_GLOBALS(mysqlnd),
PHP_GINIT(mysqlnd),
NULL,
NULL,
STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
/*
* Local variables:
* tab-width: 4

View File

@@ -23,7 +23,7 @@
#ifndef MYSQLND_H
#define MYSQLND_H
#define MYSQLND_VERSION "mysqlnd 5.0.2-dev - 070928 - $Revision$"
#define MYSQLND_VERSION "mysqlnd 5.0.3-dev - 080129 - $Revision$"
#define MYSQLND_VERSION_ID 50002
/* This forces inlining of some accessor functions */
@@ -57,7 +57,12 @@
#include "mysqlnd_structs.h"
/* Library related */
void mysqlnd_library_init(TSRMLS_D);
void mysqlnd_library_end(TSRMLS_D);
#define mysqlnd_restart_psession(conn) _mysqlnd_restart_psession((conn) TSRMLS_CC)
PHPAPI void _mysqlnd_restart_psession(MYSQLND *conn TSRMLS_DC);
PHPAPI void mysqlnd_end_psession(MYSQLND *conn);