Commit ec38c1bb authored by Sergei Golubchik's avatar Sergei Golubchik

small cleanup

parent b27d93f3
...@@ -88,7 +88,4 @@ static const char *handler_error_messages[]= ...@@ -88,7 +88,4 @@ static const char *handler_error_messages[]=
"Disk full" "Disk full"
}; };
extern void my_handler_error_register(void);
extern void my_handler_error_unregister(void);
#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */ #endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */
...@@ -2340,15 +2340,8 @@ void close_connection(THD *thd, uint sql_errno) ...@@ -2340,15 +2340,8 @@ void close_connection(THD *thd, uint sql_errno)
if (sql_errno) if (sql_errno)
net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL); net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL);
if (global_system_variables.log_warnings > 3) thd->print_aborted_warning(3, sql_errno ? ER_DEFAULT(sql_errno)
{ : "CLOSE_CONNECTION");
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->disconnect(); thd->disconnect();
......
...@@ -1528,15 +1528,7 @@ void THD::awake(killed_state state_to_set) ...@@ -1528,15 +1528,7 @@ void THD::awake(killed_state state_to_set)
THD_CHECK_SENTRY(this); THD_CHECK_SENTRY(this);
mysql_mutex_assert_owner(&LOCK_thd_data); mysql_mutex_assert_owner(&LOCK_thd_data);
if (global_system_variables.log_warnings > 3) print_aborted_warning(3, "KILLED");
{
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");
}
/* Set the 'killed' flag of 'this', which is the target THD object. */ /* Set the 'killed' flag of 'this', which is the target THD object. */
killed= state_to_set; killed= state_to_set;
......
...@@ -2987,6 +2987,18 @@ class THD :public Statement, ...@@ -2987,6 +2987,18 @@ class THD :public Statement,
LEX_STRING get_invoker_host() { return invoker_host; } LEX_STRING get_invoker_host() { return invoker_host; }
bool has_invoker() { return invoker_user.length > 0; } 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: private:
/* /*
This reference points to the table arena when the expression This reference points to the table arena when the expression
......
...@@ -1072,20 +1072,8 @@ void end_connection(THD *thd) ...@@ -1072,20 +1072,8 @@ void end_connection(THD *thd)
status_var_increment(thd->status_var.lost_connections); status_var_increment(thd->status_var.lost_connections);
} }
if (net->error && net->vio != 0) if (!thd->killed && (net->error && net->vio != 0))
{ thd->print_aborted_warning(1, ER(ER_UNKNOWN_ERROR));
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)));
}
}
} }
...@@ -1116,10 +1104,7 @@ void prepare_new_connection_state(THD* thd) ...@@ -1116,10 +1104,7 @@ void prepare_new_connection_state(THD* thd)
if (thd->is_error()) if (thd->is_error())
{ {
thd->killed= KILL_CONNECTION; thd->killed= KILL_CONNECTION;
sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), thd->print_aborted_warning(0, "init_connect command failed");
thd->thread_id,(thd->db ? thd->db : "unconnected"),
sctx->user ? sctx->user : "unauthenticated",
sctx->host_or_ip, "init_connect command failed");
sql_print_warning("%s", thd->stmt_da->message()); sql_print_warning("%s", thd->stmt_da->message());
} }
thd->proc_info=0; thd->proc_info=0;
......
...@@ -3751,14 +3751,7 @@ case SQLCOM_PREPARE: ...@@ -3751,14 +3751,7 @@ case SQLCOM_PREPARE:
if (tx_release) if (tx_release)
{ {
thd->killed= KILL_CONNECTION; thd->killed= KILL_CONNECTION;
if (global_system_variables.log_warnings > 3) thd->print_aborted_warning(3, "RELEASE");
{
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");
}
} }
my_ok(thd); my_ok(thd);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment