diff options
author | unknown <holyfoot@deer.(none)> | 2006-06-19 22:11:01 +0500 |
---|---|---|
committer | unknown <holyfoot@deer.(none)> | 2006-06-19 22:11:01 +0500 |
commit | 8b6c2d312b51f10de453aca1ca2164e7432acf3c (patch) | |
tree | 20d968927ec70e5b39ffcb4c3320841f23309a5b /libmysqld | |
parent | b10b25fbb59fb10527c207154bbb65270beddb84 (diff) | |
download | mariadb-git-8b6c2d312b51f10de453aca1ca2164e7432acf3c.tar.gz |
bug #20318 (ctype_ucs2_def test fails with embedded)
there was two problems about charsets in embedded server
1. mysys/charset.c - defined there default_charset_info variable is
modified by both server and client code (particularly when
--default-charset option is handled)
In embedded server we get two codelines modifying one variable.
I created separate default_client_charset_info for client code
2. mysql->charset and mysql->options.charset initialization isn't
properly done for embedded server - necessary calls added
include/sql_common.h:
client charset info default declared
libmysqld/lib_sql.cc:
thd_init_client_charset calls added
libmysqld/libmysqld.c:
check_embedded_connection moved to client.c to avoid code duplication
sql-common/client.c:
charset initialization moved to mysql_init_character_set to
be used in embedded server
sql/sql_parse.cc:
thread client charset initialization moved to thd_init_client_charset
to avoid code duplication
Diffstat (limited to 'libmysqld')
-rw-r--r-- | libmysqld/lib_sql.cc | 7 | ||||
-rw-r--r-- | libmysqld/libmysqld.c | 48 |
2 files changed, 10 insertions, 45 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index bf8c17a71af..56f4200e695 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -41,6 +41,8 @@ static const char *fake_groups[] = { "server", "embedded", 0 }; int check_user(THD *thd, enum enum_server_command command, const char *passwd, uint passwd_len, const char *db, bool check_count); +void thd_init_client_charset(THD *thd, uint cs_number); + C_MODE_START #include <mysql.h> #undef ER @@ -532,10 +534,13 @@ err: return NULL; } + #ifdef NO_EMBEDDED_ACCESS_CHECKS int check_embedded_connection(MYSQL *mysql) { THD *thd= (THD*)mysql->thd; + thd_init_client_charset(thd, mysql->charset->number); + thd->update_charset(); thd->host= (char*)my_localhost; thd->host_or_ip= thd->host; thd->user= my_strdup(mysql->user, MYF(0)); @@ -551,6 +556,8 @@ int check_embedded_connection(MYSQL *mysql) char scramble_buff[SCRAMBLE_LENGTH]; int passwd_len; + thd_init_client_charset(thd, mysql->charset->number); + thd->update_charset(); if (mysql->options.client_ip) { thd->host= my_strdup(mysql->options.client_ip, MYF(0)); diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 6fa41fb3fd0..a2bd4242c3d 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -85,49 +85,7 @@ static void end_server(MYSQL *mysql) } -static int mysql_init_charset(MYSQL *mysql) -{ - char charset_name_buff[16], *charset_name; - - if ((charset_name=mysql->options.charset_name)) - { - const char *save=charsets_dir; - if (mysql->options.charset_dir) - charsets_dir=mysql->options.charset_dir; - mysql->charset=get_charset_by_name(mysql->options.charset_name, - MYF(MY_WME)); - charsets_dir=save; - } - else if (mysql->server_language) - { - charset_name=charset_name_buff; - sprintf(charset_name,"%d",mysql->server_language); /* In case of errors */ - mysql->charset=get_charset((uint8) mysql->server_language, MYF(MY_WME)); - } - else - mysql->charset=default_charset_info; - - if (!mysql->charset) - { - mysql->net.last_errno=CR_CANT_READ_CHARSET; - strmov(mysql->net.sqlstate, "HY0000"); - if (mysql->options.charset_dir) - sprintf(mysql->net.last_error,ER(mysql->net.last_errno), - charset_name ? charset_name : "unknown", - mysql->options.charset_dir); - else - { - char cs_dir_name[FN_REFLEN]; - get_charsets_dir(cs_dir_name); - sprintf(mysql->net.last_error,ER(mysql->net.last_errno), - charset_name ? charset_name : "unknown", - cs_dir_name); - } - return mysql->net.last_errno; - } - return 0; -} - +int mysql_init_character_set(MYSQL *mysql); MYSQL * STDCALL mysql_real_connect(MYSQL *mysql,const char *host, const char *user, @@ -203,10 +161,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, init_embedded_mysql(mysql, client_flag, db_name); - if (check_embedded_connection(mysql)) + if (mysql_init_character_set(mysql)) goto error; - if (mysql_init_charset(mysql)) + if (check_embedded_connection(mysql)) goto error; /* Send client information for access check */ |