summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-08-11 13:14:26 +0500
committerunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-08-11 13:14:26 +0500
commit256ac388eb65ed9fb381d9e743b8cea389a5eb54 (patch)
tree55829fd8d6aa1bcd6437f570c97a35517eb5b8de /sql-common
parentbfdbb780c26aae2705cf0d7e3048b5c0e40f59e1 (diff)
downloadmariadb-git-256ac388eb65ed9fb381d9e743b8cea389a5eb54.tar.gz
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). sql-common/client.c: - Take into account MYSQL_DEFAULT_COLLATION_NAME if character set is not set using mysql_option(), to honor --with-collation argument to configure. - Use default collation for the character set when it's not set using mysql_option().
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index e5bab51ca8a..ff5f1ef150a 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1544,11 +1544,18 @@ C_MODE_START
int mysql_init_character_set(MYSQL *mysql)
{
NET *net= &mysql->net;
+ const char *default_collation_name;
+
/* Set character set */
- if (!mysql->options.charset_name &&
- !(mysql->options.charset_name=
+ if (!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))))
return 1;
+ }
+ else
+ default_collation_name= NULL;
{
const char *save= charsets_dir;
@@ -1556,6 +1563,28 @@ int mysql_init_character_set(MYSQL *mysql)
charsets_dir=mysql->options.charset_dir;
mysql->charset=get_charset_by_csname(mysql->options.charset_name,
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;
}