mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
mysqlshow and mysqldump now send their vharacter set to server
character_set_results is now the same with character_set_client by default
This commit is contained in:
parent
e15ea0291a
commit
bb611fa0a2
8 changed files with 25 additions and 10 deletions
|
|
@ -30,6 +30,7 @@
|
|||
static my_string host=0,opt_password=0,user=0;
|
||||
static my_bool opt_show_keys=0,opt_compress=0,opt_status=0, tty_password=0;
|
||||
static uint opt_verbose=0;
|
||||
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
static char *shared_memory_base_name=0;
|
||||
|
|
@ -115,6 +116,8 @@ int main(int argc, char **argv)
|
|||
if (shared_memory_base_name)
|
||||
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
|
||||
#endif
|
||||
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
|
||||
if (!(mysql_real_connect(&mysql,host,user,opt_password,
|
||||
(first_argument_uses_wildcards) ? "" : argv[0],opt_mysql_port,opt_mysql_unix_port,
|
||||
0)))
|
||||
|
|
@ -155,6 +158,9 @@ static struct my_option my_long_options[] =
|
|||
{"character-sets-dir", 'c', "Directory where character sets are",
|
||||
(gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0,
|
||||
0, 0, 0, 0, 0},
|
||||
{"default-character-set", OPT_DEFAULT_CHARSET,
|
||||
"Set the default character set.", (gptr*) &default_charset,
|
||||
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"compress", 'C', "Use compression in server/client protocol",
|
||||
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||
0, 0, 0},
|
||||
|
|
@ -558,7 +564,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
|||
mysql_error(mysql));
|
||||
return 1;
|
||||
}
|
||||
end=strmov(strmov(query,"show /*!32332 FULL */ columns from "),table);
|
||||
end=strmov(strmov(strmov(query,"show /*!32332 FULL */ columns from `"),table),"`");
|
||||
if (wild && wild[0])
|
||||
strxmov(end," like '",wild,"'",NullS);
|
||||
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
|
||||
|
|
@ -580,7 +586,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
|||
print_res_top(result);
|
||||
if (opt_show_keys)
|
||||
{
|
||||
end=strmov(strmov(query,"show keys from "),table);
|
||||
end=strmov(strmov(strmov(query,"show keys from `"),table),"`");
|
||||
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
|
||||
{
|
||||
fprintf(stderr,"%s: Cannot list keys in db: %s, table: %s: %s\n",
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
|
|||
select cast("1:2:3" as TIME);
|
||||
cast("1:2:3" as TIME)
|
||||
01:02:03
|
||||
set names binary;
|
||||
select cast(_latin1'test' as char character set latin2);
|
||||
cast(_latin1'test' as char character set latin2)
|
||||
test
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ select cast("1:2:3" as TIME);
|
|||
#
|
||||
# Character set convertion
|
||||
#
|
||||
set names binary;
|
||||
select cast(_latin1'test' as char character set latin2);
|
||||
select cast(_koi8r'ÔÅÓÔ' as char character set cp1251);
|
||||
create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t;
|
||||
|
|
|
|||
|
|
@ -2048,7 +2048,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
|
|||
}
|
||||
global_system_variables.character_set_server= default_charset_info;
|
||||
global_system_variables.character_set_database= default_charset_info;
|
||||
global_system_variables.character_set_results= NULL;
|
||||
global_system_variables.character_set_results= default_charset_info;
|
||||
global_system_variables.character_set_client= default_charset_info;
|
||||
global_system_variables.collation_connection= default_charset_info;
|
||||
|
||||
|
|
@ -4689,7 +4689,7 @@ static void mysql_init_variables(void)
|
|||
/* Set default values for some option variables */
|
||||
global_system_variables.character_set_server= default_charset_info;
|
||||
global_system_variables.character_set_database= default_charset_info;
|
||||
global_system_variables.character_set_results= NULL;
|
||||
global_system_variables.character_set_results= default_charset_info;
|
||||
global_system_variables.character_set_client= default_charset_info;
|
||||
global_system_variables.collation_connection= default_charset_info;
|
||||
global_system_variables.table_type= DB_TYPE_MYISAM;
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
|
|||
String tmp((char*) buff,sizeof(buff),&my_charset_bin);
|
||||
Protocol_simple prot(thd);
|
||||
String *packet= prot.storage_packet();
|
||||
CHARSET_INFO *thd_charset= thd->charset();
|
||||
CHARSET_INFO *thd_charset= thd->variables.character_set_results;
|
||||
DBUG_ENTER("send_fields");
|
||||
|
||||
if (flag & 1)
|
||||
|
|
|
|||
|
|
@ -1355,7 +1355,7 @@ CHARSET_INFO ** sys_var_character_set_results::ci_ptr(THD *thd, enum_var_type ty
|
|||
void sys_var_character_set_results::set_default(THD *thd, enum_var_type type)
|
||||
{
|
||||
if (type == OPT_GLOBAL)
|
||||
global_system_variables.character_set_results= NULL;
|
||||
global_system_variables.character_set_results= default_charset_info;
|
||||
else
|
||||
thd->variables.character_set_results= global_system_variables.character_set_results;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -669,9 +669,12 @@ check_connections(THD *thd)
|
|||
global_system_variables.character_set_client;
|
||||
thd->variables.collation_connection=
|
||||
global_system_variables.collation_connection;
|
||||
thd->variables.character_set_results=
|
||||
global_system_variables.character_set_results;
|
||||
}
|
||||
else
|
||||
{
|
||||
thd->variables.character_set_results=
|
||||
thd->variables.collation_connection=
|
||||
thd->variables.character_set_client;
|
||||
}
|
||||
|
|
@ -1319,7 +1322,8 @@ restore_user:
|
|||
break;
|
||||
#else
|
||||
{
|
||||
char *fields;
|
||||
char *fields, *pend;
|
||||
String convname;
|
||||
TABLE_LIST table_list;
|
||||
statistic_increment(com_stat[SQLCOM_SHOW_FIELDS],&LOCK_status);
|
||||
bzero((char*) &table_list,sizeof(table_list));
|
||||
|
|
@ -1329,8 +1333,11 @@ restore_user:
|
|||
break;
|
||||
}
|
||||
thd->free_list=0;
|
||||
table_list.alias= table_list.real_name= thd->strdup(packet);
|
||||
packet=strend(packet)+1;
|
||||
pend= strend(packet);
|
||||
convname.copy(packet, pend-packet,
|
||||
thd->variables.character_set_client, system_charset_info);
|
||||
table_list.alias= table_list.real_name= convname.c_ptr();
|
||||
packet= pend+1;
|
||||
// command not cachable => no gap for data base name
|
||||
if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1)))
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -4452,7 +4452,7 @@ option_value:
|
|||
net_printf(thd,ER_COLLATION_CHARSET_MISMATCH,$3->name,$2->csname);
|
||||
YYABORT;
|
||||
}
|
||||
lex->var_list.push_back(new set_var_collation_client($3,$3,NULL));
|
||||
lex->var_list.push_back(new set_var_collation_client($3,$3,$3));
|
||||
}
|
||||
| PASSWORD equal text_or_password
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue