diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-08-20 13:32:53 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-08-20 13:33:45 +0200 |
commit | 3771d661426f33a27590b05df9c8983a2273fab6 (patch) | |
tree | 427df7fcca9778975d83ecebf072e019f23ba8b8 /ext/mysqlnd | |
parent | 5e19f1d458556183230fe0e09a6a24b413553e9b (diff) | |
parent | cdf16c010a11fc1f91c8807556ccc15b374c0922 (diff) | |
download | php-git-3771d661426f33a27590b05df9c8983a2273fab6.tar.gz |
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
fix the problem for connect_attr, set db condition, and add a new attribute _server_host
Diffstat (limited to 'ext/mysqlnd')
-rw-r--r-- | ext/mysqlnd/mysqlnd_auth.c | 3 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_connection.c | 9 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_wireprotocol.c | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c index e56ea20380..30ef6639ca 100644 --- a/ext/mysqlnd/mysqlnd_auth.c +++ b/ext/mysqlnd/mysqlnd_auth.c @@ -409,6 +409,9 @@ mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn, auth_packet.auth_data_len = auth_plugin_data_len; auth_packet.auth_plugin_name = auth_protocol; + if (conn->server_capabilities & CLIENT_CONNECT_ATTRS) { + auth_packet.connect_attr = conn->options->connect_attr; + } if (conn->m->get_server_version(conn) >= 50123) { auth_packet.charset_no = conn->charset->nr; diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c index 21a542517a..dba65c0954 100644 --- a/ext/mysqlnd/mysqlnd_connection.c +++ b/ext/mysqlnd/mysqlnd_connection.c @@ -510,6 +510,10 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags)(MYSQLND_CONN_DATA * } #endif + if (conn->options->connect_attr && zend_hash_num_elements(conn->options->connect_attr)) { + mysql_flags |= CLIENT_CONNECT_ATTRS; + } + DBG_RETURN(mysql_flags); } /* }}} */ @@ -653,7 +657,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, password.s = ""; password.l = 0; } - if (!database.s) { + if (!database.s || !database.s[0]) { DBG_INF_FMT("no db given, using empty string"); database.s = ""; database.l = 0; @@ -821,6 +825,9 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn_handle, if (PASS == conn->m->local_tx_start(conn, this_func)) { mysqlnd_options4(conn_handle, MYSQL_OPT_CONNECT_ATTR_ADD, "_client_name", "mysqlnd"); + if (hostname.l > 0) { + mysqlnd_options4(conn_handle, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", hostname.s); + } ret = conn->m->connect(conn, hostname, username, password, database, port, socket_or_pipe, mysql_flags); conn->m->local_tx_end(conn, this_func, FAIL); diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 82df845daa..6459fe4964 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -546,7 +546,7 @@ size_t php_mysqlnd_auth_write(MYSQLND_CONN_DATA * conn, void * _packet) p+= packet->auth_data_len; } - if (packet->db) { + if (packet->db_len > 0) { /* CLIENT_CONNECT_WITH_DB should have been set */ size_t real_db_len = MIN(MYSQLND_MAX_ALLOWED_DB_LEN, packet->db_len); memcpy(p, packet->db, real_db_len); |