php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_mysqlnd.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Andrey Hristov <andrey@php.net> |
14 | Ulf Wendel <uw@php.net> |
15 +----------------------------------------------------------------------+
16*/
17
18#ifdef HAVE_CONFIG_H
19#include <config.h>
20#endif
21#include "php.h"
22#include "mysqlnd.h"
23#include "mysqlnd_priv.h"
24#include "mysqlnd_debug.h"
25#include "mysqlnd_statistics.h"
26#include "mysqlnd_reverse_api.h"
27#include "ext/standard/info.h"
28#include "zend_smart_str.h"
29
30/* {{{ mysqlnd_minfo_print_hash */
31PHPAPI void
33{
34 zval *values_entry;
35 zend_string *string_key;
36
37 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), string_key, values_entry) {
38 convert_to_string(values_entry);
39 php_info_print_table_row(2, ZSTR_VAL(string_key), Z_STRVAL_P(values_entry));
41}
42/* }}} */
43
44
45/* {{{ mysqlnd_minfo_dump_loaded_plugins */
46static int
47mysqlnd_minfo_dump_loaded_plugins(zval *el, void * buf)
48{
50 struct st_mysqlnd_plugin_header * plugin_header = (struct st_mysqlnd_plugin_header *)Z_PTR_P(el);
51 if (plugin_header->plugin_name) {
52 if (buffer->s) {
53 smart_str_appendc(buffer, ',');
54 }
55 smart_str_appends(buffer, plugin_header->plugin_name);
56 }
58}
59/* }}} */
60
61
62/* {{{ mysqlnd_minfo_dump_api_plugins */
63static void
64mysqlnd_minfo_dump_api_plugins(smart_str * buffer)
65{
68
70 if (buffer->s) {
71 smart_str_appendc(buffer, ',');
72 }
73 smart_str_appends(buffer, ext->module->name);
75}
76/* }}} */
77
78
79/* {{{ PHP_MINFO_FUNCTION */
81{
82 char buf[32];
83
85 php_info_print_table_row(2, "mysqlnd", "enabled");
87 php_info_print_table_row(2, "Compression",
88#ifdef MYSQLND_COMPRESSION_ENABLED
89 "supported");
90#else
91 "not supported");
92#endif
93 php_info_print_table_row(2, "core SSL",
94#ifdef MYSQLND_SSL_SUPPORTED
95 "supported");
96#else
97 "not supported");
98#endif
99 php_info_print_table_row(2, "extended SSL",
100#ifdef MYSQLND_HAVE_SSL
101 "supported");
102#else
103 "not supported");
104#endif
106 php_info_print_table_row(2, "Command buffer size", buf);
108 php_info_print_table_row(2, "Read buffer size", buf);
110 php_info_print_table_row(2, "Read timeout", buf);
111 php_info_print_table_row(2, "Collecting statistics", MYSQLND_G(collect_statistics)? "Yes":"No");
112 php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");
113
115
116 /* loaded plugins */
117 {
118 smart_str tmp_str = {0};
119 mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_loaded_plugins, &tmp_str);
120 smart_str_0(&tmp_str);
121 php_info_print_table_row(2, "Loaded plugins", tmp_str.s? ZSTR_VAL(tmp_str.s) : "");
122 smart_str_free(&tmp_str);
123
124 mysqlnd_minfo_dump_api_plugins(&tmp_str);
125 smart_str_0(&tmp_str);
126 php_info_print_table_row(2, "API Extensions", tmp_str.s? ZSTR_VAL(tmp_str.s) : "");
127 smart_str_free(&tmp_str);
128 }
129
131}
132/* }}} */
133
134
136
137
138/* {{{ PHP_GINIT_FUNCTION */
139static PHP_GINIT_FUNCTION(mysqlnd)
140{
141#if defined(COMPILE_DL_MYSQLND) && defined(ZTS)
143#endif
144 mysqlnd_globals->collect_statistics = TRUE;
145 mysqlnd_globals->collect_memory_statistics = FALSE;
146 mysqlnd_globals->debug = NULL; /* The actual string */
147 mysqlnd_globals->dbg = NULL; /* The DBG object*/
148 mysqlnd_globals->trace_alloc_settings = NULL;
149 mysqlnd_globals->trace_alloc = NULL;
150 mysqlnd_globals->net_cmd_buffer_size = MYSQLND_NET_CMD_BUFFER_MIN_SIZE;
151 mysqlnd_globals->net_read_buffer_size = 32768;
152 mysqlnd_globals->net_read_timeout = 31536000;
153 mysqlnd_globals->log_mask = 0;
154 mysqlnd_globals->mempool_default_size = 16000;
155 mysqlnd_globals->sha256_server_public_key = NULL;
156}
157/* }}} */
158
159
160/* {{{ PHP_INI_MH */
161static PHP_INI_MH(OnUpdateNetCmdBufferSize)
162{
165 return FAILURE;
166 }
168
169 return SUCCESS;
170}
171/* }}} */
172
173
174/* {{{ PHP_INI_BEGIN */
176 STD_PHP_INI_BOOLEAN("mysqlnd.collect_statistics", "1", PHP_INI_ALL, OnUpdateBool, collect_statistics, zend_mysqlnd_globals, mysqlnd_globals)
177 STD_PHP_INI_BOOLEAN("mysqlnd.collect_memory_statistics","0",PHP_INI_SYSTEM, OnUpdateBool, collect_memory_statistics, zend_mysqlnd_globals, mysqlnd_globals)
178 STD_PHP_INI_ENTRY("mysqlnd.debug", NULL, PHP_INI_SYSTEM, OnUpdateString, debug, zend_mysqlnd_globals, mysqlnd_globals)
179 STD_PHP_INI_ENTRY("mysqlnd.trace_alloc", NULL, PHP_INI_SYSTEM, OnUpdateString, trace_alloc_settings, zend_mysqlnd_globals, mysqlnd_globals)
180 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)
181 STD_PHP_INI_ENTRY("mysqlnd.net_read_buffer_size", "32768",PHP_INI_ALL, OnUpdateLong, net_read_buffer_size, zend_mysqlnd_globals, mysqlnd_globals)
182 STD_PHP_INI_ENTRY("mysqlnd.net_read_timeout", "86400",PHP_INI_ALL, OnUpdateLong, net_read_timeout, zend_mysqlnd_globals, mysqlnd_globals)
183 STD_PHP_INI_ENTRY("mysqlnd.log_mask", "0", PHP_INI_ALL, OnUpdateLong, log_mask, zend_mysqlnd_globals, mysqlnd_globals)
184 STD_PHP_INI_ENTRY("mysqlnd.mempool_default_size","16000", PHP_INI_ALL, OnUpdateLong, mempool_default_size, zend_mysqlnd_globals, mysqlnd_globals)
185 STD_PHP_INI_ENTRY("mysqlnd.sha256_server_public_key",NULL, PHP_INI_PERDIR, OnUpdateString, sha256_server_public_key, zend_mysqlnd_globals, mysqlnd_globals)
187/* }}} */
188
189
190/* {{{ PHP_MINIT_FUNCTION */
191static PHP_MINIT_FUNCTION(mysqlnd)
192{
194
196 return SUCCESS;
197}
198/* }}} */
199
200
201/* {{{ PHP_MSHUTDOWN_FUNCTION */
202static PHP_MSHUTDOWN_FUNCTION(mysqlnd)
203{
205
207 return SUCCESS;
208}
209/* }}} */
210
211
212#if PHP_DEBUG
213/* {{{ PHP_RINIT_FUNCTION */
214static PHP_RINIT_FUNCTION(mysqlnd)
215{
216 if (MYSQLND_G(debug)) {
217 struct st_mysqlnd_plugin_trace_log * trace_log_plugin = mysqlnd_plugin_find("debug_trace");
218 MYSQLND_G(dbg) = NULL;
219 if (trace_log_plugin) {
222 if (!dbg || !trace_alloc) {
223 return FAILURE;
224 }
225 dbg->m->set_mode(dbg, MYSQLND_G(debug));
227 MYSQLND_G(dbg) = dbg;
229 }
230 }
231 return SUCCESS;
232}
233/* }}} */
234#endif
235
236
237#if PHP_DEBUG
238/* {{{ PHP_RSHUTDOWN_FUNCTION */
239static PHP_RSHUTDOWN_FUNCTION(mysqlnd)
240{
243 DBG_ENTER("RSHUTDOWN");
244 if (dbg) {
245 dbg->m->close(dbg);
246 dbg->m->free_handle(dbg);
247 MYSQLND_G(dbg) = NULL;
248 }
249 if (trace_alloc) {
250 trace_alloc->m->close(trace_alloc);
251 trace_alloc->m->free_handle(trace_alloc);
253 }
254 return SUCCESS;
255}
256/* }}} */
257#endif
258
259
260static const zend_module_dep mysqlnd_deps[] = {
261 ZEND_MOD_REQUIRED("standard")
263};
264
265/* {{{ mysqlnd_module_entry */
268 NULL,
269 mysqlnd_deps,
270 "mysqlnd",
271 NULL,
272 PHP_MINIT(mysqlnd),
273 PHP_MSHUTDOWN(mysqlnd),
274#if PHP_DEBUG
275 PHP_RINIT(mysqlnd),
276#else
277 NULL,
278#endif
279#if PHP_DEBUG
280 PHP_RSHUTDOWN(mysqlnd),
281#else
282 NULL,
283#endif
284 PHP_MINFO(mysqlnd),
286 PHP_MODULE_GLOBALS(mysqlnd),
287 PHP_GINIT(mysqlnd),
288 NULL,
289 NULL,
291};
292/* }}} */
293
294/* {{{ COMPILE_DL_MYSQLND */
295#ifdef COMPILE_DL_MYSQLND
296#ifdef ZTS
298#endif
299ZEND_GET_MODULE(mysqlnd)
300#endif
301/* }}} */
file_private const char ext[]
HashTable * ht
Definition ffi.c:4838
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
#define TRUE
Definition gd_gd.c:7
#define FALSE
Definition gd_gd.c:8
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
zend_long log_mask
Definition mysqlnd.h:304
MYSQLND_DEBUG * dbg
Definition mysqlnd.h:300
bool collect_statistics
Definition mysqlnd.h:308
PHPAPI const char * mysqlnd_get_client_info(void)
PHPAPI void mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void *argument)
#define PHP_MYSQLND_VERSION
Definition mysqlnd.h:22
zend_long mempool_default_size
Definition mysqlnd.h:306
PHPAPI void mysqlnd_library_init(void)
PHPAPI void * mysqlnd_plugin_find(const char *const name)
char * sha256_server_public_key
Definition mysqlnd.h:307
MYSQLND_DEBUG * trace_alloc
Definition mysqlnd.h:301
zend_long net_read_timeout
Definition mysqlnd.h:305
#define MYSQLND_G(v)
zend_long net_read_buffer_size
Definition mysqlnd.h:303
zend_long net_cmd_buffer_size
Definition mysqlnd.h:302
char * trace_alloc_settings
Definition mysqlnd.h:299
char * debug
Definition mysqlnd.h:298
bool collect_memory_statistics
Definition mysqlnd.h:309
PHPAPI void mysqlnd_library_end(void)
PHPAPI const char * mysqlnd_debug_std_no_trace_funcs[]
#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR
#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE
PHPAPI HashTable * mysqlnd_reverse_api_get_api_list(void)
struct st_mysqlnd_reverse_api MYSQLND_REVERSE_API
struct st_mysqlnd_debug MYSQLND_DEBUG
php_info_print_table_start()
Definition info.c:1064
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
Definition info.c:1074
#define PHP_GINIT
Definition php.h:397
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINFO
Definition php.h:396
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_RINIT
Definition php.h:394
#define PHP_MSHUTDOWN
Definition php.h:393
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_GINIT_FUNCTION
Definition php.h:405
#define PHP_RSHUTDOWN
Definition php.h:395
#define PHP_RINIT_FUNCTION
Definition php.h:402
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
#define PHP_MINIT
Definition php.h:392
#define PHPAPI
Definition php.h:71
#define PHP_MODULE_GLOBALS
Definition php.h:408
zend_long long_value
Definition php_dl_test.h:30
#define PHP_INI_PERDIR
Definition php_ini.h:42
#define PHP_INI_ALL
Definition php_ini.h:45
#define PHP_INI_BEGIN
Definition php_ini.h:52
#define STD_PHP_INI_ENTRY
Definition php_ini.h:64
#define STD_PHP_INI_BOOLEAN
Definition php_ini.h:66
#define PHP_INI_MH
Definition php_ini.h:49
#define PHP_INI_SYSTEM
Definition php_ini.h:43
#define PHP_INI_END
Definition php_ini.h:53
zend_module_entry mysqlnd_module_entry
PHPAPI void mysqlnd_minfo_print_hash(zval *values)
Definition php_mysqlnd.c:32
Definition file.h:177
zend_string * s
struct st_mysqlnd_plugin_trace_log::@135250356370041002364233320207075236242207017335 methods
MYSQLND_DEBUG *(* trace_instance_init)(const char *skip_functions[])
#define ZEND_TSRMLS_CACHE_UPDATE()
Definition zend.h:69
#define ZEND_TSRMLS_CACHE_DEFINE()
Definition zend.h:68
#define ZEND_DECLARE_MODULE_GLOBALS(module_name)
Definition zend_API.h:268
#define ZEND_GET_MODULE(name)
Definition zend_API.h:241
struct _zval_struct zval
#define snprintf
#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr)
Definition zend_hash.h:1326
#define ZEND_HASH_APPLY_KEEP
Definition zend_hash.h:146
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val)
Definition zend_hash.h:1374
#define UNREGISTER_INI_ENTRIES()
Definition zend_ini.h:204
#define REGISTER_INI_ENTRIES()
Definition zend_ini.h:203
int32_t zend_long
Definition zend_long.h:42
#define ZEND_ATOL(s)
Definition zend_long.h:101
#define ZEND_LONG_FMT
Definition zend_long.h:87
struct _zend_string zend_string
#define ZEND_MOD_END
struct _zend_module_dep zend_module_dep
struct _zend_module_entry zend_module_entry
#define ZEND_MOD_REQUIRED(name)
#define STANDARD_MODULE_PROPERTIES_EX
#define STANDARD_MODULE_HEADER_EX
#define convert_to_string(op)
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define Z_STRVAL_P(zval_p)
Definition zend_types.h:975
#define Z_ARRVAL_P(zval_p)
Definition zend_types.h:987
struct _zend_array HashTable
Definition zend_types.h:386
#define Z_PTR_P(zval_p)
@ FAILURE
Definition zend_types.h:61