summaryrefslogtreecommitdiff
path: root/ext/mysqlnd
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mysqlnd')
-rw-r--r--ext/mysqlnd/config-win.h10
-rw-r--r--ext/mysqlnd/config.w323
-rw-r--r--ext/mysqlnd/config9.m434
-rw-r--r--ext/mysqlnd/mysql_float_to_double.h13
-rw-r--r--ext/mysqlnd/mysqlnd.h18
-rw-r--r--ext/mysqlnd/mysqlnd_alloc.c161
-rw-r--r--ext/mysqlnd/mysqlnd_alloc.h11
-rw-r--r--ext/mysqlnd/mysqlnd_auth.c634
-rw-r--r--ext/mysqlnd/mysqlnd_auth.h79
-rw-r--r--ext/mysqlnd/mysqlnd_block_alloc.c107
-rw-r--r--ext/mysqlnd/mysqlnd_block_alloc.h12
-rw-r--r--ext/mysqlnd/mysqlnd_charset.c86
-rw-r--r--ext/mysqlnd/mysqlnd_charset.h23
-rw-r--r--ext/mysqlnd/mysqlnd_commands.c948
-rw-r--r--ext/mysqlnd/mysqlnd_commands.h13
-rw-r--r--ext/mysqlnd/mysqlnd_connection.c63
-rw-r--r--ext/mysqlnd/mysqlnd_connection.h11
-rw-r--r--ext/mysqlnd/mysqlnd_debug.c18
-rw-r--r--ext/mysqlnd/mysqlnd_debug.h11
-rw-r--r--ext/mysqlnd/mysqlnd_driver.c33
-rw-r--r--ext/mysqlnd/mysqlnd_enum_n_def.h13
-rw-r--r--ext/mysqlnd/mysqlnd_ext_plugin.c19
-rw-r--r--ext/mysqlnd/mysqlnd_ext_plugin.h23
-rw-r--r--ext/mysqlnd/mysqlnd_libmysql_compat.h2
-rw-r--r--ext/mysqlnd/mysqlnd_loaddata.c11
-rw-r--r--ext/mysqlnd/mysqlnd_net.c1229
-rw-r--r--ext/mysqlnd/mysqlnd_plugin.c12
-rw-r--r--ext/mysqlnd/mysqlnd_plugin.h12
-rw-r--r--ext/mysqlnd/mysqlnd_portability.h85
-rw-r--r--ext/mysqlnd/mysqlnd_priv.h12
-rw-r--r--ext/mysqlnd/mysqlnd_protocol_frame_codec.c19
-rw-r--r--ext/mysqlnd/mysqlnd_protocol_frame_codec.h11
-rw-r--r--ext/mysqlnd/mysqlnd_ps.c165
-rw-r--r--ext/mysqlnd/mysqlnd_ps.h11
-rw-r--r--ext/mysqlnd/mysqlnd_ps_codec.c22
-rw-r--r--ext/mysqlnd/mysqlnd_read_buffer.c11
-rw-r--r--ext/mysqlnd/mysqlnd_read_buffer.h2
-rw-r--r--ext/mysqlnd/mysqlnd_result.c60
-rw-r--r--ext/mysqlnd/mysqlnd_result.h11
-rw-r--r--ext/mysqlnd/mysqlnd_result_meta.c11
-rw-r--r--ext/mysqlnd/mysqlnd_result_meta.h11
-rw-r--r--ext/mysqlnd/mysqlnd_reverse_api.c12
-rw-r--r--ext/mysqlnd/mysqlnd_reverse_api.h11
-rw-r--r--ext/mysqlnd/mysqlnd_statistics.c15
-rw-r--r--ext/mysqlnd/mysqlnd_statistics.h11
-rw-r--r--ext/mysqlnd/mysqlnd_structs.h112
-rw-r--r--ext/mysqlnd/mysqlnd_vio.c50
-rw-r--r--ext/mysqlnd/mysqlnd_vio.h11
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c194
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.h30
-rw-r--r--ext/mysqlnd/php_mysqlnd.c38
-rw-r--r--ext/mysqlnd/php_mysqlnd.h11
52 files changed, 1299 insertions, 3236 deletions
diff --git a/ext/mysqlnd/config-win.h b/ext/mysqlnd/config-win.h
index 3b5f95ed18..1047664f64 100644
--- a/ext/mysqlnd/config-win.h
+++ b/ext/mysqlnd/config-win.h
@@ -55,7 +55,6 @@ This file is public domain and comes with NO WARRANTY of any kind */
/* Type information */
-#define SIZEOF_CHAR 1
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
@@ -104,12 +103,3 @@ This file is public domain and comes with NO WARRANTY of any kind */
#endif /* _WIN64 */
#endif /* _MYSQLND_CONFIG_WIN_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/config.w32 b/ext/mysqlnd/config.w32
index 1dac93578a..5f191297d1 100644
--- a/ext/mysqlnd/config.w32
+++ b/ext/mysqlnd/config.w32
@@ -36,6 +36,9 @@ if (PHP_MYSQLND != "no") {
{
AC_DEFINE("MYSQLND_COMPRESSION_ENABLED", 1, "Compression support");
AC_DEFINE("MYSQLND_SSL_SUPPORTED", 1, "SSL support");
+ if (CHECK_LIB("crypt32.lib", "mysqlnd")) {
+ AC_DEFINE("MYSQLND_HAVE_SSL", 1, "Extended SSL support");
+ }
}
PHP_INSTALL_HEADERS("", "ext/mysqlnd");
}
diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4
index 573190fa43..5c01ed762f 100644
--- a/ext/mysqlnd/config9.m4
+++ b/ext/mysqlnd/config9.m4
@@ -1,17 +1,17 @@
-dnl config.m4 for mysqlnd driver
-
-PHP_ARG_ENABLE(mysqlnd, whether to enable mysqlnd,
- [ --enable-mysqlnd Enable mysqlnd explicitly, will be done implicitly
- when required by other extensions], no, yes)
-
-PHP_ARG_ENABLE(mysqlnd_compression_support, whether to disable compressed protocol support in mysqlnd,
-[ --disable-mysqlnd-compression-support
- Disable support for the MySQL compressed protocol in mysqlnd], yes, no)
-
-if test -z "$PHP_ZLIB_DIR"; then
- PHP_ARG_WITH(zlib-dir, for the location of libz,
- [ --with-zlib-dir[=DIR] mysqlnd: Set the path to libz install prefix], no, no)
-fi
+PHP_ARG_ENABLE([mysqlnd],
+ [whether to enable mysqlnd],
+ [AS_HELP_STRING([--enable-mysqlnd],
+ [Enable mysqlnd explicitly, will be done implicitly when required by other
+ extensions])],
+ [no],
+ [yes])
+
+PHP_ARG_ENABLE([mysqlnd_compression_support],
+ [whether to disable compressed protocol support in mysqlnd],
+ [AS_HELP_STRING([--disable-mysqlnd-compression-support],
+ [Disable support for the MySQL compressed protocol in mysqlnd])],
+ [yes],
+ [no])
dnl If some extension uses mysqlnd it will get compiled in PHP core
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
@@ -24,6 +24,9 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
if test "$PHP_MYSQLND_COMPRESSION_SUPPORT" != "no"; then
+ PKG_CHECK_MODULES([ZLIB], [zlib])
+ PHP_EVAL_LIBLINE($ZLIB_LIBS, MYSQLND_SHARED_LIBADD)
+ PHP_EVAL_INCLINE($ZLIB_CFLAGS)
AC_DEFINE([MYSQLND_COMPRESSION_WANTED], 1, [Enable compressed protocol support])
fi
@@ -32,9 +35,6 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
if test "$PHP_OPENSSL" != "no" || test "$PHP_OPENSSL_DIR" != "no"; then
- AC_CHECK_LIB(ssl, DSA_get_default_method, AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later]))
- AC_CHECK_LIB(crypto, X509_free, AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later]))
-
PHP_SETUP_OPENSSL(MYSQLND_SHARED_LIBADD, [AC_DEFINE(MYSQLND_HAVE_SSL,1,[Enable mysqlnd code that uses OpenSSL directly])])
fi
diff --git a/ext/mysqlnd/mysql_float_to_double.h b/ext/mysqlnd/mysql_float_to_double.h
index 7ac77d9127..0690a4c498 100644
--- a/ext/mysqlnd/mysql_float_to_double.h
+++ b/ext/mysqlnd/mysql_float_to_double.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -42,19 +42,10 @@ static inline double mysql_float_to_double(float fp4, int decimals) {
if (decimals < 0) {
php_gcvt(fp4, FLT_DIG, '.', 'e', num_buf);
} else {
- php_sprintf(num_buf, "%.*f", decimals, fp4);
+ sprintf(num_buf, "%.*f", decimals, fp4);
}
return zend_strtod(num_buf, NULL);
}
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
-
#endif /* MYSQL_FLOAT_TO_DOUBLE_H */
diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h
index 7cc7cc96e6..77cbce93ae 100644
--- a/ext/mysqlnd/mysqlnd.h
+++ b/ext/mysqlnd/mysqlnd.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -21,8 +21,8 @@
#ifndef MYSQLND_H
#define MYSQLND_H
-#define PHP_MYSQLND_VERSION "mysqlnd 5.0.12-dev - 20150407 - $Id$"
-#define MYSQLND_VERSION_ID 50012
+#define PHP_MYSQLND_VERSION "mysqlnd " PHP_VERSION
+#define MYSQLND_VERSION_ID PHP_VERSION_ID
#define MYSQLND_PLUGIN_API_VERSION 2
@@ -78,7 +78,7 @@ PHPAPI void mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void
PHPAPI void mysqlnd_minfo_print_hash(zval *values);
#define mysqlnd_thread_safe() TRUE
-PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(unsigned int charsetno);
+PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(const unsigned int charsetno);
PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const charsetname);
@@ -338,13 +338,3 @@ ZEND_TSRMLS_CACHE_EXTERN()
PHPAPI void mysqlnd_minfo_print_hash(zval *values);
#endif /* MYSQLND_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c
index 5ee2d4537f..e4fe274901 100644
--- a/ext/mysqlnd/mysqlnd_alloc.c
+++ b/ext/mysqlnd/mysqlnd_alloc.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -82,26 +82,22 @@ static void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
zend_long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_emalloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = emalloc_rel(REAL_SIZE(size));
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_emalloc_name);
+ ret = emalloc_rel(REAL_SIZE(size));
#endif
TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret);
@@ -122,26 +118,22 @@ static void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
zend_long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = pemalloc_rel(REAL_SIZE(size), persistent);
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name);
+ ret = pemalloc_rel(REAL_SIZE(size), persistent);
#endif
TRACE_ALLOC_INF_FMT("size=%lu ptr=%p persistent=%u", size, ret, persistent);
@@ -165,27 +157,24 @@ static void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
zend_long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(FALSE));
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = ecalloc_rel(nmemb, REAL_SIZE(size));
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name);
+ TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(FALSE));
+ ret = ecalloc_rel(nmemb, REAL_SIZE(size));
#endif
TRACE_ALLOC_INF_FMT("after : %lu", zend_memory_usage(FALSE));
@@ -206,25 +195,21 @@ static void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persi
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
zend_long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = pecalloc_rel(nmemb, REAL_SIZE(size), persistent);
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name);
+ ret = pecalloc_rel(nmemb, REAL_SIZE(size), persistent);
#endif
TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret);
@@ -249,27 +234,24 @@ static void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
#if PHP_DEBUG
zend_long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_erealloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size);
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = erealloc_rel(REAL_PTR(ptr), REAL_SIZE(new_size));
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_erealloc_name);
+ TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size);
+ ret = erealloc_rel(REAL_PTR(ptr), REAL_SIZE(new_size));
#endif
TRACE_ALLOC_INF_FMT("new_ptr=%p", (char*)ret);
@@ -290,27 +272,24 @@ static void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persisten
size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
#if PHP_DEBUG
zend_long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_perealloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent);
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = perealloc_rel(REAL_PTR(ptr), REAL_SIZE(new_size), persistent);
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_perealloc_name);
+ TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent);
+ ret = perealloc_rel(REAL_PTR(ptr), REAL_SIZE(new_size), persistent);
#endif
TRACE_ALLOC_INF_FMT("new_ptr=%p", (char*)ret);
@@ -396,26 +375,22 @@ static void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
zend_long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_malloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = malloc(REAL_SIZE(size));
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_malloc_name);
+ ret = malloc(REAL_SIZE(size));
#endif
TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret);
@@ -435,26 +410,22 @@ static void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
zend_long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_calloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = calloc(nmemb, REAL_SIZE(size));
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_calloc_name);
+ ret = calloc(nmemb, REAL_SIZE(size));
#endif
TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret);
@@ -474,28 +445,26 @@ static void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D)
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
zend_long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
-#endif
TRACE_ALLOC_ENTER(mysqlnd_realloc_name);
-#if PHP_DEBUG
{
char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR);
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno);
}
-#endif
TRACE_ALLOC_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr);
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(TRUE));
-#if PHP_DEBUG
- /* -1 is also "true" */
- if (*threshold) {
-#endif
+ if (*threshold == 0) {
+ ret = NULL;
+ } else {
ret = realloc(REAL_PTR(ptr), REAL_SIZE(new_size));
-#if PHP_DEBUG
--*threshold;
- } else if (*threshold == 0) {
- ret = NULL;
}
+#else
+ TRACE_ALLOC_ENTER(mysqlnd_realloc_name);
+ TRACE_ALLOC_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr);
+ TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(TRUE));
+ ret = realloc(REAL_PTR(ptr), REAL_SIZE(new_size));
#endif
TRACE_ALLOC_INF_FMT("new_ptr=%p", (char*)ret);
@@ -848,13 +817,3 @@ PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator =
_mysqlnd_sprintf_free,
#endif
};
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_alloc.h b/ext/mysqlnd/mysqlnd_alloc.h
index d9ceca2eac..5764063df7 100644
--- a/ext/mysqlnd/mysqlnd_alloc.h
+++ b/ext/mysqlnd/mysqlnd_alloc.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -85,12 +85,3 @@ static inline MYSQLND_CSTRING mnd_str2c(const MYSQLND_STRING str)
}
#endif /* MYSQLND_ALLOC_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c
index 2c50c1fdc5..915b735553 100644
--- a/ext/mysqlnd/mysqlnd_auth.c
+++ b/ext/mysqlnd/mysqlnd_auth.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -36,7 +36,7 @@ static const char * const mysqlnd_old_passwd = "mysqlnd cannot connect to MySQL
/* {{{ mysqlnd_run_authentication */
enum_func_status
mysqlnd_run_authentication(
- MYSQLND_CONN_DATA * conn,
+ MYSQLND_CONN_DATA * const conn,
const char * const user,
const char * const passwd,
const size_t passwd_len,
@@ -44,11 +44,11 @@ mysqlnd_run_authentication(
const size_t db_len,
const MYSQLND_STRING auth_plugin_data,
const char * const auth_protocol,
- unsigned int charset_no,
+ const unsigned int charset_no,
const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags,
- zend_bool silent,
- zend_bool is_change_user
+ const zend_ulong mysql_flags,
+ const zend_bool silent,
+ const zend_bool is_change_user
)
{
enum_func_status ret = FAIL;
@@ -89,6 +89,7 @@ mysqlnd_run_authentication(
}
}
+
{
zend_uchar * switch_to_auth_protocol_data = NULL;
size_t switch_to_auth_protocol_data_len = 0;
@@ -113,10 +114,11 @@ mysqlnd_run_authentication(
DBG_INF_FMT("salt(%d)=[%.*s]", plugin_data_len, plugin_data_len, plugin_data);
/* The data should be allocated with malloc() */
if (auth_plugin) {
- scrambled_data =
- auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len,
- plugin_data, plugin_data_len, session_options,
- conn->protocol_frame_codec->data, mysql_flags);
+ scrambled_data = auth_plugin->methods.get_auth_data(
+ NULL, &scrambled_data_len, conn, user, passwd,
+ passwd_len, plugin_data, plugin_data_len,
+ session_options, conn->protocol_frame_codec->data,
+ mysql_flags);
}
if (conn->error_info->error_no) {
@@ -127,6 +129,7 @@ mysqlnd_run_authentication(
charset_no,
first_call,
requested_protocol,
+ auth_plugin, plugin_data, plugin_data_len,
scrambled_data, scrambled_data_len,
&switch_to_auth_protocol, &switch_to_auth_protocol_len,
&switch_to_auth_protocol_data, &switch_to_auth_protocol_data_len
@@ -135,6 +138,7 @@ mysqlnd_run_authentication(
ret = mysqlnd_auth_change_user(conn, user, strlen(user), passwd, passwd_len, db, db_len, silent,
first_call,
requested_protocol,
+ auth_plugin, plugin_data, plugin_data_len,
scrambled_data, scrambled_data_len,
&switch_to_auth_protocol, &switch_to_auth_protocol_len,
&switch_to_auth_protocol_data, &switch_to_auth_protocol_data_len
@@ -177,23 +181,23 @@ end:
/* {{{ mysqlnd_switch_to_ssl_if_needed */
static enum_func_status
-mysqlnd_switch_to_ssl_if_needed(MYSQLND_CONN_DATA * conn,
+mysqlnd_switch_to_ssl_if_needed(MYSQLND_CONN_DATA * const conn,
unsigned int charset_no,
- size_t server_capabilities,
+ const size_t server_capabilities,
const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags)
+ const zend_ulong mysql_flags)
{
enum_func_status ret = FAIL;
const MYSQLND_CHARSET * charset;
DBG_ENTER("mysqlnd_switch_to_ssl_if_needed");
if (session_options->charset_name && (charset = mysqlnd_find_charset_name(session_options->charset_name))) {
- charset_no = charset->nr;
+ charset_no = charset->nr;
}
{
- size_t client_capabilities = mysql_flags;
- ret = conn->run_command(COM_ENABLE_SSL, conn, client_capabilities, server_capabilities, charset_no);
+ const size_t client_capabilities = mysql_flags;
+ ret = conn->command->enable_ssl(conn, client_capabilities, server_capabilities, charset_no);
}
DBG_RETURN(ret);
}
@@ -203,18 +207,18 @@ mysqlnd_switch_to_ssl_if_needed(MYSQLND_CONN_DATA * conn,
/* {{{ mysqlnd_connect_run_authentication */
enum_func_status
mysqlnd_connect_run_authentication(
- MYSQLND_CONN_DATA * conn,
+ MYSQLND_CONN_DATA * const conn,
const char * const user,
const char * const passwd,
const char * const db,
- size_t db_len,
- size_t passwd_len,
- MYSQLND_STRING authentication_plugin_data,
+ const size_t db_len,
+ const size_t passwd_len,
+ const MYSQLND_STRING authentication_plugin_data,
const char * const authentication_protocol,
const unsigned int charset_no,
- size_t server_capabilities,
+ const size_t server_capabilities,
const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags
+ const zend_ulong mysql_flags
)
{
enum_func_status ret = FAIL;
@@ -240,16 +244,19 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
const char * const db,
const size_t db_len,
const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags,
- unsigned int server_charset_no,
- zend_bool use_full_blown_auth_packet,
+ const zend_ulong mysql_flags,
+ const unsigned int server_charset_no,
+ const zend_bool use_full_blown_auth_packet,
const char * const auth_protocol,
+ struct st_mysqlnd_authentication_plugin * auth_plugin,
+ const zend_uchar * const orig_auth_plugin_data,
+ const size_t orig_auth_plugin_data_len,
const zend_uchar * const auth_plugin_data,
const size_t auth_plugin_data_len,
char ** switch_to_auth_protocol,
- size_t * switch_to_auth_protocol_len,
+ size_t * const switch_to_auth_protocol_len,
zend_uchar ** switch_to_auth_protocol_data,
- size_t * switch_to_auth_protocol_data_len
+ size_t * const switch_to_auth_protocol_data_len
)
{
enum_func_status ret = FAIL;
@@ -313,6 +320,15 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
PACKET_FREE(&auth_packet);
}
+ if (auth_plugin && auth_plugin->methods.handle_server_response) {
+ if (FAIL == auth_plugin->methods.handle_server_response(auth_plugin, conn,
+ orig_auth_plugin_data, orig_auth_plugin_data_len, passwd, passwd_len,
+ switch_to_auth_protocol, switch_to_auth_protocol_len,
+ switch_to_auth_protocol_data, switch_to_auth_protocol_data_len)) {
+ goto end;
+ }
+ }
+
if (FAIL == PACKET_READ(conn, &auth_resp_packet) || auth_resp_packet.response_code >= 0xFE) {
if (auth_resp_packet.response_code == 0xFE) {
/* old authentication with new server !*/
@@ -360,14 +376,17 @@ mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn,
const char * const db,
const size_t db_len,
const zend_bool silent,
- zend_bool use_full_blown_auth_packet,
+ const zend_bool use_full_blown_auth_packet,
const char * const auth_protocol,
- zend_uchar * auth_plugin_data,
- size_t auth_plugin_data_len,
+ struct st_mysqlnd_authentication_plugin * auth_plugin,
+ const zend_uchar * const orig_auth_plugin_data,
+ const size_t orig_auth_plugin_data_len,
+ const zend_uchar * const auth_plugin_data,
+ const size_t auth_plugin_data_len,
char ** switch_to_auth_protocol,
- size_t * switch_to_auth_protocol_len,
+ size_t * const switch_to_auth_protocol_len,
zend_uchar ** switch_to_auth_protocol_data,
- size_t * switch_to_auth_protocol_data_len
+ size_t * const switch_to_auth_protocol_data_len
)
{
enum_func_status ret = FAIL;
@@ -427,6 +446,15 @@ mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn,
PACKET_FREE(&auth_packet);
}
+ if (auth_plugin && auth_plugin->methods.handle_server_response) {
+ if (FAIL == auth_plugin->methods.handle_server_response(auth_plugin, conn,
+ orig_auth_plugin_data, orig_auth_plugin_data_len, passwd, passwd_len,
+ switch_to_auth_protocol, switch_to_auth_protocol_len,
+ switch_to_auth_protocol_data, switch_to_auth_protocol_data_len)) {
+ goto end;
+ }
+ }
+
ret = PACKET_READ(conn, &chg_user_resp);
COPY_CLIENT_ERROR(conn->error_info, chg_user_resp.error_info);
@@ -551,10 +579,10 @@ static zend_uchar *
mysqlnd_native_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
size_t * auth_data_len,
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
- const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
+ const size_t passwd_len, zend_uchar * auth_plugin_data, const size_t auth_plugin_data_len,
const MYSQLND_SESSION_OPTIONS * const session_options,
const MYSQLND_PFC_DATA * const pfc_data,
- zend_ulong mysql_flags
+ const zend_ulong mysql_flags
)
{
zend_uchar * ret = NULL;
@@ -599,7 +627,8 @@ static struct st_mysqlnd_authentication_plugin mysqlnd_native_auth_plugin =
}
},
{/* methods */
- mysqlnd_native_auth_get_auth_data
+ mysqlnd_native_auth_get_auth_data,
+ NULL
}
};
@@ -611,10 +640,10 @@ static zend_uchar *
mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
size_t * auth_data_len,
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
- const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
+ const size_t passwd_len, zend_uchar * auth_plugin_data, const size_t auth_plugin_data_len,
const MYSQLND_SESSION_OPTIONS * const session_options,
const MYSQLND_PFC_DATA * const pfc_data,
- zend_ulong mysql_flags
+ const zend_ulong mysql_flags
)
{
zend_uchar * ret = NULL;
@@ -648,7 +677,8 @@ static struct st_mysqlnd_authentication_plugin mysqlnd_pam_authentication_plugin
}
},
{/* methods */
- mysqlnd_pam_auth_get_auth_data
+ mysqlnd_pam_auth_get_auth_data,
+ NULL
}
};
@@ -664,20 +694,149 @@ mysqlnd_xor_string(char * dst, const size_t dst_len, const char * xor_str, const
}
}
+#ifndef PHP_WIN32
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
+typedef RSA * mysqlnd_rsa_t;
+
+/* {{{ mysqlnd_sha256_get_rsa_from_pem */
+static mysqlnd_rsa_t
+mysqlnd_sha256_get_rsa_from_pem(const char *buf, size_t len)
+{
+ BIO * bio = BIO_new_mem_buf(buf, len);
+ RSA * ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
+ BIO_free(bio);
+ return ret;
+}
+/* }}} */
+
+/* {{{ mysqlnd_sha256_public_encrypt */
+static zend_uchar *
+mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, size_t * auth_data_len, char *xor_str)
+{
+ zend_uchar * ret = NULL;
+ size_t server_public_key_len = (size_t) RSA_size(server_public_key);
+
+ DBG_ENTER("mysqlnd_sha256_public_encrypt");
+ /*
+ Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
+ RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
+ http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
+ */
+ if (server_public_key_len <= passwd_len + 41) {
+ /* password message is to long */
+ RSA_free(server_public_key);
+ SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
+ DBG_ERR("password is too long");
+ DBG_RETURN(NULL);
+ }
+
+ *auth_data_len = server_public_key_len;
+ ret = malloc(*auth_data_len);
+ RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, ret, server_public_key, RSA_PKCS1_OAEP_PADDING);
+ RSA_free(server_public_key);
+ DBG_RETURN(ret);
+}
+/* }}} */
+
+#else
+
+#include <wincrypt.h>
+#include <bcrypt.h>
+
+typedef HANDLE mysqlnd_rsa_t;
+
+/* {{{ mysqlnd_sha256_get_rsa_from_pem */
+static mysqlnd_rsa_t
+mysqlnd_sha256_get_rsa_from_pem(const char *buf, size_t len)
+{
+ BCRYPT_KEY_HANDLE ret = 0;
+ LPCSTR der_buf = NULL;
+ DWORD der_len;
+ CERT_PUBLIC_KEY_INFO *key_info = NULL;
+ DWORD key_info_len;
+ ALLOCA_FLAG(use_heap);
+
+ if (!CryptStringToBinaryA(buf, len, CRYPT_STRING_BASE64HEADER, NULL, &der_len, NULL, NULL)) {
+ goto finish;
+ }
+ der_buf = do_alloca(der_len, use_heap);
+ if (!CryptStringToBinaryA(buf, len, CRYPT_STRING_BASE64HEADER, der_buf, &der_len, NULL, NULL)) {
+ goto finish;
+ }
+ if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, der_buf, der_len, CRYPT_ENCODE_ALLOC_FLAG, NULL, &key_info, &key_info_len)) {
+ goto finish;
+ }
+ if (!CryptImportPublicKeyInfoEx2(X509_ASN_ENCODING, key_info, CRYPT_OID_INFO_PUBKEY_ENCRYPT_KEY_FLAG, NULL, &ret)) {
+ goto finish;
+ }
+
+finish:
+ if (key_info) {
+ LocalFree(key_info);
+ }
+ if (der_buf) {
+ free_alloca(der_buf, use_heap);
+ }
+ return (mysqlnd_rsa_t) ret;
+}
+/* }}} */
+
+/* {{{ mysqlnd_sha256_public_encrypt */
+static zend_uchar *
+mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, size_t * auth_data_len, char *xor_str)
+{
+ zend_uchar * ret = NULL;
+ DWORD server_public_key_len = passwd_len;
+ BCRYPT_OAEP_PADDING_INFO padding_info;
+
+ DBG_ENTER("mysqlnd_sha256_public_encrypt");
+
+ ZeroMemory(&padding_info, sizeof padding_info);
+ padding_info.pszAlgId = BCRYPT_SHA1_ALGORITHM;
+ if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
+ NULL, 0, NULL, 0, &server_public_key_len, BCRYPT_PAD_OAEP)) {
+ DBG_RETURN(0);
+ }
+
+ /*
+ Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
+ RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
+ http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
+ */
+ if ((size_t) server_public_key_len <= passwd_len + 41) {
+ /* password message is to long */
+ BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
+ SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
+ DBG_ERR("password is too long");
+ DBG_RETURN(0);
+ }
+
+ *auth_data_len = server_public_key_len;
+ ret = malloc(*auth_data_len);
+ if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
+ NULL, 0, ret, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
+ BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
+ DBG_RETURN(0);
+ }
+ BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
+ DBG_RETURN(ret);
+}
+/* }}} */
+
+#endif
/* {{{ mysqlnd_sha256_get_rsa_key */
-static RSA *
+static mysqlnd_rsa_t
mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
const MYSQLND_SESSION_OPTIONS * const session_options,
const MYSQLND_PFC_DATA * const pfc_data
)
{
- RSA * ret = NULL;
+ mysqlnd_rsa_t ret = NULL;
const char * fname = (pfc_data->sha256_server_public_key && pfc_data->sha256_server_public_key[0] != '\0')?
pfc_data->sha256_server_public_key:
MYSQLND_G(sha256_server_public_key);
@@ -709,11 +868,7 @@ mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
}
DBG_INF_FMT("Public key(%d):\n%s", pk_resp_packet.public_key_len, pk_resp_packet.public_key);
/* now extract the public key */
- {
- BIO * bio = BIO_new_mem_buf(pk_resp_packet.public_key, pk_resp_packet.public_key_len);
- ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
- BIO_free(bio);
- }
+ ret = mysqlnd_sha256_get_rsa_from_pem((const char *) pk_resp_packet.public_key, pk_resp_packet.public_key_len);
} while (0);
PACKET_FREE(&pk_req_packet);
PACKET_FREE(&pk_resp_packet);
@@ -732,9 +887,7 @@ mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
if (stream) {
if ((key_str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) {
- BIO * bio = BIO_new_mem_buf(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
- ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
- BIO_free(bio);
+ ret = mysqlnd_sha256_get_rsa_from_pem(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
DBG_INF("Successfully loaded");
DBG_INF_FMT("Public key:%*.s", ZSTR_LEN(key_str), ZSTR_VAL(key_str));
zend_string_release_ex(key_str, 0);
@@ -752,13 +905,13 @@ static zend_uchar *
mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
size_t * auth_data_len,
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
- const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
+ const size_t passwd_len, zend_uchar * auth_plugin_data, const size_t auth_plugin_data_len,
const MYSQLND_SESSION_OPTIONS * const session_options,
const MYSQLND_PFC_DATA * const pfc_data,
- zend_ulong mysql_flags
+ const zend_ulong mysql_flags
)
{
- RSA * server_public_key;
+ mysqlnd_rsa_t server_public_key;
zend_uchar * ret = NULL;
DBG_ENTER("mysqlnd_sha256_auth_get_auth_data");
DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
@@ -775,28 +928,13 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
server_public_key = mysqlnd_sha256_get_rsa_key(conn, session_options, pfc_data);
if (server_public_key) {
- int server_public_key_len;
- char xor_str[passwd_len + 1];
+ ALLOCA_FLAG(use_heap);
+ char *xor_str = do_alloca(passwd_len + 1, use_heap);
memcpy(xor_str, passwd, passwd_len);
xor_str[passwd_len] = '\0';
mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, auth_plugin_data_len);
-
- server_public_key_len = RSA_size(server_public_key);
- /*
- Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
- RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
- http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
- */
- if ((size_t) server_public_key_len - 41 <= passwd_len) {
- /* password message is to long */
- SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
- DBG_ERR("password is too long");
- DBG_RETURN(NULL);
- }
-
- *auth_data_len = server_public_key_len;
- ret = malloc(*auth_data_len);
- RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, ret, server_public_key, RSA_PKCS1_OAEP_PADDING);
+ ret = mysqlnd_sha256_public_encrypt(conn, server_public_key, passwd_len, auth_data_len, xor_str);
+ free_alloca(xor_str, use_heap);
}
}
@@ -823,11 +961,354 @@ static struct st_mysqlnd_authentication_plugin mysqlnd_sha256_authentication_plu
}
},
{/* methods */
- mysqlnd_sha256_auth_get_auth_data
+ mysqlnd_sha256_auth_get_auth_data,
+ NULL
}
};
#endif
+/*************************************** CACHING SHA2 Password *******************************/
+#ifdef MYSQLND_HAVE_SSL
+
+#undef L64
+
+#include "ext/hash/php_hash.h"
+#include "ext/hash/php_hash_sha.h"
+
+#define SHA256_LENGTH 32
+
+/* {{{ php_mysqlnd_scramble_sha2 */
+void php_mysqlnd_scramble_sha2(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const password, const size_t password_len)
+{
+ PHP_SHA256_CTX context;
+ zend_uchar sha1[SHA256_LENGTH];
+ zend_uchar sha2[SHA256_LENGTH];
+
+ /* Phase 1: hash password */
+ PHP_SHA256Init(&context);
+ PHP_SHA256Update(&context, password, password_len);
+ PHP_SHA256Final(sha1, &context);
+
+ /* Phase 2: hash sha1 */
+ PHP_SHA256Init(&context);
+ PHP_SHA256Update(&context, (zend_uchar*)sha1, SHA256_LENGTH);
+ PHP_SHA256Final(sha2, &context);
+
+ /* Phase 3: hash scramble + sha2 */
+ PHP_SHA256Init(&context);
+ PHP_SHA256Update(&context, (zend_uchar*)sha2, SHA256_LENGTH);
+ PHP_SHA256Update(&context, scramble, SCRAMBLE_LENGTH);
+ PHP_SHA256Final(buffer, &context);
+
+ /* let's crypt buffer now */
+ php_mysqlnd_crypt(buffer, (const zend_uchar *)sha1, (const zend_uchar *)buffer, SHA256_LENGTH);
+}
+/* }}} */
+
+#ifndef PHP_WIN32
+
+/* {{{ mysqlnd_caching_sha2_public_encrypt */
+static size_t
+mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, unsigned char **crypted, char *xor_str)
+{
+ size_t server_public_key_len = (size_t) RSA_size(server_public_key);
+
+ DBG_ENTER("mysqlnd_caching_sha2_public_encrypt");
+ /*
+ Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
+ RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
+ http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
+ */
+ if (server_public_key_len <= passwd_len + 41) {
+ /* password message is to long */
+ RSA_free(server_public_key);
+ SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
+ DBG_ERR("password is too long");
+ DBG_RETURN(0);
+ }
+
+ *crypted = emalloc(server_public_key_len);
+ RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, *crypted, server_public_key, RSA_PKCS1_OAEP_PADDING);
+ RSA_free(server_public_key);
+ DBG_RETURN(server_public_key_len);
+}
+/* }}} */
+
+#else
+
+/* {{{ mysqlnd_caching_sha2_public_encrypt */
+static size_t
+mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t passwd_len, unsigned char **crypted, char *xor_str)
+{
+ DWORD server_public_key_len = passwd_len;
+ BCRYPT_OAEP_PADDING_INFO padding_info;
+
+ DBG_ENTER("mysqlnd_caching_sha2_public_encrypt");
+
+ ZeroMemory(&padding_info, sizeof padding_info);
+ padding_info.pszAlgId = BCRYPT_SHA1_ALGORITHM;
+ if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
+ NULL, 0, NULL, 0, &server_public_key_len, BCRYPT_PAD_OAEP)) {
+ DBG_RETURN(0);
+ }
+
+ /*
+ Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
+ RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
+ http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
+ */
+ if ((size_t) server_public_key_len <= passwd_len + 41) {
+ /* password message is to long */
+ BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
+ SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
+ DBG_ERR("password is too long");
+ DBG_RETURN(0);
+ }
+
+ *crypted = emalloc(server_public_key_len);
+ if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info,
+ NULL, 0, *crypted, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) {
+ BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
+ DBG_RETURN(0);
+ }
+ BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key);
+ DBG_RETURN(server_public_key_len);
+}
+/* }}} */
+
+#endif
+
+/* {{{ mysqlnd_native_auth_get_auth_data */
+static zend_uchar *
+mysqlnd_caching_sha2_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
+ size_t * auth_data_len,
+ MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
+ const size_t passwd_len, zend_uchar * auth_plugin_data, const size_t auth_plugin_data_len,
+ const MYSQLND_SESSION_OPTIONS * const session_options,
+ const MYSQLND_PFC_DATA * const pfc_data,
+ const zend_ulong mysql_flags
+ )
+{
+ zend_uchar * ret = NULL;
+ DBG_ENTER("mysqlnd_caching_sha2_get_auth_data");
+ DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
+ *auth_data_len = 0;
+
+ if (auth_plugin_data_len < SCRAMBLE_LENGTH) {
+ SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "The server sent wrong length for scramble");
+ DBG_ERR_FMT("The server sent wrong length for scramble %u. Expected %u", auth_plugin_data_len, SCRAMBLE_LENGTH);
+ DBG_RETURN(NULL);
+ }
+
+ DBG_INF("First auth step: send hashed password");
+ /* copy scrambled pass*/
+ if (passwd && passwd_len) {
+ ret = malloc(SHA256_LENGTH + 1);
+ *auth_data_len = SHA256_LENGTH;
+ php_mysqlnd_scramble_sha2((zend_uchar*)ret, auth_plugin_data, (zend_uchar*)passwd, passwd_len);
+ ret[SHA256_LENGTH] = '\0';
+ DBG_INF_FMT("hash(%d)=[%.*s]", *auth_data_len, *auth_data_len, ret);
+ }
+
+ DBG_RETURN(ret);
+}
+/* }}} */
+
+static mysqlnd_rsa_t
+mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn)
+{
+ mysqlnd_rsa_t ret = NULL;
+ const MYSQLND_PFC_DATA * const pfc_data = conn->protocol_frame_codec->data;
+ const char * fname = (pfc_data->sha256_server_public_key && pfc_data->sha256_server_public_key[0] != '\0')?
+ pfc_data->sha256_server_public_key:
+ MYSQLND_G(sha256_server_public_key);
+ php_stream * stream;
+ DBG_ENTER("mysqlnd_cached_sha2_get_key");
+ DBG_INF_FMT("options_s256_pk=[%s] MYSQLND_G(sha256_server_public_key)=[%s]",
+ pfc_data->sha256_server_public_key? pfc_data->sha256_server_public_key:"n/a",
+ MYSQLND_G(sha256_server_public_key)? MYSQLND_G(sha256_server_public_key):"n/a");
+ if (!fname || fname[0] == '\0') {
+ MYSQLND_PACKET_CACHED_SHA2_RESULT req_packet;
+ MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE pk_resp_packet;
+
+ do {
+ DBG_INF("requesting the public key from the server");
+ conn->payload_decoder_factory->m.init_cached_sha2_result_packet(&req_packet);
+ conn->payload_decoder_factory->m.init_sha256_pk_request_response_packet(&pk_resp_packet);
+ req_packet.request = 1;
+
+ if (! PACKET_WRITE(conn, &req_packet)) {
+ DBG_ERR_FMT("Error while sending public key request packet");
+ php_error(E_WARNING, "Error while sending public key request packet. PID=%d", getpid());
+ SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
+ break;
+ }
+ if (FAIL == PACKET_READ(conn, &pk_resp_packet) || NULL == pk_resp_packet.public_key) {
+ DBG_ERR_FMT("Error while receiving public key");
+ php_error(E_WARNING, "Error while receiving public key. PID=%d", getpid());
+ SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
+ break;
+ }
+ DBG_INF_FMT("Public key(%d):\n%s", pk_resp_packet.public_key_len, pk_resp_packet.public_key);
+ /* now extract the public key */
+ ret = mysqlnd_sha256_get_rsa_from_pem((const char *) pk_resp_packet.public_key, pk_resp_packet.public_key_len);
+ } while (0);
+ PACKET_FREE(&req_packet);
+ PACKET_FREE(&pk_resp_packet);
+
+ DBG_INF_FMT("ret=%p", ret);
+ DBG_RETURN(ret);
+
+ SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE,
+ "caching_sha2_server_public_key is not set for the connection or as mysqlnd.sha256_server_public_key");
+ DBG_ERR("server_public_key is not set");
+ DBG_RETURN(NULL);
+ } else {
+ zend_string * key_str;
+ DBG_INF_FMT("Key in a file. [%s]", fname);
+ stream = php_stream_open_wrapper((char *) fname, "rb", REPORT_ERRORS, NULL);
+
+ if (stream) {
+ if ((key_str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) {
+ ret = mysqlnd_sha256_get_rsa_from_pem(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
+ DBG_INF("Successfully loaded");
+ DBG_INF_FMT("Public key:%*.s", ZSTR_LEN(key_str), ZSTR_VAL(key_str));
+ zend_string_release(key_str);
+ }
+ php_stream_close(stream);
+ }
+ }
+ DBG_RETURN(ret);
+
+}
+
+
+/* {{{ mysqlnd_caching_sha2_get_and_use_key */
+static size_t
+mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn,
+ const zend_uchar * auth_plugin_data, const size_t auth_plugin_data_len,
+ unsigned char **crypted,
+ const char * const passwd,
+ const size_t passwd_len)
+{
+ mysqlnd_rsa_t server_public_key = mysqlnd_caching_sha2_get_key(conn);
+
+ DBG_ENTER("mysqlnd_caching_sha2_get_and_use_key(");
+
+ if (server_public_key) {
+ int server_public_key_len;
+ ALLOCA_FLAG(use_heap)
+ char *xor_str = do_alloca(passwd_len + 1, use_heap);
+ memcpy(xor_str, passwd, passwd_len);
+ xor_str[passwd_len] = '\0';
+ mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, SCRAMBLE_LENGTH);
+ server_public_key_len = mysqlnd_caching_sha2_public_encrypt(conn, server_public_key, passwd_len, crypted, xor_str);
+ free_alloca(xor_str, use_heap);
+ DBG_RETURN(server_public_key_len);
+ }
+ DBG_RETURN(0);
+}
+/* }}} */
+
+static int is_secure_transport(MYSQLND_CONN_DATA *conn) {
+ if (conn->vio->data->ssl) {
+ return 1;
+ }
+
+ return strcmp(conn->vio->data->stream->ops->label, "unix_socket") == 0;
+}
+
+/* {{{ mysqlnd_caching_sha2_handle_server_response */
+static enum_func_status
+mysqlnd_caching_sha2_handle_server_response(struct st_mysqlnd_authentication_plugin *self,
+ MYSQLND_CONN_DATA * conn,
+ const zend_uchar * auth_plugin_data, const size_t auth_plugin_data_len,
+ const char * const passwd,
+ const size_t passwd_len,
+ char **new_auth_protocol, size_t *new_auth_protocol_len,
+ zend_uchar **new_auth_protocol_data, size_t *new_auth_protocol_data_len
+ )
+{
+ DBG_ENTER("mysqlnd_caching_sha2_handle_server_response");
+ MYSQLND_PACKET_CACHED_SHA2_RESULT result_packet;
+
+ if (passwd_len == 0) {
+ DBG_INF("empty password fast path");
+ DBG_RETURN(PASS);
+ }
+
+ conn->payload_decoder_factory->m.init_cached_sha2_result_packet(&result_packet);
+ if (FAIL == PACKET_READ(conn, &result_packet)) {
+ DBG_RETURN(PASS);
+ }
+
+ switch (result_packet.response_code) {
+ case 0xFF:
+ if (result_packet.sqlstate[0]) {
+ strlcpy(conn->error_info->sqlstate, result_packet.sqlstate, sizeof(conn->error_info->sqlstate));
+ DBG_ERR_FMT("ERROR:%u [SQLSTATE:%s] %s", result_packet.error_no, result_packet.sqlstate, result_packet.error);
+ }
+ SET_CLIENT_ERROR(conn->error_info, result_packet.error_no, UNKNOWN_SQLSTATE, result_packet.error);
+ DBG_RETURN(FAIL);
+ case 0xFE:
+ DBG_INF("auth switch response");
+ *new_auth_protocol = result_packet.new_auth_protocol;
+ *new_auth_protocol_len = result_packet.new_auth_protocol_len;
+ *new_auth_protocol_data = result_packet.new_auth_protocol_data;
+ *new_auth_protocol_data_len = result_packet.new_auth_protocol_data_len;
+ DBG_RETURN(FAIL);
+ case 3:
+ DBG_INF("fast path succeeded");
+ DBG_RETURN(PASS);
+ case 4:
+ if (is_secure_transport(conn)) {
+ DBG_INF("fast path failed, doing full auth via secure transport");
+ result_packet.password = (zend_uchar *)passwd;
+ result_packet.password_len = passwd_len + 1;
+ PACKET_WRITE(conn, &result_packet);
+ } else {
+ DBG_INF("fast path failed, doing full auth via insecure transport");
+ result_packet.password_len = mysqlnd_caching_sha2_get_and_use_key(conn, auth_plugin_data, auth_plugin_data_len, &result_packet.password, passwd, passwd_len);
+ PACKET_WRITE(conn, &result_packet);
+ efree(result_packet.password);
+ }
+ DBG_RETURN(PASS);
+ case 2:
+ // The server tried to send a key, which we didn't expect
+ // fall-through
+ default:
+ php_error_docref(NULL, E_WARNING, "Unexpected server response while doing caching_sha2 auth: %i", result_packet.response_code);
+ }
+
+ DBG_RETURN(PASS);
+}
+/* }}} */
+
+static struct st_mysqlnd_authentication_plugin mysqlnd_caching_sha2_auth_plugin =
+{
+ {
+ MYSQLND_PLUGIN_API_VERSION,
+ "auth_plugin_caching_sha2_password",
+ MYSQLND_VERSION_ID,
+ PHP_MYSQLND_VERSION,
+ "PHP License 3.01",
+ "Johannes Schlüter <johannes.schlueter@php.net>",
+ {
+ NULL, /* no statistics , will be filled later if there are some */
+ NULL, /* no statistics */
+ },
+ {
+ NULL /* plugin shutdown */
+ }
+ },
+ {/* methods */
+ mysqlnd_caching_sha2_get_auth_data,
+ mysqlnd_caching_sha2_handle_server_response
+ }
+};
+#endif
+
+
/* {{{ mysqlnd_register_builtin_authentication_plugins */
void
mysqlnd_register_builtin_authentication_plugins(void)
@@ -835,17 +1316,8 @@ mysqlnd_register_builtin_authentication_plugins(void)
mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_native_auth_plugin);
mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_pam_authentication_plugin);
#ifdef MYSQLND_HAVE_SSL
+ mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_caching_sha2_auth_plugin);
mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_sha256_authentication_plugin);
#endif
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_auth.h b/ext/mysqlnd/mysqlnd_auth.h
index 8fc369abca..54fac21bde 100644
--- a/ext/mysqlnd/mysqlnd_auth.h
+++ b/ext/mysqlnd/mysqlnd_auth.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,36 +27,19 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
const char * const db,
const size_t db_len,
const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags,
- unsigned int server_charset_no,
- zend_bool use_full_blown_auth_packet,
+ const zend_ulong mysql_flags,
+ const unsigned int server_charset_no,
+ const zend_bool use_full_blown_auth_packet,
const char * const auth_protocol,
+ struct st_mysqlnd_authentication_plugin * auth_plugin,
+ const zend_uchar * const orig_auth_plugin_data,
+ const size_t orig_auth_plugin_data_len,
const zend_uchar * const auth_plugin_data,
const size_t auth_plugin_data_len,
char ** switch_to_auth_protocol,
- size_t * switch_to_auth_protocol_len,
+ size_t * const switch_to_auth_protocol_len,
zend_uchar ** switch_to_auth_protocol_data,
- size_t * switch_to_auth_protocol_data_len
- );
-
-enum_func_status
-mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
- const char * const user,
- const char * const passwd,
- const size_t passwd_len,
- const char * const db,
- const size_t db_len,
- const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags,
- unsigned int server_charset_no,
- zend_bool use_full_blown_auth_packet,
- const char * const auth_protocol,
- const zend_uchar * const auth_plugin_data,
- const size_t auth_plugin_data_len,
- char ** switch_to_auth_protocol,
- size_t * switch_to_auth_protocol_len,
- zend_uchar ** switch_to_auth_protocol_data,
- size_t * switch_to_auth_protocol_data_len
+ size_t * const switch_to_auth_protocol_data_len
);
enum_func_status
@@ -68,36 +51,39 @@ mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn,
const char * const db,
const size_t db_len,
const zend_bool silent,
- zend_bool use_full_blown_auth_packet,
+ const zend_bool use_full_blown_auth_packet,
const char * const auth_protocol,
- zend_uchar * auth_plugin_data,
- size_t auth_plugin_data_len,
+ struct st_mysqlnd_authentication_plugin * auth_plugin,
+ const zend_uchar * const orig_auth_plugin_data,
+ const size_t orig_auth_plugin_data_len,
+ const zend_uchar * auth_plugin_data,
+ const size_t auth_plugin_data_len,
char ** switch_to_auth_protocol,
- size_t * switch_to_auth_protocol_len,
+ size_t * const switch_to_auth_protocol_len,
zend_uchar ** switch_to_auth_protocol_data,
- size_t * switch_to_auth_protocol_data_len
+ size_t * const switch_to_auth_protocol_data_len
);
enum_func_status
mysqlnd_connect_run_authentication(
- MYSQLND_CONN_DATA * conn,
+ MYSQLND_CONN_DATA * const conn,
const char * const user,
const char * const passwd,
const char * const db,
- size_t db_len,
- size_t passwd_len,
- MYSQLND_STRING authentication_plugin_data,
+ const size_t db_len,
+ const size_t passwd_len,
+ const MYSQLND_STRING authentication_plugin_data,
const char * const authentication_protocol,
const unsigned int charset_no,
- size_t server_capabilities,
+ const size_t server_capabilities,
const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags
+ const zend_ulong mysql_flags
);
enum_func_status
mysqlnd_run_authentication(
- MYSQLND_CONN_DATA * conn,
+ MYSQLND_CONN_DATA * const conn,
const char * const user,
const char * const passwd,
const size_t passwd_len,
@@ -105,22 +91,13 @@ mysqlnd_run_authentication(
const size_t db_len,
const MYSQLND_STRING auth_plugin_data,
const char * const auth_protocol,
- unsigned int charset_no,
+ const unsigned int charset_no,
const MYSQLND_SESSION_OPTIONS * const session_options,
- zend_ulong mysql_flags,
- zend_bool silent,
- zend_bool is_change_user
+ const zend_ulong mysql_flags,
+ const zend_bool silent,
+ const zend_bool is_change_user
);
PHPAPI void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass, const size_t pass_len);
#endif /* MYSQLND_AUTH_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c
index cba7530c8d..cb785238c7 100644
--- a/ext/mysqlnd/mysqlnd_block_alloc.c
+++ b/ext/mysqlnd/mysqlnd_block_alloc.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,83 +24,13 @@
#include "mysqlnd_debug.h"
#include "mysqlnd_priv.h"
-
-/* {{{ mysqlnd_arena_create */
-static zend_always_inline zend_arena* mysqlnd_arena_create(size_t size)
-{
- zend_arena *arena = (zend_arena*)mnd_emalloc(size);
-
- arena->ptr = (char*) arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
- arena->end = (char*) arena + size;
- arena->prev = NULL;
- return arena;
-}
-/* }}} */
-
-/* {{{ mysqlnd_arena_destroy */
-static zend_always_inline void mysqlnd_arena_destroy(zend_arena *arena)
-{
- do {
- zend_arena *prev = arena->prev;
- mnd_efree(arena);
- arena = prev;
- } while (arena);
-}
-/* }}} */
-
-/* {{{ mysqlnd_arena_alloc */
-static zend_always_inline void* mysqlnd_arena_alloc(zend_arena **arena_ptr, size_t size)
-{
- zend_arena *arena = *arena_ptr;
- char *ptr = arena->ptr;
-
- size = ZEND_MM_ALIGNED_SIZE(size);
-
- if (EXPECTED(size <= (size_t)(arena->end - ptr))) {
- arena->ptr = ptr + size;
- } else {
- size_t arena_size =
- UNEXPECTED((size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) > (size_t)(arena->end - (char*) arena)) ?
- (size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) :
- (size_t)(arena->end - (char*) arena);
- zend_arena *new_arena = (zend_arena*)mnd_emalloc(arena_size);
-
- ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
- new_arena->ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena)) + size;
- new_arena->end = (char*) new_arena + arena_size;
- new_arena->prev = arena;
- *arena_ptr = new_arena;
- }
-
- return (void*) ptr;
-}
-/* }}} */
-
-static zend_always_inline void* mysqlnd_arena_checkpoint(zend_arena *arena)
-{
- return arena->ptr;
-}
-
-static zend_always_inline void mysqlnd_arena_release(zend_arena **arena_ptr, void *checkpoint)
-{
- zend_arena *arena = *arena_ptr;
-
- while (UNEXPECTED((char*)checkpoint > arena->end) ||
- UNEXPECTED((char*)checkpoint <= (char*)arena)) {
- zend_arena *prev = arena->prev;
- mnd_efree(arena);
- *arena_ptr = arena = prev;
- }
- ZEND_ASSERT((char*)checkpoint > (char*)arena && (char*)checkpoint <= arena->end);
- arena->ptr = (char*)checkpoint;
-}
-
/* {{{ mysqlnd_mempool_free_chunk */
static void
mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL * pool, void * ptr)
{
DBG_ENTER("mysqlnd_mempool_free_chunk");
/* Try to back-off and guess if this is the last block allocated */
+#ifndef ZEND_TRACK_ARENA_ALLOC
if (ptr == pool->last) {
/*
This was the last allocation. Lucky us, we can free
@@ -109,6 +39,7 @@ mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL * pool, void * ptr)
pool->arena->ptr = (char*)ptr;
pool->last = NULL;
}
+#endif
DBG_VOID_RETURN;
}
/* }}} */
@@ -120,6 +51,7 @@ mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL * pool, void * ptr, size_t old_
{
DBG_ENTER("mysqlnd_mempool_resize_chunk");
+#ifndef ZEND_TRACK_ARENA_ALLOC
/* Try to back-off and guess if this is the last block allocated */
if (ptr == pool->last
&& (ZEND_MM_ALIGNED_SIZE(size) <= ((char*)pool->arena->end - (char*)ptr))) {
@@ -128,11 +60,13 @@ mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL * pool, void * ptr, size_t old_
a bit of memory from the pool. Next time we will return from the same ptr.
*/
pool->arena->ptr = (char*)ptr + ZEND_MM_ALIGNED_SIZE(size);
- } else {
- void *new_ptr = mysqlnd_arena_alloc(&pool->arena, size);
- memcpy(new_ptr, ptr, MIN(old_size, size));
- pool->last = ptr = new_ptr;
+ DBG_RETURN(ptr);
}
+#endif
+
+ void *new_ptr = zend_arena_alloc(&pool->arena, size);
+ memcpy(new_ptr, ptr, MIN(old_size, size));
+ pool->last = ptr = new_ptr;
DBG_RETURN(ptr);
}
/* }}} */
@@ -145,7 +79,7 @@ mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool, size_t size)
void *ptr = NULL;
DBG_ENTER("mysqlnd_mempool_get_chunk");
- ptr = mysqlnd_arena_alloc(&pool->arena, size);
+ ptr = zend_arena_alloc(&pool->arena, size);
pool->last = ptr;
DBG_RETURN(ptr);
@@ -161,8 +95,8 @@ mysqlnd_mempool_create(size_t arena_size)
MYSQLND_MEMORY_POOL * ret;
DBG_ENTER("mysqlnd_mempool_create");
- arena = mysqlnd_arena_create(MAX(arena_size, ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))));
- ret = mysqlnd_arena_alloc(&arena, sizeof(MYSQLND_MEMORY_POOL));
+ arena = zend_arena_create(MAX(arena_size, ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))));
+ ret = zend_arena_alloc(&arena, sizeof(MYSQLND_MEMORY_POOL));
ret->arena = arena;
ret->last = NULL;
ret->checkpoint = NULL;
@@ -180,7 +114,7 @@ mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool)
{
DBG_ENTER("mysqlnd_mempool_destroy");
/* mnd_free will reference LOCK_access and might crash, depending on the caller...*/
- mysqlnd_arena_destroy(pool->arena);
+ zend_arena_destroy(pool->arena);
DBG_VOID_RETURN;
}
/* }}} */
@@ -190,7 +124,7 @@ PHPAPI void
mysqlnd_mempool_save_state(MYSQLND_MEMORY_POOL * pool)
{
DBG_ENTER("mysqlnd_mempool_save_state");
- pool->checkpoint = mysqlnd_arena_checkpoint(pool->arena);
+ pool->checkpoint = zend_arena_checkpoint(pool->arena);
DBG_VOID_RETURN;
}
/* }}} */
@@ -204,19 +138,10 @@ mysqlnd_mempool_restore_state(MYSQLND_MEMORY_POOL * pool)
ZEND_ASSERT(pool->checkpoint);
#endif
if (pool->checkpoint) {
- mysqlnd_arena_release(&pool->arena, pool->checkpoint);
+ zend_arena_release(&pool->arena, pool->checkpoint);
pool->last = NULL;
pool->checkpoint = NULL;
}
DBG_VOID_RETURN;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_block_alloc.h b/ext/mysqlnd/mysqlnd_block_alloc.h
index f3adde5af0..1adf8997c0 100644
--- a/ext/mysqlnd/mysqlnd_block_alloc.h
+++ b/ext/mysqlnd/mysqlnd_block_alloc.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -26,13 +26,3 @@ PHPAPI void mysqlnd_mempool_save_state(MYSQLND_MEMORY_POOL * pool);
PHPAPI void mysqlnd_mempool_restore_state(MYSQLND_MEMORY_POOL * pool);
#endif /* MYSQLND_BLOCK_ALLOC_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c
index 04dcd82295..729cdcd11f 100644
--- a/ext/mysqlnd/mysqlnd_charset.c
+++ b/ext/mysqlnd/mysqlnd_charset.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -25,7 +25,7 @@
#include "mysqlnd_charset.h"
/* {{{ utf8 functions */
-static unsigned int check_mb_utf8mb3_sequence(const char *start, const char *end)
+static unsigned int check_mb_utf8mb3_sequence(const char * const start, const char * const end)
{
zend_uchar c;
@@ -64,7 +64,7 @@ static unsigned int check_mb_utf8mb3_sequence(const char *start, const char *end
}
-static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
+static unsigned int check_mb_utf8_sequence(const char * const start, const char * const end)
{
zend_uchar c;
@@ -136,20 +136,20 @@ static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
return 0;
}
-static unsigned int check_mb_utf8mb3_valid(const char *start, const char *end)
+static unsigned int check_mb_utf8mb3_valid(const char * const start, const char * const end)
{
unsigned int len = check_mb_utf8mb3_sequence(start, end);
return (len > 1)? len:0;
}
-static unsigned int check_mb_utf8_valid(const char *start, const char *end)
+static unsigned int check_mb_utf8_valid(const char * const start, const char * const end)
{
unsigned int len = check_mb_utf8_sequence(start, end);
return (len > 1)? len:0;
}
-static unsigned int mysqlnd_mbcharlen_utf8mb3(unsigned int utf8)
+static unsigned int mysqlnd_mbcharlen_utf8mb3(const unsigned int utf8)
{
if (utf8 < 0x80) {
return 1; /* single byte character */
@@ -167,7 +167,7 @@ static unsigned int mysqlnd_mbcharlen_utf8mb3(unsigned int utf8)
}
-static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
+static unsigned int mysqlnd_mbcharlen_utf8(const unsigned int utf8)
{
if (utf8 < 0x80) {
return 1; /* single byte character */
@@ -196,13 +196,13 @@ static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
#define isbig5code(c,d) (isbig5head(c) && isbig5tail(d))
-static unsigned int check_mb_big5(const char *start, const char *end)
+static unsigned int check_mb_big5(const char * const start, const char * const end)
{
return (valid_big5head(*(start)) && (end - start) > 1 && valid_big5tail(*(start + 1)) ? 2 : 0);
}
-static unsigned int mysqlnd_mbcharlen_big5(unsigned int big5)
+static unsigned int mysqlnd_mbcharlen_big5(const unsigned int big5)
{
return (valid_big5head(big5)) ? 2 : 1;
}
@@ -214,14 +214,14 @@ static unsigned int mysqlnd_mbcharlen_big5(unsigned int big5)
#define valid_cp932tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && c <= 0xFC))
-static unsigned int check_mb_cp932(const char *start, const char *end)
+static unsigned int check_mb_cp932(const char * const start, const char * const end)
{
return (valid_cp932head((zend_uchar)start[0]) && (end - start > 1) &&
valid_cp932tail((zend_uchar)start[1])) ? 2 : 0;
}
-static unsigned int mysqlnd_mbcharlen_cp932(unsigned int cp932)
+static unsigned int mysqlnd_mbcharlen_cp932(const unsigned int cp932)
{
return (valid_cp932head((zend_uchar)cp932)) ? 2 : 1;
}
@@ -231,7 +231,7 @@ static unsigned int mysqlnd_mbcharlen_cp932(unsigned int cp932)
/* {{{ euckr functions */
#define valid_euckr(c) ((0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE))
-static unsigned int check_mb_euckr(const char *start, const char *end)
+static unsigned int check_mb_euckr(const char * const start, const char * const end)
{
if (end - start <= 1) {
return 0; /* invalid length */
@@ -246,7 +246,7 @@ static unsigned int check_mb_euckr(const char *start, const char *end)
}
-static unsigned int mysqlnd_mbcharlen_euckr(unsigned int kr)
+static unsigned int mysqlnd_mbcharlen_euckr(const unsigned int kr)
{
return (valid_euckr(kr)) ? 2 : 1;
}
@@ -259,7 +259,7 @@ static unsigned int mysqlnd_mbcharlen_euckr(unsigned int kr)
#define valid_eucjpms_ss2(c) (((c) & 0xFF) == 0x8E)
#define valid_eucjpms_ss3(c) (((c) & 0xFF) == 0x8F)
-static unsigned int check_mb_eucjpms(const char *start, const char *end)
+static unsigned int check_mb_eucjpms(const char * const start, const char * const end)
{
if (*((zend_uchar *)start) < 0x80) {
return 0; /* invalid eucjpms character */
@@ -278,7 +278,7 @@ static unsigned int check_mb_eucjpms(const char *start, const char *end)
}
-static unsigned int mysqlnd_mbcharlen_eucjpms(unsigned int jpms)
+static unsigned int mysqlnd_mbcharlen_eucjpms(const unsigned int jpms)
{
if (valid_eucjpms(jpms) || valid_eucjpms_ss2(jpms)) {
return 2;
@@ -296,14 +296,14 @@ static unsigned int mysqlnd_mbcharlen_eucjpms(unsigned int jpms)
#define valid_gb2312_tail(c) (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE)
-static unsigned int check_mb_gb2312(const char *start, const char *end)
+static unsigned int check_mb_gb2312(const char * const start, const char * const end)
{
return (valid_gb2312_head((unsigned int)start[0]) && end - start > 1 &&
valid_gb2312_tail((unsigned int)start[1])) ? 2 : 0;
}
-static unsigned int mysqlnd_mbcharlen_gb2312(unsigned int gb)
+static unsigned int mysqlnd_mbcharlen_gb2312(const unsigned int gb)
{
return (valid_gb2312_head(gb)) ? 2 : 1;
}
@@ -314,12 +314,12 @@ static unsigned int mysqlnd_mbcharlen_gb2312(unsigned int gb)
#define valid_gbk_head(c) (0x81<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE)
#define valid_gbk_tail(c) ((0x40<=(zend_uchar)(c) && (zend_uchar)(c)<=0x7E) || (0x80<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE))
-static unsigned int check_mb_gbk(const char *start, const char *end)
+static unsigned int check_mb_gbk(const char * const start, const char * const end)
{
return (valid_gbk_head(start[0]) && (end) - (start) > 1 && valid_gbk_tail(start[1])) ? 2 : 0;
}
-static unsigned int mysqlnd_mbcharlen_gbk(unsigned int gbk)
+static unsigned int mysqlnd_mbcharlen_gbk(const unsigned int gbk)
{
return (valid_gbk_head(gbk) ? 2 : 1);
}
@@ -331,13 +331,13 @@ static unsigned int mysqlnd_mbcharlen_gbk(unsigned int gbk)
#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && (c) <= 0xFC))
-static unsigned int check_mb_sjis(const char *start, const char *end)
+static unsigned int check_mb_sjis(const char * const start, const char * const end)
{
return (valid_sjis_head((zend_uchar)start[0]) && (end - start) > 1 && valid_sjis_tail((zend_uchar)start[1])) ? 2 : 0;
}
-static unsigned int mysqlnd_mbcharlen_sjis(unsigned int sjis)
+static unsigned int mysqlnd_mbcharlen_sjis(const unsigned int sjis)
{
return (valid_sjis_head((zend_uchar)sjis)) ? 2 : 1;
}
@@ -345,12 +345,12 @@ static unsigned int mysqlnd_mbcharlen_sjis(unsigned int sjis)
/* {{{ ucs2 functions */
-static unsigned int check_mb_ucs2(const char *start __attribute((unused)), const char *end __attribute((unused)))
+static unsigned int check_mb_ucs2(const char * const start __attribute((unused)), const char * const end __attribute((unused)))
{
return 2; /* always 2 */
}
-static unsigned int mysqlnd_mbcharlen_ucs2(unsigned int ucs2 __attribute((unused)))
+static unsigned int mysqlnd_mbcharlen_ucs2(const unsigned int ucs2 __attribute((unused)))
{
return 2; /* always 2 */
}
@@ -363,7 +363,7 @@ static unsigned int mysqlnd_mbcharlen_ucs2(unsigned int ucs2 __attribute((unused
#define valid_ujis_ss2(c) (((c)&0xFF) == 0x8E)
#define valid_ujis_ss3(c) (((c)&0xFF) == 0x8F)
-static unsigned int check_mb_ujis(const char *start, const char *end)
+static unsigned int check_mb_ujis(const char * const start, const char * const end)
{
if (*(zend_uchar*)start < 0x80) {
return 0; /* invalid ujis character */
@@ -381,7 +381,7 @@ static unsigned int check_mb_ujis(const char *start, const char *end)
}
-static unsigned int mysqlnd_mbcharlen_ujis(unsigned int ujis)
+static unsigned int mysqlnd_mbcharlen_ujis(const unsigned int ujis)
{
return (valid_ujis(ujis)? 2: valid_ujis_ss2(ujis)? 2: valid_ujis_ss3(ujis)? 3: 1);
}
@@ -393,7 +393,7 @@ static unsigned int mysqlnd_mbcharlen_ujis(unsigned int ujis)
#define UTF16_HIGH_HEAD(x) ((((zend_uchar) (x)) & 0xFC) == 0xD8)
#define UTF16_LOW_HEAD(x) ((((zend_uchar) (x)) & 0xFC) == 0xDC)
-static unsigned int check_mb_utf16(const char *start, const char *end)
+static unsigned int check_mb_utf16(const char * const start, const char * const end)
{
if (start + 2 > end) {
return 0;
@@ -410,7 +410,7 @@ static unsigned int check_mb_utf16(const char *start, const char *end)
}
-static uint32_t mysqlnd_mbcharlen_utf16(unsigned int utf16)
+static uint32_t mysqlnd_mbcharlen_utf16(const unsigned int utf16)
{
return UTF16_HIGH_HEAD(utf16) ? 4 : 2;
}
@@ -418,13 +418,13 @@ static uint32_t mysqlnd_mbcharlen_utf16(unsigned int utf16)
/* {{{ utf32 functions */
-static unsigned int check_mb_utf32(const char *start __attribute((unused)), const char *end __attribute((unused)))
+static unsigned int check_mb_utf32(const char * const start __attribute((unused)), const char * const end __attribute((unused)))
{
return 4;
}
-static unsigned int mysqlnd_mbcharlen_utf32(unsigned int utf32 __attribute((unused)))
+static unsigned int mysqlnd_mbcharlen_utf32(const unsigned int utf32 __attribute((unused)))
{
return 4;
}
@@ -437,7 +437,7 @@ static unsigned int mysqlnd_mbcharlen_utf32(unsigned int utf32 __attribute((unus
#define is_gb18030_even_4(c) (0x30 <= (zend_uchar) (c) && (zend_uchar) (c) <= 0x39)
-static unsigned int mysqlnd_mbcharlen_gb18030(unsigned int c)
+static unsigned int mysqlnd_mbcharlen_gb18030(const unsigned int c)
{
if (c <= 0xFF) {
return !is_gb18030_odd(c);
@@ -740,7 +740,7 @@ const MYSQLND_CHARSET mysqlnd_charsets[] =
/* {{{ mysqlnd_find_charset_nr */
-PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(unsigned int charsetnr)
+PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(const unsigned int charsetnr)
{
const MYSQLND_CHARSET * c = mysqlnd_charsets;
@@ -773,8 +773,8 @@ PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const name
/* {{{ mysqlnd_cset_escape_quotes */
-PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, char *newstr,
- const char * escapestr, size_t escapestr_len)
+PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, char * newstr,
+ const char * escapestr, const size_t escapestr_len)
{
const char *newstr_s = newstr;
const char *newstr_e = newstr + 2 * escapestr_len;
@@ -819,16 +819,16 @@ PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset,
*newstr = '\0';
if (escape_overflow) {
- DBG_RETURN((ulong)~0);
+ DBG_RETURN((zend_ulong)~0);
}
- DBG_RETURN((ulong)(newstr - newstr_s));
+ DBG_RETURN((zend_ulong)(newstr - newstr_s));
}
/* }}} */
/* {{{ mysqlnd_cset_escape_slashes */
PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
- const char * escapestr, size_t escapestr_len)
+ const char * escapestr, const size_t escapestr_len)
{
const char *newstr_s = newstr;
const char *newstr_e = newstr + 2 * escapestr_len;
@@ -899,9 +899,9 @@ PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset
*newstr = '\0';
if (escape_overflow) {
- DBG_RETURN((ulong)~0);
+ DBG_RETURN((zend_ulong)~0);
}
- DBG_RETURN((ulong)(newstr - newstr_s));
+ DBG_RETURN((zend_ulong)(newstr - newstr_s));
}
/* }}} */
@@ -939,13 +939,3 @@ mysqlnd_charsets_plugin_register(void)
mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_plugin_charsets_plugin);
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_charset.h b/ext/mysqlnd/mysqlnd_charset.h
index 9a6e07a066..a87891c67c 100644
--- a/ext/mysqlnd/mysqlnd_charset.h
+++ b/ext/mysqlnd/mysqlnd_charset.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -21,11 +21,11 @@
#ifndef MYSQLND_CHARSET_H
#define MYSQLND_CHARSET_H
-PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const charset, char *newstr,
- const char *escapestr, size_t escapestr_len);
+PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const charset, char * newstr,
+ const char * escapestr, const size_t escapestr_len);
-PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
- const char *escapestr, size_t escapestr_len);
+PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char * newstr,
+ const char * escapestr, const size_t escapestr_len);
struct st_mysqlnd_plugin_charsets
{
@@ -34,20 +34,11 @@ struct st_mysqlnd_plugin_charsets
{
const MYSQLND_CHARSET * (*const find_charset_by_nr)(unsigned int charsetnr);
const MYSQLND_CHARSET * (*const find_charset_by_name)(const char * const name);
- zend_ulong (*const escape_quotes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len);
- zend_ulong (*const escape_slashes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len);
+ zend_ulong (*const escape_quotes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, const size_t escapestr_len);
+ zend_ulong (*const escape_slashes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, const size_t escapestr_len);
} methods;
};
void mysqlnd_charsets_plugin_register(void);
#endif /* MYSQLND_CHARSET_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_commands.c b/ext/mysqlnd/mysqlnd_commands.c
index 21b95a8f57..76a67f8f8f 100644
--- a/ext/mysqlnd/mysqlnd_commands.c
+++ b/ext/mysqlnd/mysqlnd_commands.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -23,43 +23,19 @@
#include "mysqlnd_priv.h"
#include "mysqlnd_auth.h"
#include "mysqlnd_wireprotocol.h"
-#include "mysqlnd_statistics.h"
#include "mysqlnd_debug.h"
-struct st_mysqlnd_protocol_no_params_command
-{
- struct st_mysqlnd_protocol_no_params_command_context
- {
- MYSQLND_CONN_DATA * conn;
- } context;
-};
-
-
-/************************** COM_SET_OPTION ******************************************/
-struct st_mysqlnd_protocol_com_set_option_command
-{
- struct st_mysqlnd_com_set_option_context
- {
- MYSQLND_CONN_DATA * conn;
- enum_mysqlnd_server_option option;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_set_option_run */
+/* {{{ mysqlnd_command::set_option */
static enum_func_status
-mysqlnd_com_set_option_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, set_option)(MYSQLND_CONN_DATA * const conn, const enum_mysqlnd_server_option option)
{
- struct st_mysqlnd_protocol_com_set_option_command * command = (struct st_mysqlnd_protocol_com_set_option_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
zend_uchar buffer[2];
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- enum_mysqlnd_server_option option = command->context.option;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_set_option_run");
+ DBG_ENTER("mysqlnd_command::set_option");
int2store(buffer, (unsigned int) option);
ret = send_command(conn->payload_decoder_factory, COM_SET_OPTION, buffer, sizeof(buffer), FALSE,
@@ -78,36 +54,15 @@ mysqlnd_com_set_option_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_set_option_run_command */
-static enum_func_status
-mysqlnd_com_set_option_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_set_option_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_set_option_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.option = va_arg(args, enum_mysqlnd_server_option);
-
- ret = mysqlnd_com_set_option_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_DEBUG ******************************************/
-/* {{{ mysqlnd_com_debug_run */
+/* {{{ mysqlnd_command::debug */
static enum_func_status
-mysqlnd_com_debug_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, debug)(MYSQLND_CONN_DATA * const conn)
{
- struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_debug_run");
+ DBG_ENTER("mysqlnd_command::debug");
ret = send_command(conn->payload_decoder_factory, COM_DEBUG, NULL, 0, FALSE,
&conn->state,
@@ -126,48 +81,17 @@ mysqlnd_com_debug_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_debug_run_command */
+/* {{{ mysqlnd_command::init_db */
static enum_func_status
-mysqlnd_com_debug_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, init_db)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING db)
{
- struct st_mysqlnd_protocol_no_params_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_debug_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-
- ret = mysqlnd_com_debug_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_INIT_DB ******************************************/
-struct st_mysqlnd_protocol_com_init_db_command
-{
- struct st_mysqlnd_com_init_db_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING db;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_init_db_run */
-static enum_func_status
-mysqlnd_com_init_db_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_init_db_command * command = (struct st_mysqlnd_protocol_com_init_db_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- const MYSQLND_CSTRING db = command->context.db;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_init_db_run");
+ DBG_ENTER("mysqlnd_command::init_db");
- ret = send_command(conn->payload_decoder_factory, COM_INIT_DB, (zend_uchar*) command->context.db.s, command->context.db.l, FALSE,
+ ret = send_command(conn->payload_decoder_factory, COM_INIT_DB, (const zend_uchar*) db.s, db.l, FALSE,
&conn->state,
conn->error_info,
conn->upsert_status,
@@ -202,36 +126,15 @@ mysqlnd_com_init_db_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_init_db_run_command */
+/* {{{ mysqlnd_command::ping */
static enum_func_status
-mysqlnd_com_init_db_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, ping)(MYSQLND_CONN_DATA * const conn)
{
- struct st_mysqlnd_protocol_com_init_db_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_init_db_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.db = va_arg(args, MYSQLND_CSTRING);
-
- ret = mysqlnd_com_init_db_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_PING ******************************************/
-/* {{{ mysqlnd_com_ping_run */
-static enum_func_status
-mysqlnd_com_ping_run(void *cmd)
-{
- struct st_mysqlnd_protocol_no_params_command * command = (struct st_mysqlnd_protocol_no_params_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_ping_run");
+ DBG_ENTER("mysqlnd_command::ping");
ret = send_command(conn->payload_decoder_factory, COM_PING, NULL, 0, TRUE,
&conn->state,
@@ -255,45 +158,14 @@ mysqlnd_com_ping_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_ping_run_command */
-static enum_func_status
-mysqlnd_com_ping_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_no_params_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_ping_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-
- ret = mysqlnd_com_ping_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_STATISTICS ******************************************/
-struct st_mysqlnd_protocol_com_statistics_command
-{
- struct st_mysqlnd_com_statistics_context
- {
- MYSQLND_CONN_DATA * conn;
- zend_string ** message;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_statistics_run */
+/* {{{ mysqlnd_command::statistics */
static enum_func_status
-mysqlnd_com_statistics_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, statistics)(MYSQLND_CONN_DATA * const conn, zend_string ** message)
{
- struct st_mysqlnd_protocol_com_statistics_command * command = (struct st_mysqlnd_protocol_com_statistics_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- zend_string **message = command->context.message;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- DBG_ENTER("mysqlnd_com_statistics_run");
+ DBG_ENTER("mysqlnd_command::statistics");
ret = send_command(conn->payload_decoder_factory, COM_STATISTICS, NULL, 0, FALSE,
&conn->state,
@@ -320,49 +192,17 @@ mysqlnd_com_statistics_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_statistics_run_command */
+/* {{{ mysqlnd_command::process_kill */
static enum_func_status
-mysqlnd_com_statistics_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, process_kill)(MYSQLND_CONN_DATA * const conn, const unsigned int process_id, const zend_bool read_response)
{
- struct st_mysqlnd_protocol_com_statistics_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_statistics_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.message = va_arg(args, zend_string **);
-
- ret = mysqlnd_com_statistics_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-/************************** COM_PROCESS_KILL ******************************************/
-struct st_mysqlnd_protocol_com_process_kill_command
-{
- struct st_mysqlnd_com_process_kill_context
- {
- MYSQLND_CONN_DATA * conn;
- unsigned int process_id;
- zend_bool read_response;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_process_kill_run */
-enum_func_status
-mysqlnd_com_process_kill_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_process_kill_command * command = (struct st_mysqlnd_protocol_com_process_kill_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
zend_uchar buff[4];
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- zend_bool read_response = command->context.read_response;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_process_kill_run");
- int4store(buff, command->context.process_id);
+ DBG_ENTER("mysqlnd_command::process_kill");
+ int4store(buff, process_id);
ret = send_command(conn->payload_decoder_factory, COM_PROCESS_KILL, buff, 4, FALSE,
&conn->state,
@@ -392,48 +232,17 @@ mysqlnd_com_process_kill_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_process_kill_run_command */
+/* {{{ mysqlnd_command::refresh */
static enum_func_status
-mysqlnd_com_process_kill_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_process_kill_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_process_kill_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.process_id = va_arg(args, unsigned int);
- command.context.read_response = va_arg(args, unsigned int)? TRUE:FALSE;
-
- ret = mysqlnd_com_process_kill_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-/************************** COM_REFRESH ******************************************/
-struct st_mysqlnd_protocol_com_refresh_command
+MYSQLND_METHOD(mysqlnd_command, refresh)(MYSQLND_CONN_DATA * const conn, const uint8_t options)
{
- struct st_mysqlnd_com_refresh_context
- {
- MYSQLND_CONN_DATA * conn;
- uint8_t options;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_refresh_run */
-enum_func_status
-mysqlnd_com_refresh_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_refresh_command * command = (struct st_mysqlnd_protocol_com_refresh_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
zend_uchar bits[1];
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_refresh_run");
- int1store(bits, command->context.options);
+ DBG_ENTER("mysqlnd_command::refresh");
+ int1store(bits, options);
ret = send_command(conn->payload_decoder_factory, COM_REFRESH, bits, 1, FALSE,
&conn->state,
@@ -452,48 +261,17 @@ mysqlnd_com_refresh_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_refresh_run_command */
+/* {{{ mysqlnd_command::shutdown */
static enum_func_status
-mysqlnd_com_refresh_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, shutdown)(MYSQLND_CONN_DATA * const conn, const uint8_t level)
{
- struct st_mysqlnd_protocol_com_refresh_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_refresh_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.options = va_arg(args, unsigned int);
-
- ret = mysqlnd_com_refresh_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_SHUTDOWN ******************************************/
-struct st_mysqlnd_protocol_com_shutdown_command
-{
- struct st_mysqlnd_com_shutdown_context
- {
- MYSQLND_CONN_DATA * conn;
- uint8_t level;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_shutdown_run */
-enum_func_status
-mysqlnd_com_shutdown_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_shutdown_command * command = (struct st_mysqlnd_protocol_com_shutdown_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
zend_uchar bits[1];
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_shutdown_run");
- int1store(bits, command->context.level);
+ DBG_ENTER("mysqlnd_command::shutdown");
+ int1store(bits, level);
ret = send_command(conn->payload_decoder_factory, COM_SHUTDOWN, bits, 1, FALSE,
&conn->state,
@@ -512,44 +290,14 @@ mysqlnd_com_shutdown_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_shutdown_run_command */
+/* {{{ mysqlnd_command::quit */
static enum_func_status
-mysqlnd_com_shutdown_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, quit)(MYSQLND_CONN_DATA * const conn)
{
- struct st_mysqlnd_protocol_com_shutdown_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_shutdown_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.level = va_arg(args, unsigned int);
-
- ret = mysqlnd_com_shutdown_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_QUIT ******************************************/
-struct st_mysqlnd_protocol_com_quit_command
-{
- struct st_mysqlnd_com_quit_context
- {
- MYSQLND_CONN_DATA * conn;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_quit_run */
-enum_func_status
-mysqlnd_com_quit_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_quit_command * command = (struct st_mysqlnd_protocol_com_quit_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- DBG_ENTER("mysqlnd_com_quit_run");
+ DBG_ENTER("mysqlnd_command::quit");
ret = send_command(conn->payload_decoder_factory, COM_QUIT, NULL, 0, TRUE,
&conn->state,
@@ -564,45 +312,16 @@ mysqlnd_com_quit_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_quit_run_command */
+/* {{{ mysqlnd_command::query */
static enum_func_status
-mysqlnd_com_quit_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, query)(MYSQLND_CONN_DATA * const conn, MYSQLND_CSTRING query)
{
- struct st_mysqlnd_protocol_com_quit_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_quit_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-
- ret = mysqlnd_com_quit_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-/************************** COM_QUERY ******************************************/
-struct st_mysqlnd_protocol_com_query_command
-{
- struct st_mysqlnd_com_query_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING query;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_query_run */
-static enum_func_status
-mysqlnd_com_query_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_query_command * command = (struct st_mysqlnd_protocol_com_query_command *) cmd;
- enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ enum_func_status ret = FAIL;
- DBG_ENTER("mysqlnd_com_query_run");
+ DBG_ENTER("mysqlnd_command::query");
- ret = send_command(conn->payload_decoder_factory, COM_QUERY, (zend_uchar*) command->context.query.s, command->context.query.l, FALSE,
+ ret = send_command(conn->payload_decoder_factory, COM_QUERY, (const zend_uchar*) query.s, query.l, FALSE,
&conn->state,
conn->error_info,
conn->upsert_status,
@@ -619,47 +338,16 @@ mysqlnd_com_query_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_query_run_command */
-static enum_func_status
-mysqlnd_com_query_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_query_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_query_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.query = va_arg(args, MYSQLND_CSTRING);
-
- ret = mysqlnd_com_query_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-/************************** COM_CHANGE_USER ******************************************/
-struct st_mysqlnd_protocol_com_change_user_command
-{
- struct st_mysqlnd_com_change_user_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING payload;
- zend_bool silent;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_change_user_run */
+/* {{{ mysqlnd_command::change_user */
static enum_func_status
-mysqlnd_com_change_user_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, change_user)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload, const zend_bool silent)
{
- struct st_mysqlnd_protocol_com_change_user_command * command = (struct st_mysqlnd_protocol_com_change_user_command *) cmd;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- DBG_ENTER("mysqlnd_com_change_user_run");
+ DBG_ENTER("mysqlnd_command::change_user");
- ret = send_command(conn->payload_decoder_factory, COM_CHANGE_USER, (zend_uchar*) command->context.payload.s, command->context.payload.l, command->context.silent,
+ ret = send_command(conn->payload_decoder_factory, COM_CHANGE_USER, (const zend_uchar*) payload.s, payload.l, silent,
&conn->state,
conn->error_info,
conn->upsert_status,
@@ -672,45 +360,14 @@ mysqlnd_com_change_user_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_change_user_run_command */
+/* {{{ mysqlnd_command::reap_result */
static enum_func_status
-mysqlnd_com_change_user_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, reap_result)(MYSQLND_CONN_DATA * const conn)
{
- struct st_mysqlnd_protocol_com_change_user_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_change_user_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.payload = va_arg(args, MYSQLND_CSTRING);
- command.context.silent = va_arg(args, unsigned int);
-
- ret = mysqlnd_com_change_user_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_REAP_RESULT ******************************************/
-struct st_mysqlnd_protocol_com_reap_result_command
-{
- struct st_mysqlnd_com_reap_result_context
- {
- MYSQLND_CONN_DATA * conn;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_reap_result_run */
-static enum_func_status
-mysqlnd_com_reap_result_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_reap_result_command * command = (struct st_mysqlnd_protocol_com_reap_result_command *) cmd;
- enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
const enum_mysqlnd_connection_state state = GET_CONNECTION_STATE(&conn->state);
+ enum_func_status ret = FAIL;
- DBG_ENTER("mysqlnd_com_reap_result_run");
+ DBG_ENTER("mysqlnd_command::reap_result");
if (state <= CONN_READY || state == CONN_QUIT_SENT) {
php_error_docref(NULL, E_WARNING, "Connection not opened, clear or has been closed");
DBG_ERR_FMT("Connection not opened, clear or has been closed. State=%u", state);
@@ -723,46 +380,16 @@ mysqlnd_com_reap_result_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_reap_result_run_command */
-static enum_func_status
-mysqlnd_com_reap_result_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_reap_result_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_reap_result_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
-
- ret = mysqlnd_com_reap_result_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_STMT_PREPARE ******************************************/
-struct st_mysqlnd_protocol_com_stmt_prepare_command
-{
- struct st_mysqlnd_com_stmt_prepare_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING query;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_prepare_run */
+/* {{{ mysqlnd_command::stmt_prepare */
static enum_func_status
-mysqlnd_com_stmt_prepare_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, stmt_prepare)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING query)
{
- struct st_mysqlnd_protocol_com_stmt_prepare_command * command = (struct st_mysqlnd_protocol_com_stmt_prepare_command *) cmd;
- enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ enum_func_status ret = FAIL;
- DBG_ENTER("mysqlnd_com_stmt_prepare_run");
+ DBG_ENTER("mysqlnd_command::stmt_prepare");
- ret = send_command(conn->payload_decoder_factory, COM_STMT_PREPARE, (zend_uchar*) command->context.query.s, command->context.query.l, FALSE,
+ ret = send_command(conn->payload_decoder_factory, COM_STMT_PREPARE, (const zend_uchar*) query.s, query.l, FALSE,
&conn->state,
conn->error_info,
conn->upsert_status,
@@ -775,47 +402,17 @@ mysqlnd_com_stmt_prepare_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_stmt_prepare_run_command */
+/* {{{ mysqlnd_command::stmt_execute */
static enum_func_status
-mysqlnd_com_stmt_prepare_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, stmt_execute)(MYSQLND_CONN_DATA * conn, const MYSQLND_CSTRING payload)
{
- struct st_mysqlnd_protocol_com_stmt_prepare_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_stmt_prepare_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.query = va_arg(args, MYSQLND_CSTRING);
-
- ret = mysqlnd_com_stmt_prepare_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_STMT_EXECUTE ******************************************/
-struct st_mysqlnd_protocol_com_stmt_execute_command
-{
- struct st_mysqlnd_com_stmt_execute_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING payload;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_execute_run */
-static enum_func_status
-mysqlnd_com_stmt_execute_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_stmt_execute_command * command = (struct st_mysqlnd_protocol_com_stmt_execute_command *) cmd;
- enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ enum_func_status ret = FAIL;
- DBG_ENTER("mysqlnd_com_stmt_execute_run");
+ DBG_ENTER("mysqlnd_command::stmt_execute");
- ret = send_command(conn->payload_decoder_factory, COM_STMT_EXECUTE, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE,
+ ret = send_command(conn->payload_decoder_factory, COM_STMT_EXECUTE,
+ (const unsigned char *) payload.s, payload.l, FALSE,
&conn->state,
conn->error_info,
conn->upsert_status,
@@ -828,47 +425,16 @@ mysqlnd_com_stmt_execute_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_stmt_execute_run_command */
+/* {{{ mysqlnd_command::stmt_fetch */
static enum_func_status
-mysqlnd_com_stmt_execute_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, stmt_fetch)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload)
{
- struct st_mysqlnd_protocol_com_stmt_execute_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_stmt_execute_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.payload = va_arg(args, MYSQLND_CSTRING);
-
- ret = mysqlnd_com_stmt_execute_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_STMT_FETCH ******************************************/
-struct st_mysqlnd_protocol_com_stmt_fetch_command
-{
- struct st_mysqlnd_com_stmt_fetch_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING payload;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_fetch_run */
-static enum_func_status
-mysqlnd_com_stmt_fetch_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_stmt_fetch_command * command = (struct st_mysqlnd_protocol_com_stmt_fetch_command *) cmd;
- enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ enum_func_status ret = FAIL;
- DBG_ENTER("mysqlnd_com_stmt_fetch_run");
+ DBG_ENTER("mysqlnd_command::stmt_fetch");
- ret = send_command(conn->payload_decoder_factory, COM_STMT_FETCH, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE,
+ ret = send_command(conn->payload_decoder_factory, COM_STMT_FETCH, (const zend_uchar*) payload.s, payload.l, FALSE,
&conn->state,
conn->error_info,
conn->upsert_status,
@@ -881,49 +447,18 @@ mysqlnd_com_stmt_fetch_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_stmt_fetch_run_command */
-static enum_func_status
-mysqlnd_com_stmt_fetch_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_stmt_fetch_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_stmt_fetch_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.payload = va_arg(args, MYSQLND_CSTRING);
-
- ret = mysqlnd_com_stmt_fetch_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_STMT_RESET ******************************************/
-struct st_mysqlnd_protocol_com_stmt_reset_command
-{
- struct st_mysqlnd_com_stmt_reset_context
- {
- MYSQLND_CONN_DATA * conn;
- zend_ulong stmt_id;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_reset_run */
+/* {{{ mysqlnd_command::stmt_reset */
static enum_func_status
-mysqlnd_com_stmt_reset_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, stmt_reset)(MYSQLND_CONN_DATA * const conn, const zend_ulong stmt_id)
{
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
zend_uchar cmd_buf[MYSQLND_STMT_ID_LENGTH /* statement id */];
- struct st_mysqlnd_protocol_com_stmt_reset_command * command = (struct st_mysqlnd_protocol_com_stmt_reset_command *) cmd;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
- DBG_ENTER("mysqlnd_com_stmt_reset_run");
+ DBG_ENTER("mysqlnd_command::stmt_reset");
- int4store(cmd_buf, command->context.stmt_id);
+ int4store(cmd_buf, stmt_id);
ret = send_command(conn->payload_decoder_factory, COM_STMT_RESET, cmd_buf, sizeof(cmd_buf), FALSE,
&conn->state,
conn->error_info,
@@ -941,101 +476,39 @@ mysqlnd_com_stmt_reset_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_stmt_reset_run_command */
+/* {{{ mysqlnd_command::stmt_send_long_data */
static enum_func_status
-mysqlnd_com_stmt_reset_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, stmt_send_long_data)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload)
{
- struct st_mysqlnd_protocol_com_stmt_reset_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_stmt_reset_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.stmt_id = va_arg(args, size_t);
-
- ret = mysqlnd_com_stmt_reset_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/************************** COM_STMT_SEND_LONG_DATA ******************************************/
-struct st_mysqlnd_protocol_com_stmt_send_long_data_command
-{
- struct st_mysqlnd_com_stmt_send_long_data_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING payload;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_send_long_data_run */
-static enum_func_status
-mysqlnd_com_stmt_send_long_data_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_stmt_send_long_data_command * command = (struct st_mysqlnd_protocol_com_stmt_send_long_data_command *) cmd;
- enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
+ enum_func_status ret = FAIL;
- DBG_ENTER("mysqlnd_com_stmt_send_long_data_run");
+ DBG_ENTER("mysqlnd_command::stmt_send_long_data");
- ret = send_command(conn->payload_decoder_factory, COM_STMT_SEND_LONG_DATA, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE,
+ ret = send_command(conn->payload_decoder_factory, COM_STMT_SEND_LONG_DATA, (const zend_uchar*) payload.s, payload.l, FALSE,
&conn->state,
conn->error_info,
conn->upsert_status,
conn->stats,
conn->m->send_close,
conn);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_com_stmt_send_long_data_run_command */
-static enum_func_status
-mysqlnd_com_stmt_send_long_data_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_stmt_send_long_data_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_stmt_send_long_data_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.payload = va_arg(args, MYSQLND_CSTRING);
-
- ret = mysqlnd_com_stmt_send_long_data_run(&command);
-
+ /* COM_STMT_SEND_LONG_DATA - doesn't read result, the server doesn't send ACK */
DBG_RETURN(ret);
}
/* }}} */
-/************************** COM_STMT_CLOSE ******************************************/
-struct st_mysqlnd_protocol_com_stmt_close_command
-{
- struct st_mysqlnd_com_stmt_close_context
- {
- MYSQLND_CONN_DATA * conn;
- zend_ulong stmt_id;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_stmt_close_run */
+/* {{{ mysqlnd_command::stmt_close */
static enum_func_status
-mysqlnd_com_stmt_close_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, stmt_close)(MYSQLND_CONN_DATA * const conn, const zend_ulong stmt_id)
{
+ func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
zend_uchar cmd_buf[MYSQLND_STMT_ID_LENGTH /* statement id */];
- struct st_mysqlnd_protocol_com_stmt_close_command * command = (struct st_mysqlnd_protocol_com_stmt_close_command *) cmd;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
- func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
- DBG_ENTER("mysqlnd_com_stmt_close_run");
+ DBG_ENTER("mysqlnd_command::stmt_close");
- int4store(cmd_buf, command->context.stmt_id);
+ int4store(cmd_buf, stmt_id);
ret = send_command(conn->payload_decoder_factory, COM_STMT_CLOSE, cmd_buf, sizeof(cmd_buf), FALSE,
&conn->state,
conn->error_info,
@@ -1049,50 +522,15 @@ mysqlnd_com_stmt_close_run(void *cmd)
/* }}} */
-/* {{{ mysqlnd_com_stmt_close_run_command */
-static enum_func_status
-mysqlnd_com_stmt_close_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_stmt_close_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_stmt_close_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.stmt_id = va_arg(args, size_t);
-
- ret = mysqlnd_com_stmt_close_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-
-/************************** COM_ENABLE_SSL ******************************************/
-struct st_mysqlnd_protocol_com_enable_ssl_command
-{
- struct st_mysqlnd_com_enable_ssl_context
- {
- MYSQLND_CONN_DATA * conn;
- size_t client_capabilities;
- size_t server_capabilities;
- unsigned int charset_no;
- } context;
-};
-
-
-/* {{{ mysqlnd_com_enable_ssl_run */
+/* {{{ mysqlnd_command::enable_ssl */
static enum_func_status
-mysqlnd_com_enable_ssl_run(void *cmd)
+MYSQLND_METHOD(mysqlnd_command, enable_ssl)(MYSQLND_CONN_DATA * const conn, const size_t client_capabilities, const size_t server_capabilities, const unsigned int charset_no)
{
- struct st_mysqlnd_protocol_com_enable_ssl_command * command = (struct st_mysqlnd_protocol_com_enable_ssl_command *) cmd;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn = command->context.conn;
MYSQLND_PACKET_AUTH auth_packet;
- size_t client_capabilities = command->context.client_capabilities;
- size_t server_capabilities = command->context.server_capabilities;
- DBG_ENTER("mysqlnd_com_enable_ssl_run");
+ DBG_ENTER("mysqlnd_command::enable_ssl");
+
DBG_INF_FMT("client_capability_flags=%lu", client_capabilities);
DBG_INF_FMT("CLIENT_LONG_PASSWORD= %d", client_capabilities & CLIENT_LONG_PASSWORD? 1:0);
DBG_INF_FMT("CLIENT_FOUND_ROWS= %d", client_capabilities & CLIENT_FOUND_ROWS? 1:0);
@@ -1123,7 +561,7 @@ mysqlnd_com_enable_ssl_run(void *cmd)
auth_packet.client_flags = client_capabilities;
auth_packet.max_packet_size = MYSQLND_ASSEMBLED_PACKET_MAX_SIZE;
- auth_packet.charset_no = command->context.charset_no;
+ auth_packet.charset_no = charset_no;
#ifdef MYSQLND_SSL_SUPPORTED
if (client_capabilities & CLIENT_SSL) {
@@ -1169,58 +607,24 @@ close_conn:
/* }}} */
-/* {{{ mysqlnd_com_enable_ssl_run_command */
+/* {{{ mysqlnd_command::handshake */
static enum_func_status
-mysqlnd_com_enable_ssl_run_command(va_list args)
+MYSQLND_METHOD(mysqlnd_command, handshake)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING username, const MYSQLND_CSTRING password, const MYSQLND_CSTRING database, const size_t client_flags)
{
- struct st_mysqlnd_protocol_com_enable_ssl_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_enable_ssl_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.client_capabilities = va_arg(args, size_t);
- command.context.server_capabilities = va_arg(args, size_t);
- command.context.charset_no = va_arg(args, unsigned int);
-
- ret = mysqlnd_com_enable_ssl_run(&command);
+ const char * const user = username.s;
- DBG_RETURN(ret);
-}
-/* }}} */
+ const char * const passwd = password.s;
+ const size_t passwd_len = password.l;
-/************************** COM_READ_HANDSHAKE ******************************************/
-struct st_mysqlnd_protocol_com_handshake_command
-{
- struct st_mysqlnd_com_handshake_context
- {
- MYSQLND_CONN_DATA * conn;
- MYSQLND_CSTRING user;
- MYSQLND_CSTRING passwd;
- MYSQLND_CSTRING database;
- size_t client_flags;
- } context;
-};
+ const char * const db = database.s;
+ const size_t db_len = database.l;
+ const size_t mysql_flags = client_flags;
-/* {{{ mysqlnd_com_handshake_run */
-static enum_func_status
-mysqlnd_com_handshake_run(void *cmd)
-{
- struct st_mysqlnd_protocol_com_handshake_command * command = (struct st_mysqlnd_protocol_com_handshake_command *) cmd;
- const char * user = command->context.user.s;
-
- const char * passwd = command->context.passwd.s;
- size_t passwd_len = command->context.passwd.l;
-
- const char * db = command->context.database.s;
- size_t db_len = command->context.database.l;
-
- size_t mysql_flags = command->context.client_flags;
-
- MYSQLND_CONN_DATA * conn = command->context.conn;
MYSQLND_PACKET_GREET greet_packet;
- DBG_ENTER("mysqlnd_conn_data::connect_handshake");
+ DBG_ENTER("mysqlnd_command::handshake");
+
DBG_INF_FMT("stream=%p", conn->vio->data->m.get_stream(conn->vio));
DBG_INF_FMT("[user=%s] [db=%s:%d] [flags=%llu]", user, db, db_len, mysql_flags);
@@ -1279,113 +683,25 @@ err:
/* }}} */
-/* {{{ mysqlnd_com_handshake_run_command */
-static enum_func_status
-mysqlnd_com_handshake_run_command(va_list args)
-{
- struct st_mysqlnd_protocol_com_handshake_command command;
- enum_func_status ret;
-
- DBG_ENTER("mysqlnd_com_handshake_run_command");
- command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
- command.context.user = *va_arg(args, const MYSQLND_CSTRING *);
- command.context.passwd = *va_arg(args, const MYSQLND_CSTRING *);
- command.context.database = *va_arg(args, const MYSQLND_CSTRING *);
- command.context.client_flags = va_arg(args, size_t);
-
- ret = mysqlnd_com_handshake_run(&command);
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-
-/* {{{ _mysqlnd_run_command */
-static enum_func_status
-_mysqlnd_run_command(enum php_mysqlnd_server_command command, ...)
-{
- enum_func_status ret = FAIL;
- va_list args;
- DBG_ENTER("_mysqlnd_run_command");
-
- va_start(args, command);
- switch (command) {
- case COM_SET_OPTION:
- ret = mysqlnd_com_set_option_run_command(args);
- break;
- case COM_DEBUG:
- ret = mysqlnd_com_debug_run_command(args);
- break;
- case COM_INIT_DB:
- ret = mysqlnd_com_init_db_run_command(args);
- break;
- case COM_PING:
- ret = mysqlnd_com_ping_run_command(args);
- break;
- case COM_STATISTICS:
- ret = mysqlnd_com_statistics_run_command(args);
- break;
- case COM_PROCESS_KILL:
- ret = mysqlnd_com_process_kill_run_command(args);
- break;
- case COM_REFRESH:
- ret = mysqlnd_com_refresh_run_command(args);
- break;
- case COM_SHUTDOWN:
- ret = mysqlnd_com_shutdown_run_command(args);
- break;
- case COM_QUIT:
- ret = mysqlnd_com_quit_run_command(args);
- break;
- case COM_QUERY:
- ret = mysqlnd_com_query_run_command(args);
- break;
- case COM_REAP_RESULT:
- ret = mysqlnd_com_reap_result_run_command(args);
- break;
- case COM_CHANGE_USER:
- ret = mysqlnd_com_change_user_run_command(args);
- break;
- case COM_STMT_PREPARE:
- ret = mysqlnd_com_stmt_prepare_run_command(args);
- break;
- case COM_STMT_EXECUTE:
- ret = mysqlnd_com_stmt_execute_run_command(args);
- break;
- case COM_STMT_FETCH:
- ret = mysqlnd_com_stmt_fetch_run_command(args);
- break;
- case COM_STMT_RESET:
- ret = mysqlnd_com_stmt_reset_run_command(args);
- break;
- case COM_STMT_SEND_LONG_DATA:
- ret = mysqlnd_com_stmt_send_long_data_run_command(args);
- break;
- case COM_STMT_CLOSE:
- ret = mysqlnd_com_stmt_close_run_command(args);
- break;
- case COM_ENABLE_SSL:
- ret = mysqlnd_com_enable_ssl_run_command(args);
- break;
- case COM_HANDSHAKE:
- ret = mysqlnd_com_handshake_run_command(args);
- break;
- default:
- break;
- }
- va_end(args);
- DBG_RETURN(ret);
-}
-/* }}} */
-
-func_mysqlnd__run_command mysqlnd_run_command = _mysqlnd_run_command;
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
+MYSQLND_CLASS_METHODS_START(mysqlnd_command)
+ MYSQLND_METHOD(mysqlnd_command, set_option),
+ MYSQLND_METHOD(mysqlnd_command, debug),
+ MYSQLND_METHOD(mysqlnd_command, init_db),
+ MYSQLND_METHOD(mysqlnd_command, ping),
+ MYSQLND_METHOD(mysqlnd_command, statistics),
+ MYSQLND_METHOD(mysqlnd_command, process_kill),
+ MYSQLND_METHOD(mysqlnd_command, refresh),
+ MYSQLND_METHOD(mysqlnd_command, shutdown),
+ MYSQLND_METHOD(mysqlnd_command, quit),
+ MYSQLND_METHOD(mysqlnd_command, query),
+ MYSQLND_METHOD(mysqlnd_command, change_user),
+ MYSQLND_METHOD(mysqlnd_command, reap_result),
+ MYSQLND_METHOD(mysqlnd_command, stmt_prepare),
+ MYSQLND_METHOD(mysqlnd_command, stmt_execute),
+ MYSQLND_METHOD(mysqlnd_command, stmt_fetch),
+ MYSQLND_METHOD(mysqlnd_command, stmt_reset),
+ MYSQLND_METHOD(mysqlnd_command, stmt_send_long_data),
+ MYSQLND_METHOD(mysqlnd_command, stmt_close),
+ MYSQLND_METHOD(mysqlnd_command, enable_ssl),
+ MYSQLND_METHOD(mysqlnd_command, handshake),
+MYSQLND_CLASS_METHODS_END;
diff --git a/ext/mysqlnd/mysqlnd_commands.h b/ext/mysqlnd/mysqlnd_commands.h
index 86b4ccebb4..f043910dcb 100644
--- a/ext/mysqlnd/mysqlnd_commands.h
+++ b/ext/mysqlnd/mysqlnd_commands.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -20,15 +20,6 @@
#ifndef MYSQLND_COMMANDS_H
#define MYSQLND_COMMANDS_H
-extern func_mysqlnd__run_command mysqlnd_run_command;
+//extern func_mysqlnd__run_command mysqlnd_run_command;
#endif /* MYSQLND_COMMANDS_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c
index dba65c0954..2822672da5 100644
--- a/ext/mysqlnd/mysqlnd_connection.c
+++ b/ext/mysqlnd/mysqlnd_connection.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -379,7 +379,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_server_option)(MYSQLND_CONN_DATA * const c
enum_func_status ret = FAIL;
DBG_ENTER("mysqlnd_conn_data::set_server_option");
if (PASS == conn->m->local_tx_start(conn, this_func)) {
- ret = conn->run_command(COM_SET_OPTION, conn, option);
+ ret = conn->command->set_option(conn, option);
conn->m->local_tx_end(conn, this_func, ret);
}
DBG_RETURN(ret);
@@ -536,7 +536,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake)(MYSQLND_CONN_DATA * conn,
{
size_t client_flags = mysql_flags;
- ret = conn->run_command(COM_HANDSHAKE, conn, username, password, database, client_flags);
+ ret = conn->command->handshake(conn, *username, *password, *database, client_flags);
}
DBG_RETURN(ret);
}
@@ -791,7 +791,7 @@ err:
DBG_ERR_FMT("[%u] %.128s (trying to connect via %s)", conn->error_info->error_no, conn->error_info->error, conn->scheme.s);
if (!conn->error_info->error_no) {
- SET_CLIENT_ERROR(conn->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, conn->error_info->error? conn->error_info->error:"Unknown error");
+ SET_CLIENT_ERROR(conn->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, conn->error_info->error);
php_error_docref(NULL, E_WARNING, "[%u] %.128s (trying to connect via %s)", conn->error_info->error_no, conn->error_info->error, conn->scheme.s);
}
@@ -881,7 +881,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_query)(MYSQLND_CONN_DATA * conn, const ch
{
const MYSQLND_CSTRING query_string = {query, query_len};
- ret = conn->run_command(COM_QUERY, conn, query_string);
+ ret = conn->command->query(conn, query_string);
if (type == MYSQLND_SEND_QUERY_EXPLICIT) {
conn->m->local_tx_end(conn, this_func, ret);
@@ -905,7 +905,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, reap_query)(MYSQLND_CONN_DATA * conn, enum_mys
DBG_INF_FMT("conn->server_status=%u", UPSERT_STATUS_GET_SERVER_STATUS(conn->upsert_status));
if (type == MYSQLND_REAP_RESULT_IMPLICIT || PASS == conn->m->local_tx_start(conn, this_func))
{
- ret = conn->run_command(COM_REAP_RESULT, conn);
+ ret = conn->command->reap_result(conn);
if (type == MYSQLND_REAP_RESULT_EXPLICIT) {
conn->m->local_tx_end(conn, this_func, ret);
@@ -1050,7 +1050,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, dump_debug_info)(MYSQLND_CONN_DATA * const con
DBG_ENTER("mysqlnd_conn_data::dump_debug_info");
DBG_INF_FMT("conn=%llu", conn->thread_id);
if (PASS == conn->m->local_tx_start(conn, this_func)) {
- ret = conn->run_command(COM_DEBUG, conn);
+ ret = conn->command->debug(conn);
conn->m->local_tx_end(conn, this_func, ret);
}
@@ -1072,7 +1072,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, select_db)(MYSQLND_CONN_DATA * const conn, con
if (PASS == conn->m->local_tx_start(conn, this_func)) {
const MYSQLND_CSTRING database = {db, db_len};
- ret = conn->run_command(COM_INIT_DB, conn, database);
+ ret = conn->command->init_db(conn, database);
conn->m->local_tx_end(conn, this_func, ret);
}
DBG_RETURN(ret);
@@ -1091,7 +1091,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, ping)(MYSQLND_CONN_DATA * const conn)
DBG_INF_FMT("conn=%llu", conn->thread_id);
if (PASS == conn->m->local_tx_start(conn, this_func)) {
- ret = conn->run_command(COM_PING, conn);
+ ret = conn->command->ping(conn);
conn->m->local_tx_end(conn, this_func, ret);
}
DBG_INF_FMT("ret=%u", ret);
@@ -1111,7 +1111,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, zend_stri
DBG_INF_FMT("conn=%llu", conn->thread_id);
if (PASS == conn->m->local_tx_start(conn, this_func)) {
- ret = conn->run_command(COM_STATISTICS, conn, message);
+ ret = conn->command->statistics(conn, message);
conn->m->local_tx_end(conn, this_func, ret);
}
DBG_RETURN(ret);
@@ -1130,11 +1130,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, kill)(MYSQLND_CONN_DATA * conn, unsigned int p
DBG_INF_FMT("conn=%llu pid=%u", conn->thread_id, pid);
if (PASS == conn->m->local_tx_start(conn, this_func)) {
- unsigned int process_id = pid;
+ const unsigned int process_id = pid;
/* 'unsigned char' is promoted to 'int' when passed through '...' */
- unsigned int read_response = (pid != conn->thread_id);
+ const unsigned int read_response = (pid != conn->thread_id);
- ret = conn->run_command(COM_PROCESS_KILL, conn, process_id, read_response);
+ ret = conn->command->process_kill(conn, process_id, read_response);
conn->m->local_tx_end(conn, this_func, ret);
}
DBG_RETURN(ret);
@@ -1191,9 +1191,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, refresh)(MYSQLND_CONN_DATA * const conn, uint8
DBG_INF_FMT("conn=%llu options=%lu", conn->thread_id, options);
if (PASS == conn->m->local_tx_start(conn, this_func)) {
- unsigned int options_param = (unsigned int) options;
-
- ret = conn->run_command(COM_REFRESH, conn, options_param);
+ ret = conn->command->refresh(conn, options);
conn->m->local_tx_end(conn, this_func, ret);
}
DBG_RETURN(ret);
@@ -1211,9 +1209,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, shutdown)(MYSQLND_CONN_DATA * const conn, uint
DBG_INF_FMT("conn=%llu level=%lu", conn->thread_id, level);
if (PASS == conn->m->local_tx_start(conn, this_func)) {
- unsigned int level_param = (unsigned int) level;
-
- ret = conn->run_command(COM_SHUTDOWN, conn, level_param);
+ ret = conn->command->shutdown(conn, level);
conn->m->local_tx_end(conn, this_func, ret);
}
DBG_RETURN(ret);
@@ -1244,7 +1240,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn)
case CONN_READY:
DBG_INF("Connection clean, sending COM_QUIT");
if (net_stream) {
- ret = conn->run_command(COM_QUIT, conn);
+ ret = conn->command->quit(conn);
vio->data->m.close_stream(vio, conn->stats, conn->error_info);
}
SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
@@ -1590,7 +1586,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, change_user)(MYSQLND_CONN_DATA * const conn,
DBG_ENTER("mysqlnd_conn_data::change_user");
DBG_INF_FMT("conn=%llu user=%s passwd=%s db=%s silent=%u",
- conn->thread_id, user?user:"", passwd?"***":"null", db?db:"", (silent == TRUE)?1:0 );
+ conn->thread_id, user?user:"", passwd?"***":"null", db?db:"", silent == TRUE);
if (PASS != conn->m->local_tx_start(conn, this_func)) {
goto end;
@@ -1826,10 +1822,17 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * cons
DBG_INF_FMT("Adding [%s][%s]", key, value);
{
zval attrz;
- zend_string *str = zend_string_init(key, strlen(key), 1);
- GC_MAKE_PERSISTENT_LOCAL(str);
- ZVAL_NEW_STR(&attrz, zend_string_init(value, strlen(value), conn->persistent));
- GC_MAKE_PERSISTENT_LOCAL(Z_COUNTED(attrz));
+ zend_string *str;
+
+ if (conn->persistent) {
+ str = zend_string_init(key, strlen(key), 1);
+ GC_MAKE_PERSISTENT_LOCAL(str);
+ ZVAL_NEW_STR(&attrz, zend_string_init(value, strlen(value), 1));
+ GC_MAKE_PERSISTENT_LOCAL(Z_COUNTED(attrz));
+ } else {
+ str = zend_string_init(key, strlen(key), 0);
+ ZVAL_NEW_STR(&attrz, zend_string_init(value, strlen(value), 0));
+ }
zend_hash_update(conn->options->connect_attr, str, &attrz);
zend_string_release_ex(str, 1);
}
@@ -2720,13 +2723,3 @@ mysqlnd_connection_init(const size_t client_flags, const zend_bool persistent, M
DBG_RETURN(ret);
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_connection.h b/ext/mysqlnd/mysqlnd_connection.h
index a5c07c3af6..5887327b35 100644
--- a/ext/mysqlnd/mysqlnd_connection.h
+++ b/ext/mysqlnd/mysqlnd_connection.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -76,12 +76,3 @@ PHPAPI void mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO * const info);
PHPAPI void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state);
#endif /* MYSQLND_CONNECTION_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c
index 409097a559..cb512e1e9e 100644
--- a/ext/mysqlnd/mysqlnd_debug.c
+++ b/ext/mysqlnd/mysqlnd_debug.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -699,6 +699,10 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_debug)
MYSQLND_CLASS_METHODS_END;
+static void free_ptr(zval *zv) {
+ efree(Z_PTR_P(zv));
+}
+
/* {{{ mysqlnd_debug_init */
PHPAPI MYSQLND_DEBUG *
mysqlnd_debug_init(const char * skip_functions[])
@@ -710,7 +714,7 @@ mysqlnd_debug_init(const char * skip_functions[])
zend_stack_init(&ret->call_stack, sizeof(char *));
zend_stack_init(&ret->call_time_stack, sizeof(uint64_t));
zend_hash_init(&ret->not_filtered_functions, 0, NULL, NULL, 0);
- zend_hash_init(&ret->function_profiles, 0, NULL, NULL, 0);
+ zend_hash_init(&ret->function_profiles, 0, NULL, free_ptr, 0);
ret->m = & mysqlnd_mysqlnd_debug_methods;
ret->skip_functions = skip_functions;
@@ -780,13 +784,3 @@ mysqlnd_debug_trace_plugin_register(void)
mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_plugin_trace_log_plugin);
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h
index 08a3a2b6a2..32dc7316a7 100644
--- a/ext/mysqlnd/mysqlnd_debug.h
+++ b/ext/mysqlnd/mysqlnd_debug.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -228,12 +228,3 @@ static inline void TRACE_ALLOC_ENTER(const char * const func_name) {}
#endif
#endif /* MYSQLND_DEBUG_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c
index b61720fe7c..c1da994f41 100644
--- a/ext/mysqlnd/mysqlnd_driver.c
+++ b/ext/mysqlnd/mysqlnd_driver.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -98,8 +98,8 @@ PHPAPI void mysqlnd_library_init(void)
static MYSQLND *
MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *factory, const zend_bool persistent)
{
- size_t alloc_size_ret = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
- size_t alloc_size_ret_data = sizeof(MYSQLND_CONN_DATA) + mysqlnd_plugin_count() * sizeof(void *);
+ const size_t alloc_size_ret = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
+ const size_t alloc_size_ret_data = sizeof(MYSQLND_CONN_DATA) + mysqlnd_plugin_count() * sizeof(void *);
MYSQLND * new_object;
MYSQLND_CONN_DATA * data;
@@ -143,9 +143,9 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(MYSQLND_CLASS_METHODS_TYP
data->protocol_frame_codec = mysqlnd_pfc_init(persistent, factory, data->stats, data->error_info);
data->vio = mysqlnd_vio_init(persistent, factory, data->stats, data->error_info);
data->payload_decoder_factory = mysqlnd_protocol_payload_decoder_factory_init(data, persistent);
- data->run_command = mysqlnd_command_factory_get();
+ data->command = mysqlnd_command_get_methods();
- if (!data->protocol_frame_codec || !data->vio || !data->payload_decoder_factory || !data->run_command) {
+ if (!data->protocol_frame_codec || !data->vio || !data->payload_decoder_factory || !data->command) {
new_object->m->dtor(new_object);
DBG_RETURN(NULL);
}
@@ -159,7 +159,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(MYSQLND_CLASS_METHODS_TYP
static MYSQLND *
MYSQLND_METHOD(mysqlnd_object_factory, clone_connection_object)(MYSQLND * to_be_cloned)
{
- size_t alloc_size_ret = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
+ const size_t alloc_size_ret = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
MYSQLND * new_object;
DBG_ENTER("mysqlnd_driver::clone_connection_object");
@@ -188,7 +188,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, clone_connection_object)(MYSQLND * to_be_
static MYSQLND_STMT *
MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA * const conn)
{
- size_t alloc_size = sizeof(MYSQLND_STMT) + mysqlnd_plugin_count() * sizeof(void *);
+ const size_t alloc_size = sizeof(MYSQLND_STMT) + mysqlnd_plugin_count() * sizeof(void *);
MYSQLND_STMT * ret = mnd_ecalloc(1, alloc_size);
MYSQLND_STMT_DATA * stmt = NULL;
@@ -245,8 +245,8 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA
static MYSQLND_PFC *
MYSQLND_METHOD(mysqlnd_object_factory, get_pfc)(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
{
- size_t pfc_alloc_size = ZEND_MM_ALIGNED_SIZE(sizeof(MYSQLND_PFC) + mysqlnd_plugin_count() * sizeof(void *));
- size_t pfc_data_alloc_size = sizeof(MYSQLND_PFC_DATA) + mysqlnd_plugin_count() * sizeof(void *);
+ const size_t pfc_alloc_size = ZEND_MM_ALIGNED_SIZE(sizeof(MYSQLND_PFC) + mysqlnd_plugin_count() * sizeof(void *));
+ const size_t pfc_data_alloc_size = sizeof(MYSQLND_PFC_DATA) + mysqlnd_plugin_count() * sizeof(void *);
MYSQLND_PFC * pfc = mnd_pecalloc(1, pfc_alloc_size + pfc_data_alloc_size, persistent);
DBG_ENTER("mysqlnd_object_factory::get_pfc");
@@ -270,8 +270,8 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_pfc)(const zend_bool persistent, MYSQ
static MYSQLND_VIO *
MYSQLND_METHOD(mysqlnd_object_factory, get_vio)(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
{
- size_t vio_alloc_size = ZEND_MM_ALIGNED_SIZE(sizeof(MYSQLND_VIO) + mysqlnd_plugin_count() * sizeof(void *));
- size_t vio_data_alloc_size = sizeof(MYSQLND_VIO_DATA) + mysqlnd_plugin_count() * sizeof(void *);
+ const size_t vio_alloc_size = ZEND_MM_ALIGNED_SIZE(sizeof(MYSQLND_VIO) + mysqlnd_plugin_count() * sizeof(void *));
+ const size_t vio_data_alloc_size = sizeof(MYSQLND_VIO_DATA) + mysqlnd_plugin_count() * sizeof(void *);
MYSQLND_VIO * vio = mnd_pecalloc(1, vio_alloc_size + vio_data_alloc_size, persistent);
DBG_ENTER("mysqlnd_object_factory::get_vio");
@@ -295,7 +295,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_vio)(const zend_bool persistent, MYSQ
static MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY *
MYSQLND_METHOD(mysqlnd_object_factory, get_protocol_payload_decoder_factory)(MYSQLND_CONN_DATA * conn, const zend_bool persistent)
{
- size_t alloc_size = sizeof(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY) + mysqlnd_plugin_count() * sizeof(void *);
+ const size_t alloc_size = sizeof(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY) + mysqlnd_plugin_count() * sizeof(void *);
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY *ret = mnd_pecalloc(1, alloc_size, persistent);
DBG_ENTER("mysqlnd_object_factory::get_protocol_payload_decoder_factory");
@@ -319,12 +319,3 @@ PHPAPI MYSQLND_CLASS_METHODS_START(mysqlnd_object_factory)
MYSQLND_METHOD(mysqlnd_object_factory, get_vio),
MYSQLND_METHOD(mysqlnd_object_factory, get_protocol_payload_decoder_factory)
MYSQLND_CLASS_METHODS_END;
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h
index 7630a0a988..8eaf68214e 100644
--- a/ext/mysqlnd/mysqlnd_enum_n_def.h
+++ b/ext/mysqlnd/mysqlnd_enum_n_def.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -631,6 +631,7 @@ enum mysqlnd_packet_type
PROT_CHG_USER_RESP_PACKET,
PROT_SHA256_PK_REQUEST_PACKET,
PROT_SHA256_PK_REQUEST_RESPONSE_PACKET,
+ PROT_CACHED_SHA2_RESULT_PACKET,
PROT_LAST /* should always be last */
};
@@ -710,13 +711,3 @@ enum mysqlnd_buffered_type
#define MYSQLND_CLIENT_KNOWS_RSET_COPY_DATA 1
#endif /* MYSQLND_ENUM_N_DEF_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_ext_plugin.c b/ext/mysqlnd/mysqlnd_ext_plugin.c
index b17c80f190..c2884b4f30 100644
--- a/ext/mysqlnd/mysqlnd_ext_plugin.c
+++ b/ext/mysqlnd/mysqlnd_ext_plugin.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -362,19 +362,19 @@ _mysqlnd_vio_set_methods(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_vio) * methods)
/* {{{ mysqlnd_command_factory_get */
-static func_mysqlnd__run_command
+static MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) *
_mysqlnd_command_factory_get()
{
- return mysqlnd_run_command;
+ return &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_command);
}
/* }}} */
/* {{{ mysqlnd_command_factory_set */
static void
-_mysqlnd_command_factory_set(func_mysqlnd__run_command run_command)
+_mysqlnd_command_factory_set(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * methods)
{
- mysqlnd_run_command = run_command;
+ MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_command) = *methods;
}
/* }}} */
@@ -448,12 +448,3 @@ struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters =
_mysqlnd_command_factory_set,
},
};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_ext_plugin.h b/ext/mysqlnd/mysqlnd_ext_plugin.h
index 008e147198..1d4d96364f 100644
--- a/ext/mysqlnd/mysqlnd_ext_plugin.h
+++ b/ext/mysqlnd/mysqlnd_ext_plugin.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -117,11 +117,11 @@ struct st_mysqlnd_plugin_methods_xetters
void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) * methods);
} error_info;
- struct st_mnd_command_factory_xetters
+ struct st_mnd_command_xetters
{
- func_mysqlnd__run_command (*get)();
- void (*set)(func_mysqlnd__run_command factory);
- } command_factory;
+ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * (*get)();
+ void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * methods);
+ } command;
};
PHPAPI extern struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters;
@@ -157,19 +157,10 @@ PHPAPI extern struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xe
#define mysqlnd_vio_get_methods() mysqlnd_plugin_methods_xetters.vio.get()
#define mysqlnd_vio_set_methods(m) mysqlnd_plugin_methods_xetters.vio.set((m))
-#define mysqlnd_command_factory_get() mysqlnd_plugin_methods_xetters.command_factory.get()
-#define mysqlnd_command_factory_set(m) mysqlnd_plugin_methods_xetters.command_factory.set((m))
+#define mysqlnd_command_get_methods() mysqlnd_plugin_methods_xetters.command.get()
+#define mysqlnd_command_set_methods(m) mysqlnd_plugin_methods_xetters.command.set((m))
#define mysqlnd_error_info_get_methods() mysqlnd_plugin_methods_xetters.error_info.get()
#define mysqlnd_error_info_set_methods(m) mysqlnd_plugin_methods_xetters.error_info.set((m))
#endif /* MYSQLND_EXT_PLUGIN_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_libmysql_compat.h b/ext/mysqlnd/mysqlnd_libmysql_compat.h
index fe7a317544..93f7254a7c 100644
--- a/ext/mysqlnd/mysqlnd_libmysql_compat.h
+++ b/ext/mysqlnd/mysqlnd_libmysql_compat.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c
index a7d4163693..5362f1c7dd 100644
--- a/ext/mysqlnd/mysqlnd_loaddata.c
+++ b/ext/mysqlnd/mysqlnd_loaddata.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -230,12 +230,3 @@ infile_error:
DBG_RETURN(result);
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c
deleted file mode 100644
index 6fb9c5fde2..0000000000
--- a/ext/mysqlnd/mysqlnd_net.c
+++ /dev/null
@@ -1,1229 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andrey Hristov <andrey@php.net> |
- | Ulf Wendel <uw@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-#include "php.h"
-#include "php_globals.h"
-#include "mysqlnd.h"
-#include "mysqlnd_priv.h"
-#include "mysqlnd_wireprotocol.h"
-#include "mysqlnd_statistics.h"
-#include "mysqlnd_debug.h"
-#include "mysqlnd_ext_plugin.h"
-#include "php_network.h"
-#include "zend_ini.h"
-#ifdef MYSQLND_COMPRESSION_ENABLED
-#include <zlib.h>
-#endif
-
-#ifndef PHP_WIN32
-#include <netinet/tcp.h>
-#else
-#include <winsock.h>
-#endif
-
-
-/* {{{ mysqlnd_set_sock_no_delay */
-static int
-mysqlnd_set_sock_no_delay(php_stream * stream)
-{
-
- int socketd = ((php_netstream_data_t*)stream->abstract)->socket;
- int ret = SUCCESS;
- int flag = 1;
- int result = setsockopt(socketd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
-
- DBG_ENTER("mysqlnd_set_sock_no_delay");
-
- if (result == -1) {
- ret = FAILURE;
- }
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_set_sock_keepalive */
-static int
-mysqlnd_set_sock_keepalive(php_stream * stream)
-{
-
- int socketd = ((php_netstream_data_t*)stream->abstract)->socket;
- int ret = SUCCESS;
- int flag = 1;
- int result = setsockopt(socketd, SOL_SOCKET, SO_KEEPALIVE, (char *) &flag, sizeof(int));
-
- DBG_ENTER("mysqlnd_set_sock_keepalive");
-
- if (result == -1) {
- ret = FAILURE;
- }
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::network_read_ex */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, network_read_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count,
- MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
-{
- enum_func_status return_value = PASS;
- php_stream * net_stream = net->data->m.get_stream(net);
- size_t old_chunk_size = net_stream->chunk_size;
- size_t to_read = count, ret;
- zend_uchar * p = buffer;
-
- DBG_ENTER("mysqlnd_net::network_read_ex");
- DBG_INF_FMT("count="MYSQLND_SZ_T_SPEC, count);
-
- net_stream->chunk_size = MIN(to_read, net->data->options.net_read_buffer_size);
- while (to_read) {
- if (!(ret = php_stream_read(net_stream, (char *) p, to_read))) {
- DBG_ERR_FMT("Error while reading header from socket");
- return_value = FAIL;
- break;
- }
- p += ret;
- to_read -= ret;
- }
- MYSQLND_INC_CONN_STATISTIC_W_VALUE(stats, STAT_BYTES_RECEIVED, count - to_read);
- net_stream->chunk_size = old_chunk_size;
- DBG_RETURN(return_value);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::network_write_ex */
-static size_t
-MYSQLND_METHOD(mysqlnd_net, network_write_ex)(MYSQLND_NET * const net, const zend_uchar * const buffer, const size_t count,
- MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
-{
- size_t ret;
- DBG_ENTER("mysqlnd_net::network_write_ex");
- DBG_INF_FMT("sending %u bytes", count);
- ret = php_stream_write(net->data->m.get_stream(net), (char *)buffer, count);
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::open_pipe */
-static php_stream *
-MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
- const zend_bool persistent,
- MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
-{
- unsigned int streams_options = 0;
- dtor_func_t origin_dtor;
- php_stream * net_stream = NULL;
-
- DBG_ENTER("mysqlnd_net::open_pipe");
- if (persistent) {
- streams_options |= STREAM_OPEN_PERSISTENT;
- }
- streams_options |= IGNORE_URL;
- net_stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL);
- if (!net_stream) {
- SET_CLIENT_ERROR(*error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "Unknown errror while connecting");
- DBG_RETURN(NULL);
- }
- /*
- Streams are not meant for C extensions! Thus we need a hack. Every connected stream will
- be registered as resource (in EG(regular_list). So far, so good. However, it won't be
- unregistered until the script ends. So, we need to take care of that.
- */
- origin_dtor = EG(regular_list).pDestructor;
- EG(regular_list).pDestructor = NULL;
- zend_hash_index_del(&EG(regular_list), net_stream->res->handle); /* ToDO: should it be res->handle, do streams register with addref ?*/
- EG(regular_list).pDestructor = origin_dtor;
- net_stream->res = NULL;
-
- DBG_RETURN(net_stream);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::open_tcp_or_unix */
-static php_stream *
-MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
- const zend_bool persistent,
- MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
-{
- unsigned int streams_options = 0;
- unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
- char * hashed_details = NULL;
- int hashed_details_len = 0;
- zend_string *errstr = NULL;
- int errcode = 0;
- struct timeval tv;
- dtor_func_t origin_dtor;
- php_stream * net_stream = NULL;
-
- DBG_ENTER("mysqlnd_net::open_tcp_or_unix");
-
- net->data->stream = NULL;
-
- if (persistent) {
- hashed_details_len = mnd_sprintf(&hashed_details, 0, "%p", net);
- DBG_INF_FMT("hashed_details=%s", hashed_details);
- }
-
- if (net->data->options.timeout_connect) {
- tv.tv_sec = net->data->options.timeout_connect;
- tv.tv_usec = 0;
- }
-
- DBG_INF_FMT("calling php_stream_xport_create");
- net_stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags,
- hashed_details, (net->data->options.timeout_connect) ? &tv : NULL,
- NULL /*ctx*/, &errstr, &errcode);
- if (errstr || !net_stream) {
- DBG_ERR("Error");
- if (hashed_details) {
- mnd_sprintf_free(hashed_details);
- }
- errcode = CR_CONNECTION_ERROR;
- SET_CLIENT_ERROR(*error_info,
- CR_CONNECTION_ERROR,
- UNKNOWN_SQLSTATE,
- errstr? ZSTR_VAL(errstr):"Unknown error while connecting");
- if (errstr) {
- zend_string_release_ex(errstr, 0);
- }
- DBG_RETURN(NULL);
- }
- if (hashed_details) {
- /*
- If persistent, the streams register it in EG(persistent_list).
- This is unwanted. ext/mysql or ext/mysqli are responsible to clean,
- whatever they have to.
- */
- zend_resource *le;
-
- if ((le = zend_hash_str_find_ptr(&EG(persistent_list), hashed_details, hashed_details_len))) {
- origin_dtor = EG(persistent_list).pDestructor;
- /*
- in_free will let streams code skip destructing - big HACK,
- but STREAMS suck big time regarding persistent streams.
- Just not compatible for extensions that need persistency.
- */
- EG(persistent_list).pDestructor = NULL;
- zend_hash_str_del(&EG(persistent_list), hashed_details, hashed_details_len);
- EG(persistent_list).pDestructor = origin_dtor;
- pefree(le, 1);
- }
-#if ZEND_DEBUG
- /* Shut-up the streams, they don't know what they are doing */
- net_stream->__exposed = 1;
-#endif
- mnd_sprintf_free(hashed_details);
- }
-
- /*
- Streams are not meant for C extensions! Thus we need a hack. Every connected stream will
- be registered as resource (in EG(regular_list). So far, so good. However, it won't be
- unregistered until the script ends. So, we need to take care of that.
- */
- origin_dtor = EG(regular_list).pDestructor;
- EG(regular_list).pDestructor = NULL;
- zend_hash_index_del(&EG(regular_list), net_stream->res->handle); /* ToDO: should it be res->handle, do streams register with addref ?*/
- efree(net_stream->res);
- net_stream->res = NULL;
- EG(regular_list).pDestructor = origin_dtor;
- DBG_RETURN(net_stream);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::post_connect_set_opt */
-static void
-MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt)(MYSQLND_NET * const net,
- const char * const scheme, const size_t scheme_len,
- MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
-{
- php_stream * net_stream = net->data->m.get_stream(net);
- DBG_ENTER("mysqlnd_net::post_connect_set_opt");
- if (net_stream) {
- if (net->data->options.timeout_read) {
- struct timeval tv;
- DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->data->options.timeout_read);
- tv.tv_sec = net->data->options.timeout_read;
- tv.tv_usec = 0;
- php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
- }
-
- if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) {
- /* TCP -> Set TCP_NODELAY */
- mysqlnd_set_sock_no_delay(net_stream);
- /* TCP -> Set SO_KEEPALIVE */
- mysqlnd_set_sock_keepalive(net_stream);
- }
- }
-
- DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::get_open_stream */
-static func_mysqlnd_net__open_stream
-MYSQLND_METHOD(mysqlnd_net, get_open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
- MYSQLND_ERROR_INFO * const error_info)
-{
- func_mysqlnd_net__open_stream ret = NULL;
- DBG_ENTER("mysqlnd_net::get_open_stream");
- if (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1)) {
- ret = net->data->m.open_pipe;
- } else if ((scheme_len > (sizeof("tcp://") - 1) && !memcmp(scheme, "tcp://", sizeof("tcp://") - 1))
- ||
- (scheme_len > (sizeof("unix://") - 1) && !memcmp(scheme, "unix://", sizeof("unix://") - 1)))
- {
- ret = net->data->m.open_tcp_or_unix;
- }
-
- if (!ret) {
- SET_CLIENT_ERROR(*error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "No handler for this scheme");
- }
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::connect_ex */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
- const zend_bool persistent,
- MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
-{
- enum_func_status ret = FAIL;
- func_mysqlnd_net__open_stream open_stream = NULL;
- DBG_ENTER("mysqlnd_net::connect_ex");
-
- net->packet_no = net->compressed_envelope_packet_no = 0;
-
- net->data->m.close_stream(net, conn_stats, error_info);
-
- open_stream = net->data->m.get_open_stream(net, scheme, scheme_len, error_info);
- if (open_stream) {
- php_stream * net_stream = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info);
- if (net_stream) {
- (void) net->data->m.set_stream(net, net_stream);
- net->data->m.post_connect_set_opt(net, scheme, scheme_len, conn_stats, error_info);
- ret = PASS;
- }
- }
-
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* We assume that MYSQLND_HEADER_SIZE is 4 bytes !! */
-#define COPY_HEADER(T,A) do { \
- *(((char *)(T))) = *(((char *)(A)));\
- *(((char *)(T))+1) = *(((char *)(A))+1);\
- *(((char *)(T))+2) = *(((char *)(A))+2);\
- *(((char *)(T))+3) = *(((char *)(A))+3); } while (0)
-#define STORE_HEADER_SIZE(safe_storage, buffer) COPY_HEADER((safe_storage), (buffer))
-#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
-
-
-/* {{{ mysqlnd_net::send_ex */
-/*
- IMPORTANT : It's expected that buffer has place in the beginning for MYSQLND_HEADER_SIZE !!!!
- This is done for performance reasons in the caller of this function.
- Otherwise we will have to do send two TCP packets, or do new alloc and memcpy.
- Neither are quick, thus the clients of this function are obligated to do
- what they are asked for.
-
- `count` is actually the length of the payload data. Thus :
- count + MYSQLND_HEADER_SIZE = sizeof(buffer) (not the pointer but the actual buffer)
-*/
-static size_t
-MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count,
- MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
-{
- zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
- zend_uchar * safe_storage = safe_buf;
- size_t bytes_sent, packets_sent = 1;
- size_t left = count;
- zend_uchar * p = (zend_uchar *) buffer;
- zend_uchar * compress_buf = NULL;
- size_t to_be_sent;
-
- DBG_ENTER("mysqlnd_net::send_ex");
- DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, net->data->compressed);
-
- if (net->data->compressed == TRUE) {
- size_t comp_buf_size = MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE + MIN(left, MYSQLND_MAX_PACKET_SIZE);
- DBG_INF_FMT("compress_buf_size="MYSQLND_SZ_T_SPEC, comp_buf_size);
- compress_buf = mnd_emalloc(comp_buf_size);
- }
-
- do {
- to_be_sent = MIN(left, MYSQLND_MAX_PACKET_SIZE);
- DBG_INF_FMT("to_be_sent=%u", to_be_sent);
- DBG_INF_FMT("packets_sent=%u", packets_sent);
- DBG_INF_FMT("compressed_envelope_packet_no=%u", net->compressed_envelope_packet_no);
- DBG_INF_FMT("packet_no=%u", net->packet_no);
-#ifdef MYSQLND_COMPRESSION_ENABLED
- if (net->data->compressed == TRUE) {
- /* here we need to compress the data and then write it, first comes the compressed header */
- size_t tmp_complen = to_be_sent;
- size_t payload_size;
- zend_uchar * uncompressed_payload = p; /* should include the header */
-
- STORE_HEADER_SIZE(safe_storage, uncompressed_payload);
- int3store(uncompressed_payload, to_be_sent);
- int1store(uncompressed_payload + 3, net->packet_no);
- if (PASS == net->data->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), &tmp_complen,
- uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE))
- {
- int3store(compress_buf + MYSQLND_HEADER_SIZE, to_be_sent + MYSQLND_HEADER_SIZE);
- payload_size = tmp_complen;
- } else {
- int3store(compress_buf + MYSQLND_HEADER_SIZE, 0);
- memcpy(compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE);
- payload_size = to_be_sent + MYSQLND_HEADER_SIZE;
- }
- RESTORE_HEADER_SIZE(uncompressed_payload, safe_storage);
-
- int3store(compress_buf, payload_size);
- int1store(compress_buf + 3, net->packet_no);
- DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
- bytes_sent = net->data->m.network_write_ex(net, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE,
- conn_stats, error_info);
- net->compressed_envelope_packet_no++;
- #if WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY
- if (res == Z_OK) {
- size_t decompressed_size = left + MYSQLND_HEADER_SIZE;
- zend_uchar * decompressed_data = mnd_malloc(decompressed_size);
- int error = net->data->m.decode(decompressed_data, decompressed_size,
- compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, payload_size);
- if (error == Z_OK) {
- int i;
- DBG_INF("success decompressing");
- for (i = 0 ; i < decompressed_size; i++) {
- if (i && (i % 30 == 0)) {
- printf("\n\t\t");
- }
- printf("%.2X ", (int)*((char*)&(decompressed_data[i])));
- DBG_INF_FMT("%.2X ", (int)*((char*)&(decompressed_data[i])));
- }
- } else {
- DBG_INF("error decompressing");
- }
- mnd_free(decompressed_data);
- }
- #endif /* WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY */
- } else
-#endif /* MYSQLND_COMPRESSION_ENABLED */
- {
- DBG_INF("no compression");
- STORE_HEADER_SIZE(safe_storage, p);
- int3store(p, to_be_sent);
- int1store(p + 3, net->packet_no);
- bytes_sent = net->data->m.network_write_ex(net, p, to_be_sent + MYSQLND_HEADER_SIZE, conn_stats, error_info);
- RESTORE_HEADER_SIZE(p, safe_storage);
- net->compressed_envelope_packet_no++;
- }
- net->packet_no++;
-
- p += to_be_sent;
- left -= to_be_sent;
- packets_sent++;
- /*
- if left is 0 then there is nothing more to send, but if the last packet was exactly
- with the size MYSQLND_MAX_PACKET_SIZE we need to send additional packet, which has
- empty payload. Thus if left == 0 we check for to_be_sent being the max size. If it is
- indeed it then loop once more, then to_be_sent will become 0, left will stay 0. Empty
- packet will be sent and this loop will end.
- */
- } while (bytes_sent && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
-
- DBG_INF_FMT("packet_size="MYSQLND_SZ_T_SPEC" packet_no=%u", left, net->packet_no);
-
- MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats,
- STAT_BYTES_SENT, count + packets_sent * MYSQLND_HEADER_SIZE,
- STAT_PROTOCOL_OVERHEAD_OUT, packets_sent * MYSQLND_HEADER_SIZE,
- STAT_PACKETS_SENT, packets_sent);
-
- if (compress_buf) {
- mnd_efree(compress_buf);
- }
-
- /* Even for zero size payload we have to send a packet */
- if (!bytes_sent) {
- DBG_ERR_FMT("Can't %u send bytes", count);
- SET_CLIENT_ERROR(*error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
- }
- DBG_RETURN(bytes_sent);
-}
-/* }}} */
-
-
-#ifdef MYSQLND_COMPRESSION_ENABLED
-/* {{{ php_mysqlnd_read_buffer_is_empty */
-static zend_bool
-php_mysqlnd_read_buffer_is_empty(MYSQLND_READ_BUFFER * buffer)
-{
- return buffer->len? FALSE:TRUE;
-}
-/* }}} */
-
-
-/* {{{ php_mysqlnd_read_buffer_read */
-static void
-php_mysqlnd_read_buffer_read(MYSQLND_READ_BUFFER * buffer, size_t count, zend_uchar * dest)
-{
- if (buffer->len >= count) {
- memcpy(dest, buffer->data + buffer->offset, count);
- buffer->offset += count;
- buffer->len -= count;
- }
-}
-/* }}} */
-
-
-/* {{{ php_mysqlnd_read_buffer_bytes_left */
-static size_t
-php_mysqlnd_read_buffer_bytes_left(MYSQLND_READ_BUFFER * buffer)
-{
- return buffer->len;
-}
-/* }}} */
-
-
-/* {{{ php_mysqlnd_read_buffer_free */
-static void
-php_mysqlnd_read_buffer_free(MYSQLND_READ_BUFFER ** buffer)
-{
- DBG_ENTER("php_mysqlnd_read_buffer_free");
- if (*buffer) {
- mnd_efree((*buffer)->data);
- mnd_efree(*buffer);
- *buffer = NULL;
- }
- DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ php_mysqlnd_create_read_buffer */
-static MYSQLND_READ_BUFFER *
-mysqlnd_create_read_buffer(size_t count)
-{
- MYSQLND_READ_BUFFER * ret = mnd_emalloc(sizeof(MYSQLND_READ_BUFFER));
- DBG_ENTER("mysqlnd_create_read_buffer");
- ret->is_empty = php_mysqlnd_read_buffer_is_empty;
- ret->read = php_mysqlnd_read_buffer_read;
- ret->bytes_left = php_mysqlnd_read_buffer_bytes_left;
- ret->free_buffer = php_mysqlnd_read_buffer_free;
- ret->data = mnd_emalloc(count);
- ret->size = ret->len = count;
- ret->offset = 0;
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::read_compressed_packet_from_stream_and_fill_read_buffer */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buffer)
- (MYSQLND_NET * net, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info)
-{
- size_t decompressed_size;
- enum_func_status retval = PASS;
- zend_uchar * compressed_data = NULL;
- zend_uchar comp_header[COMPRESSED_HEADER_SIZE];
- DBG_ENTER("mysqlnd_net::read_compressed_packet_from_stream_and_fill_read_buffer");
-
- /* Read the compressed header */
- if (FAIL == net->data->m.network_read_ex(net, comp_header, COMPRESSED_HEADER_SIZE, conn_stats, error_info)) {
- DBG_RETURN(FAIL);
- }
- decompressed_size = uint3korr(comp_header);
-
- /* When decompressed_size is 0, then the data is not compressed, and we have wasted 3 bytes */
- /* we need to decompress the data */
-
- if (decompressed_size) {
- compressed_data = mnd_emalloc(net_payload_size);
- if (FAIL == net->data->m.network_read_ex(net, compressed_data, net_payload_size, conn_stats, error_info)) {
- retval = FAIL;
- goto end;
- }
- net->uncompressed_data = mysqlnd_create_read_buffer(decompressed_size);
- retval = net->data->m.decode(net->uncompressed_data->data, decompressed_size, compressed_data, net_payload_size);
- if (FAIL == retval) {
- goto end;
- }
- } else {
- DBG_INF_FMT("The server decided not to compress the data. Our job is easy. Copying %u bytes", net_payload_size);
- net->uncompressed_data = mysqlnd_create_read_buffer(net_payload_size);
- if (FAIL == net->data->m.network_read_ex(net, net->uncompressed_data->data, net_payload_size, conn_stats, error_info)) {
- retval = FAIL;
- goto end;
- }
- }
-end:
- if (compressed_data) {
- mnd_efree(compressed_data);
- }
- DBG_RETURN(retval);
-}
-/* }}} */
-#endif /* MYSQLND_COMPRESSION_ENABLED */
-
-
-/* {{{ mysqlnd_net::decode */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len,
- const zend_uchar * const compressed_data, const size_t compressed_data_len)
-{
-#ifdef MYSQLND_COMPRESSION_ENABLED
- int error;
- uLongf tmp_complen = uncompressed_data_len;
- DBG_ENTER("mysqlnd_net::decode");
- error = uncompress(uncompressed_data, &tmp_complen, compressed_data, compressed_data_len);
-
- DBG_INF_FMT("compressed data: decomp_len=%lu compressed_size="MYSQLND_SZ_T_SPEC, tmp_complen, compressed_data_len);
- if (error != Z_OK) {
- DBG_INF_FMT("decompression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
- }
- DBG_RETURN(error == Z_OK? PASS:FAIL);
-#else
- DBG_ENTER("mysqlnd_net::decode");
- DBG_RETURN(FAIL);
-#endif
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::encode */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len,
- const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len)
-{
-#ifdef MYSQLND_COMPRESSION_ENABLED
- int error;
- uLongf tmp_complen = *compress_buffer_len;
- DBG_ENTER("mysqlnd_net::encode");
- error = compress(compress_buffer, &tmp_complen, uncompressed_data, uncompressed_data_len);
-
- if (error != Z_OK) {
- DBG_INF_FMT("compression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
- } else {
- *compress_buffer_len = tmp_complen;
- DBG_INF_FMT("compression successful. compressed size=%lu", tmp_complen);
- }
-
- DBG_RETURN(error == Z_OK? PASS:FAIL);
-#else
- DBG_ENTER("mysqlnd_net::encode");
- DBG_RETURN(FAIL);
-#endif
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::receive_ex */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, receive_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count,
- MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
-{
- size_t to_read = count;
- zend_uchar * p = buffer;
-
- DBG_ENTER("mysqlnd_net::receive_ex");
-#ifdef MYSQLND_COMPRESSION_ENABLED
- if (net->data->compressed) {
- if (net->uncompressed_data) {
- size_t to_read_from_buffer = MIN(net->uncompressed_data->bytes_left(net->uncompressed_data), to_read);
- DBG_INF_FMT("reading "MYSQLND_SZ_T_SPEC" from uncompressed_data buffer", to_read_from_buffer);
- if (to_read_from_buffer) {
- net->uncompressed_data->read(net->uncompressed_data, to_read_from_buffer, (zend_uchar *) p);
- p += to_read_from_buffer;
- to_read -= to_read_from_buffer;
- }
- DBG_INF_FMT("left "MYSQLND_SZ_T_SPEC" to read", to_read);
- if (TRUE == net->uncompressed_data->is_empty(net->uncompressed_data)) {
- /* Everything was consumed. This should never happen here, but for security */
- net->uncompressed_data->free_buffer(&net->uncompressed_data);
- }
- }
- if (to_read) {
- zend_uchar net_header[MYSQLND_HEADER_SIZE];
- size_t net_payload_size;
- zend_uchar packet_no;
-
- if (FAIL == net->data->m.network_read_ex(net, net_header, MYSQLND_HEADER_SIZE, conn_stats, error_info)) {
- DBG_RETURN(FAIL);
- }
- net_payload_size = uint3korr(net_header);
- packet_no = uint1korr(net_header + 3);
- if (net->compressed_envelope_packet_no != packet_no) {
- DBG_ERR_FMT("Transport level: packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
- net->compressed_envelope_packet_no, packet_no, net_payload_size);
-
- php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
- net->compressed_envelope_packet_no, packet_no, net_payload_size);
- DBG_RETURN(FAIL);
- }
- net->compressed_envelope_packet_no++;
-#ifdef MYSQLND_DUMP_HEADER_N_BODY
- DBG_INF_FMT("HEADER: hwd_packet_no=%u size=%3u", packet_no, (zend_ulong) net_payload_size);
-#endif
- /* Now let's read from the wire, decompress it and fill the read buffer */
- net->data->m.read_compressed_packet_from_stream_and_fill_read_buffer(net, net_payload_size, conn_stats, error_info);
-
- /*
- Now a bit of recursion - read from the read buffer,
- if the data which we have just read from the wire
- is not enough, then the recursive call will try to
- satisfy it until it is satisfied.
- */
- DBG_RETURN(net->data->m.receive_ex(net, p, to_read, conn_stats, error_info));
- }
- DBG_RETURN(PASS);
- }
-#endif /* MYSQLND_COMPRESSION_ENABLED */
- DBG_RETURN(net->data->m.network_read_ex(net, p, to_read, conn_stats, error_info));
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::set_client_option */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, set_client_option)(MYSQLND_NET * const net, enum mysqlnd_option option, const char * const value)
-{
- DBG_ENTER("mysqlnd_net::set_client_option");
- DBG_INF_FMT("option=%u", option);
- switch (option) {
- case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
- DBG_INF("MYSQLND_OPT_NET_CMD_BUFFER_SIZE");
- if (*(unsigned int*) value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
- DBG_RETURN(FAIL);
- }
- net->cmd_buffer.length = *(unsigned int*) value;
- DBG_INF_FMT("new_length="MYSQLND_SZ_T_SPEC, net->cmd_buffer.length);
- if (!net->cmd_buffer.buffer) {
- net->cmd_buffer.buffer = mnd_pemalloc(net->cmd_buffer.length, net->persistent);
- } else {
- net->cmd_buffer.buffer = mnd_perealloc(net->cmd_buffer.buffer, net->cmd_buffer.length, net->persistent);
- }
- break;
- case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
- DBG_INF("MYSQLND_OPT_NET_READ_BUFFER_SIZE");
- net->data->options.net_read_buffer_size = *(unsigned int*) value;
- DBG_INF_FMT("new_length="MYSQLND_SZ_T_SPEC, net->data->options.net_read_buffer_size);
- break;
- case MYSQL_OPT_CONNECT_TIMEOUT:
- DBG_INF("MYSQL_OPT_CONNECT_TIMEOUT");
- net->data->options.timeout_connect = *(unsigned int*) value;
- break;
- case MYSQLND_OPT_SSL_KEY:
- {
- zend_bool pers = net->persistent;
- if (net->data->options.ssl_key) {
- mnd_pefree(net->data->options.ssl_key, pers);
- }
- net->data->options.ssl_key = value? mnd_pestrdup(value, pers) : NULL;
- break;
- }
- case MYSQLND_OPT_SSL_CERT:
- {
- zend_bool pers = net->persistent;
- if (net->data->options.ssl_cert) {
- mnd_pefree(net->data->options.ssl_cert, pers);
- }
- net->data->options.ssl_cert = value? mnd_pestrdup(value, pers) : NULL;
- break;
- }
- case MYSQLND_OPT_SSL_CA:
- {
- zend_bool pers = net->persistent;
- if (net->data->options.ssl_ca) {
- mnd_pefree(net->data->options.ssl_ca, pers);
- }
- net->data->options.ssl_ca = value? mnd_pestrdup(value, pers) : NULL;
- break;
- }
- case MYSQLND_OPT_SSL_CAPATH:
- {
- zend_bool pers = net->persistent;
- if (net->data->options.ssl_capath) {
- mnd_pefree(net->data->options.ssl_capath, pers);
- }
- net->data->options.ssl_capath = value? mnd_pestrdup(value, pers) : NULL;
- break;
- }
- case MYSQLND_OPT_SSL_CIPHER:
- {
- zend_bool pers = net->persistent;
- if (net->data->options.ssl_cipher) {
- mnd_pefree(net->data->options.ssl_cipher, pers);
- }
- net->data->options.ssl_cipher = value? mnd_pestrdup(value, pers) : NULL;
- break;
- }
- case MYSQLND_OPT_SSL_PASSPHRASE:
- {
- zend_bool pers = net->persistent;
- if (net->data->options.ssl_passphrase) {
- mnd_pefree(net->data->options.ssl_passphrase, pers);
- }
- net->data->options.ssl_passphrase = value? mnd_pestrdup(value, pers) : NULL;
- break;
- }
- case MYSQL_OPT_SSL_VERIFY_SERVER_CERT:
- {
- enum mysqlnd_ssl_peer val = *((enum mysqlnd_ssl_peer *)value);
- switch (val) {
- case MYSQLND_SSL_PEER_VERIFY:
- DBG_INF("MYSQLND_SSL_PEER_VERIFY");
- break;
- case MYSQLND_SSL_PEER_DONT_VERIFY:
- DBG_INF("MYSQLND_SSL_PEER_DONT_VERIFY");
- break;
- case MYSQLND_SSL_PEER_DEFAULT:
- DBG_INF("MYSQLND_SSL_PEER_DEFAULT");
- val = MYSQLND_SSL_PEER_DEFAULT;
- break;
- default:
- DBG_INF("default = MYSQLND_SSL_PEER_DEFAULT_ACTION");
- val = MYSQLND_SSL_PEER_DEFAULT;
- break;
- }
- net->data->options.ssl_verify_peer = val;
- break;
- }
- case MYSQL_OPT_READ_TIMEOUT:
- DBG_INF("MYSQL_OPT_READ_TIMEOUT");
- net->data->options.timeout_read = *(unsigned int*) value;
- break;
- case MYSQL_OPT_WRITE_TIMEOUT:
- DBG_INF("MYSQL_OPT_WRITE_TIMEOUT");
- net->data->options.timeout_write = *(unsigned int*) value;
- break;
- case MYSQL_OPT_COMPRESS:
- net->data->options.flags |= MYSQLND_NET_FLAG_USE_COMPRESSION;
- break;
- case MYSQL_SERVER_PUBLIC_KEY:
- {
- zend_bool pers = net->persistent;
- if (net->data->options.sha256_server_public_key) {
- mnd_pefree(net->data->options.sha256_server_public_key, pers);
- }
- net->data->options.sha256_server_public_key = value? mnd_pestrdup(value, pers) : NULL;
- break;
- }
- default:
- DBG_RETURN(FAIL);
- }
- DBG_RETURN(PASS);
-}
-/* }}} */
-
-/* {{{ mysqlnd_net::consume_uneaten_data */
-size_t
-MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data)(MYSQLND_NET * const net, enum php_mysqlnd_server_command cmd)
-{
-#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
- /*
- Switch to non-blocking mode and try to consume something from
- the line, if possible, then continue. This saves us from looking for
- the actual place where out-of-order packets have been sent.
- If someone is completely sure that everything is fine, he can switch it
- off.
- */
- char tmp_buf[256];
- size_t skipped_bytes = 0;
- int opt = PHP_STREAM_OPTION_BLOCKING;
- php_stream * net_stream = net->data->get_stream(net);
- int was_blocked = net_stream->ops->set_option(net_stream, opt, 0, NULL);
-
- DBG_ENTER("mysqlnd_net::consume_uneaten_data");
-
- if (PHP_STREAM_OPTION_RETURN_ERR != was_blocked) {
- /* Do a read of 1 byte */
- int bytes_consumed;
-
- do {
- skipped_bytes += (bytes_consumed = php_stream_read(net_stream, tmp_buf, sizeof(tmp_buf)));
- } while (bytes_consumed == sizeof(tmp_buf));
-
- if (was_blocked) {
- net_stream->ops->set_option(net_stream, opt, 1, NULL);
- }
-
- if (bytes_consumed) {
- DBG_ERR_FMT("Skipped %u bytes. Last command %s hasn't consumed all the output from the server",
- bytes_consumed, mysqlnd_command_to_text[net->last_command]);
- php_error_docref(NULL, E_WARNING, "Skipped %u bytes. Last command %s hasn't "
- "consumed all the output from the server",
- bytes_consumed, mysqlnd_command_to_text[net->last_command]);
- }
- }
- net->last_command = cmd;
-
- DBG_RETURN(skipped_bytes);
-#else
- return 0;
-#endif
-}
-/* }}} */
-
-/*
- in libmyusql, if cert and !key then key=cert
-*/
-/* {{{ mysqlnd_net::enable_ssl */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net)
-{
-#ifdef MYSQLND_SSL_SUPPORTED
- php_stream_context * context = php_stream_context_alloc();
- php_stream * net_stream = net->data->m.get_stream(net);
- zend_bool any_flag = FALSE;
-
- DBG_ENTER("mysqlnd_net::enable_ssl");
-
- if (net->data->options.ssl_key) {
- zval key_zval;
- ZVAL_STRING(&key_zval, net->data->options.ssl_key);
- php_stream_context_set_option(context, "ssl", "local_pk", &key_zval);
- zval_ptr_dtor(&key_zval);
- any_flag = TRUE;
- }
- if (net->data->options.ssl_cert) {
- zval cert_zval;
- ZVAL_STRING(&cert_zval, net->data->options.ssl_cert);
- php_stream_context_set_option(context, "ssl", "local_cert", &cert_zval);
- if (!net->data->options.ssl_key) {
- php_stream_context_set_option(context, "ssl", "local_pk", &cert_zval);
- }
- zval_ptr_dtor(&cert_zval);
- any_flag = TRUE;
- }
- if (net->data->options.ssl_ca) {
- zval cafile_zval;
- ZVAL_STRING(&cafile_zval, net->data->options.ssl_ca);
- php_stream_context_set_option(context, "ssl", "cafile", &cafile_zval);
- any_flag = TRUE;
- }
- if (net->data->options.ssl_capath) {
- zval capath_zval;
- ZVAL_STRING(&capath_zval, net->data->options.ssl_capath);
- php_stream_context_set_option(context, "ssl", "capath", &capath_zval);
- zval_ptr_dtor(&capath_zval);
- any_flag = TRUE;
- }
- if (net->data->options.ssl_passphrase) {
- zval passphrase_zval;
- ZVAL_STRING(&passphrase_zval, net->data->options.ssl_passphrase);
- php_stream_context_set_option(context, "ssl", "passphrase", &passphrase_zval);
- zval_ptr_dtor(&passphrase_zval);
- any_flag = TRUE;
- }
- if (net->data->options.ssl_cipher) {
- zval cipher_zval;
- ZVAL_STRING(&cipher_zval, net->data->options.ssl_cipher);
- php_stream_context_set_option(context, "ssl", "ciphers", &cipher_zval);
- zval_ptr_dtor(&cipher_zval);
- any_flag = TRUE;
- }
- {
- zval verify_peer_zval;
- zend_bool verify;
-
- if (net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_DEFAULT) {
- net->data->options.ssl_verify_peer = any_flag? MYSQLND_SSL_PEER_DEFAULT_ACTION:MYSQLND_SSL_PEER_DONT_VERIFY;
- }
-
- verify = net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_VERIFY? TRUE:FALSE;
-
- DBG_INF_FMT("VERIFY=%d", verify);
- ZVAL_BOOL(&verify_peer_zval, verify);
- php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval);
- php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval);
- if (net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_DONT_VERIFY) {
- ZVAL_TRUE(&verify_peer_zval);
- php_stream_context_set_option(context, "ssl", "allow_self_signed", &verify_peer_zval);
- }
- }
- php_stream_context_set(net_stream, context);
- if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 ||
- php_stream_xport_crypto_enable(net_stream, 1) < 0)
- {
- DBG_ERR("Cannot connect to MySQL by using SSL");
- php_error_docref(NULL, E_WARNING, "Cannot connect to MySQL by using SSL");
- DBG_RETURN(FAIL);
- }
- net->data->ssl = TRUE;
- /*
- get rid of the context. we are persistent and if this is a real pconn used by mysql/mysqli,
- then the context would not survive cleaning of EG(regular_list), where it is registered, as a
- resource. What happens is that after this destruction any use of the network will mean usage
- of the context, which means usage of already freed memory, bad. Actually we don't need this
- context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it.
- */
- php_stream_context_set(net_stream, NULL);
-
- if (net->data->options.timeout_read) {
- struct timeval tv;
- DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->data->options.timeout_read);
- tv.tv_sec = net->data->options.timeout_read;
- tv.tv_usec = 0;
- php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
- }
-
- DBG_RETURN(PASS);
-#else
- DBG_ENTER("mysqlnd_net::enable_ssl");
- DBG_INF("MYSQLND_SSL_SUPPORTED is not defined");
- DBG_RETURN(PASS);
-#endif
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::disable_ssl */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, disable_ssl)(MYSQLND_NET * const net)
-{
- DBG_ENTER("mysqlnd_net::disable_ssl");
- DBG_RETURN(PASS);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::free_contents */
-static void
-MYSQLND_METHOD(mysqlnd_net, free_contents)(MYSQLND_NET * net)
-{
- zend_bool pers = net->persistent;
- DBG_ENTER("mysqlnd_net::free_contents");
-
-#ifdef MYSQLND_COMPRESSION_ENABLED
- if (net->uncompressed_data) {
- net->uncompressed_data->free_buffer(&net->uncompressed_data);
- }
-#endif
- if (net->data->options.ssl_key) {
- mnd_pefree(net->data->options.ssl_key, pers);
- net->data->options.ssl_key = NULL;
- }
- if (net->data->options.ssl_cert) {
- mnd_pefree(net->data->options.ssl_cert, pers);
- net->data->options.ssl_cert = NULL;
- }
- if (net->data->options.ssl_ca) {
- mnd_pefree(net->data->options.ssl_ca, pers);
- net->data->options.ssl_ca = NULL;
- }
- if (net->data->options.ssl_capath) {
- mnd_pefree(net->data->options.ssl_capath, pers);
- net->data->options.ssl_capath = NULL;
- }
- if (net->data->options.ssl_cipher) {
- mnd_pefree(net->data->options.ssl_cipher, pers);
- net->data->options.ssl_cipher = NULL;
- }
- if (net->data->options.sha256_server_public_key) {
- mnd_pefree(net->data->options.sha256_server_public_key, pers);
- net->data->options.sha256_server_public_key = NULL;
- }
-
- DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::close_stream */
-static void
-MYSQLND_METHOD(mysqlnd_net, close_stream)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
-{
- php_stream * net_stream;
- DBG_ENTER("mysqlnd_net::close_stream");
- if (net && (net_stream = net->data->m.get_stream(net))) {
- zend_bool pers = net->persistent;
- DBG_INF_FMT("Freeing stream. abstract=%p", net_stream->abstract);
- if (pers) {
- if (EG(active)) {
- php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
- } else {
- /*
- otherwise we will crash because the EG(persistent_list) has been freed already,
- before the modules are shut down
- */
- php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR);
- }
- } else {
- php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE);
- }
- (void) net->data->m.set_stream(net, NULL);
- }
-
- DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::init */
-static enum_func_status
-MYSQLND_METHOD(mysqlnd_net, init)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
-{
- unsigned int buf_size;
- DBG_ENTER("mysqlnd_net::init");
-
- buf_size = MYSQLND_G(net_cmd_buffer_size); /* this is long, cast to unsigned int*/
- net->data->m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) &buf_size);
-
- buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/
- net->data->m.set_client_option(net, MYSQLND_OPT_NET_READ_BUFFER_SIZE, (char *)&buf_size);
-
- buf_size = MYSQLND_G(net_read_timeout); /* this is long, cast to unsigned int*/
- net->data->m.set_client_option(net, MYSQL_OPT_READ_TIMEOUT, (char *)&buf_size);
-
- DBG_RETURN(PASS);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::dtor */
-static void
-MYSQLND_METHOD(mysqlnd_net, dtor)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
-{
- DBG_ENTER("mysqlnd_net::dtor");
- if (net) {
- net->data->m.free_contents(net);
- net->data->m.close_stream(net, stats, error_info);
-
- if (net->cmd_buffer.buffer) {
- DBG_INF("Freeing cmd buffer");
- mnd_pefree(net->cmd_buffer.buffer, net->persistent);
- net->cmd_buffer.buffer = NULL;
- }
-
- mnd_pefree(net->data, net->data->persistent);
- mnd_pefree(net, net->persistent);
- }
- DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::get_stream */
-static php_stream *
-MYSQLND_METHOD(mysqlnd_net, get_stream)(const MYSQLND_NET * const net)
-{
- DBG_ENTER("mysqlnd_net::get_stream");
- DBG_INF_FMT("%p", net? net->data->stream:NULL);
- DBG_RETURN(net? net->data->stream:NULL);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net::set_stream */
-static php_stream *
-MYSQLND_METHOD(mysqlnd_net, set_stream)(MYSQLND_NET * const net, php_stream * net_stream)
-{
- php_stream * ret = NULL;
- DBG_ENTER("mysqlnd_net::set_stream");
- if (net) {
- net->data->stream = net_stream;
- ret = net->data->stream;
- }
- DBG_RETURN(ret);
-}
-/* }}} */
-
-
-MYSQLND_CLASS_METHODS_START(mysqlnd_net)
- MYSQLND_METHOD(mysqlnd_net, init),
- MYSQLND_METHOD(mysqlnd_net, dtor),
- MYSQLND_METHOD(mysqlnd_net, connect_ex),
- MYSQLND_METHOD(mysqlnd_net, close_stream),
- MYSQLND_METHOD(mysqlnd_net, open_pipe),
- MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix),
- MYSQLND_METHOD(mysqlnd_net, get_stream),
- MYSQLND_METHOD(mysqlnd_net, set_stream),
- MYSQLND_METHOD(mysqlnd_net, get_open_stream),
- MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt),
- MYSQLND_METHOD(mysqlnd_net, set_client_option),
- MYSQLND_METHOD(mysqlnd_net, decode),
- MYSQLND_METHOD(mysqlnd_net, encode),
- MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data),
- MYSQLND_METHOD(mysqlnd_net, free_contents),
- MYSQLND_METHOD(mysqlnd_net, enable_ssl),
- MYSQLND_METHOD(mysqlnd_net, disable_ssl),
- MYSQLND_METHOD(mysqlnd_net, network_read_ex),
- MYSQLND_METHOD(mysqlnd_net, network_write_ex),
- MYSQLND_METHOD(mysqlnd_net, send_ex),
- MYSQLND_METHOD(mysqlnd_net, receive_ex),
-#ifdef MYSQLND_COMPRESSION_ENABLED
- MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buffer),
-#else
- NULL,
-#endif
- NULL, /* unused 1 */
- NULL, /* unused 2 */
- NULL, /* unused 3 */
- NULL, /* unused 4 */
- NULL /* unused 5 */
-MYSQLND_CLASS_METHODS_END;
-
-
-/* {{{ mysqlnd_net_init */
-PHPAPI MYSQLND_NET *
-mysqlnd_net_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
-{
- MYSQLND_NET * net;
- DBG_ENTER("mysqlnd_net_init");
- net = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).get_io_channel(persistent, stats, error_info);
- DBG_RETURN(net);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_net_free */
-PHPAPI void
-mysqlnd_net_free(MYSQLND_NET * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
-{
- DBG_ENTER("mysqlnd_net_free");
- if (net) {
- net->data->m.dtor(net, stats, error_info);
- }
- DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_plugin.c b/ext/mysqlnd/mysqlnd_plugin.c
index 4c9d0a0bf5..1d19dba7e2 100644
--- a/ext/mysqlnd/mysqlnd_plugin.c
+++ b/ext/mysqlnd/mysqlnd_plugin.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -188,13 +188,3 @@ PHPAPI unsigned int mysqlnd_plugin_count()
return mysqlnd_plugins_counter;
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_plugin.h b/ext/mysqlnd/mysqlnd_plugin.h
index 7a1448faba..863bb5a476 100644
--- a/ext/mysqlnd/mysqlnd_plugin.h
+++ b/ext/mysqlnd/mysqlnd_plugin.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -29,13 +29,3 @@ void mysqlnd_register_builtin_authentication_plugins(void);
void mysqlnd_example_plugin_register(void);
#endif /* MYSQLND_PLUGIN_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h
index cb09a47915..2064906193 100644
--- a/ext/mysqlnd/mysqlnd_portability.h
+++ b/ext/mysqlnd/mysqlnd_portability.h
@@ -15,7 +15,7 @@ This file is public domain and comes with NO WARRANTY of any kind */
/* Comes from global.h as OFFSET, renamed to STRUCT_OFFSET */
-#define STRUCT_OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
+#define STRUCT_OFFSET(t, f) XtOffsetOf(t, f)
#ifndef __attribute
#if !defined(__GNUC__)
@@ -49,84 +49,19 @@ This file is public domain and comes with NO WARRANTY of any kind */
#define _LONG_LONG 1 /* For AIX string library */
#endif
-
/* Go around some bugs in different OS and compilers */
-#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
-#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */
-#define HAVE_ULONG
-#endif
-
#if SIZEOF_LONG_LONG > 4
#define HAVE_LONG_LONG 1
#endif
#ifdef PHP_WIN32
-#define MYSQLND_LLU_SPEC "%I64u"
-#define MYSQLND_LL_SPEC "%I64d"
#define MYSQLND_SZ_T_SPEC "%Id"
#ifndef L64
#define L64(x) x##i64
#endif
#else
-#if __i386__
-#define MYSQLND_LL_SPEC "%lli"
-#define MYSQLND_LLU_SPEC "%llu"
-#endif
-
-#if __ia64__
-#define MYSQLND_LL_SPEC "%li"
-#define MYSQLND_LLU_SPEC "%lu"
-#endif
-
-#if __powerpc64__ || __ppc64__
-#define MYSQLND_LL_SPEC "%li"
-#define MYSQLND_LLU_SPEC "%lu"
-#endif
-
-#if (__powerpc__ || __ppc__ ) && !(__powerpc64__ || __ppc64__)
-#define MYSQLND_LL_SPEC "%lli"
-#define MYSQLND_LLU_SPEC "%llu"
-#endif
-
-#if __x86_64__
-#define MYSQLND_LL_SPEC "%li"
-#define MYSQLND_LLU_SPEC "%lu"
-#endif
-
-#if __s390x__
-#define MYSQLND_LL_SPEC "%li"
-#define MYSQLND_LLU_SPEC "%lu"
-#endif
-
-#if __s390__ && !__s390x__
-#define MYSQLND_LL_SPEC "%lli"
-#define MYSQLND_LLU_SPEC "%llu"
-#endif
-
-#ifdef _AIX
-#define MYSQLND_LL_SPEC "%lli"
-#define MYSQLND_LLU_SPEC "%llu"
-#endif
-
-#ifndef MYSQLND_LL_SPEC
- #if SIZEOF_LONG == 8
- #define MYSQLND_LL_SPEC "%li"
- #elif SIZEOF_LONG == 4
- #define MYSQLND_LL_SPEC "%lli"
- #endif
-#endif
-
-#ifndef MYSQLND_LLU_SPEC
- #if SIZEOF_LONG == 8
- #define MYSQLND_LLU_SPEC "%lu"
- #elif SIZEOF_LONG == 4
- #define MYSQLND_LLU_SPEC "%llu"
- #endif
-#endif /* MYSQLND_LLU_SPEC*/
-
-
#define MYSQLND_SZ_T_SPEC "%zd"
#ifndef L64
#define L64(x) x##LL
@@ -256,10 +191,10 @@ typedef union {
(((uint32_t) (zend_uchar) (A)[2]) << 16) |\
(((uint32_t) (zend_uchar) (A)[1]) << 8) | \
((uint32_t) (zend_uchar) (A)[0])))
-#define sint4korr(A) (int32_t) (((int32_t) ((zend_uchar) (A)[0])) +\
- (((int32_t) ((zend_uchar) (A)[1]) << 8)) +\
- (((int32_t) ((zend_uchar) (A)[2]) << 16)) +\
- (((int32_t) ((int16_t) (A)[3]) << 24)))
+#define sint4korr(A) (int32_t) (((uint32_t) ((A)[0])) +\
+ (((uint32_t) ((A)[1]) << 8)) +\
+ (((uint32_t) ((A)[2]) << 16)) +\
+ (((uint32_t) ((A)[3]) << 24)))
#define sint8korr(A) (int64_t) uint8korr(A)
#define uint2korr(A) (uint16_t) (((uint16_t) ((zend_uchar) (A)[0])) +\
@@ -389,13 +324,3 @@ typedef union {
#endif /* float8get */
#endif /* MYSQLND_PORTABILITY_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h
index 013f51b8a0..eeec53c8d1 100644
--- a/ext/mysqlnd/mysqlnd_priv.h
+++ b/ext/mysqlnd/mysqlnd_priv.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -30,15 +30,7 @@ PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_protocol_packet_fr
PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_vio);
PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_upsert_status);
PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_error_info);
+PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_command);
enum_func_status mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * const filename, zend_bool * is_warning);
#endif /* MYSQLND_PRIV_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_protocol_frame_codec.c b/ext/mysqlnd/mysqlnd_protocol_frame_codec.c
index 4f84c02c5d..038a1eb6ad 100644
--- a/ext/mysqlnd/mysqlnd_protocol_frame_codec.c
+++ b/ext/mysqlnd/mysqlnd_protocol_frame_codec.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -68,11 +68,12 @@ MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const v
{
zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
zend_uchar * safe_storage = safe_buf;
- size_t bytes_sent, packets_sent = 1;
+ size_t packets_sent = 1;
size_t left = count;
zend_uchar * p = (zend_uchar *) buffer;
zend_uchar * compress_buf = NULL;
size_t to_be_sent;
+ ssize_t bytes_sent;
DBG_ENTER("mysqlnd_pfc::send");
DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, pfc->data->compressed);
@@ -161,7 +162,7 @@ MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const v
indeed it then loop once more, then to_be_sent will become 0, left will stay 0. Empty
packet will be sent and this loop will end.
*/
- } while (bytes_sent && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
+ } while (bytes_sent > 0 && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
DBG_INF_FMT("packet_size="MYSQLND_SZ_T_SPEC" packet_no=%u", left, pfc->data->packet_no);
@@ -175,7 +176,7 @@ MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const v
}
/* Even for zero size payload we have to send a packet */
- if (!bytes_sent) {
+ if (bytes_sent <= 0) {
DBG_ERR_FMT("Can't %u send bytes", count);
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
}
@@ -495,13 +496,3 @@ mysqlnd_pfc_free(MYSQLND_PFC * const pfc, MYSQLND_STATS * stats, MYSQLND_ERROR_I
DBG_VOID_RETURN;
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_protocol_frame_codec.h b/ext/mysqlnd/mysqlnd_protocol_frame_codec.h
index e69a61be44..abd65da708 100644
--- a/ext/mysqlnd/mysqlnd_protocol_frame_codec.h
+++ b/ext/mysqlnd/mysqlnd_protocol_frame_codec.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,12 +24,3 @@ PHPAPI MYSQLND_PFC * mysqlnd_pfc_init(const zend_bool persistent, MYSQLND_CLASS_
PHPAPI void mysqlnd_pfc_free(MYSQLND_PFC * const pfc, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
#endif /* MYSQLND_PROTOCOL_FRAME_CODEC_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index d93a5ed7b1..de4e19a402 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -122,7 +122,6 @@ MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s)
} else {
COPY_CLIENT_ERROR(conn->error_info, result->stored_data->error_info);
stmt->result->m.free_result_contents(stmt->result);
- mysqlnd_mempool_destroy(stmt->result->memory_pool);
stmt->result = NULL;
stmt->state = MYSQLND_STMT_PREPARED;
}
@@ -341,7 +340,6 @@ mysqlnd_stmt_prepare_read_eof(MYSQLND_STMT * s)
if (FAIL == (ret = PACKET_READ(conn, &fields_eof))) {
if (stmt->result) {
stmt->result->m.free_result_contents(stmt->result);
- mnd_efree(stmt->result);
/* XXX: This will crash, because we will null also the methods.
But seems it happens in extreme cases or doesn't. Should be fixed by exporting a function
(from mysqlnd_driver.c?) to do the reset.
@@ -409,7 +407,7 @@ MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const s, const char * const
enum_func_status ret = FAIL;
const MYSQLND_CSTRING query_string = {query, query_len};
- ret = conn->run_command(COM_STMT_PREPARE, conn, query_string);
+ ret = conn->command->stmt_prepare(conn, query_string);
if (FAIL == ret) {
goto fail;
}
@@ -641,39 +639,6 @@ MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, const enum_my
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
if (stmt->result && stmt->state >= MYSQLND_STMT_PREPARED && stmt->field_count) {
- /*
- We don need to copy the data from the buffers which we will clean.
- Because it has already been copied. See
- #ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
- */
-#ifdef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
- if (stmt->result_bind &&
- stmt->result_zvals_separated_once == TRUE &&
- stmt->state >= MYSQLND_STMT_USER_FETCHING)
- {
- /*
- We need to copy the data from the buffers which we will clean.
- The bound variables point to them only if the user has started
- to fetch data (MYSQLND_STMT_USER_FETCHING).
- We need to check 'result_zvals_separated_once' or we will leak
- in the following scenario
- prepare("select 1 from dual");
- execute();
- fetch(); <-- no binding, but that's not a problem
- bind_result();
- execute(); <-- here we will leak because we separate without need
- */
- unsigned int i;
- for (i = 0; i < stmt->field_count; i++) {
- if (stmt->result_bind[i].bound == TRUE) {
- zval *result = &stmt->result_bind[i].zv;
- ZVAL_DEREF(result);
- Z_TRY_ADDREF_P(result);
- }
- }
- }
-#endif
-
s->m->flush(s);
/*
@@ -719,7 +684,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, const enum_my
if (ret == PASS) {
const MYSQLND_CSTRING payload = {(const char*) request, request_len};
- ret = conn->run_command(COM_STMT_EXECUTE, conn, payload);
+ ret = conn->command->stmt_execute(conn, payload);
} else {
SET_CLIENT_ERROR(stmt->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "Couldn't generate the request. Possibly OOM.");
}
@@ -794,32 +759,11 @@ mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, const unsign
}
for (i = 0; i < result->field_count; i++) {
- zval *result = &stmt->result_bind[i].zv;
-
- ZVAL_DEREF(result);
- /* Clean what we copied last time */
-#ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
- zval_ptr_dtor(result);
-#endif
/* copy the type */
+ zval *resultzv = &stmt->result_bind[i].zv;
if (stmt->result_bind[i].bound == TRUE) {
DBG_INF_FMT("i=%u type=%u", i, Z_TYPE(current_row[i]));
- if (Z_TYPE(current_row[i]) != IS_NULL) {
- /*
- Copy the value.
- Pre-condition is that the zvals in the result_bind buffer
- have been ZVAL_NULL()-ed or to another simple type
- (int, double, bool but not string). Because of the reference
- counting the user can't delete the strings the variables point to.
- */
-
- ZVAL_COPY_VALUE(result, &current_row[i]);
-#ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
- Z_TRY_ADDREF_P(result);
-#endif
- } else {
- ZVAL_NULL(result);
- }
+ ZEND_TRY_ASSIGN_COPY_EX(resultzv, &current_row[i], 0);
}
}
}
@@ -905,28 +849,17 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
}
for (i = 0; i < field_count; i++) {
+ zval *resultzv = &stmt->result_bind[i].zv;
if (stmt->result_bind[i].bound == TRUE) {
zval *data = &result->unbuf->last_row_data[i];
- zval *result = &stmt->result_bind[i].zv;
-
- ZVAL_DEREF(result);
- /*
- stmt->result_bind[i].zv has been already destructed
- in result->unbuf->m.free_last_data()
- */
-#ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
- zval_ptr_dtor(result);
-#endif
- if (!Z_ISNULL_P(data)) {
- if ((Z_TYPE_P(data) == IS_STRING) && (meta->fields[i].max_length < (zend_ulong) Z_STRLEN_P(data))){
- meta->fields[i].max_length = Z_STRLEN_P(data);
- }
- ZVAL_COPY_VALUE(result, data);
- /* copied data, thus also the ownership. Thus null data */
- ZVAL_NULL(data);
- } else {
- ZVAL_NULL(result);
+
+ if (Z_TYPE_P(data) == IS_STRING && (meta->fields[i].max_length < (zend_ulong) Z_STRLEN_P(data))){
+ meta->fields[i].max_length = Z_STRLEN_P(data);
}
+
+ ZEND_TRY_ASSIGN_VALUE_EX(resultzv, data, 0);
+ /* copied data, thus also the ownership. Thus null data */
+ ZVAL_NULL(data);
}
}
MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF);
@@ -1058,7 +991,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, const unsigned
{
const MYSQLND_CSTRING payload = {(const char*) buf, sizeof(buf)};
- ret = conn->run_command(COM_STMT_FETCH, conn, payload);
+ ret = conn->command->stmt_fetch(conn, payload);
if (ret == FAIL) {
COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
DBG_RETURN(FAIL);
@@ -1093,33 +1026,22 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, const unsigned
/* If no result bind, do nothing. We consumed the data */
for (i = 0; i < field_count; i++) {
+ zval *resultzv = &stmt->result_bind[i].zv;
if (stmt->result_bind[i].bound == TRUE) {
zval *data = &result->unbuf->last_row_data[i];
- zval *result = &stmt->result_bind[i].zv;
-
- ZVAL_DEREF(result);
- /*
- stmt->result_bind[i].zv has been already destructed
- in result->unbuf->m.free_last_data()
- */
-#ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
- zval_ptr_dtor(result);
-#endif
+
DBG_INF_FMT("i=%u bound_var=%p type=%u refc=%u", i, &stmt->result_bind[i].zv,
Z_TYPE_P(data), Z_REFCOUNTED(stmt->result_bind[i].zv)?
Z_REFCOUNT(stmt->result_bind[i].zv) : 0);
- if (!Z_ISNULL_P(data)) {
- if ((Z_TYPE_P(data) == IS_STRING) &&
- (meta->fields[i].max_length < (zend_ulong) Z_STRLEN_P(data))) {
- meta->fields[i].max_length = Z_STRLEN_P(data);
- }
- ZVAL_COPY_VALUE(result, data);
- /* copied data, thus also the ownership. Thus null data */
- ZVAL_NULL(data);
- } else {
- ZVAL_NULL(result);
+ if (Z_TYPE_P(data) == IS_STRING &&
+ (meta->fields[i].max_length < (zend_ulong) Z_STRLEN_P(data))) {
+ meta->fields[i].max_length = Z_STRLEN_P(data);
}
+
+ ZEND_TRY_ASSIGN_VALUE_EX(resultzv, data, 0);
+ /* copied data, thus also the ownership. Thus null data */
+ ZVAL_NULL(data);
}
}
} else {
@@ -1197,28 +1119,6 @@ MYSQLND_METHOD(mysqlnd_stmt, fetch)(MYSQLND_STMT * const s, zend_bool * const fe
SET_EMPTY_ERROR(stmt->error_info);
SET_EMPTY_ERROR(conn->error_info);
- DBG_INF_FMT("result_bind=%p separated_once=%u", &stmt->result_bind, stmt->result_zvals_separated_once);
- /*
- The user might have not bound any variables for result.
- Do the binding once she does it.
- */
- if (stmt->result_bind && !stmt->result_zvals_separated_once) {
- unsigned int i;
- /*
- mysqlnd_stmt_store_result() has been called free the bind
- variables to prevent leaking of their previous content.
- */
- for (i = 0; i < stmt->result->field_count; i++) {
- if (stmt->result_bind[i].bound == TRUE) {
- zval *result = &stmt->result_bind[i].zv;
- ZVAL_DEREF(result);
- zval_ptr_dtor(result);
- ZVAL_NULL(result);
- }
- }
- stmt->result_zvals_separated_once = TRUE;
- }
-
ret = stmt->result->m.fetch_row(stmt->result, (void*)s, 0, fetched_anything);
DBG_RETURN(ret);
}
@@ -1266,7 +1166,7 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const s)
if (GET_CONNECTION_STATE(&conn->state) == CONN_READY) {
size_t stmt_id = stmt->stmt_id;
- ret = stmt->conn->run_command(COM_STMT_RESET, stmt->conn, stmt_id);
+ ret = stmt->conn->command->stmt_reset(stmt->conn, stmt_id);
if (ret == FAIL) {
COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
}
@@ -1372,7 +1272,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
{
const MYSQLND_CSTRING payload = {(const char *) cmd_buf, packet_len};
- ret = conn->run_command(COM_STMT_SEND_LONG_DATA, conn, payload);
+ ret = conn->command->stmt_send_long_data(conn, payload);
if (ret == FAIL) {
COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
}
@@ -1614,7 +1514,6 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const s,
}
mysqlnd_stmt_separate_result_bind(s);
- stmt->result_zvals_separated_once = FALSE;
stmt->result_bind = result_bind;
for (i = 0; i < stmt->field_count; i++) {
/* Prevent from freeing */
@@ -2197,9 +2096,9 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, close_on_server)(MYSQLND_STMT * const s, ze
if (GET_CONNECTION_STATE(&conn->state) == CONN_READY) {
enum_func_status ret = FAIL;
- size_t stmt_id = stmt->stmt_id;
+ const size_t stmt_id = stmt->stmt_id;
- ret = conn->run_command(COM_STMT_CLOSE, conn, stmt_id);
+ ret = conn->command->stmt_close(conn, stmt_id);
if (ret == FAIL) {
COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
DBG_RETURN(FAIL);
@@ -2376,13 +2275,3 @@ void _mysqlnd_init_ps_subsystem()
_mysqlnd_init_ps_fetch_subsystem();
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_ps.h b/ext/mysqlnd/mysqlnd_ps.h
index 36ca1227e7..fbc3d51fb7 100644
--- a/ext/mysqlnd/mysqlnd_ps.h
+++ b/ext/mysqlnd/mysqlnd_ps.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -43,12 +43,3 @@ void _mysqlnd_init_ps_fetch_subsystem();
void ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row, unsigned int byte_count);
#endif /* MYSQLND_PS_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c
index acc73334be..12edd9a284 100644
--- a/ext/mysqlnd/mysqlnd_ps_codec.c
+++ b/ext/mysqlnd/mysqlnd_ps_codec.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -79,7 +79,7 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, const u
#if SIZEOF_ZEND_LONG==4
if (uval > INT_MAX) {
DBG_INF("stringify");
- tmp_len = sprintf((char *)&tmp, MYSQLND_LLU_SPEC, uval);
+ tmp_len = sprintf((char *)&tmp, "%" PRIu64, uval);
} else
#endif /* #if SIZEOF_LONG==4 */
{
@@ -87,7 +87,7 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, const u
ZVAL_LONG(zv, (zend_long) uval); /* the cast is safe, we are in the range */
} else {
DBG_INF("stringify");
- tmp_len = sprintf((char *)&tmp, MYSQLND_LLU_SPEC, uval);
+ tmp_len = sprintf((char *)&tmp, "%" PRIu64, uval);
DBG_INF_FMT("value=%s", tmp);
}
}
@@ -109,7 +109,7 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, const u
#if SIZEOF_ZEND_LONG==4
if ((L64(2147483647) < (int64_t) lval) || (L64(-2147483648) > (int64_t) lval)) {
DBG_INF("stringify");
- tmp_len = sprintf((char *)&tmp, MYSQLND_LL_SPEC, lval);
+ tmp_len = sprintf((char *)&tmp, "%" PRIi64, lval);
} else
#endif /* SIZEOF */
{
@@ -777,7 +777,10 @@ use_string:
}
the_var = &((*copies_param)[i]);
}
- convert_to_string_ex(the_var);
+
+ if (!try_convert_to_string(the_var)) {
+ goto end;
+ }
*data_size += Z_STRLEN_P(the_var);
break;
}
@@ -973,12 +976,3 @@ mysqlnd_stmt_execute_generate_request(MYSQLND_STMT * const s, zend_uchar ** requ
DBG_RETURN(ret);
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_read_buffer.c b/ext/mysqlnd/mysqlnd_read_buffer.c
index 198764baa1..5efb9fec1f 100644
--- a/ext/mysqlnd/mysqlnd_read_buffer.c
+++ b/ext/mysqlnd/mysqlnd_read_buffer.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -85,12 +85,3 @@ mysqlnd_create_read_buffer(const size_t count)
DBG_RETURN(ret);
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_read_buffer.h b/ext/mysqlnd/mysqlnd_read_buffer.h
index 63a10945c0..d033d7b06d 100644
--- a/ext/mysqlnd/mysqlnd_read_buffer.h
+++ b/ext/mysqlnd/mysqlnd_read_buffer.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 10b4d09905..69e47759ca 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -89,7 +89,7 @@ static enum_func_status
MYSQLND_METHOD(mysqlnd_result_buffered_c, initialize_result_set_rest)(MYSQLND_RES_BUFFERED * const result,
MYSQLND_RES_METADATA * const meta,
MYSQLND_STATS * stats,
- zend_bool int_and_float_native)
+ const zend_bool int_and_float_native)
{
unsigned int row, field;
enum_func_status ret = PASS;
@@ -244,7 +244,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered, free_result)(MYSQLND_RES_BUFFERED * cons
{
DBG_ENTER("mysqlnd_result_buffered::free_result");
- DBG_INF_FMT("Freeing "MYSQLND_LLU_SPEC" row(s)", set->row_count);
+ DBG_INF_FMT("Freeing "PRIu64" row(s)", set->row_count);
mysqlnd_error_info_free_contents(&set->error_info);
@@ -301,6 +301,13 @@ void MYSQLND_METHOD(mysqlnd_res, free_result_contents_internal)(MYSQLND_RES * re
result->m.free_result_buffers(result);
+ if (result->conn) {
+ result->conn->m->free_reference(result->conn);
+ result->conn = NULL;
+ }
+
+ mysqlnd_mempool_destroy(result->memory_pool);
+
DBG_VOID_RETURN;
}
/* }}} */
@@ -311,17 +318,10 @@ static
void MYSQLND_METHOD(mysqlnd_res, free_result_internal)(MYSQLND_RES * result)
{
DBG_ENTER("mysqlnd_res::free_result_internal");
- result->m.skip_result(result);
+ result->m.skip_result(result);
result->m.free_result_contents(result);
- if (result->conn) {
- result->conn->m->free_reference(result->conn);
- result->conn = NULL;
- }
-
- mysqlnd_mempool_destroy(result->memory_pool);
-
DBG_VOID_RETURN;
}
/* }}} */
@@ -354,7 +354,8 @@ MYSQLND_METHOD(mysqlnd_res, read_result_metadata)(MYSQLND_RES * result, MYSQLND_
/* It's safe to reread without freeing */
if (FAIL == result->meta->m->read_metadata(result->meta, conn, result)) {
- result->m.free_result_contents(result);
+ result->meta->m->free_metadata(result->meta);
+ result->meta = NULL;
DBG_RETURN(FAIL);
}
/* COM_FIELD_LIST is broken and has premature EOF, thus we need to hack here and in mysqlnd_res_meta.c */
@@ -390,7 +391,9 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s)
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
if (FAIL == (ret = PACKET_READ(conn, &rset_header))) {
- php_error_docref(NULL, E_WARNING, "Error reading result set's header");
+ if (conn->error_info->error_no != CR_SERVER_GONE_ERROR) {
+ php_error_docref(NULL, E_WARNING, "Error reading result set's header");
+ }
break;
}
@@ -514,7 +517,6 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s)
if (FAIL == (ret = PACKET_READ(conn, &fields_eof))) {
DBG_ERR("Error occurred while reading the EOF packet");
result->m.free_result_contents(result);
- mysqlnd_mempool_destroy(result->memory_pool);
if (!stmt) {
conn->current_result = NULL;
} else {
@@ -568,9 +570,9 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s)
completeness.
*/
static const size_t *
-MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_lengths)(MYSQLND_RES_BUFFERED * const result)
+MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_lengths)(const MYSQLND_RES_BUFFERED * const result)
{
- const MYSQLND_RES_BUFFERED_ZVAL * set = (MYSQLND_RES_BUFFERED_ZVAL *) result;
+ const MYSQLND_RES_BUFFERED_ZVAL * const set = (const MYSQLND_RES_BUFFERED_ZVAL *) result;
/*
If:
- unbuffered result
@@ -600,9 +602,9 @@ MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_lengths)(MYSQLND_RES_BUFFERED
completeness.
*/
static const size_t *
-MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_lengths)(MYSQLND_RES_BUFFERED * const result)
+MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_lengths)(const MYSQLND_RES_BUFFERED * const result)
{
- const MYSQLND_RES_BUFFERED_C * set = (MYSQLND_RES_BUFFERED_C *) result;
+ const MYSQLND_RES_BUFFERED_C * const set = (const MYSQLND_RES_BUFFERED_C *) result;
DBG_ENTER("mysqlnd_result_buffered_c::fetch_lengths");
if (set->current_row > set->row_count || set->current_row == 0) {
@@ -617,7 +619,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_lengths)(MYSQLND_RES_BUFFERED *
/* {{{ mysqlnd_result_unbuffered::fetch_lengths */
static const size_t *
-MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_lengths)(MYSQLND_RES_UNBUFFERED * const result)
+MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_lengths)(const MYSQLND_RES_UNBUFFERED * const result)
{
/* simulate output of libmysql */
return (result->last_row_data || result->eof_reached)? result->lengths : NULL;
@@ -627,7 +629,7 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_lengths)(MYSQLND_RES_UNBUFFERED
/* {{{ mysqlnd_res::fetch_lengths */
static const size_t *
-MYSQLND_METHOD(mysqlnd_res, fetch_lengths)(MYSQLND_RES * const result)
+MYSQLND_METHOD(mysqlnd_res, fetch_lengths)(const MYSQLND_RES * const result)
{
const size_t * ret;
DBG_ENTER("mysqlnd_res::fetch_lengths");
@@ -958,12 +960,12 @@ oom:
/* {{{ mysqlnd_result_buffered::fetch_row_c */
static enum_func_status
-MYSQLND_METHOD(mysqlnd_result_buffered, fetch_row_c)(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything)
+MYSQLND_METHOD(mysqlnd_result_buffered, fetch_row_c)(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * const fetched_anything)
{
enum_func_status ret = FAIL;
MYSQLND_ROW_C * row = (MYSQLND_ROW_C *) param;
const MYSQLND_RES_METADATA * const meta = result->meta;
- unsigned int field_count = meta->field_count;
+ const unsigned int field_count = meta->field_count;
MYSQLND_CONN_DATA * const conn = result->conn;
DBG_ENTER("mysqlnd_result_buffered::fetch_row_c");
@@ -1051,7 +1053,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered, fetch_row_c)(MYSQLND_RES * result, void
/* {{{ mysqlnd_result_buffered_zval::fetch_row */
static enum_func_status
-MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_row)(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * fetched_anything)
+MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_row)(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * const fetched_anything)
{
enum_func_status ret = FAIL;
zval * row = (zval *) param;
@@ -1823,7 +1825,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, const unsigned int
/* {{{ mysqlnd_res::fetch_field_data */
static void
-MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES * result, unsigned int offset, zval *return_value)
+MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES * result, const unsigned int offset, zval *return_value)
{
zval row;
zval *entry;
@@ -2050,13 +2052,3 @@ mysqlnd_result_buffered_c_init(MYSQLND_RES * result, const unsigned int field_co
DBG_RETURN(ret);
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_result.h b/ext/mysqlnd/mysqlnd_result.h
index b8b919d942..9df70271bc 100644
--- a/ext/mysqlnd/mysqlnd_result.h
+++ b/ext/mysqlnd/mysqlnd_result.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -28,12 +28,3 @@ PHPAPI MYSQLND_RES_BUFFERED_C * mysqlnd_result_buffered_c_init(MYSQLND_RES * res
enum_func_status mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * stmt);
#endif /* MYSQLND_RESULT_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c
index 0141cec4f0..9a8b8d72ee 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.c
+++ b/ext/mysqlnd/mysqlnd_result_meta.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -330,12 +330,3 @@ _mysqlnd_plugin_get_plugin_result_metadata_data(const MYSQLND_RES_METADATA * met
DBG_RETURN((void *)((char *)meta + sizeof(MYSQLND_RES_METADATA) + plugin_id * sizeof(void *)));
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_result_meta.h b/ext/mysqlnd/mysqlnd_result_meta.h
index 09af69837e..f35b6c890e 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.h
+++ b/ext/mysqlnd/mysqlnd_result_meta.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -26,12 +26,3 @@ PHPAPI struct st_mysqlnd_res_meta_methods * mysqlnd_result_metadata_get_methods(
PHPAPI void ** _mysqlnd_plugin_get_plugin_result_metadata_data(const MYSQLND_RES_METADATA * meta, unsigned int plugin_id);
#endif /* MYSQLND_RESULT_META_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_reverse_api.c b/ext/mysqlnd/mysqlnd_reverse_api.c
index 931c3b26e2..25175e9b03 100644
--- a/ext/mysqlnd/mysqlnd_reverse_api.c
+++ b/ext/mysqlnd/mysqlnd_reverse_api.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -99,13 +99,3 @@ zval_to_mysqlnd(zval * zv, const unsigned int client_api_capabilities, unsigned
return NULL;
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_reverse_api.h b/ext/mysqlnd/mysqlnd_reverse_api.h
index 448f33bfea..3311086bfa 100644
--- a/ext/mysqlnd/mysqlnd_reverse_api.h
+++ b/ext/mysqlnd/mysqlnd_reverse_api.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -36,12 +36,3 @@ PHPAPI void mysqlnd_reverse_api_register_api(const MYSQLND_REVERSE_API * apiext)
PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int client_api_capabilities, unsigned int * save_client_api_capabilities);
#endif /* MYSQLND_REVERSE_API_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c
index f3069b580f..2058441254 100644
--- a/ext/mysqlnd/mysqlnd_statistics.c
+++ b/ext/mysqlnd/mysqlnd_statistics.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -205,7 +205,7 @@ mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING
for (i = 0; i < stats->count; i++) {
char tmp[25];
- sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]);
+ sprintf((char *)&tmp, "%" PRIu64, stats->values[i]);
add_assoc_string_ex(return_value, names[i].s, names[i].l, tmp);
}
}
@@ -292,14 +292,3 @@ _mysqlnd_get_client_stats(MYSQLND_STATS * stats_ptr, zval *return_value ZEND_FIL
DBG_VOID_RETURN;
}
/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_statistics.h b/ext/mysqlnd/mysqlnd_statistics.h
index 869c24a56e..5626fbffe6 100644
--- a/ext/mysqlnd/mysqlnd_statistics.h
+++ b/ext/mysqlnd/mysqlnd_statistics.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -119,12 +119,3 @@ PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger(MYSQLND_STATS * const stat
PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers(MYSQLND_STATS * const stats);
#endif /* MYSQLND_STATISTICS_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index a7c892b48d..fcd3bc2f39 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -174,6 +174,12 @@ typedef struct st_mysqlnd_infile_info
} MYSQLND_INFILE_INFO;
+typedef int (*func_mysqlnd_local_infile__init)(void ** ptr, const char * const filename);
+typedef int (*func_mysqlnd_local_infile__read)(void * ptr, zend_uchar * buf, unsigned int buf_len);
+typedef int (*func_mysqlnd_local_infile__error)(void * ptr, char * error_msg, unsigned int error_msg_len);
+typedef void (*func_mysqlnd_local_infile__end)(void * ptr);
+
+
/* character set information */
typedef struct st_mysqlnd_charset
{
@@ -183,23 +189,24 @@ typedef struct st_mysqlnd_charset
unsigned int char_minlen;
unsigned int char_maxlen;
const char *comment;
- unsigned int (*mb_charlen)(unsigned int c);
- unsigned int (*mb_valid)(const char *start, const char *end);
+ unsigned int (*mb_charlen)(const unsigned int c);
+ unsigned int (*mb_valid)(const char * const start, const char * const end);
} MYSQLND_CHARSET;
/* local infile handler */
typedef struct st_mysqlnd_infile
{
- int (*local_infile_init)(void **ptr, const char * const filename);
- int (*local_infile_read)(void *ptr, zend_uchar * buf, unsigned int buf_len);
- int (*local_infile_error)(void *ptr, char * error_msg, unsigned int error_msg_len);
- void (*local_infile_end)(void *ptr);
+ func_mysqlnd_local_infile__init local_infile_init;
+ func_mysqlnd_local_infile__read local_infile_read;
+ func_mysqlnd_local_infile__error local_infile_error;
+ func_mysqlnd_local_infile__end local_infile_end;
} MYSQLND_INFILE;
+
typedef struct st_mysqlnd_session_options
{
- ulong flags;
+ unsigned int flags;
/* init commands - we need to send them to server directly after connect */
unsigned int num_commands;
@@ -224,7 +231,7 @@ typedef struct st_mysqlnd_session_options
char *charset_name;
/* maximum allowed packet size for communication */
- ulong max_allowed_packet;
+ unsigned int max_allowed_packet;
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
zend_bool int_and_float_native;
@@ -309,6 +316,54 @@ struct st_mysqlnd_stats
};
+typedef enum_func_status (*func_mysqlnd_execute_com_set_option)(MYSQLND_CONN_DATA * const conn, const enum_mysqlnd_server_option option);
+typedef enum_func_status (*func_mysqlnd_execute_com_debug)(MYSQLND_CONN_DATA * const conn);
+typedef enum_func_status (*func_mysqlnd_execute_com_init_db)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING db);
+typedef enum_func_status (*func_mysqlnd_execute_com_ping)(MYSQLND_CONN_DATA * const conn);
+typedef enum_func_status (*func_mysqlnd_execute_com_statistics)(MYSQLND_CONN_DATA * const conn, zend_string ** message);
+typedef enum_func_status (*func_mysqlnd_execute_com_process_kill)(MYSQLND_CONN_DATA * const conn, const unsigned int process_id, const zend_bool read_response);
+typedef enum_func_status (*func_mysqlnd_execute_com_refresh)(MYSQLND_CONN_DATA * const conn, const uint8_t options);
+typedef enum_func_status (*func_mysqlnd_execute_com_shutdown)(MYSQLND_CONN_DATA * const conn, const uint8_t level);
+typedef enum_func_status (*func_mysqlnd_execute_com_quit)(MYSQLND_CONN_DATA * const conn);
+typedef enum_func_status (*func_mysqlnd_execute_com_query)(MYSQLND_CONN_DATA * const conn, MYSQLND_CSTRING query);
+typedef enum_func_status (*func_mysqlnd_execute_com_change_user)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload, const zend_bool silent);
+typedef enum_func_status (*func_mysqlnd_execute_com_reap_result)(MYSQLND_CONN_DATA * const conn);
+typedef enum_func_status (*func_mysqlnd_execute_com_stmt_prepare)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING query);
+typedef enum_func_status (*func_mysqlnd_execute_com_stmt_execute)(MYSQLND_CONN_DATA * conn, const MYSQLND_CSTRING payload);
+typedef enum_func_status (*func_mysqlnd_execute_com_stmt_fetch)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload);
+typedef enum_func_status (*func_mysqlnd_execute_com_stmt_reset)(MYSQLND_CONN_DATA * const conn, const zend_ulong stmt_id);
+typedef enum_func_status (*func_mysqlnd_execute_com_stmt_send_long_data)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload);
+typedef enum_func_status (*func_mysqlnd_execute_com_stmt_close)(MYSQLND_CONN_DATA * const conn, const zend_ulong stmt_id);
+typedef enum_func_status (*func_mysqlnd_execute_com_enable_ssl)(MYSQLND_CONN_DATA * const conn, const size_t client_capabilities, const size_t server_capabilities, const unsigned int charset_no);
+typedef enum_func_status (*func_mysqlnd_execute_com_handshake)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING username, const MYSQLND_CSTRING password, const MYSQLND_CSTRING database, const size_t client_flags);
+
+
+MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command)
+{
+ func_mysqlnd_execute_com_set_option set_option;
+ func_mysqlnd_execute_com_debug debug;
+ func_mysqlnd_execute_com_init_db init_db;
+ func_mysqlnd_execute_com_ping ping;
+ func_mysqlnd_execute_com_statistics statistics;
+ func_mysqlnd_execute_com_process_kill process_kill;
+ func_mysqlnd_execute_com_refresh refresh;
+ func_mysqlnd_execute_com_shutdown shutdown;
+ func_mysqlnd_execute_com_quit quit;
+ func_mysqlnd_execute_com_query query;
+ func_mysqlnd_execute_com_change_user change_user;
+ func_mysqlnd_execute_com_reap_result reap_result;
+ func_mysqlnd_execute_com_stmt_prepare stmt_prepare;
+ func_mysqlnd_execute_com_stmt_execute stmt_execute;
+ func_mysqlnd_execute_com_stmt_fetch stmt_fetch;
+ func_mysqlnd_execute_com_stmt_reset stmt_reset;
+ func_mysqlnd_execute_com_stmt_send_long_data stmt_send_long_data;
+ func_mysqlnd_execute_com_stmt_close stmt_close;
+ func_mysqlnd_execute_com_enable_ssl enable_ssl;
+ func_mysqlnd_execute_com_handshake handshake;
+};
+
+
+
typedef enum_func_status (*func_mysqlnd_vio__init)(MYSQLND_VIO * const vio, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info);
typedef void (*func_mysqlnd_vio__dtor)(MYSQLND_VIO * const vio, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info);
@@ -327,7 +382,7 @@ typedef void (*func_mysqlnd_vio__post_connect_set_opt)(MYSQLND_VIO * const vi
typedef enum_func_status (*func_mysqlnd_vio__enable_ssl)(MYSQLND_VIO * const vio);
typedef enum_func_status (*func_mysqlnd_vio__disable_ssl)(MYSQLND_VIO * const vio);
typedef enum_func_status (*func_mysqlnd_vio__network_read)(MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info);
-typedef size_t (*func_mysqlnd_vio__network_write)(MYSQLND_VIO * const vio, const zend_uchar * const buf, const size_t count, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info);
+typedef ssize_t (*func_mysqlnd_vio__network_write)(MYSQLND_VIO * const vio, const zend_uchar * const buf, const size_t count, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info);
typedef size_t (*func_mysqlnd_vio__consume_uneaten_data)(MYSQLND_VIO * const vio, enum php_mysqlnd_server_command cmd);
@@ -584,8 +639,8 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn)
/* for decoding - binary or text protocol */
typedef enum_func_status (*func_mysqlnd_res__row_decoder)(MYSQLND_ROW_BUFFER * row_buffer, zval * fields,
- unsigned int field_count, const MYSQLND_FIELD * fields_metadata,
- zend_bool as_int_or_float, MYSQLND_STATS * stats);
+ const unsigned int field_count, const MYSQLND_FIELD * const fields_metadata,
+ const zend_bool as_int_or_float, MYSQLND_STATS * const stats);
typedef MYSQLND_RES * (*func_mysqlnd_res__use_result)(MYSQLND_RES * const result, const zend_bool ps_protocol);
@@ -593,7 +648,7 @@ typedef MYSQLND_RES * (*func_mysqlnd_res__store_result)(MYSQLND_RES * result, M
typedef void (*func_mysqlnd_res__fetch_into)(MYSQLND_RES *result, const unsigned int flags, zval *return_value, enum_mysqlnd_extension ext ZEND_FILE_LINE_DC);
typedef MYSQLND_ROW_C (*func_mysqlnd_res__fetch_row_c)(MYSQLND_RES *result);
typedef void (*func_mysqlnd_res__fetch_all)(MYSQLND_RES *result, const unsigned int flags, zval *return_value ZEND_FILE_LINE_DC);
-typedef void (*func_mysqlnd_res__fetch_field_data)(MYSQLND_RES *result, unsigned int offset, zval *return_value);
+typedef void (*func_mysqlnd_res__fetch_field_data)(MYSQLND_RES *result, const unsigned int offset, zval *return_value);
typedef uint64_t (*func_mysqlnd_res__num_rows)(const MYSQLND_RES * const result);
typedef unsigned int (*func_mysqlnd_res__num_fields)(const MYSQLND_RES * const result);
typedef enum_func_status (*func_mysqlnd_res__skip_result)(MYSQLND_RES * const result);
@@ -605,7 +660,7 @@ typedef const MYSQLND_FIELD *(*func_mysqlnd_res__fetch_field_direct)(MYSQLND_RES
typedef const MYSQLND_FIELD *(*func_mysqlnd_res__fetch_fields)(MYSQLND_RES * const result);
typedef enum_func_status (*func_mysqlnd_res__read_result_metadata)(MYSQLND_RES * result, MYSQLND_CONN_DATA * conn);
-typedef const size_t * (*func_mysqlnd_res__fetch_lengths)(MYSQLND_RES * const result);
+typedef const size_t * (*func_mysqlnd_res__fetch_lengths)(const MYSQLND_RES * const result);
typedef enum_func_status (*func_mysqlnd_res__store_result_fetch_data)(MYSQLND_CONN_DATA * const conn, MYSQLND_RES * result, MYSQLND_RES_METADATA * meta, MYSQLND_ROW_BUFFER ** row_buffers, zend_bool binary_protocol);
typedef void (*func_mysqlnd_res__free_result_buffers)(MYSQLND_RES * result); /* private */
@@ -656,7 +711,7 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res)
typedef uint64_t (*func_mysqlnd_result_unbuffered__num_rows)(const MYSQLND_RES_UNBUFFERED * const result);
-typedef const size_t * (*func_mysqlnd_result_unbuffered__fetch_lengths)(MYSQLND_RES_UNBUFFERED * const result);
+typedef const size_t * (*func_mysqlnd_result_unbuffered__fetch_lengths)(const MYSQLND_RES_UNBUFFERED * const result);
typedef void (*func_mysqlnd_result_unbuffered__free_last_data)(MYSQLND_RES_UNBUFFERED * result, MYSQLND_STATS * const global_stats);
typedef void (*func_mysqlnd_result_unbuffered__free_result)(MYSQLND_RES_UNBUFFERED * const result, MYSQLND_STATS * const global_stats);
@@ -672,8 +727,8 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_unbuffered)
typedef uint64_t (*func_mysqlnd_result_buffered__num_rows)(const MYSQLND_RES_BUFFERED * const result);
typedef enum_func_status (*func_mysqlnd_result_buffered__initialize_result_set_rest)(MYSQLND_RES_BUFFERED * const result, MYSQLND_RES_METADATA * const meta,
- MYSQLND_STATS * stats, zend_bool int_and_float_native);
-typedef const size_t * (*func_mysqlnd_result_buffered__fetch_lengths)(MYSQLND_RES_BUFFERED * const result);
+ MYSQLND_STATS * stats, const zend_bool int_and_float_native);
+typedef const size_t * (*func_mysqlnd_result_buffered__fetch_lengths)(const MYSQLND_RES_BUFFERED * const result);
typedef enum_func_status (*func_mysqlnd_result_buffered__data_seek)(MYSQLND_RES_BUFFERED * const result, const uint64_t row);
typedef void (*func_mysqlnd_result_buffered__free_result)(MYSQLND_RES_BUFFERED * const result);
@@ -841,10 +896,6 @@ struct st_mysqlnd_vio
-typedef enum_func_status (*func_mysqlnd__run_command)(enum php_mysqlnd_server_command command, ...);
-
-
-
typedef struct st_mysqlnd_connection_state MYSQLND_CONNECTION_STATE;
typedef enum mysqlnd_connection_state (*func_mysqlnd_connection_state__get)(const MYSQLND_CONNECTION_STATE * const state_struct);
typedef void (*func_mysqlnd_connection_state__set)(MYSQLND_CONNECTION_STATE * const state_struct, const enum mysqlnd_connection_state state);
@@ -929,8 +980,7 @@ struct st_mysqlnd_connection_data
zend_bool in_async_err_cb;
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) object_factory;
- func_mysqlnd__run_command run_command;
-
+ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * command;
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data) * m;
/* persistent connection */
@@ -963,6 +1013,7 @@ struct st_mysqlnd_packet_chg_user_resp;
struct st_mysqlnd_packet_auth_pam;
struct st_mysqlnd_packet_sha256_pk_request;
struct st_mysqlnd_packet_sha256_pk_request_response;
+struct st_mysqlnd_packet_cached_sha2_result;
typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_greet_packet)(struct st_mysqlnd_packet_greet *packet);
typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_auth_packet)(struct st_mysqlnd_packet_auth *packet);
@@ -979,6 +1030,7 @@ typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_prepare_respo
typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_change_user_response_packet)(struct st_mysqlnd_packet_chg_user_resp *packet);
typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_packet)(struct st_mysqlnd_packet_sha256_pk_request *packet);
typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_response_packet)(struct st_mysqlnd_packet_sha256_pk_request_response *packet);
+typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_cached_sha2_result_packet)(struct st_mysqlnd_packet_cached_sha2_result *packet);
typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command)(
MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory,
@@ -1034,6 +1086,7 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory)
func_mysqlnd_protocol_payload_decoder_factory__init_change_user_response_packet init_change_user_response_packet;
func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_packet init_sha256_pk_request_packet;
func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_response_packet init_sha256_pk_request_response_packet;
+ func_mysqlnd_protocol_payload_decoder_factory__init_cached_sha2_result_packet init_cached_sha2_result_packet;
func_mysqlnd_protocol_payload_decoder_factory__send_command send_command;
func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response;
@@ -1256,7 +1309,6 @@ struct st_mysqlnd_stmt_data
unsigned char send_types_to_server;
MYSQLND_PARAM_BIND *param_bind;
MYSQLND_RESULT_BIND *result_bind;
- zend_bool result_zvals_separated_once;
MYSQLND_UPSERT_STATUS * upsert_status;
MYSQLND_UPSERT_STATUS upsert_status_impl;
@@ -1328,14 +1380,24 @@ typedef zend_uchar * (*func_auth_plugin__get_auth_data)(struct st_mysqlnd_authen
MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
const MYSQLND_SESSION_OPTIONS * const session_options,
- const MYSQLND_PFC_DATA * const pfc_data, zend_ulong mysql_flags
+ const MYSQLND_PFC_DATA * const pfc_data, const zend_ulong mysql_flags
);
+typedef enum_func_status (*func_auth_plugin__handle_server_response)(struct st_mysqlnd_authentication_plugin * self,
+ MYSQLND_CONN_DATA * conn,
+ const zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
+ const char * const passwd,
+ const size_t passwd_len,
+ char **new_auth_protocol, size_t *new_auth_protocol_len,
+ zend_uchar **new_auth_protocol_data, size_t *new_auth_protocol_data_len
+ );
+
struct st_mysqlnd_authentication_plugin
{
struct st_mysqlnd_plugin_header plugin_header;
struct {
func_auth_plugin__get_auth_data get_auth_data;
+ func_auth_plugin__handle_server_response handle_server_response;
} methods;
};
diff --git a/ext/mysqlnd/mysqlnd_vio.c b/ext/mysqlnd/mysqlnd_vio.c
index 50db782be6..a5685e6707 100644
--- a/ext/mysqlnd/mysqlnd_vio.c
+++ b/ext/mysqlnd/mysqlnd_vio.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -79,14 +79,15 @@ MYSQLND_METHOD(mysqlnd_vio, network_read)(MYSQLND_VIO * const vio, zend_uchar *
{
enum_func_status return_value = PASS;
php_stream * net_stream = vio->data->m.get_stream(vio);
- size_t to_read = count, ret;
+ size_t to_read = count;
zend_uchar * p = buffer;
DBG_ENTER("mysqlnd_vio::network_read");
DBG_INF_FMT("count="MYSQLND_SZ_T_SPEC, count);
while (to_read) {
- if (!(ret = php_stream_read(net_stream, (char *) p, to_read))) {
+ ssize_t ret = php_stream_read(net_stream, (char *) p, to_read);
+ if (ret <= 0) {
DBG_ERR_FMT("Error while reading header from socket");
return_value = FAIL;
break;
@@ -101,11 +102,11 @@ MYSQLND_METHOD(mysqlnd_vio, network_read)(MYSQLND_VIO * const vio, zend_uchar *
/* {{{ mysqlnd_vio::network_write */
-static size_t
+static ssize_t
MYSQLND_METHOD(mysqlnd_vio, network_write)(MYSQLND_VIO * const vio, const zend_uchar * const buffer, const size_t count,
MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
{
- size_t ret;
+ ssize_t ret;
DBG_ENTER("mysqlnd_vio::network_write");
DBG_INF_FMT("sending %u bytes", count);
ret = php_stream_write(vio->data->m.get_stream(vio), (char *)buffer, count);
@@ -451,10 +452,14 @@ MYSQLND_METHOD(mysqlnd_vio, consume_uneaten_data)(MYSQLND_VIO * const net, enum
if (PHP_STREAM_OPTION_RETURN_ERR != was_blocked) {
/* Do a read of 1 byte */
- int bytes_consumed;
+ ssize_t bytes_consumed;
do {
- skipped_bytes += (bytes_consumed = php_stream_read(net_stream, tmp_buf, sizeof(tmp_buf)));
+ bytes_consumed = php_stream_read(net_stream, tmp_buf, sizeof(tmp_buf));
+ if (bytes_consumed <= 0) {
+ break;
+ }
+ skipped_bytes += bytes_consumed;
} while (bytes_consumed == sizeof(tmp_buf));
if (was_blocked) {
@@ -644,18 +649,17 @@ MYSQLND_METHOD(mysqlnd_vio, close_stream)(MYSQLND_VIO * const net, MYSQLND_STATS
if (net && (net_stream = net->data->m.get_stream(net))) {
zend_bool pers = net->persistent;
DBG_INF_FMT("Freeing stream. abstract=%p", net_stream->abstract);
- if (pers) {
- if (EG(active)) {
- php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
- } else {
- /*
- otherwise we will crash because the EG(persistent_list) has been freed already,
- before the modules are shut down
- */
- php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR);
- }
+ /* We removed the resource from the stream, so pass FREE_RSRC_DTOR now to force
+ * destruction to occur during shutdown, because it won't happen through the resource. */
+ /* TODO: The EG(active) check here is dead -- check IN_SHUTDOWN? */
+ if (pers && EG(active)) {
+ php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
} else {
- php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE);
+ /*
+ otherwise we will crash because the EG(persistent_list) has been freed already,
+ before the modules are shut down
+ */
+ php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR);
}
net->data->m.set_stream(net, NULL);
}
@@ -789,13 +793,3 @@ mysqlnd_vio_free(MYSQLND_VIO * const vio, MYSQLND_STATS * stats, MYSQLND_ERROR_I
DBG_VOID_RETURN;
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_vio.h b/ext/mysqlnd/mysqlnd_vio.h
index b0f6d85589..93038bd8bb 100644
--- a/ext/mysqlnd/mysqlnd_vio.h
+++ b/ext/mysqlnd/mysqlnd_vio.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,12 +24,3 @@ PHPAPI MYSQLND_VIO * mysqlnd_vio_init(zend_bool persistent, MYSQLND_CLASS_METHOD
PHPAPI void mysqlnd_vio_free(MYSQLND_VIO * const vio, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
#endif /* MYSQLND_VIO_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index 6459fe4964..b9a91c900e 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -287,7 +287,8 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
MYSQLND_STATS * stats,
MYSQLND_ERROR_INFO * error_info,
MYSQLND_CONNECTION_STATE * connection_state,
- zend_uchar * buf, size_t buf_size, const char * const packet_type_as_text,
+ zend_uchar * const buf, const size_t buf_size,
+ const char * const packet_type_as_text,
enum mysqlnd_packet_type packet_type)
{
DBG_ENTER("mysqlnd_read_packet_header_and_body");
@@ -295,7 +296,6 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
if (FAIL == mysqlnd_read_header(pfc, vio, packet_header, stats, error_info)) {
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
- php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
DBG_ERR_FMT("Can't read %s's header", packet_type_as_text);
DBG_RETURN(FAIL);
}
@@ -307,7 +307,6 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
if (FAIL == pfc->data->m.receive(pfc, vio, buf, packet_header->size, stats, error_info)) {
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
- php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
DBG_ERR_FMT("Empty '%s' packet body", packet_type_as_text);
DBG_RETURN(FAIL);
}
@@ -620,10 +619,14 @@ size_t php_mysqlnd_auth_write(MYSQLND_CONN_DATA * conn, void * _packet)
const MYSQLND_CSTRING payload = {(char*) buffer + MYSQLND_HEADER_SIZE, p - (buffer + MYSQLND_HEADER_SIZE)};
const unsigned int silent = packet->silent;
- ret = conn->run_command(COM_CHANGE_USER, conn, payload, silent);
+ ret = conn->command->change_user(conn, payload, silent);
DBG_RETURN(ret == PASS? (p - buffer - MYSQLND_HEADER_SIZE) : 0);
} else {
- size_t sent = pfc->data->m.send(pfc, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
+ /*
+ The auth handshake packet has no command in it. Thus we can't go over conn->command directly.
+ Well, we can have a command->no_command(conn, payload)
+ */
+ const size_t sent = pfc->data->m.send(pfc, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
if (!sent) {
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
}
@@ -768,7 +771,7 @@ php_mysqlnd_change_auth_response_write(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_VIO * vio = conn->vio;
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
- zend_uchar * buffer = pfc->cmd_buffer.length >= packet->auth_data_len? pfc->cmd_buffer.buffer : mnd_emalloc(packet->auth_data_len);
+ zend_uchar * const buffer = pfc->cmd_buffer.length >= packet->auth_data_len? pfc->cmd_buffer.buffer : mnd_emalloc(packet->auth_data_len);
zend_uchar * p = buffer + MYSQLND_HEADER_SIZE; /* start after the header */
DBG_ENTER("php_mysqlnd_change_auth_response_write");
@@ -779,7 +782,11 @@ php_mysqlnd_change_auth_response_write(MYSQLND_CONN_DATA * conn, void * _packet)
}
{
- size_t sent = pfc->data->m.send(pfc, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
+ /*
+ The auth handshake packet has no command in it. Thus we can't go over conn->command directly.
+ Well, we can have a command->no_command(conn, payload)
+ */
+ const size_t sent = pfc->data->m.send(pfc, vio, buffer, p - buffer - MYSQLND_HEADER_SIZE, stats, error_info);
if (buffer != pfc->cmd_buffer.buffer) {
mnd_efree(buffer);
}
@@ -805,8 +812,8 @@ php_mysqlnd_ok_read(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
zend_uchar local_buf[OK_BUFFER_SIZE];
- size_t buf_len = pfc->cmd_buffer.buffer? pfc->cmd_buffer.length : OK_BUFFER_SIZE;
- zend_uchar * buf = pfc->cmd_buffer.buffer? (zend_uchar *) pfc->cmd_buffer.buffer : local_buf;
+ const size_t buf_len = pfc->cmd_buffer.buffer? pfc->cmd_buffer.length : OK_BUFFER_SIZE;
+ zend_uchar * const buf = pfc->cmd_buffer.buffer? (zend_uchar *) pfc->cmd_buffer.buffer : local_buf;
const zend_uchar * p = buf;
const zend_uchar * const begin = buf;
zend_ulong net_len;
@@ -899,8 +906,8 @@ php_mysqlnd_eof_read(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_VIO * vio = conn->vio;
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
- size_t buf_len = pfc->cmd_buffer.length;
- zend_uchar * buf = (zend_uchar *) pfc->cmd_buffer.buffer;
+ const size_t buf_len = pfc->cmd_buffer.length;
+ zend_uchar * const buf = (zend_uchar *) pfc->cmd_buffer.buffer;
const zend_uchar * p = buf;
const zend_uchar * const begin = buf;
@@ -967,7 +974,7 @@ size_t php_mysqlnd_cmd_write(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_VIO * vio = conn->vio;
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
- unsigned int error_reporting = EG(error_reporting);
+ const unsigned int error_reporting = EG(error_reporting);
size_t sent = 0;
DBG_ENTER("php_mysqlnd_cmd_write");
@@ -1036,8 +1043,8 @@ php_mysqlnd_rset_header_read(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
enum_func_status ret = PASS;
- size_t buf_len = pfc->cmd_buffer.length;
- zend_uchar * buf = (zend_uchar *) pfc->cmd_buffer.buffer;
+ const size_t buf_len = pfc->cmd_buffer.length;
+ zend_uchar * const buf = (zend_uchar *) pfc->cmd_buffer.buffer;
const zend_uchar * p = buf;
const zend_uchar * const begin = buf;
size_t len;
@@ -1177,8 +1184,9 @@ php_mysqlnd_rset_field_read(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_VIO * vio = conn->vio;
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
- size_t buf_len = pfc->cmd_buffer.length, total_len = 0;
- zend_uchar * buf = (zend_uchar *) pfc->cmd_buffer.buffer;
+ const size_t buf_len = pfc->cmd_buffer.length;
+ size_t total_len = 0;
+ zend_uchar * const buf = (zend_uchar *) pfc->cmd_buffer.buffer;
const zend_uchar * p = buf;
const zend_uchar * const begin = buf;
char *root_ptr;
@@ -1355,7 +1363,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
MYSQLND_ERROR_INFO * error_info,
MYSQLND_MEMORY_POOL * pool,
MYSQLND_ROW_BUFFER * buffer,
- size_t * data_size)
+ size_t * const data_size)
{
enum_func_status ret = PASS;
MYSQLND_PACKET_HEADER header;
@@ -1435,8 +1443,8 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
/* {{{ php_mysqlnd_rowp_read_binary_protocol */
enum_func_status
php_mysqlnd_rowp_read_binary_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fields,
- unsigned int field_count, const MYSQLND_FIELD * fields_metadata,
- zend_bool as_int_or_float, MYSQLND_STATS * stats)
+ const unsigned int field_count, const MYSQLND_FIELD * const fields_metadata,
+ const zend_bool as_int_or_float, MYSQLND_STATS * const stats)
{
unsigned int i;
const zend_uchar * p = row_buffer->ptr;
@@ -1532,7 +1540,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
unsigned int i;
zval *current_field, *end_field, *start_field;
zend_uchar * p = row_buffer->ptr;
- size_t data_size = row_buffer->size;
+ const size_t data_size = row_buffer->size;
const zend_uchar * const packet_end = (zend_uchar*) p + data_size;
DBG_ENTER("php_mysqlnd_rowp_read_text_protocol_aux");
@@ -1655,7 +1663,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
if (Z_TYPE_P(current_field) == IS_LONG && !as_int_or_float) {
/* we are using the text protocol, so convert to string */
char tmp[22];
- const size_t tmp_len = sprintf((char *)&tmp, MYSQLND_LLU_SPEC, (uint64_t) Z_LVAL_P(current_field));
+ const size_t tmp_len = sprintf((char *)&tmp, ZEND_ULONG_FMT, Z_LVAL_P(current_field));
ZVAL_STRINGL(current_field, tmp, tmp_len);
} else if (Z_TYPE_P(current_field) == IS_STRING) {
/* nothing to do here, as we want a string and ps_fetch_from_1_to_8_bytes() has given us one */
@@ -1679,8 +1687,8 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
/* {{{ php_mysqlnd_rowp_read_text_protocol_zval */
enum_func_status
php_mysqlnd_rowp_read_text_protocol_zval(MYSQLND_ROW_BUFFER * row_buffer, zval * fields,
- unsigned int field_count, const MYSQLND_FIELD * fields_metadata,
- zend_bool as_int_or_float, MYSQLND_STATS * stats)
+ const unsigned int field_count, const MYSQLND_FIELD * fields_metadata,
+ const zend_bool as_int_or_float, MYSQLND_STATS * stats)
{
enum_func_status ret;
DBG_ENTER("php_mysqlnd_rowp_read_text_protocol_zval");
@@ -1693,8 +1701,8 @@ php_mysqlnd_rowp_read_text_protocol_zval(MYSQLND_ROW_BUFFER * row_buffer, zval *
/* {{{ php_mysqlnd_rowp_read_text_protocol_c */
enum_func_status
php_mysqlnd_rowp_read_text_protocol_c(MYSQLND_ROW_BUFFER * row_buffer, zval * fields,
- unsigned int field_count, const MYSQLND_FIELD * fields_metadata,
- zend_bool as_int_or_float, MYSQLND_STATS * stats)
+ const unsigned int field_count, const MYSQLND_FIELD * const fields_metadata,
+ const zend_bool as_int_or_float, MYSQLND_STATS * const stats)
{
enum_func_status ret;
DBG_ENTER("php_mysqlnd_rowp_read_text_protocol_c");
@@ -1838,7 +1846,7 @@ php_mysqlnd_stats_read(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_VIO * vio = conn->vio;
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
- size_t buf_len = pfc->cmd_buffer.length;
+ const size_t buf_len = pfc->cmd_buffer.length;
zend_uchar *buf = (zend_uchar *) pfc->cmd_buffer.buffer;
DBG_ENTER("php_mysqlnd_stats_read");
@@ -1885,7 +1893,7 @@ php_mysqlnd_prepare_read(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
/* In case of an error, we should have place to put it */
- size_t buf_len = pfc->cmd_buffer.length;
+ const size_t buf_len = pfc->cmd_buffer.length;
zend_uchar *buf = (zend_uchar *) pfc->cmd_buffer.buffer;
zend_uchar *p = buf;
const zend_uchar * const begin = buf;
@@ -1968,7 +1976,7 @@ php_mysqlnd_chg_user_read(MYSQLND_CONN_DATA * conn, void * _packet)
MYSQLND_STATS * stats = conn->stats;
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
/* There could be an error message */
- size_t buf_len = pfc->cmd_buffer.length;
+ const size_t buf_len = pfc->cmd_buffer.length;
zend_uchar *buf = (zend_uchar *) pfc->cmd_buffer.buffer;
zend_uchar *p = buf;
const zend_uchar * const begin = buf;
@@ -2125,6 +2133,101 @@ php_mysqlnd_sha256_pk_request_response_free_mem(void * _packet)
}
/* }}} */
+static
+size_t php_mysqlnd_cached_sha2_result_write(MYSQLND_CONN_DATA * conn, void * _packet)
+{
+ MYSQLND_PACKET_CACHED_SHA2_RESULT * packet= (MYSQLND_PACKET_CACHED_SHA2_RESULT *) _packet;
+ MYSQLND_ERROR_INFO * error_info = conn->error_info;
+ MYSQLND_PFC * pfc = conn->protocol_frame_codec;
+ MYSQLND_VIO * vio = conn->vio;
+ MYSQLND_STATS * stats = conn->stats;
+ ALLOCA_FLAG(use_heap)
+ zend_uchar *buffer = do_alloca(MYSQLND_HEADER_SIZE + packet->password_len + 1, use_heap);
+ size_t sent;
+
+ DBG_ENTER("php_mysqlnd_cached_sha2_result_write");
+
+ if (packet->request == 1) {
+ int1store(buffer + MYSQLND_HEADER_SIZE, '\2');
+ sent = pfc->data->m.send(pfc, vio, buffer, 1, stats, error_info);
+ } else {
+ memcpy(buffer + MYSQLND_HEADER_SIZE, packet->password, packet->password_len);
+ sent = pfc->data->m.send(pfc, vio, buffer, packet->password_len, stats, error_info);
+ }
+
+ free_alloca(buffer, use_heap);
+ DBG_RETURN(sent);
+}
+
+static enum_func_status
+php_mysqlnd_cached_sha2_result_read(MYSQLND_CONN_DATA * conn, void * _packet)
+{
+ MYSQLND_PACKET_CACHED_SHA2_RESULT * packet= (MYSQLND_PACKET_CACHED_SHA2_RESULT *) _packet;
+ MYSQLND_ERROR_INFO * error_info = conn->error_info;
+ MYSQLND_PFC * pfc = conn->protocol_frame_codec;
+ MYSQLND_VIO * vio = conn->vio;
+ MYSQLND_STATS * stats = conn->stats;
+ MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
+ zend_uchar buf[SHA256_PK_REQUEST_RESP_BUFFER_SIZE];
+ zend_uchar *p = buf;
+ const zend_uchar * const begin = buf;
+
+ DBG_ENTER("php_mysqlnd_cached_sha2_result_read");
+ if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, sizeof(buf), "PROT_CACHED_SHA2_RESULT_PACKET", PROT_CACHED_SHA2_RESULT_PACKET)) {
+ DBG_RETURN(FAIL);
+ }
+ BAIL_IF_NO_MORE_DATA;
+
+ packet->response_code = uint1korr(p);
+ p++;
+ BAIL_IF_NO_MORE_DATA;
+
+ if (ERROR_MARKER == packet->response_code) {
+ php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
+ packet->error, sizeof(packet->error),
+ &packet->error_no, packet->sqlstate
+ );
+ DBG_RETURN(PASS);
+ }
+ if (0xFE == packet->response_code) {
+ /* Authentication Switch Response */
+ if (packet->header.size > (size_t) (p - buf)) {
+ packet->new_auth_protocol = mnd_pestrdup((char *)p, FALSE);
+ packet->new_auth_protocol_len = strlen(packet->new_auth_protocol);
+ p+= packet->new_auth_protocol_len + 1; /* +1 for the \0 */
+
+ packet->new_auth_protocol_data_len = packet->header.size - (size_t) (p - buf);
+ if (packet->new_auth_protocol_data_len) {
+ packet->new_auth_protocol_data = mnd_emalloc(packet->new_auth_protocol_data_len);
+ memcpy(packet->new_auth_protocol_data, p, packet->new_auth_protocol_data_len);
+ }
+ DBG_INF_FMT("The server requested switching auth plugin to : %s", packet->new_auth_protocol);
+ DBG_INF_FMT("Server salt : [%d][%.*s]", packet->new_auth_protocol_data_len, packet->new_auth_protocol_data_len, packet->new_auth_protocol_data);
+ }
+ DBG_RETURN(PASS);
+ }
+
+ if (0x1 != packet->response_code) {
+ DBG_ERR_FMT("Unexpected response code %d", packet->response_code);
+ }
+
+ /* This is not really the response code, but we reuse the field. */
+ packet->response_code = uint1korr(p);
+ p++;
+ BAIL_IF_NO_MORE_DATA;
+
+ packet->result = uint1korr(p);
+ BAIL_IF_NO_MORE_DATA;
+
+ DBG_RETURN(PASS);
+
+premature_end:
+ DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - begin - packet->header.size);
+ php_error_docref(NULL, E_WARNING, "SHA256_PK_REQUEST_RESPONSE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
+ p - begin - packet->header.size);
+ DBG_RETURN(FAIL);
+}
+
/* {{{ packet_methods */
static
mysqlnd_packet_methods packet_methods[PROT_LAST] =
@@ -2203,7 +2306,12 @@ mysqlnd_packet_methods packet_methods[PROT_LAST] =
php_mysqlnd_sha256_pk_request_response_read,
NULL, /* write */
php_mysqlnd_sha256_pk_request_response_free_mem,
- } /* PROT_SHA256_PK_REQUEST_RESPONSE_PACKET */
+ }, /* PROT_SHA256_PK_REQUEST_RESPONSE_PACKET */
+ {
+ php_mysqlnd_cached_sha2_result_read,
+ php_mysqlnd_cached_sha2_result_write,
+ NULL
+ } /* PROT_CACHED_SHA2_RESULT_PACKET */
};
/* }}} */
@@ -2387,6 +2495,17 @@ MYSQLND_METHOD(mysqlnd_protocol, init_sha256_pk_request_response_packet)(struct
}
/* }}} */
+/* {{{ mysqlnd_protocol::init_cached_sha2_result_packet */
+static void
+MYSQLND_METHOD(mysqlnd_protocol, init_cached_sha2_result_packet)(struct st_mysqlnd_packet_cached_sha2_result *packet)
+{
+ DBG_ENTER("mysqlnd_protocol::init_cached_sha2_result_packet");
+ memset(packet, 0, sizeof(*packet));
+ packet->header.m = &packet_methods[PROT_CACHED_SHA2_RESULT_PACKET];
+ DBG_VOID_RETURN;
+}
+/* }}} */
+
/* {{{ mysqlnd_protocol::send_command */
static enum_func_status
@@ -2397,7 +2516,7 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command)(
const zend_bool silent,
struct st_mysqlnd_connection_state * connection_state,
- MYSQLND_ERROR_INFO * error_info,
+ MYSQLND_ERROR_INFO * error_info,
MYSQLND_UPSERT_STATUS * upsert_status,
MYSQLND_STATS * stats,
func_mysqlnd_conn_data__send_close send_close,
@@ -2439,7 +2558,7 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command)(
MYSQLND_INC_CONN_STATISTIC(stats, STAT_COM_QUIT + command - 1 /* because of COM_SLEEP */ );
if (! PACKET_WRITE(payload_decoder_factory->conn, &cmd_packet)) {
- if (!silent) {
+ if (!silent && error_info->error_no != CR_SERVER_GONE_ERROR) {
DBG_ERR_FMT("Error while sending %s packet", mysqlnd_command_to_text[command]);
php_error(E_WARNING, "Error while sending %s packet. PID=%d", mysqlnd_command_to_text[command], getpid());
}
@@ -2605,6 +2724,7 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_protocol_payload_decoder_factory)
MYSQLND_METHOD(mysqlnd_protocol, init_change_user_response_packet),
MYSQLND_METHOD(mysqlnd_protocol, init_sha256_pk_request_packet),
MYSQLND_METHOD(mysqlnd_protocol, init_sha256_pk_request_response_packet),
+ MYSQLND_METHOD(mysqlnd_protocol, init_cached_sha2_result_packet),
MYSQLND_METHOD(mysqlnd_protocol, send_command),
MYSQLND_METHOD(mysqlnd_protocol, send_command_handle_response),
@@ -2638,13 +2758,3 @@ mysqlnd_protocol_payload_decoder_factory_free(MYSQLND_PROTOCOL_PAYLOAD_DECODER_F
DBG_VOID_RETURN;
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.h b/ext/mysqlnd/mysqlnd_wireprotocol.h
index 6e531b0e54..c4ef4c3dad 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.h
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -281,6 +281,25 @@ typedef struct st_mysqlnd_packet_sha256_pk_request_response {
size_t public_key_len;
} MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE;
+typedef struct st_mysqlnd_packet_cached_sha2_result {
+ MYSQLND_PACKET_HEADER header;
+ uint8_t response_code;
+ uint8_t result;
+ uint8_t request;
+ zend_uchar * password;
+ size_t password_len;
+ /* Used for auth switch request */
+ char *new_auth_protocol;
+ size_t new_auth_protocol_len;
+ zend_uchar *new_auth_protocol_data;
+ size_t new_auth_protocol_data_len;
+ /* Used for error result */
+ char error[MYSQLND_ERRMSG_SIZE+1];
+ char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
+ unsigned int error_no;
+} MYSQLND_PACKET_CACHED_SHA2_RESULT;
+
+
zend_ulong php_mysqlnd_net_field_length(const zend_uchar **packet);
zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, const uint64_t length);
@@ -306,12 +325,3 @@ PHPAPI MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * mysqlnd_protocol_payload_decod
PHPAPI void mysqlnd_protocol_payload_decoder_factory_free(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory);
#endif /* MYSQLND_WIREPROTOCOL_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c
index 53a85701d1..276d8968cd 100644
--- a/ext/mysqlnd/php_mysqlnd.c
+++ b/ext/mysqlnd/php_mysqlnd.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -51,29 +51,6 @@ mysqlnd_minfo_print_hash(zval *values)
/* }}} */
-/* {{{ mysqlnd_minfo_dump_plugin_stats */
-static int
-mysqlnd_minfo_dump_plugin_stats(zval *el, void * argument)
-{
- struct st_mysqlnd_plugin_header * plugin_header = (struct st_mysqlnd_plugin_header *)Z_PTR_P(el);
- 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 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();
- zend_array_destroy(Z_ARR(values));
- }
- return ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
-
/* {{{ mysqlnd_minfo_dump_loaded_plugins */
static int
mysqlnd_minfo_dump_loaded_plugins(zval *el, void * buf)
@@ -161,10 +138,6 @@ PHP_MINFO_FUNCTION(mysqlnd)
}
php_info_print_table_end();
-
-
- /* Print client stats */
- mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_plugin_stats, NULL);
}
/* }}} */
@@ -363,12 +336,3 @@ ZEND_TSRMLS_CACHE_DEFINE()
ZEND_GET_MODULE(mysqlnd)
#endif
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/mysqlnd/php_mysqlnd.h b/ext/mysqlnd/php_mysqlnd.h
index a3e88bf496..f202d038bb 100644
--- a/ext/mysqlnd/php_mysqlnd.h
+++ b/ext/mysqlnd/php_mysqlnd.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2006-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,12 +24,3 @@
extern zend_module_entry mysqlnd_module_entry;
#endif /* PHP_MYSQLND_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */