Commit d1c24548 authored by bar@mysql.com's avatar bar@mysql.com

Bug#7192 Specify --with-collation doesn't work for connections?

--with-collation worked only on the server side.
Client side ignored this argument, so collation_connection
was not properly set (remained latin1_swedish_ci).
parent 69f0e87b
...@@ -1543,11 +1543,18 @@ C_MODE_START ...@@ -1543,11 +1543,18 @@ C_MODE_START
int mysql_init_character_set(MYSQL *mysql) int mysql_init_character_set(MYSQL *mysql)
{ {
NET *net= &mysql->net; NET *net= &mysql->net;
const char *default_collation_name;
/* Set character set */ /* Set character set */
if (!mysql->options.charset_name && if (!mysql->options.charset_name)
!(mysql->options.charset_name= {
default_collation_name= MYSQL_DEFAULT_COLLATION_NAME;
if (!(mysql->options.charset_name=
my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME)))) my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME))))
return 1; return 1;
}
else
default_collation_name= NULL;
{ {
const char *save= charsets_dir; const char *save= charsets_dir;
...@@ -1555,6 +1562,28 @@ int mysql_init_character_set(MYSQL *mysql) ...@@ -1555,6 +1562,28 @@ int mysql_init_character_set(MYSQL *mysql)
charsets_dir=mysql->options.charset_dir; charsets_dir=mysql->options.charset_dir;
mysql->charset=get_charset_by_csname(mysql->options.charset_name, mysql->charset=get_charset_by_csname(mysql->options.charset_name,
MY_CS_PRIMARY, MYF(MY_WME)); MY_CS_PRIMARY, MYF(MY_WME));
if (mysql->charset && default_collation_name)
{
CHARSET_INFO *collation;
if ((collation=
get_charset_by_name(default_collation_name, MYF(MY_WME))))
{
if (!my_charset_same(mysql->charset, collation))
{
my_printf_error(ER_UNKNOWN_ERROR,
"COLLATION %s is not valid for CHARACTER SET %s",
MYF(0),
default_collation_name, mysql->options.charset_name);
mysql->charset= NULL;
}
else
{
mysql->charset= collation;
}
}
else
mysql->charset= NULL;
}
charsets_dir= save; charsets_dir= save;
} }
......
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