diff options
author | Ashish Agarwal <ashish.y.agarwal@oracle.com> | 2013-08-23 09:07:09 +0530 |
---|---|---|
committer | Ashish Agarwal <ashish.y.agarwal@oracle.com> | 2013-08-23 09:07:09 +0530 |
commit | d75c58e11fb864abafb48d74efd9bb1dbdc9f4c4 (patch) | |
tree | 01a2e2f69168201021668f8d6144a6aa701c61ad /sql/mysqld.cc | |
parent | f7e0cc8204ab2e9e09e96e77f015dfb369553de0 (diff) | |
parent | f5b5e6b951eabe6d6add84fa915d305a4a95cddf (diff) | |
download | mariadb-git-d75c58e11fb864abafb48d74efd9bb1dbdc9f4c4.tar.gz |
WL#7076: Backporting wl6715 to support both formats
in 5.5, 5.6, 5.7.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 287ca3e4aa4..145e2220d38 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3088,6 +3088,44 @@ SHOW_VAR com_status_vars[]= { {NullS, NullS, SHOW_LONG} }; +LEX_CSTRING sql_statement_names[(uint) SQLCOM_END + 1]; + +void init_sql_statement_names() +{ + static LEX_CSTRING empty= { C_STRING_WITH_LEN("") }; + + char *first_com= (char*) offsetof(STATUS_VAR, com_stat[0]); + char *last_com= (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_END]); + int record_size= (char*) offsetof(STATUS_VAR, com_stat[1]) + - (char*) offsetof(STATUS_VAR, com_stat[0]); + char *ptr; + uint i; + uint com_index; + + for (i= 0; i < ((uint) SQLCOM_END + 1); i++) + sql_statement_names[i]= empty; + + SHOW_VAR *var= &com_status_vars[0]; + while (var->name != NULL) + { + ptr= var->value; + if ((first_com <= ptr) && (ptr <= last_com)) + { + com_index= ((int)(ptr - first_com))/record_size; + DBUG_ASSERT(com_index < (uint) SQLCOM_END); + sql_statement_names[com_index].str= var->name; + /* TODO: Change SHOW_VAR::name to a LEX_STRING, to avoid strlen() */ + sql_statement_names[com_index].length= strlen(var->name); + } + var++; + } + + DBUG_ASSERT(strcmp(sql_statement_names[(uint) SQLCOM_SELECT].str, "select") == 0); + DBUG_ASSERT(strcmp(sql_statement_names[(uint) SQLCOM_SIGNAL].str, "signal") == 0); + + sql_statement_names[(uint) SQLCOM_END].str= "error"; +} + /** Create the name of the default general log file @@ -4284,6 +4322,7 @@ int mysqld_main(int argc, char **argv) /* Must be initialized early for comparison of options name */ system_charset_info= &my_charset_utf8_general_ci; + init_sql_statement_names(); sys_var_init(); #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE @@ -5366,7 +5405,7 @@ void handle_connections_sockets() continue; } if (sock == unix_sock) - thd->security_ctx->host=(char*) my_localhost; + thd->security_ctx->set_host((char*) my_localhost); create_new_thread(thd); } @@ -5470,7 +5509,7 @@ pthread_handler_t handle_connections_namedpipes(void *arg) continue; } /* Host is unknown */ - thd->security_ctx->host= my_strdup(my_localhost, MYF(0)); + thd->security_ctx->set_host(my_strdup(my_localhost, MYF(0))); create_new_thread(thd); } CloseHandle(connectOverlapped.hEvent); @@ -5664,7 +5703,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg) errmsg= 0; goto errorconn; } - thd->security_ctx->host= my_strdup(my_localhost, MYF(0)); /* Host is unknown */ + thd->security_ctx->set_host(my_strdup(my_localhost, MYF(0))); /* Host is unknown */ create_new_thread(thd); connect_number++; continue; |