Commit 5fa9440a authored by kostja@bodhi.(none)'s avatar kostja@bodhi.(none)

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime

into  bodhi.(none):/opt/local/work/mysql-5.1-runtime-inc-2
parents 8423c7ef c0bb7f86
...@@ -920,7 +920,6 @@ bool init_new_connection_handler_thread(); ...@@ -920,7 +920,6 @@ bool init_new_connection_handler_thread();
void reset_mqh(LEX_USER *lu, bool get_them); void reset_mqh(LEX_USER *lu, bool get_them);
bool check_mqh(THD *thd, uint check_command); bool check_mqh(THD *thd, uint check_command);
void time_out_user_resource_limits(THD *thd, USER_CONN *uc); void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
int check_for_max_user_connections(THD *thd, USER_CONN *uc);
void decrease_user_connections(USER_CONN *uc); void decrease_user_connections(USER_CONN *uc);
void thd_init_client_charset(THD *thd, uint cs_number); void thd_init_client_charset(THD *thd, uint cs_number);
bool setup_connection_thread_globals(THD *thd); bool setup_connection_thread_globals(THD *thd);
......
...@@ -4302,6 +4302,7 @@ void create_thread_to_handle_connection(THD *thd) ...@@ -4302,6 +4302,7 @@ void create_thread_to_handle_connection(THD *thd)
} }
else else
{ {
char error_message_buff[MYSQL_ERRMSG_SIZE];
/* Create new thread to handle connection */ /* Create new thread to handle connection */
int error; int error;
thread_created++; thread_created++;
...@@ -4320,7 +4321,10 @@ void create_thread_to_handle_connection(THD *thd) ...@@ -4320,7 +4321,10 @@ void create_thread_to_handle_connection(THD *thd)
thd->killed= THD::KILL_CONNECTION; // Safety thd->killed= THD::KILL_CONNECTION; // Safety
(void) pthread_mutex_unlock(&LOCK_thread_count); (void) pthread_mutex_unlock(&LOCK_thread_count);
statistic_increment(aborted_connects,&LOCK_status); statistic_increment(aborted_connects,&LOCK_status);
net_printf_error(thd, ER_CANT_CREATE_THREAD, error); /* Can't use my_error() since store_globals has not been called. */
my_snprintf(error_message_buff, sizeof(error_message_buff),
ER(ER_CANT_CREATE_THREAD), error);
net_send_error(thd, ER_CANT_CREATE_THREAD, error_message_buff);
(void) pthread_mutex_lock(&LOCK_thread_count); (void) pthread_mutex_lock(&LOCK_thread_count);
close_connection(thd,0,0); close_connection(thd,0,0);
delete thd; delete thd;
......
...@@ -58,7 +58,7 @@ bool Protocol_binary::net_store_data(const uchar *from, size_t length) ...@@ -58,7 +58,7 @@ bool Protocol_binary::net_store_data(const uchar *from, size_t length)
Design note: Design note:
net_printf_error and net_send_error are low-level functions net_send_error is a low-level functions
that shall be used only when a new connection is being that shall be used only when a new connection is being
established or at server startup. established or at server startup.
For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's
...@@ -120,124 +120,6 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -120,124 +120,6 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
Write error package and flush to client
It's a little too low level, but I don't want to use another buffer for
this
Design note:
net_printf_error and net_send_error are low-level functions
that shall be used only when a new connection is being
established or at server startup.
For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's
critical that every error that can be intercepted is issued in one
place only, my_message_sql.
*/
void
net_printf_error(THD *thd, uint errcode, ...)
{
va_list args;
uint length,offset;
const char *format;
#ifndef EMBEDDED_LIBRARY
const char *text_pos;
int head_length= NET_HEADER_SIZE;
#else
char text_pos[1024];
#endif
NET *net= &thd->net;
DBUG_ENTER("net_printf_error");
DBUG_PRINT("enter",("message: %u",errcode));
DBUG_ASSERT(!thd->spcont);
if (net && net->no_send_error)
{
thd->clear_error();
thd->is_fatal_error= 0; // Error message is given
DBUG_PRINT("info", ("sending error messages prohibited"));
DBUG_VOID_RETURN;
}
thd->is_slave_error= 1; // needed to catch query errors during replication
#ifndef EMBEDDED_LIBRARY
query_cache_abort(net); // Safety
#endif
va_start(args,errcode);
/*
The following is needed to make net_printf_error() work with 0 argument
for errorcode and use the argument after that as the format string. This
is useful for rare errors that are not worth the hassle to put in
errmsg.sys, but at the same time, the message is not fixed text
*/
if (errcode)
format= ER(errcode);
else
{
format=va_arg(args,char*);
errcode= ER_UNKNOWN_ERROR;
}
offset= (net->return_errno ?
((thd->client_capabilities & CLIENT_PROTOCOL_41) ?
2+SQLSTATE_LENGTH+1 : 2) : 0);
#ifndef EMBEDDED_LIBRARY
text_pos=(char*) net->buff + head_length + offset + 1;
length= (uint) ((char*)net->buff_end - text_pos);
#else
length=sizeof(text_pos)-1;
#endif
length=my_vsnprintf(my_const_cast(char*) (text_pos),
min(length, sizeof(net->last_error)),
format,args);
va_end(args);
/* Replication slave relies on net->last_* to see if there was error */
net->last_errno= errcode;
strmake(net->last_error, text_pos, sizeof(net->last_error)-1);
#ifndef EMBEDDED_LIBRARY
if (net->vio == 0)
{
if (thd->bootstrap)
{
/*
In bootstrap it's ok to print on stderr
This may also happen when we get an error from a slave thread
*/
fprintf(stderr,"ERROR: %d %s\n",errcode,text_pos);
thd->fatal_error();
}
DBUG_VOID_RETURN;
}
int3store(net->buff,length+1+offset);
net->buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
net->buff[head_length]=(uchar) 255; // Error package
if (offset)
{
uchar *pos= net->buff+head_length+1;
int2store(pos, errcode);
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
pos[2]= '#'; /* To make the protocol backward compatible */
memcpy(pos+3, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH);
}
}
VOID(net_real_write(net, net->buff, length+head_length+1+offset));
#else
net->last_errno= errcode;
strmake(net->last_error, text_pos, length);
strmake(net->sqlstate, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH);
#endif
if (thd->killed != THD::KILL_CONNECTION)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, errcode,
text_pos ? text_pos : ER(errcode));
thd->is_fatal_error=0; // Error message is given
DBUG_VOID_RETURN;
}
/* /*
Return ok to the client. Return ok to the client.
......
...@@ -172,7 +172,6 @@ class Protocol_binary :public Protocol ...@@ -172,7 +172,6 @@ class Protocol_binary :public Protocol
}; };
void send_warning(THD *thd, uint sql_errno, const char *err=0); void send_warning(THD *thd, uint sql_errno, const char *err=0);
void net_printf_error(THD *thd, uint sql_errno, ...);
void net_send_error(THD *thd, uint sql_errno=0, const char *err=0); void net_send_error(THD *thd, uint sql_errno=0, const char *err=0);
void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L,
const char *info=0); const char *info=0);
......
This diff is collapsed.
...@@ -915,11 +915,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -915,11 +915,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (res) if (res)
{ {
/* authentication failure, we shall restore old user */
if (res > 0)
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
else
thd->clear_error(); // Error already sent to client
x_free(thd->security_ctx->user); x_free(thd->security_ctx->user);
*thd->security_ctx= save_security_ctx; *thd->security_ctx= save_security_ctx;
thd->user_connect= save_user_connect; thd->user_connect= save_user_connect;
......
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