diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4753435bbfa..268a452095e 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -472,6 +472,7 @@ void mysqld_list_processes(THD *thd,const char *user,bool verbose); int mysqld_show_status(THD *thd); int mysqld_show_variables(THD *thd,const char *wild); int mysqld_show(THD *thd, const char *wild, show_var_st *variables); +int mysqld_show_charsets(THD *thd,const char *wild); /* sql_handler.cc */ int mysql_ha_open(THD *thd, TABLE_LIST *tables); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 25798bbf079..ee0209f9329 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -41,7 +41,7 @@ enum enum_sql_command { SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS, SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS, SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT, - SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, + SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS, SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES, SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 174942054e1..a5d8aa3185e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2101,6 +2101,9 @@ mysql_execute_command(void) case SQLCOM_SHOW_OPEN_TABLES: res= mysqld_show_open_tables(thd,(lex->wild ? lex->wild->ptr() : NullS)); break; + case SQLCOM_SHOW_CHARSETS: + res= mysqld_show_charsets(thd,(lex->wild ? lex->wild->ptr() : NullS)); + break; case SQLCOM_SHOW_FIELDS: #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 995142d6566..1421eac168f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1162,6 +1162,44 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) ** Status functions *****************************************************************************/ +int mysqld_show_charsets(THD *thd, const char *wild) +{ + uint i; + char buff[8192]; + String packet2(buff,sizeof(buff),default_charset_info); + List field_list; + CONVERT *convert=thd->convert_set; + CHARSET_INFO *cs; + DBUG_ENTER("mysqld_show_charsets"); + + field_list.push_back(new Item_empty_string("Name",30)); + field_list.push_back(new Item_int("Id",0,7)); + field_list.push_back(new Item_int("strx_maxlen",0,7)); + field_list.push_back(new Item_int("mb_maxlen",0,7)); + + if (send_fields(thd,field_list,1)) + DBUG_RETURN(1); + + for (cs=compiled_charsets ; cs->name ; cs++ ) + { + if (!(wild && wild[0] && wild_case_compare(system_charset_info,cs->name,wild))) + { + packet2.length(0); + net_store_data(&packet2,convert,cs->name); + net_store_data(&packet2,(uint32) cs->number); + net_store_data(&packet2,(uint32) cs->strxfrm_multiply); + net_store_data(&packet2,(uint32) cs->mbmaxlen); + + if (my_net_write(&thd->net, (char*) packet2.ptr(),packet2.length())) + goto err; /* purecov: inspected */ + } + } + send_eof(&thd->net); + DBUG_RETURN(0); +err: + DBUG_RETURN(1); +} + int mysqld_show(THD *thd, const char *wild, show_var_st *variables) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index efc8b8b5389..25d8dbbab16 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2801,6 +2801,8 @@ show_param: { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;} | VARIABLES wild { Lex->sql_command= SQLCOM_SHOW_VARIABLES; } + | CHAR_SYM SET wild + { Lex->sql_command= SQLCOM_SHOW_CHARSETS; } | LOGS_SYM { Lex->sql_command= SQLCOM_SHOW_LOGS; } | GRANTS FOR_SYM user