summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/php_mysqlnd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mysqlnd/php_mysqlnd.c')
-rw-r--r--ext/mysqlnd/php_mysqlnd.c118
1 files changed, 96 insertions, 22 deletions
diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c
index 58632443da..20fcc5e7ad 100644
--- a/ext/mysqlnd/php_mysqlnd.c
+++ b/ext/mysqlnd/php_mysqlnd.c
@@ -12,9 +12,9 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Authors: Georg Richter <georg@mysql.com> |
- | Andrey Hristov <andrey@mysql.com> |
+ | Authors: Andrey Hristov <andrey@mysql.com> |
| Ulf Wendel <uwendel@mysql.com> |
+ | Georg Richter <georg@mysql.com> |
+----------------------------------------------------------------------+
*/
@@ -24,7 +24,10 @@
#include "mysqlnd.h"
#include "mysqlnd_priv.h"
#include "mysqlnd_debug.h"
+#include "mysqlnd_statistics.h"
+#include "mysqlnd_reverse_api.h"
#include "ext/standard/info.h"
+#include "ext/standard/php_smart_str.h"
/* {{{ mysqlnd_functions[]
*
@@ -92,12 +95,71 @@ PHPAPI void mysqlnd_minfo_print_hash(zval *values)
/* }}} */
+/* {{{ mysqlnd_minfo_dump_plugin_stats */
+static int
+mysqlnd_minfo_dump_plugin_stats(void *pDest, void * argument TSRMLS_DC)
+{
+ struct st_mysqlnd_plugin_header * plugin_header = *(struct st_mysqlnd_plugin_header **) pDest;
+ if (plugin_header->plugin_stats.values) {
+ char buf[64];
+ zval values;
+ snprintf(buf, sizeof(buf), "%s statistics", plugin_header->plugin_name);
+
+ mysqlnd_fill_stats_hash(plugin_header->plugin_stats.values, plugin_header->plugin_stats.names, &values TSRMLS_CC ZEND_FILE_LINE_CC);
+
+ php_info_print_table_start();
+ php_info_print_table_header(2, buf, "");
+ mysqlnd_minfo_print_hash(&values);
+ php_info_print_table_end();
+ zval_dtor(&values);
+ }
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_minfo_dump_loaded_plugins */
+static int
+mysqlnd_minfo_dump_loaded_plugins(void *pDest, void * buf TSRMLS_DC)
+{
+ smart_str * buffer = (smart_str *) buf;
+ struct st_mysqlnd_plugin_header * plugin_header = *(struct st_mysqlnd_plugin_header **) pDest;
+ if (plugin_header->plugin_name) {
+ if (buffer->len) {
+ smart_str_appendc(buffer, ',');
+ }
+ smart_str_appends(buffer, plugin_header->plugin_name);
+ }
+ return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+
+/* {{{ mysqlnd_minfo_dump_api_plugins */
+static void
+mysqlnd_minfo_dump_api_plugins(smart_str * buffer TSRMLS_DC)
+{
+ HashTable *ht = mysqlnd_reverse_api_get_api_list(TSRMLS_C);
+ Bucket *p;
+
+ p = ht->pListHead;
+ while(p != NULL) {
+ MYSQLND_REVERSE_API * ext = *(MYSQLND_REVERSE_API **) p->pData;
+ if (buffer->len) {
+ smart_str_appendc(buffer, ',');
+ }
+ smart_str_appends(buffer, ext->module->name);
+
+ p = p->pListNext;
+ }
+}
+/* }}} */
+
+
/* {{{ 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");
@@ -124,16 +186,26 @@ PHP_MINFO_FUNCTION(mysqlnd)
php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");
php_info_print_table_row(2, "Tracing", MYSQLND_G(debug)? MYSQLND_G(debug):"n/a");
- php_info_print_table_end();
- /* Print client stats */
- php_info_print_table_start();
- php_info_print_table_header(2, "Client statistics", "");
- mysqlnd_get_client_stats(&values);
- mysqlnd_minfo_print_hash(&values);
+ /* loaded plugins */
+ {
+ smart_str tmp_str = {0, 0, 0};
+ mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_loaded_plugins, &tmp_str);
+ smart_str_0(&tmp_str);
+ php_info_print_table_row(2, "Loaded plugins", tmp_str.c);
+ smart_str_free(&tmp_str);
+
+ mysqlnd_minfo_dump_api_plugins(&tmp_str TSRMLS_CC);
+ smart_str_0(&tmp_str);
+ php_info_print_table_row(2, "API Extensions", tmp_str.c);
+ smart_str_free(&tmp_str);
+ }
- zval_dtor(&values);
php_info_print_table_end();
+
+
+ /* Print client stats */
+ mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_plugin_stats, NULL);
}
/* }}} */
@@ -187,7 +259,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("mysqlnd.log_mask", "0", PHP_INI_ALL, OnUpdateLong, log_mask, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.mempool_default_size","16000", PHP_INI_ALL, OnUpdateLong, mempool_default_size, zend_mysqlnd_globals, mysqlnd_globals)
-#ifdef PHP_DEBUG
+#if PHP_DEBUG
STD_PHP_INI_ENTRY("mysqlnd.debug_emalloc_fail_threshold","-1", PHP_INI_SYSTEM, OnUpdateLong, debug_emalloc_fail_threshold, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.debug_ecalloc_fail_threshold","-1", PHP_INI_SYSTEM, OnUpdateLong, debug_ecalloc_fail_threshold, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.debug_erealloc_fail_threshold","-1", PHP_INI_SYSTEM, OnUpdateLong, debug_erealloc_fail_threshold, zend_mysqlnd_globals, mysqlnd_globals)
@@ -224,28 +296,30 @@ static PHP_MSHUTDOWN_FUNCTION(mysqlnd)
/* }}} */
-#if defined(PHP_DEBUG)
+#if PHP_DEBUG
/* {{{ PHP_RINIT_FUNCTION
*/
static PHP_RINIT_FUNCTION(mysqlnd)
{
-#if defined(PHP_DEBUG)
if (MYSQLND_G(debug)) {
- MYSQLND_DEBUG *dbg = mysqlnd_debug_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC);
- if (!dbg) {
- return FAILURE;
+ struct st_mysqlnd_plugin_trace_log * trace_log_plugin = mysqlnd_plugin_find("debug_trace");
+ MYSQLND_G(dbg) = NULL;
+ if (trace_log_plugin) {
+ MYSQLND_DEBUG * dbg = trace_log_plugin->methods.trace_instance_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC);
+ if (!dbg) {
+ return FAILURE;
+ }
+ dbg->m->set_mode(dbg, MYSQLND_G(debug));
+ MYSQLND_G(dbg) = dbg;
}
- dbg->m->set_mode(dbg, MYSQLND_G(debug));
- MYSQLND_G(dbg) = dbg;
}
-#endif
return SUCCESS;
}
/* }}} */
#endif
-#if defined(PHP_DEBUG)
+#if PHP_DEBUG
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
static PHP_RSHUTDOWN_FUNCTION(mysqlnd)
@@ -279,12 +353,12 @@ zend_module_entry mysqlnd_module_entry = {
mysqlnd_functions,
PHP_MINIT(mysqlnd),
PHP_MSHUTDOWN(mysqlnd),
-#if defined(PHP_DEBUG)
+#if PHP_DEBUG
PHP_RINIT(mysqlnd),
#else
NULL,
#endif
-#ifdef PHP_DEBUG
+#if PHP_DEBUG
PHP_RSHUTDOWN(mysqlnd),
#else
NULL,