PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/mysqlnd - php_mysqlnd.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 76 78 97.4 %
Date: 2014-04-18 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   +----------------------------------------------------------------------+
       3             :   | PHP Version 5                                                        |
       4             :   +----------------------------------------------------------------------+
       5             :   | Copyright (c) 2006-2013 The PHP Group                                |
       6             :   +----------------------------------------------------------------------+
       7             :   | This source file is subject to version 3.01 of the PHP license,      |
       8             :   | that is bundled with this package in the file LICENSE, and is        |
       9             :   | available through the world-wide-web at the following url:           |
      10             :   | http://www.php.net/license/3_01.txt                                  |
      11             :   | If you did not receive a copy of the PHP license and are unable to   |
      12             :   | obtain it through the world-wide-web, please send a note to          |
      13             :   | license@php.net so we can mail you a copy immediately.               |
      14             :   +----------------------------------------------------------------------+
      15             :   | Authors: Georg Richter <georg@mysql.com>                             |
      16             :   |          Andrey Hristov <andrey@mysql.com>                           |
      17             :   |          Ulf Wendel <uwendel@mysql.com>                              |
      18             :   +----------------------------------------------------------------------+
      19             : */
      20             : 
      21             : /* $Id$ */
      22             : #include "php.h"
      23             : #include "php_ini.h"
      24             : #include "mysqlnd.h"
      25             : #include "mysqlnd_priv.h"
      26             : #include "mysqlnd_debug.h"
      27             : #include "ext/standard/info.h"
      28             : 
      29             : /* {{{ mysqlnd_functions[]
      30             :  *
      31             :  * Every user visible function must have an entry in mysqlnd_functions[].
      32             :  */
      33             : static zend_function_entry mysqlnd_functions[] = {
      34             :         PHP_FE_END
      35             : };
      36             : /* }}} */
      37             : 
      38             : 
      39             : /* {{{ mysqlnd_minfo_print_hash */
      40             : #if MYSQLND_UNICODE
      41             : PHPAPI void mysqlnd_minfo_print_hash(zval *values)
      42             : {
      43             :         zval **values_entry;
      44             :         HashPosition pos_values;
      45             : 
      46             :         zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
      47             :         while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values),
      48             :                 (void **)&values_entry, &pos_values) == SUCCESS) {
      49             :                 zstr    string_key;
      50             :                 uint    string_key_len;
      51             :                 ulong   num_key;
      52             :                 int             s_len;
      53             :                 char    *s = NULL;
      54             : 
      55             :                 TSRMLS_FETCH();
      56             :                 zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values);
      57             : 
      58             :                 convert_to_string(*values_entry);
      59             : 
      60             :                 if (zend_unicode_to_string(ZEND_U_CONVERTER(UG(runtime_encoding_conv)),
      61             :                                                                    &s, &s_len, string_key.u, string_key_len TSRMLS_CC) == SUCCESS) {
      62             :                         php_info_print_table_row(2, s, Z_STRVAL_PP(values_entry));
      63             :                 }
      64             :                 if (s) {
      65             :                         mnd_efree(s);
      66             :                 }
      67             : 
      68             :                 zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values);
      69             :         }
      70             : }
      71             : #else
      72         148 : PHPAPI void mysqlnd_minfo_print_hash(zval *values)
      73             : {
      74             :         zval **values_entry;
      75             :         HashPosition pos_values;
      76             : 
      77         148 :         zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
      78       23976 :         while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&values_entry, &pos_values) == SUCCESS) {
      79             :                 char    *string_key;
      80             :                 uint    string_key_len;
      81             :                 ulong   num_key;
      82             : 
      83       23680 :                 zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values);
      84             : 
      85       23680 :                 convert_to_string(*values_entry);
      86       23680 :                 php_info_print_table_row(2, string_key, Z_STRVAL_PP(values_entry));
      87             : 
      88       23680 :                 zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values);
      89             :         }
      90         148 : }
      91             : #endif
      92             : /* }}} */
      93             : 
      94             : 
      95             : /* {{{ PHP_MINFO_FUNCTION
      96             :  */
      97         148 : PHP_MINFO_FUNCTION(mysqlnd)
      98             : {
      99             :         char buf[32];
     100             :         zval values;
     101             : 
     102         148 :         php_info_print_table_start();
     103         148 :         php_info_print_table_header(2, "mysqlnd", "enabled");
     104         148 :         php_info_print_table_row(2, "Version", mysqlnd_get_client_info());
     105         148 :         php_info_print_table_row(2, "Compression",
     106             : #ifdef MYSQLND_COMPRESSION_ENABLED
     107             :                                                                 "supported");
     108             : #else
     109             :                                                                 "not supported");
     110             : #endif
     111         148 :         php_info_print_table_row(2, "SSL",
     112             : #ifdef MYSQLND_SSL_SUPPORTED
     113             :                                                                 "supported");
     114             : #else
     115             :                                                                 "not supported");
     116             : #endif
     117         148 :         snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_cmd_buffer_size));
     118         148 :         php_info_print_table_row(2, "Command buffer size", buf);
     119         148 :         snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size));
     120         148 :         php_info_print_table_row(2, "Read buffer size", buf);
     121         148 :         snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_timeout));
     122         148 :         php_info_print_table_row(2, "Read timeout", buf);
     123         148 :         php_info_print_table_row(2, "Collecting statistics", MYSQLND_G(collect_statistics)? "Yes":"No");
     124         148 :         php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");
     125             : 
     126         148 :         php_info_print_table_row(2, "Tracing", MYSQLND_G(debug)? MYSQLND_G(debug):"n/a");
     127         148 :         php_info_print_table_end();
     128             : 
     129             :         /* Print client stats */
     130         148 :         php_info_print_table_start();
     131         148 :         php_info_print_table_header(2, "Client statistics", "");
     132         148 :         mysqlnd_get_client_stats(&values);
     133         148 :         mysqlnd_minfo_print_hash(&values);
     134             : 
     135         148 :         zval_dtor(&values);
     136         148 :         php_info_print_table_end();
     137         148 : }
     138             : /* }}} */
     139             : 
     140             : 
     141             : PHPAPI ZEND_DECLARE_MODULE_GLOBALS(mysqlnd)
     142             : 
     143             : 
     144             : /* {{{ PHP_GINIT_FUNCTION
     145             :  */
     146       19341 : static PHP_GINIT_FUNCTION(mysqlnd)
     147             : {
     148       19341 :         mysqlnd_globals->collect_statistics = TRUE;
     149       19341 :         mysqlnd_globals->collect_memory_statistics = FALSE;
     150       19341 :         mysqlnd_globals->debug = NULL;       /* The actual string */
     151       19341 :         mysqlnd_globals->dbg = NULL; /* The DBG object*/
     152       19341 :         mysqlnd_globals->net_cmd_buffer_size = MYSQLND_NET_CMD_BUFFER_MIN_SIZE;
     153       19341 :         mysqlnd_globals->net_read_buffer_size = 32768;
     154       19341 :         mysqlnd_globals->net_read_timeout = 31536000;
     155       19341 :         mysqlnd_globals->log_mask = 0;
     156       19341 :         mysqlnd_globals->mempool_default_size = 16000;
     157       19341 :         mysqlnd_globals->debug_emalloc_fail_threshold = -1;
     158       19341 :         mysqlnd_globals->debug_ecalloc_fail_threshold = -1;
     159       19341 :         mysqlnd_globals->debug_erealloc_fail_threshold = -1;
     160       19341 :         mysqlnd_globals->debug_malloc_fail_threshold = -1;
     161       19341 :         mysqlnd_globals->debug_calloc_fail_threshold = -1;
     162       19341 :         mysqlnd_globals->debug_realloc_fail_threshold = -1;
     163       19341 : }
     164             : /* }}} */
     165             : 
     166             : 
     167       19341 : static PHP_INI_MH(OnUpdateNetCmdBufferSize)
     168             : {
     169       19341 :         long long_value = atol(new_value);
     170       19341 :         if (long_value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
     171           0 :                 return FAILURE;
     172             :         }
     173       19341 :         MYSQLND_G(net_cmd_buffer_size) = long_value;
     174             : 
     175       19341 :         return SUCCESS;
     176             : }
     177             : 
     178             : /* {{{ PHP_INI_BEGIN
     179             : */
     180             : PHP_INI_BEGIN()
     181             :         STD_PHP_INI_BOOLEAN("mysqlnd.collect_statistics",     "1",  PHP_INI_ALL, OnUpdateBool,      collect_statistics, zend_mysqlnd_globals, mysqlnd_globals)
     182             :         STD_PHP_INI_BOOLEAN("mysqlnd.collect_memory_statistics",      "0",  PHP_INI_SYSTEM, OnUpdateBool,   collect_memory_statistics, zend_mysqlnd_globals, mysqlnd_globals)
     183             :         STD_PHP_INI_ENTRY("mysqlnd.debug",                                    NULL,   PHP_INI_SYSTEM, OnUpdateString, debug, zend_mysqlnd_globals, mysqlnd_globals)
     184             :         STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size",      MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR,    PHP_INI_ALL,    OnUpdateNetCmdBufferSize,       net_cmd_buffer_size,    zend_mysqlnd_globals,           mysqlnd_globals)
     185             :         STD_PHP_INI_ENTRY("mysqlnd.net_read_buffer_size",     "32768",PHP_INI_ALL,  OnUpdateLong,   net_read_buffer_size,   zend_mysqlnd_globals,           mysqlnd_globals)
     186             :         STD_PHP_INI_ENTRY("mysqlnd.net_read_timeout", "31536000",   PHP_INI_SYSTEM, OnUpdateLong,   net_read_timeout, zend_mysqlnd_globals, mysqlnd_globals)
     187             :         STD_PHP_INI_ENTRY("mysqlnd.log_mask",                         "0",  PHP_INI_ALL,    OnUpdateLong,   log_mask, zend_mysqlnd_globals, mysqlnd_globals)
     188             :         STD_PHP_INI_ENTRY("mysqlnd.mempool_default_size","16000",   PHP_INI_ALL,    OnUpdateLong,   mempool_default_size,   zend_mysqlnd_globals,           mysqlnd_globals)
     189             : 
     190             : #ifdef PHP_DEBUG
     191             :         STD_PHP_INI_ENTRY("mysqlnd.debug_emalloc_fail_threshold","-1",   PHP_INI_SYSTEM,    OnUpdateLong,   debug_emalloc_fail_threshold,   zend_mysqlnd_globals,           mysqlnd_globals)
     192             :         STD_PHP_INI_ENTRY("mysqlnd.debug_ecalloc_fail_threshold","-1",   PHP_INI_SYSTEM,    OnUpdateLong,   debug_ecalloc_fail_threshold,   zend_mysqlnd_globals,           mysqlnd_globals)
     193             :         STD_PHP_INI_ENTRY("mysqlnd.debug_erealloc_fail_threshold","-1",   PHP_INI_SYSTEM,   OnUpdateLong,   debug_erealloc_fail_threshold,  zend_mysqlnd_globals,           mysqlnd_globals)
     194             : 
     195             :         STD_PHP_INI_ENTRY("mysqlnd.debug_malloc_fail_threshold","-1",   PHP_INI_SYSTEM,     OnUpdateLong,   debug_malloc_fail_threshold,    zend_mysqlnd_globals,           mysqlnd_globals)
     196             :         STD_PHP_INI_ENTRY("mysqlnd.debug_calloc_fail_threshold","-1",   PHP_INI_SYSTEM,     OnUpdateLong,   debug_calloc_fail_threshold,    zend_mysqlnd_globals,           mysqlnd_globals)
     197             :         STD_PHP_INI_ENTRY("mysqlnd.debug_realloc_fail_threshold","-1",   PHP_INI_SYSTEM,    OnUpdateLong,   debug_realloc_fail_threshold,   zend_mysqlnd_globals,           mysqlnd_globals)
     198             : #endif
     199             : PHP_INI_END()
     200             : /* }}} */
     201             : 
     202             : 
     203             : /* {{{ PHP_MINIT_FUNCTION
     204             :  */
     205       19341 : static PHP_MINIT_FUNCTION(mysqlnd)
     206             : {
     207       19341 :         REGISTER_INI_ENTRIES();
     208             : 
     209       19341 :         mysqlnd_library_init(TSRMLS_C);
     210       19341 :         return SUCCESS;
     211             : }
     212             : /* }}} */
     213             : 
     214             : 
     215             : /* {{{ PHP_MSHUTDOWN_FUNCTION
     216             :  */
     217       19376 : static PHP_MSHUTDOWN_FUNCTION(mysqlnd)
     218             : {
     219       19376 :         mysqlnd_library_end(TSRMLS_C);
     220             : 
     221       19376 :         UNREGISTER_INI_ENTRIES();
     222       19376 :         return SUCCESS;
     223             : }
     224             : /* }}} */
     225             : 
     226             : 
     227             : #if defined(PHP_DEBUG)
     228             : /* {{{ PHP_RINIT_FUNCTION
     229             :  */
     230       19327 : static PHP_RINIT_FUNCTION(mysqlnd)
     231             : {
     232             : #if defined(PHP_DEBUG)
     233       19327 :         if (MYSQLND_G(debug)) {
     234           1 :                 MYSQLND_DEBUG *dbg = mysqlnd_debug_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC);
     235           1 :                 if (!dbg) {
     236           0 :                         return FAILURE;
     237             :                 }
     238           1 :                 dbg->m->set_mode(dbg, MYSQLND_G(debug));
     239           1 :                 MYSQLND_G(dbg) = dbg;
     240             :         }
     241             : #endif
     242       19327 :         return SUCCESS;
     243             : }
     244             : /* }}} */
     245             : #endif
     246             : 
     247             : 
     248             : #if defined(PHP_DEBUG)
     249             : /* {{{ PHP_RSHUTDOWN_FUNCTION
     250             :  */
     251       19362 : static PHP_RSHUTDOWN_FUNCTION(mysqlnd)
     252             : {
     253       19362 :         MYSQLND_DEBUG *dbg = MYSQLND_G(dbg);
     254       19362 :         DBG_ENTER("RSHUTDOWN");
     255       19362 :         if (dbg) {
     256           1 :                 dbg->m->close(dbg);
     257           1 :                 dbg->m->free_handle(dbg);
     258           1 :                 MYSQLND_G(dbg) = NULL;
     259             :         }
     260       19362 :         return SUCCESS;
     261             : }
     262             : /* }}} */
     263             : #endif
     264             : 
     265             : 
     266             : 
     267             : static const zend_module_dep mysqlnd_deps[] = {
     268             :         ZEND_MOD_REQUIRED("standard")
     269             :         ZEND_MOD_END
     270             : };
     271             : 
     272             : /* {{{ mysqlnd_module_entry
     273             :  */
     274             : zend_module_entry mysqlnd_module_entry = {
     275             :         STANDARD_MODULE_HEADER_EX,
     276             :         NULL,
     277             :         mysqlnd_deps,
     278             :         "mysqlnd",
     279             :         mysqlnd_functions,
     280             :         PHP_MINIT(mysqlnd),
     281             :         PHP_MSHUTDOWN(mysqlnd),
     282             : #if defined(PHP_DEBUG)
     283             :         PHP_RINIT(mysqlnd),
     284             : #else
     285             :         NULL,
     286             : #endif
     287             : #ifdef PHP_DEBUG
     288             :         PHP_RSHUTDOWN(mysqlnd),
     289             : #else
     290             :         NULL,
     291             : #endif
     292             :         PHP_MINFO(mysqlnd),
     293             :         MYSQLND_VERSION,
     294             :         PHP_MODULE_GLOBALS(mysqlnd),
     295             :         PHP_GINIT(mysqlnd),
     296             :         NULL,
     297             :         NULL,
     298             :         STANDARD_MODULE_PROPERTIES_EX
     299             : };
     300             : /* }}} */
     301             : 
     302             : /* {{{ COMPILE_DL_MYSQLND */
     303             : #ifdef COMPILE_DL_MYSQLND
     304             : ZEND_GET_MODULE(mysqlnd)
     305             : #endif
     306             : /* }}} */
     307             : 
     308             : /*
     309             :  * Local variables:
     310             :  * tab-width: 4
     311             :  * c-basic-offset: 4
     312             :  * End:
     313             :  * vim600: noet sw=4 ts=4 fdm=marker
     314             :  * vim<600: noet sw=4 ts=4
     315             :  */

Generated by: LCOV version 1.10

Generated at Fri, 18 Apr 2014 07:01:30 +0000 (2 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.