diff options
-rw-r--r-- | include/violite.h | 5 | ||||
-rw-r--r-- | sql/sql_acl.cc | 4 | ||||
-rw-r--r-- | storage/perfschema/table_threads.cc | 4 | ||||
-rw-r--r-- | vio/viosocket.c | 20 |
4 files changed, 30 insertions, 3 deletions
diff --git a/include/violite.h b/include/violite.h index 1d981c8bf83..95a4830df89 100644 --- a/include/violite.h +++ b/include/violite.h @@ -39,7 +39,10 @@ enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL + /* see also vio_type_names[] */ }; +#define FIRST_VIO_TYPE VIO_CLOSED +#define LAST_VIO_TYPE VIO_TYPE_SSL /** VIO I/O events. @@ -184,6 +187,8 @@ void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd); void vio_end(void); +const char *vio_type_name(enum enum_vio_type vio_type, size_t *len); + #ifdef __cplusplus } #endif diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 2ff8c5d8bdc..fbb80a2361e 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -70,7 +70,7 @@ const uint max_dbname_length= 64; const char *safe_vio_type_name(Vio *vio) { - int unused; + size_t unused; #ifdef EMBEDDED_LIBRARY if (!vio) return "Internal"; #endif @@ -13978,6 +13978,8 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) res= do_auth_once(thd, default_auth_plugin_name, &mpvio); } + PSI_CALL_set_connection_type(vio_type(thd->net.vio)); + Security_context * const sctx= thd->security_ctx; const ACL_USER * acl_user= mpvio.acl_user; if (!acl_user) diff --git a/storage/perfschema/table_threads.cc b/storage/perfschema/table_threads.cc index 6d83b6531b6..0b004c17c24 100644 --- a/storage/perfschema/table_threads.cc +++ b/storage/perfschema/table_threads.cc @@ -215,7 +215,7 @@ int table_threads::read_row_values(TABLE *table, { Field *f; const char *str= NULL; - int len= 0; + size_t len= 0; if (unlikely(! m_row_exists)) return HA_ERR_RECORD_DELETED; @@ -326,7 +326,7 @@ int table_threads::read_row_values(TABLE *table, case 15: /* CONNECTION_TYPE */ get_vio_type_name(m_row.m_connection_type, & str, & len); if (len > 0) - set_field_varchar_utf8(f, str, len); + set_field_varchar_utf8(f, str, (uint)len); else f->set_null(); break; diff --git a/vio/viosocket.c b/vio/viosocket.c index 9ef703dee8d..c4d55901a16 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -645,6 +645,26 @@ enum enum_vio_type vio_type(Vio* vio) return vio->type; } +static const LEX_CSTRING vio_type_names[] = +{ + { STRING_WITH_LEN("Error") }, // cannot happen + { STRING_WITH_LEN("TCP/IP") }, + { STRING_WITH_LEN("Socket") }, + { STRING_WITH_LEN("Named Pipe") }, + { STRING_WITH_LEN("SSL/TLS") }, + { STRING_WITH_LEN("Shared Memory") } +}; + +const char *vio_type_name(enum enum_vio_type vio_type, size_t *len) +{ + int index= vio_type >= FIRST_VIO_TYPE && vio_type <= LAST_VIO_TYPE + ? vio_type : 0; + + *len= vio_type_names[index].length; + return vio_type_names[index].str; +} + + my_socket vio_fd(Vio* vio) { return mysql_socket_getfd(vio->mysql_socket); |