1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Bug#57306 SHOW PROCESSLIST does not display string literals well.

Problem: Extended characters outside of ASCII range where not displayed
properly in SHOW PROCESSLIST, because thd_info->query was always sent as 
system_character_set (utf8). This was wrong, because query buffer
is never converted to utf8 - it is always have client character set.

Fix: sending query buffer using query character set

  @ sql/sql_class.cc
  @ sql/sql_class.h
    Introducing a new class CSET_STRING, a LEX_STRING with character set.
    Adding set_query(&CSET_STRING)
    Adding reset_query(), to use instead of set_query(0, NULL).

  @ sql/event_data_objects.cc
    Using reset_query()

  @ sql/log_event.cc
    Using reset_query()
    Adding charset argument to set_query_and_id().

  @ sql/slave.cc
    Using reset_query().

  @ sql/sp_head.cc
    Changing backing up and restore code to use CSET_STRING.

  @ sql/sql_audit.h
    Using CSET_STRING.
    In the "else" branch it's OK not to use
    global_system_variables.character_set_client.
    &my_charset_latin1, which is set in constructor, is fine
    (verified with Sergey Vojtovich).

  @ sql/sql_insert.cc
    Using set_query() with proper character set: table_name is utf8.

  @ sql/sql_parse.cc
    Adding character set argument to set_query_and_id().
    (This is the main point where thd->charset() is stored
     into thd->query_string.cs, for use in "SHOW PROCESSLIST".)
    Using reset_query().
    
  @ sql/sql_prepare.cc
    Storing client character set into thd->query_string.cs.

  @ sql/sql_show.cc
    Using CSET_STRING to fetch and send charset-aware query information
    from threads.

  @ storage/myisam/ha_myisam.cc
    Using set_query() with proper character set: table_name is utf8.

  @ mysql-test/r/show_check.result
  @ mysql-test/t/show_check.test
    Adding tests
This commit is contained in:
Alexander Barkov
2010-11-18 17:08:32 +03:00
parent 459c3b8f55
commit fad763a81f
14 changed files with 170 additions and 61 deletions

View File

@ -2586,8 +2586,6 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
db(NULL),
db_length(0)
{
query_string.length= 0;
query_string.str= NULL;
name.str= NULL;
}
@ -2626,15 +2624,6 @@ void Statement::restore_backup_statement(Statement *stmt, Statement *backup)
}
/** Assign a new value to thd->query. */
void Statement::set_query_inner(char *query_arg, uint32 query_length_arg)
{
query_string.str= query_arg;
query_string.length= query_length_arg;
}
void THD::end_statement()
{
/* Cleanup SQL processing state to reuse this statement in next query. */
@ -3167,7 +3156,7 @@ extern "C" struct charset_info_st *thd_charset(MYSQL_THD thd)
*/
extern "C" char **thd_query(MYSQL_THD thd)
{
return(&thd->query_string.str);
return (&thd->query_string.string.str);
}
/**
@ -3178,7 +3167,7 @@ extern "C" char **thd_query(MYSQL_THD thd)
*/
extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd)
{
return(&thd->query_string);
return(&thd->query_string.string);
}
extern "C" int thd_slave_thread(const MYSQL_THD thd)
@ -3423,20 +3412,21 @@ void THD::set_statement(Statement *stmt)
/** Assign a new value to thd->query. */
void THD::set_query(char *query_arg, uint32 query_length_arg)
void THD::set_query(const CSET_STRING &string_arg)
{
mysql_mutex_lock(&LOCK_thd_data);
set_query_inner(query_arg, query_length_arg);
set_query_inner(string_arg);
mysql_mutex_unlock(&LOCK_thd_data);
}
/** Assign a new value to thd->query and thd->query_id. */
void THD::set_query_and_id(char *query_arg, uint32 query_length_arg,
CHARSET_INFO *cs,
query_id_t new_query_id)
{
mysql_mutex_lock(&LOCK_thd_data);
set_query_inner(query_arg, query_length_arg);
set_query_inner(query_arg, query_length_arg, cs);
query_id= new_query_id;
mysql_mutex_unlock(&LOCK_thd_data);
}