New command: SHOW CHARACTER SET [LIKE 'wild']

parent 7677ee05
...@@ -472,6 +472,7 @@ void mysqld_list_processes(THD *thd,const char *user,bool verbose); ...@@ -472,6 +472,7 @@ void mysqld_list_processes(THD *thd,const char *user,bool verbose);
int mysqld_show_status(THD *thd); int mysqld_show_status(THD *thd);
int mysqld_show_variables(THD *thd,const char *wild); int mysqld_show_variables(THD *thd,const char *wild);
int mysqld_show(THD *thd, const char *wild, show_var_st *variables); int mysqld_show(THD *thd, const char *wild, show_var_st *variables);
int mysqld_show_charsets(THD *thd,const char *wild);
/* sql_handler.cc */ /* sql_handler.cc */
int mysql_ha_open(THD *thd, TABLE_LIST *tables); int mysql_ha_open(THD *thd, TABLE_LIST *tables);
......
...@@ -41,7 +41,7 @@ enum enum_sql_command { ...@@ -41,7 +41,7 @@ enum enum_sql_command {
SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS, SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS, 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_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_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB,
......
...@@ -2101,6 +2101,9 @@ mysql_execute_command(void) ...@@ -2101,6 +2101,9 @@ mysql_execute_command(void)
case SQLCOM_SHOW_OPEN_TABLES: case SQLCOM_SHOW_OPEN_TABLES:
res= mysqld_show_open_tables(thd,(lex->wild ? lex->wild->ptr() : NullS)); res= mysqld_show_open_tables(thd,(lex->wild ? lex->wild->ptr() : NullS));
break; break;
case SQLCOM_SHOW_CHARSETS:
res= mysqld_show_charsets(thd,(lex->wild ? lex->wild->ptr() : NullS));
break;
case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_FIELDS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
......
...@@ -1162,6 +1162,44 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) ...@@ -1162,6 +1162,44 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
** Status functions ** 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<Item> 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) int mysqld_show(THD *thd, const char *wild, show_var_st *variables)
{ {
......
...@@ -2801,6 +2801,8 @@ show_param: ...@@ -2801,6 +2801,8 @@ show_param:
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;} { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
| VARIABLES wild | VARIABLES wild
{ Lex->sql_command= SQLCOM_SHOW_VARIABLES; } { Lex->sql_command= SQLCOM_SHOW_VARIABLES; }
| CHAR_SYM SET wild
{ Lex->sql_command= SQLCOM_SHOW_CHARSETS; }
| LOGS_SYM | LOGS_SYM
{ Lex->sql_command= SQLCOM_SHOW_LOGS; } { Lex->sql_command= SQLCOM_SHOW_LOGS; }
| GRANTS FOR_SYM user | GRANTS FOR_SYM user
......
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