From: Andrey Hristov Date: Tue, 10 Nov 2015 13:25:06 +0000 (+0100) Subject: MNDR: X-Git-Tag: php-7.1.0alpha1~758 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e3fc57c5c205e352a805830fd3ec4c7dbfa2efa;p=php MNDR: - move things out of mysqlnd_priv.h --- diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 4be40ff75d..2c9a554a9e 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -20,8 +20,10 @@ #include "php.h" #include "mysqlnd.h" +#include "mysqlnd_connection.h" #include "mysqlnd_vio.h" #include "mysqlnd_protocol_frame_codec.h" +#include "mysqlnd_auth.h" #include "mysqlnd_wireprotocol.h" #include "mysqlnd_priv.h" #include "mysqlnd_result.h" @@ -34,11 +36,6 @@ extern MYSQLND_CHARSET *mysqlnd_charsets; -PHPAPI const char * const mysqlnd_old_passwd = "mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. " -"Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will " -"store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords " -"flag from your my.cnf file"; - PHPAPI const char * const mysqlnd_server_gone = "MySQL server has gone away"; PHPAPI const char * const mysqlnd_out_of_sync = "Commands out of sync; you can't run this command now"; PHPAPI const char * const mysqlnd_out_of_memory = "Out of memory"; @@ -417,36 +414,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, end_psession)(MYSQLND_CONN_DATA * conn) /* }}} */ -/* {{{ mysqlnd_switch_to_ssl_if_needed */ -static enum_func_status -mysqlnd_switch_to_ssl_if_needed( - MYSQLND_CONN_DATA * conn, - unsigned int charset_no, - size_t server_capabilities, - const MYSQLND_SESSION_OPTIONS * const session_options, - 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; - } - - { - size_t client_capabilities = mysql_flags; - struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_ENABLE_SSL, conn, client_capabilities, server_capabilities, charset_no); - if (command) { - ret = command->run(command); - command->free_command(command); - } - } - DBG_RETURN(ret); -} -/* }}} */ - - /* {{{ mysqlnd_conn_data::fetch_auth_plugin_by_name */ static struct st_mysqlnd_authentication_plugin * MYSQLND_METHOD(mysqlnd_conn_data, fetch_auth_plugin_by_name)(const char * const requested_protocol) @@ -465,172 +432,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, fetch_auth_plugin_by_name)(const char * const /* }}} */ -/* {{{ mysqlnd_run_authentication */ -static enum_func_status -mysqlnd_run_authentication( - 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_STRING auth_plugin_data, - const char * const auth_protocol, - unsigned int charset_no, - const MYSQLND_SESSION_OPTIONS * const session_options, - zend_ulong mysql_flags, - zend_bool silent, - zend_bool is_change_user - ) -{ - enum_func_status ret = FAIL; - zend_bool first_call = TRUE; - - char * switch_to_auth_protocol = NULL; - size_t switch_to_auth_protocol_len = 0; - char * requested_protocol = NULL; - zend_uchar * plugin_data; - size_t plugin_data_len; - - DBG_ENTER("mysqlnd_run_authentication"); - - plugin_data_len = auth_plugin_data.l; - plugin_data = mnd_emalloc(plugin_data_len + 1); - if (!plugin_data) { - goto end; - } - memcpy(plugin_data, auth_plugin_data.s, plugin_data_len); - plugin_data[plugin_data_len] = '\0'; - - requested_protocol = mnd_pestrdup(auth_protocol? auth_protocol : MYSQLND_DEFAULT_AUTH_PROTOCOL, FALSE); - if (!requested_protocol) { - goto end; - } - - do { - struct st_mysqlnd_authentication_plugin * auth_plugin = conn->m->fetch_auth_plugin_by_name(requested_protocol); - - if (!auth_plugin) { - php_error_docref(NULL, E_WARNING, "The server requested authentication method unknown to the client [%s]", requested_protocol); - SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested authentication method unknown to the client"); - goto end; - } - DBG_INF("plugin found"); - - { - zend_uchar * switch_to_auth_protocol_data = NULL; - size_t switch_to_auth_protocol_data_len = 0; - zend_uchar * scrambled_data = NULL; - size_t scrambled_data_len = 0; - - switch_to_auth_protocol = NULL; - switch_to_auth_protocol_len = 0; - - if (conn->authentication_plugin_data.s) { - mnd_pefree(conn->authentication_plugin_data.s, conn->persistent); - conn->authentication_plugin_data.s = NULL; - } - conn->authentication_plugin_data.l = plugin_data_len; - conn->authentication_plugin_data.s = mnd_pemalloc(conn->authentication_plugin_data.l, conn->persistent); - if (!conn->authentication_plugin_data.s) { - SET_OOM_ERROR(conn->error_info); - goto end; - } - memcpy(conn->authentication_plugin_data.s, plugin_data, plugin_data_len); - - DBG_INF_FMT("salt(%d)=[%.*s]", plugin_data_len, plugin_data_len, plugin_data); - /* The data should be allocated with malloc() */ - 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) { - goto end; - } - if (FALSE == is_change_user) { - ret = mysqlnd_auth_handshake(conn, user, passwd, passwd_len, db, db_len, session_options, mysql_flags, - charset_no, - first_call, - requested_protocol, - 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 - ); - } else { - ret = mysqlnd_auth_change_user(conn, user, strlen(user), passwd, passwd_len, db, db_len, silent, - first_call, - requested_protocol, - 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 - ); - } - first_call = FALSE; - free(scrambled_data); - - DBG_INF_FMT("switch_to_auth_protocol=%s", switch_to_auth_protocol? switch_to_auth_protocol:"n/a"); - if (requested_protocol && switch_to_auth_protocol) { - mnd_efree(requested_protocol); - requested_protocol = switch_to_auth_protocol; - } - - if (plugin_data) { - mnd_efree(plugin_data); - } - plugin_data_len = switch_to_auth_protocol_data_len; - plugin_data = switch_to_auth_protocol_data; - } - DBG_INF_FMT("conn->error_info->error_no = %d", conn->error_info->error_no); - } while (ret == FAIL && conn->error_info->error_no == 0 && switch_to_auth_protocol != NULL); - - if (ret == PASS) { - DBG_INF_FMT("saving requested_protocol=%s", requested_protocol); - conn->m->set_client_option(conn, MYSQLND_OPT_AUTH_PROTOCOL, requested_protocol); - } -end: - if (plugin_data) { - mnd_efree(plugin_data); - } - if (requested_protocol) { - mnd_efree(requested_protocol); - } - - DBG_RETURN(ret); -} -/* }}} */ - - -/* {{{ mysqlnd_connect_run_authentication */ -enum_func_status -mysqlnd_connect_run_authentication( - MYSQLND_CONN_DATA * 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 char * const authentication_protocol, - const unsigned int charset_no, - size_t server_capabilities, - const MYSQLND_SESSION_OPTIONS * const session_options, - zend_ulong mysql_flags - ) -{ - enum_func_status ret = FAIL; - DBG_ENTER("mysqlnd_connect_run_authentication"); - - ret = mysqlnd_switch_to_ssl_if_needed(conn, charset_no, server_capabilities, session_options, mysql_flags); - if (PASS == ret) { - ret = mysqlnd_run_authentication(conn, user, passwd, passwd_len, db, db_len, - authentication_plugin_data, authentication_protocol, - charset_no, session_options, mysql_flags, FALSE /*silent*/, FALSE/*is_change*/); - } - DBG_RETURN(ret); -} -/* }}} */ - - /* {{{ mysqlnd_conn_data::execute_init_commands */ static enum_func_status MYSQLND_METHOD(mysqlnd_conn_data, execute_init_commands)(MYSQLND_CONN_DATA * conn) @@ -685,7 +486,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags)(MYSQLND_CONN_DATA * mysql_flags &= ~CLIENT_COMPRESS; } #else - if (pfc && pfc->data->flags & MYSQLND_NET_FLAG_USE_COMPRESSION) { + if (pfc && pfc->data->flags & MYSQLND_PROTOCOL_FLAG_USE_COMPRESSION) { mysql_flags |= CLIENT_COMPRESS; } #endif diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h index 58a3aef164..a622c27b57 100644 --- a/ext/mysqlnd/mysqlnd.h +++ b/ext/mysqlnd/mysqlnd.h @@ -61,6 +61,7 @@ #include "mysqlnd_enum_n_def.h" #include "mysqlnd_structs.h" +#define MYSQLND_STR_W_LEN(str) str, (sizeof(str) - 1) /* Library related */ PHPAPI void mysqlnd_library_init(void); diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c index c28044ca7f..db1d0a22b7 100644 --- a/ext/mysqlnd/mysqlnd_alloc.c +++ b/ext/mysqlnd/mysqlnd_alloc.c @@ -12,8 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ diff --git a/ext/mysqlnd/mysqlnd_alloc.h b/ext/mysqlnd/mysqlnd_alloc.h index 958aff8934..6cac245c7d 100644 --- a/ext/mysqlnd/mysqlnd_alloc.h +++ b/ext/mysqlnd/mysqlnd_alloc.h @@ -12,15 +12,11 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd_debug.h 306938 2011-01-01 02:17:06Z felipe $ */ -/* $Id: mysqlnd_debug.h 306938 2011-01-01 02:17:06Z felipe $ */ - #ifndef MYSQLND_ALLOC_H #define MYSQLND_ALLOC_H diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c index e7d44becc3..fb70884df8 100644 --- a/ext/mysqlnd/mysqlnd_auth.c +++ b/ext/mysqlnd/mysqlnd_auth.c @@ -12,20 +12,223 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | + | Georg Richter | +----------------------------------------------------------------------+ */ #include "php.h" #include "mysqlnd.h" #include "mysqlnd_structs.h" +#include "mysqlnd_auth.h" #include "mysqlnd_wireprotocol.h" +#include "mysqlnd_connection.h" #include "mysqlnd_priv.h" #include "mysqlnd_charset.h" #include "mysqlnd_debug.h" +static const char * const mysqlnd_old_passwd = "mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. " +"Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will " +"store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords " +"flag from your my.cnf file"; + + +/* {{{ mysqlnd_run_authentication */ +enum_func_status +mysqlnd_run_authentication( + 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_STRING auth_plugin_data, + const char * const auth_protocol, + unsigned int charset_no, + const MYSQLND_SESSION_OPTIONS * const session_options, + zend_ulong mysql_flags, + zend_bool silent, + zend_bool is_change_user + ) +{ + enum_func_status ret = FAIL; + zend_bool first_call = TRUE; + + char * switch_to_auth_protocol = NULL; + size_t switch_to_auth_protocol_len = 0; + char * requested_protocol = NULL; + zend_uchar * plugin_data; + size_t plugin_data_len; + + DBG_ENTER("mysqlnd_run_authentication"); + + plugin_data_len = auth_plugin_data.l; + plugin_data = mnd_emalloc(plugin_data_len + 1); + if (!plugin_data) { + goto end; + } + memcpy(plugin_data, auth_plugin_data.s, plugin_data_len); + plugin_data[plugin_data_len] = '\0'; + + requested_protocol = mnd_pestrdup(auth_protocol? auth_protocol : MYSQLND_DEFAULT_AUTH_PROTOCOL, FALSE); + if (!requested_protocol) { + goto end; + } + + do { + struct st_mysqlnd_authentication_plugin * auth_plugin = conn->m->fetch_auth_plugin_by_name(requested_protocol); + + if (!auth_plugin) { + php_error_docref(NULL, E_WARNING, "The server requested authentication method unknown to the client [%s]", requested_protocol); + SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested authentication method unknown to the client"); + goto end; + } + DBG_INF("plugin found"); + + { + zend_uchar * switch_to_auth_protocol_data = NULL; + size_t switch_to_auth_protocol_data_len = 0; + zend_uchar * scrambled_data = NULL; + size_t scrambled_data_len = 0; + + switch_to_auth_protocol = NULL; + switch_to_auth_protocol_len = 0; + + if (conn->authentication_plugin_data.s) { + mnd_pefree(conn->authentication_plugin_data.s, conn->persistent); + conn->authentication_plugin_data.s = NULL; + } + conn->authentication_plugin_data.l = plugin_data_len; + conn->authentication_plugin_data.s = mnd_pemalloc(conn->authentication_plugin_data.l, conn->persistent); + if (!conn->authentication_plugin_data.s) { + SET_OOM_ERROR(conn->error_info); + goto end; + } + memcpy(conn->authentication_plugin_data.s, plugin_data, plugin_data_len); + + DBG_INF_FMT("salt(%d)=[%.*s]", plugin_data_len, plugin_data_len, plugin_data); + /* The data should be allocated with malloc() */ + 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) { + goto end; + } + if (FALSE == is_change_user) { + ret = mysqlnd_auth_handshake(conn, user, passwd, passwd_len, db, db_len, session_options, mysql_flags, + charset_no, + first_call, + requested_protocol, + 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 + ); + } else { + ret = mysqlnd_auth_change_user(conn, user, strlen(user), passwd, passwd_len, db, db_len, silent, + first_call, + requested_protocol, + 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 + ); + } + first_call = FALSE; + free(scrambled_data); + + DBG_INF_FMT("switch_to_auth_protocol=%s", switch_to_auth_protocol? switch_to_auth_protocol:"n/a"); + if (requested_protocol && switch_to_auth_protocol) { + mnd_efree(requested_protocol); + requested_protocol = switch_to_auth_protocol; + } + + if (plugin_data) { + mnd_efree(plugin_data); + } + plugin_data_len = switch_to_auth_protocol_data_len; + plugin_data = switch_to_auth_protocol_data; + } + DBG_INF_FMT("conn->error_info->error_no = %d", conn->error_info->error_no); + } while (ret == FAIL && conn->error_info->error_no == 0 && switch_to_auth_protocol != NULL); + + if (ret == PASS) { + DBG_INF_FMT("saving requested_protocol=%s", requested_protocol); + conn->m->set_client_option(conn, MYSQLND_OPT_AUTH_PROTOCOL, requested_protocol); + } +end: + if (plugin_data) { + mnd_efree(plugin_data); + } + if (requested_protocol) { + mnd_efree(requested_protocol); + } + + DBG_RETURN(ret); +} +/* }}} */ + + +/* {{{ mysqlnd_switch_to_ssl_if_needed */ +static enum_func_status +mysqlnd_switch_to_ssl_if_needed(MYSQLND_CONN_DATA * conn, + unsigned int charset_no, + size_t server_capabilities, + const MYSQLND_SESSION_OPTIONS * const session_options, + 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; + } + + { + size_t client_capabilities = mysql_flags; + struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_ENABLE_SSL, conn, client_capabilities, server_capabilities, charset_no); + if (command) { + ret = command->run(command); + command->free_command(command); + } + } + DBG_RETURN(ret); +} +/* }}} */ + + +/* {{{ mysqlnd_connect_run_authentication */ +enum_func_status +mysqlnd_connect_run_authentication( + MYSQLND_CONN_DATA * 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 char * const authentication_protocol, + const unsigned int charset_no, + size_t server_capabilities, + const MYSQLND_SESSION_OPTIONS * const session_options, + zend_ulong mysql_flags + ) +{ + enum_func_status ret = FAIL; + DBG_ENTER("mysqlnd_connect_run_authentication"); + + ret = mysqlnd_switch_to_ssl_if_needed(conn, charset_no, server_capabilities, session_options, mysql_flags); + if (PASS == ret) { + ret = mysqlnd_run_authentication(conn, user, passwd, passwd_len, db, db_len, + authentication_plugin_data, authentication_protocol, + charset_no, session_options, mysql_flags, FALSE /*silent*/, FALSE/*is_change*/); + } + DBG_RETURN(ret); +} +/* }}} */ + + /* {{{ mysqlnd_auth_handshake */ enum_func_status mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, diff --git a/ext/mysqlnd/mysqlnd_auth.h b/ext/mysqlnd/mysqlnd_auth.h new file mode 100644 index 0000000000..a54c6065d0 --- /dev/null +++ b/ext/mysqlnd/mysqlnd_auth.h @@ -0,0 +1,124 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 2006-2015 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 | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_AUTH_H +#define MYSQLND_AUTH_H +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 + ); + +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 + ); + +enum_func_status +mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn, + const char * const user, + const size_t user_len, + const char * const passwd, + const size_t passwd_len, + const char * const db, + const size_t db_len, + const zend_bool silent, + zend_bool use_full_blown_auth_packet, + const char * const auth_protocol, + zend_uchar * auth_plugin_data, + 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 + ); + + +enum_func_status +mysqlnd_connect_run_authentication( + MYSQLND_CONN_DATA * 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 char * const authentication_protocol, + const unsigned int charset_no, + size_t server_capabilities, + const MYSQLND_SESSION_OPTIONS * const session_options, + zend_ulong mysql_flags + ); + +enum_func_status +mysqlnd_run_authentication( + 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_STRING auth_plugin_data, + const char * const auth_protocol, + unsigned int charset_no, + const MYSQLND_SESSION_OPTIONS * const session_options, + zend_ulong mysql_flags, + zend_bool silent, + zend_bool is_change_user + ); + +#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 9a7fdae0f7..95976fca3e 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.c +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -12,8 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ diff --git a/ext/mysqlnd/mysqlnd_block_alloc.h b/ext/mysqlnd/mysqlnd_block_alloc.h index 50e4c90512..e56eb34cba 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.h +++ b/ext/mysqlnd/mysqlnd_block_alloc.h @@ -12,14 +12,11 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef MYSQLND_BLOCK_ALLOC_H #define MYSQLND_BLOCK_ALLOC_H diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c index 2bb6fde3d0..7aa7f2e7ef 100644 --- a/ext/mysqlnd/mysqlnd_charset.c +++ b/ext/mysqlnd/mysqlnd_charset.c @@ -12,9 +12,9 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | + | Georg Richter | +----------------------------------------------------------------------+ */ #include "php.h" diff --git a/ext/mysqlnd/mysqlnd_charset.h b/ext/mysqlnd/mysqlnd_charset.h index 8bdad7249e..59784948f1 100644 --- a/ext/mysqlnd/mysqlnd_charset.h +++ b/ext/mysqlnd/mysqlnd_charset.h @@ -12,12 +12,11 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | + | Georg Richter | +----------------------------------------------------------------------+ */ - #ifndef MYSQLND_CHARSET_H #define MYSQLND_CHARSET_H diff --git a/ext/mysqlnd/mysqlnd_commands.c b/ext/mysqlnd/mysqlnd_commands.c index 9b71f36008..094f8de46f 100644 --- a/ext/mysqlnd/mysqlnd_commands.c +++ b/ext/mysqlnd/mysqlnd_commands.c @@ -19,7 +19,9 @@ #include "php.h" #include "mysqlnd.h" +#include "mysqlnd_connection.h" #include "mysqlnd_priv.h" +#include "mysqlnd_auth.h" #include "mysqlnd_wireprotocol.h" #include "mysqlnd_statistics.h" #include "mysqlnd_debug.h" diff --git a/ext/mysqlnd/mysqlnd_connection.h b/ext/mysqlnd/mysqlnd_connection.h new file mode 100644 index 0000000000..7036131beb --- /dev/null +++ b/ext/mysqlnd/mysqlnd_connection.h @@ -0,0 +1,86 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 2006-2015 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 | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_CONNECTION_H +#define MYSQLND_CONNECTION_H + +PHPAPI extern const char * const mysqlnd_out_of_sync; +PHPAPI extern const char * const mysqlnd_server_gone; +PHPAPI extern const char * const mysqlnd_out_of_memory; + + +void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status); + +#define UPSERT_STATUS_RESET(status) (status)->m->reset((status)) + +#define UPSERT_STATUS_GET_SERVER_STATUS(status) (status)->server_status +#define UPSERT_STATUS_SET_SERVER_STATUS(status, server_st) (status)->server_status = (server_st) + +#define UPSERT_STATUS_GET_WARNINGS(status) (status)->warning_count +#define UPSERT_STATUS_SET_WARNINGS(status, warnings) (status)->warning_count = (warnings) + +#define UPSERT_STATUS_GET_AFFECTED_ROWS(status) (status)->affected_rows +#define UPSERT_STATUS_SET_AFFECTED_ROWS(status, rows) (status)->affected_rows = (rows) +#define UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(status) (status)->m->set_affected_rows_to_error((status)) + +#define UPSERT_STATUS_GET_LAST_INSERT_ID(status) (status)->last_insert_id +#define UPSERT_STATUS_SET_LAST_INSERT_ID(status, id) (status)->last_insert_id = (id) + + +/* Error handling */ +#define SET_NEW_MESSAGE(buf, buf_len, message, len, persistent) \ + {\ + if ((buf)) { \ + mnd_pefree((buf), (persistent)); \ + } \ + if ((message)) { \ + (buf) = mnd_pestrndup((message), (len), (persistent)); \ + } else { \ + (buf) = NULL; \ + } \ + (buf_len) = (len); \ + } + +#define SET_EMPTY_MESSAGE(buf, buf_len, persistent) \ + {\ + if ((buf)) { \ + mnd_pefree((buf), (persistent)); \ + (buf) = NULL; \ + } \ + (buf_len) = 0; \ + } + + +enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, zend_bool persistent); + +#define GET_CONNECTION_STATE(state_struct) (state_struct)->m->get((state_struct)) +#define SET_CONNECTION_STATE(state_struct, s) (state_struct)->m->set((state_struct), (s)) + +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 886a6d8ac6..87d8fe35d7 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -12,14 +12,10 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ - -/* $Id$ */ - #include "php.h" #include "mysqlnd.h" #include "mysqlnd_priv.h" diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h index 1a57143507..7354d35a3c 100644 --- a/ext/mysqlnd/mysqlnd_debug.h +++ b/ext/mysqlnd/mysqlnd_debug.h @@ -12,14 +12,10 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ - -/* $Id$ */ - #ifndef MYSQLND_DEBUG_H #define MYSQLND_DEBUG_H @@ -70,6 +66,17 @@ void mysqlnd_debug_trace_plugin_register(void); PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[]); +#define MYSQLND_DEBUG_DUMP_TIME 1 +#define MYSQLND_DEBUG_DUMP_TRACE 2 +#define MYSQLND_DEBUG_DUMP_PID 4 +#define MYSQLND_DEBUG_DUMP_LINE 8 +#define MYSQLND_DEBUG_DUMP_FILE 16 +#define MYSQLND_DEBUG_DUMP_LEVEL 32 +#define MYSQLND_DEBUG_APPEND 64 +#define MYSQLND_DEBUG_FLUSH 128 +#define MYSQLND_DEBUG_TRACE_MEMORY_CALLS 256 +#define MYSQLND_DEBUG_PROFILE_CALLS 512 + #if defined(__GNUC__) || defined(PHP_WIN32) #ifdef PHP_WIN32 diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c index f45ce661bd..b79effa338 100644 --- a/ext/mysqlnd/mysqlnd_driver.c +++ b/ext/mysqlnd/mysqlnd_driver.c @@ -17,12 +17,14 @@ | Georg Richter | +----------------------------------------------------------------------+ */ - #include "php.h" #include "mysqlnd.h" #include "mysqlnd_vio.h" #include "mysqlnd_protocol_frame_codec.h" #include "mysqlnd_wireprotocol.h" +#include "mysqlnd_connection.h" +#include "mysqlnd_ps.h" +#include "mysqlnd_plugin.h" #include "mysqlnd_priv.h" #include "mysqlnd_statistics.h" #include "mysqlnd_debug.h" diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index b4a74fae83..0bde8a969b 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -114,7 +114,29 @@ CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | \ CLIENT_MULTI_RESULTS | CLIENT_LOCAL_FILES | CLIENT_PLUGIN_AUTH) -#define MYSQLND_NET_FLAG_USE_COMPRESSION 1 +#define MYSQLND_PROTOCOL_FLAG_USE_COMPRESSION 1 + + +/* Client Error codes */ +#define CR_UNKNOWN_ERROR 2000 +#define CR_CONNECTION_ERROR 2002 +#define CR_SERVER_GONE_ERROR 2006 +#define CR_OUT_OF_MEMORY 2008 +#define CR_SERVER_LOST 2013 +#define CR_COMMANDS_OUT_OF_SYNC 2014 +#define CR_CANT_FIND_CHARSET 2019 +#define CR_MALFORMED_PACKET 2027 +#define CR_NOT_IMPLEMENTED 2054 +#define CR_NO_PREPARE_STMT 2030 +#define CR_PARAMS_NOT_BOUND 2031 +#define CR_INVALID_PARAMETER_NO 2034 +#define CR_INVALID_BUFFER_USE 2035 + +#define MYSQLND_EE_FILENOTFOUND 7890 + +#define UNKNOWN_SQLSTATE "HY000" + +#define MAX_CHARSET_LEN 32 #define TRANS_START_NO_OPT 0 diff --git a/ext/mysqlnd/mysqlnd_libmysql_compat.h b/ext/mysqlnd/mysqlnd_libmysql_compat.h index 4685c2c673..5a130880df 100644 --- a/ext/mysqlnd/mysqlnd_libmysql_compat.h +++ b/ext/mysqlnd/mysqlnd_libmysql_compat.h @@ -18,7 +18,6 @@ +----------------------------------------------------------------------+ */ - #ifndef MYSQLND_LIBMYSQL_COMPAT_H #define MYSQLND_LIBMYSQL_COMPAT_H diff --git a/ext/mysqlnd/mysqlnd_plugin.h b/ext/mysqlnd/mysqlnd_plugin.h new file mode 100644 index 0000000000..eab21175c1 --- /dev/null +++ b/ext/mysqlnd/mysqlnd_plugin.h @@ -0,0 +1,40 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 2006-2015 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 | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ +#ifndef MYSQLND_PLUGIN_H +#define MYSQLND_PLUGIN_H + + +void mysqlnd_plugin_subsystem_init(void); +void mysqlnd_plugin_subsystem_end(void); + +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_priv.h b/ext/mysqlnd/mysqlnd_priv.h index e3bfee5d8c..b334577a37 100644 --- a/ext/mysqlnd/mysqlnd_priv.h +++ b/ext/mysqlnd/mysqlnd_priv.h @@ -14,136 +14,10 @@ +----------------------------------------------------------------------+ | Authors: Andrey Hristov | | Ulf Wendel | - | Georg Richter | +----------------------------------------------------------------------+ */ #ifndef MYSQLND_PRIV_H #define MYSQLND_PRIV_H - -#ifndef Z_ADDREF_P -/* PHP 5.2, old GC */ -#define Z_ADDREF_P(pz) (++(pz)->refcount) -#define Z_DELREF_P(pz) (--(pz)->refcount) -#define Z_REFCOUNT_P(pz) ((pz)->refcount) -#define Z_SET_REFCOUNT_P(pz, rc) ((pz)->refcount = rc) -#define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz)) -#define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz)) -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#ifndef pestrndup -#define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length))) -#endif - -#define MYSQLND_STR_W_LEN(str) str, (sizeof(str) - 1) - -#define MYSQLND_DEBUG_DUMP_TIME 1 -#define MYSQLND_DEBUG_DUMP_TRACE 2 -#define MYSQLND_DEBUG_DUMP_PID 4 -#define MYSQLND_DEBUG_DUMP_LINE 8 -#define MYSQLND_DEBUG_DUMP_FILE 16 -#define MYSQLND_DEBUG_DUMP_LEVEL 32 -#define MYSQLND_DEBUG_APPEND 64 -#define MYSQLND_DEBUG_FLUSH 128 -#define MYSQLND_DEBUG_TRACE_MEMORY_CALLS 256 -#define MYSQLND_DEBUG_PROFILE_CALLS 512 - - -/* Client Error codes */ -#define CR_UNKNOWN_ERROR 2000 -#define CR_CONNECTION_ERROR 2002 -#define CR_SERVER_GONE_ERROR 2006 -#define CR_OUT_OF_MEMORY 2008 -#define CR_SERVER_LOST 2013 -#define CR_COMMANDS_OUT_OF_SYNC 2014 -#define CR_CANT_FIND_CHARSET 2019 -#define CR_MALFORMED_PACKET 2027 -#define CR_NOT_IMPLEMENTED 2054 -#define CR_NO_PREPARE_STMT 2030 -#define CR_PARAMS_NOT_BOUND 2031 -#define CR_INVALID_PARAMETER_NO 2034 -#define CR_INVALID_BUFFER_USE 2035 - -#define MYSQLND_EE_FILENOTFOUND 7890 - -#define UNKNOWN_SQLSTATE "HY000" - -#define MAX_CHARSET_LEN 32 - -void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status); - -#define UPSERT_STATUS_RESET(status) (status)->m->reset((status)) - -#define UPSERT_STATUS_GET_SERVER_STATUS(status) (status)->server_status -#define UPSERT_STATUS_SET_SERVER_STATUS(status, server_st) (status)->server_status = (server_st) - -#define UPSERT_STATUS_GET_WARNINGS(status) (status)->warning_count -#define UPSERT_STATUS_SET_WARNINGS(status, warnings) (status)->warning_count = (warnings) - -#define UPSERT_STATUS_GET_AFFECTED_ROWS(status) (status)->affected_rows -#define UPSERT_STATUS_SET_AFFECTED_ROWS(status, rows) (status)->affected_rows = (rows) -#define UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(status) (status)->m->set_affected_rows_to_error((status)) - -#define UPSERT_STATUS_GET_LAST_INSERT_ID(status) (status)->last_insert_id -#define UPSERT_STATUS_SET_LAST_INSERT_ID(status, id) (status)->last_insert_id = (id) - - -/* Error handling */ -#define SET_NEW_MESSAGE(buf, buf_len, message, len, persistent) \ - {\ - if ((buf)) { \ - mnd_pefree((buf), (persistent)); \ - } \ - if ((message)) { \ - (buf) = mnd_pestrndup((message), (len), (persistent)); \ - } else { \ - (buf) = NULL; \ - } \ - (buf_len) = (len); \ - } - -#define SET_EMPTY_MESSAGE(buf, buf_len, persistent) \ - {\ - if ((buf)) { \ - mnd_pefree((buf), (persistent)); \ - (buf) = NULL; \ - } \ - (buf_len) = 0; \ - } - - -enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, zend_bool persistent); - -#define GET_CONNECTION_STATE(state_struct) (state_struct)->m->get((state_struct)) -#define SET_CONNECTION_STATE(state_struct, s) (state_struct)->m->set((state_struct), (s)) - -void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state); - -/* PS stuff */ -typedef void (*ps_field_fetch_func)(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row); -struct st_mysqlnd_perm_bind { - ps_field_fetch_func func; - /* should be signed int */ - int pack_len; - unsigned int php_type; - zend_bool is_possibly_blob; - zend_bool can_ret_as_str_in_uni; -}; - -extern struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1]; - -enum_func_status mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything); -enum_func_status mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything); - - -PHPAPI extern const char * const mysqlnd_old_passwd; -PHPAPI extern const char * const mysqlnd_out_of_sync; -PHPAPI extern const char * const mysqlnd_server_gone; -PHPAPI extern const char * const mysqlnd_out_of_memory; - PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_object_factory); PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn); PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn_data); @@ -157,82 +31,8 @@ PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_upsert_status); PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_error_info); enum_func_status mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * const filename, zend_bool * is_warning); - - - -void _mysqlnd_init_ps_subsystem();/* This one is private, mysqlnd_library_init() will call it */ -void _mysqlnd_init_ps_fetch_subsystem(); - -void ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row, unsigned int byte_count); - -void mysqlnd_plugin_subsystem_init(void); -void mysqlnd_plugin_subsystem_end(void); - -void mysqlnd_register_builtin_authentication_plugins(void); - -void mysqlnd_example_plugin_register(void); - -struct st_mysqlnd_packet_greet; -struct st_mysqlnd_authentication_plugin; - -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 - ); - -enum_func_status -mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn, - const char * const user, - const size_t user_len, - const char * const passwd, - const size_t passwd_len, - const char * const db, - const size_t db_len, - const zend_bool silent, - zend_bool use_full_blown_auth_packet, - const char * const auth_protocol, - zend_uchar * auth_plugin_data, - 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 - ); - -enum_func_status -mysqlnd_connect_run_authentication( - MYSQLND_CONN_DATA * 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 char * const authentication_protocol, - const unsigned int charset_no, - size_t server_capabilities, - const MYSQLND_SESSION_OPTIONS * const session_options, - zend_ulong mysql_flags - ); - #endif /* MYSQLND_PRIV_H */ - /* * Local variables: * tab-width: 4 diff --git a/ext/mysqlnd/mysqlnd_protocol_frame_codec.c b/ext/mysqlnd/mysqlnd_protocol_frame_codec.c index 2c4d632342..6fb3d8ffa9 100644 --- a/ext/mysqlnd/mysqlnd_protocol_frame_codec.c +++ b/ext/mysqlnd/mysqlnd_protocol_frame_codec.c @@ -18,6 +18,7 @@ */ #include "php.h" #include "mysqlnd.h" +#include "mysqlnd_connection.h" #include "mysqlnd_priv.h" #include "mysqlnd_wireprotocol.h" #include "mysqlnd_statistics.h" @@ -420,17 +421,16 @@ MYSQLND_METHOD(mysqlnd_pfc, set_client_option)(MYSQLND_PFC * const pfc, enum_mys DBG_INF_FMT("option=%u", option); switch (option) { case MYSQL_OPT_COMPRESS: - pfc->data->flags |= MYSQLND_NET_FLAG_USE_COMPRESSION; + pfc->data->flags |= MYSQLND_PROTOCOL_FLAG_USE_COMPRESSION; break; - case MYSQL_SERVER_PUBLIC_KEY: - { - zend_bool pers = pfc->persistent; - if (pfc->data->sha256_server_public_key) { - mnd_pefree(pfc->data->sha256_server_public_key, pers); - } - pfc->data->sha256_server_public_key = value? mnd_pestrdup(value, pers) : NULL; - break; + case MYSQL_SERVER_PUBLIC_KEY: { + const zend_bool pers = pfc->persistent; + if (pfc->data->sha256_server_public_key) { + mnd_pefree(pfc->data->sha256_server_public_key, pers); } + pfc->data->sha256_server_public_key = value? mnd_pestrdup(value, pers) : NULL; + break; + } default: DBG_RETURN(FAIL); } diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index d5a9b214bf..be15c9b3ed 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -20,7 +20,9 @@ #include "php.h" #include "mysqlnd.h" #include "mysqlnd_wireprotocol.h" +#include "mysqlnd_connection.h" #include "mysqlnd_priv.h" +#include "mysqlnd_ps.h" #include "mysqlnd_result.h" #include "mysqlnd_result_meta.h" #include "mysqlnd_statistics.h" diff --git a/ext/mysqlnd/mysqlnd_ps.h b/ext/mysqlnd/mysqlnd_ps.h new file mode 100644 index 0000000000..801de6db10 --- /dev/null +++ b/ext/mysqlnd/mysqlnd_ps.h @@ -0,0 +1,53 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 2006-2015 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 | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_PS_H +#define MYSQLND_PS_H + +/* PS stuff */ +typedef void (*ps_field_fetch_func)(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row); +struct st_mysqlnd_perm_bind { + ps_field_fetch_func func; + /* should be signed int */ + int pack_len; + unsigned int php_type; + zend_bool is_possibly_blob; + zend_bool can_ret_as_str_in_uni; +}; + +extern struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1]; + +enum_func_status mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything); +enum_func_status mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything); + +void _mysqlnd_init_ps_subsystem();/* This one is private, mysqlnd_library_init() will call it */ +void _mysqlnd_init_ps_fetch_subsystem(); + +void ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, 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 a474caf730..a6ad9ff3e5 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -22,6 +22,8 @@ #include "php.h" #include "mysqlnd.h" #include "mysqlnd_wireprotocol.h" +#include "mysqlnd_connection.h" +#include "mysqlnd_ps.h" #include "mysqlnd_priv.h" #include "mysqlnd_debug.h" #include "mysql_float_to_double.h" diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index f3f26b43ce..62509f5897 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -17,12 +17,11 @@ | Georg Richter | +----------------------------------------------------------------------+ */ - -/* $Id$ */ #include "php.h" #include "mysqlnd.h" #include "mysqlnd_wireprotocol.h" #include "mysqlnd_block_alloc.h" +#include "mysqlnd_connection.h" #include "mysqlnd_priv.h" #include "mysqlnd_result.h" #include "mysqlnd_result_meta.h" diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c index bb6133471e..7da6756432 100644 --- a/ext/mysqlnd/mysqlnd_result_meta.c +++ b/ext/mysqlnd/mysqlnd_result_meta.c @@ -17,10 +17,10 @@ | Georg Richter | +----------------------------------------------------------------------+ */ - -/* $Id$ */ #include "php.h" #include "mysqlnd.h" +#include "mysqlnd_connection.h" +#include "mysqlnd_ps.h" #include "mysqlnd_priv.h" #include "mysqlnd_result.h" #include "mysqlnd_wireprotocol.h" diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c index 6050e38e86..bbd2eb0643 100644 --- a/ext/mysqlnd/mysqlnd_statistics.c +++ b/ext/mysqlnd/mysqlnd_statistics.c @@ -12,13 +12,10 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ - -/* $Id$ */ #include "php.h" #include "mysqlnd.h" #include "mysqlnd_priv.h" @@ -26,9 +23,7 @@ #include "mysqlnd_debug.h" -/* {{{ mysqlnd_stats_values_names - */ - +/* {{{ mysqlnd_stats_values_names */ const MYSQLND_STRING mysqlnd_stats_values_names[STAT_LAST] = { { MYSQLND_STR_W_LEN("bytes_sent") }, diff --git a/ext/mysqlnd/mysqlnd_statistics.h b/ext/mysqlnd/mysqlnd_statistics.h index 19aedf37a2..6caf7fab99 100644 --- a/ext/mysqlnd/mysqlnd_statistics.h +++ b/ext/mysqlnd/mysqlnd_statistics.h @@ -12,18 +12,13 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ - -/* $Id$ */ - #ifndef MYSQLND_STATISTICS_H #define MYSQLND_STATISTICS_H - PHPAPI extern MYSQLND_STATS * mysqlnd_global_stats; extern const MYSQLND_STRING mysqlnd_stats_values_names[]; diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 221b089442..868e383052 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -19,6 +19,8 @@ */ #include "php.h" #include "mysqlnd.h" +#include "mysqlnd_connection.h" +#include "mysqlnd_ps.h" #include "mysqlnd_priv.h" #include "mysqlnd_wireprotocol.h" #include "mysqlnd_statistics.h"