diff options
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r-- | sql/protocol.cc | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc index 00ce5701756..b563925f612 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -368,9 +368,8 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, buff[]: sql_errno:2 + ('#':1 + SQLSTATE_LENGTH:5) + MYSQL_ERRMSG_SIZE:512 */ uint error; - uchar converted_err[MYSQL_ERRMSG_SIZE]; - uint32 converted_err_len; - uchar buff[2+1+SQLSTATE_LENGTH+MYSQL_ERRMSG_SIZE], *pos; + char converted_err[MYSQL_ERRMSG_SIZE]; + char buff[2+1+SQLSTATE_LENGTH+MYSQL_ERRMSG_SIZE], *pos; DBUG_ENTER("send_error_packet"); @@ -390,19 +389,16 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, { /* The first # is to make the protocol backward compatible */ buff[2]= '#'; - pos= (uchar*) strmov((char*) buff+3, sqlstate); + pos= strmov(buff+3, sqlstate); } - converted_err_len= convert_error_message((char*)converted_err, - sizeof(converted_err), - thd->variables.character_set_results, - err, strlen(err), - system_charset_info, &error); - length= (uint) (strmake((char*) pos, (char*)converted_err, - MYSQL_ERRMSG_SIZE - 1) - (char*) buff); - err= (char*) buff; + convert_error_message(converted_err, sizeof(converted_err), + thd->variables.character_set_results, + err, strlen(err), system_charset_info, &error); + /* Converted error message is always null-terminated. */ + length= (uint) (strmake(pos, converted_err, MYSQL_ERRMSG_SIZE - 1) - buff); - DBUG_RETURN(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) err, + DBUG_RETURN(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) buff, length)); } |