diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-11-28 23:15:12 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-11-28 23:15:12 +0100 |
commit | ec38c1bbd709da99fb84e2889f4443247fccfb30 (patch) | |
tree | 0324b7ee684e170c655f4f9d1472282ddc589f7c | |
parent | b27d93f3471c2e06347d0c918a8ada20f6168191 (diff) | |
download | mariadb-git-ec38c1bbd709da99fb84e2889f4443247fccfb30.tar.gz |
small cleanup
-rw-r--r-- | mysys/my_handler_errors.h | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 11 | ||||
-rw-r--r-- | sql/sql_class.cc | 10 | ||||
-rw-r--r-- | sql/sql_class.h | 12 | ||||
-rw-r--r-- | sql/sql_connect.cc | 21 | ||||
-rw-r--r-- | sql/sql_parse.cc | 9 |
6 files changed, 19 insertions, 47 deletions
diff --git a/mysys/my_handler_errors.h b/mysys/my_handler_errors.h index 42839fd31f5..7e5f4ce12f0 100644 --- a/mysys/my_handler_errors.h +++ b/mysys/my_handler_errors.h @@ -88,7 +88,4 @@ static const char *handler_error_messages[]= "Disk full" }; -extern void my_handler_error_register(void); -extern void my_handler_error_unregister(void); - #endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index da496f0a67d..c43f516fc2e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2340,15 +2340,8 @@ void close_connection(THD *thd, uint sql_errno) if (sql_errno) net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL); - if (global_system_variables.log_warnings > 3) - { - Security_context *sctx= &thd->main_security_ctx; - sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), - thd->thread_id,(thd->db ? thd->db : "unconnected"), - sctx->user ? sctx->user : "unauthenticated", - sctx->host_or_ip, - (sql_errno ? ER(sql_errno) : "CLOSE_CONNECTION")); - } + thd->print_aborted_warning(3, sql_errno ? ER_DEFAULT(sql_errno) + : "CLOSE_CONNECTION"); thd->disconnect(); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 259e5f2fd4f..cc58a131f00 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1528,15 +1528,7 @@ void THD::awake(killed_state state_to_set) THD_CHECK_SENTRY(this); mysql_mutex_assert_owner(&LOCK_thd_data); - if (global_system_variables.log_warnings > 3) - { - Security_context *sctx= security_ctx; - sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), - thread_id,(db ? db : "unconnected"), - sctx->user ? sctx->user : "unauthenticated", - sctx->host_or_ip, - "KILLED"); - } + print_aborted_warning(3, "KILLED"); /* Set the 'killed' flag of 'this', which is the target THD object. */ killed= state_to_set; diff --git a/sql/sql_class.h b/sql/sql_class.h index 70f47521711..f271a6d5cd9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2987,6 +2987,18 @@ public: LEX_STRING get_invoker_host() { return invoker_host; } bool has_invoker() { return invoker_user.length > 0; } + void print_aborted_warning(uint threshold, const char *reason) + { + if (global_system_variables.log_warnings > threshold) + { + Security_context *sctx= &main_security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thread_id, (db ? db : "unconnected"), + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, reason); + } + } + private: /* This reference points to the table arena when the expression diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index bcffad06ad1..3c88b7a054d 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1072,20 +1072,8 @@ void end_connection(THD *thd) status_var_increment(thd->status_var.lost_connections); } - if (net->error && net->vio != 0) - { - if (!thd->killed && thd->variables.log_warnings > 1) - { - Security_context *sctx= thd->security_ctx; - - sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), - thd->thread_id,(thd->db ? thd->db : "unconnected"), - sctx->user ? sctx->user : "unauthenticated", - sctx->host_or_ip, - (thd->stmt_da->is_error() ? thd->stmt_da->message() : - ER(ER_UNKNOWN_ERROR))); - } - } + if (!thd->killed && (net->error && net->vio != 0)) + thd->print_aborted_warning(1, ER(ER_UNKNOWN_ERROR)); } @@ -1116,10 +1104,7 @@ void prepare_new_connection_state(THD* thd) if (thd->is_error()) { thd->killed= KILL_CONNECTION; - sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), - thd->thread_id,(thd->db ? thd->db : "unconnected"), - sctx->user ? sctx->user : "unauthenticated", - sctx->host_or_ip, "init_connect command failed"); + thd->print_aborted_warning(0, "init_connect command failed"); sql_print_warning("%s", thd->stmt_da->message()); } thd->proc_info=0; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 714542ab0af..719fcad5883 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3751,14 +3751,7 @@ end_with_restore_list: if (tx_release) { thd->killed= KILL_CONNECTION; - if (global_system_variables.log_warnings > 3) - { - Security_context *sctx= &thd->main_security_ctx; - sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), - thd->thread_id,(thd->db ? thd->db : "unconnected"), - sctx->user ? sctx->user : "unauthenticated", - sctx->host_or_ip, "RELEASE"); - } + thd->print_aborted_warning(3, "RELEASE"); } my_ok(thd); break; |