diff options
author | unknown <ingo@chilla.local> | 2006-07-06 13:18:00 +0200 |
---|---|---|
committer | unknown <ingo@chilla.local> | 2006-07-06 13:18:00 +0200 |
commit | 4ceb9bb0901432d675003d8e306c020a54f880be (patch) | |
tree | 3e33e53f128c09130bc36998981ab91bdd917b1c /sql-common | |
parent | ff7cbe83483cb2a6c82abf551fecb02df1ee38f5 (diff) | |
parent | d87e4fbffbd00558f1cce58327d6e88129db4231 (diff) | |
download | mariadb-git-4ceb9bb0901432d675003d8e306c020a54f880be.tar.gz |
Merge chilla.local:/home/mydev/mysql-5.0-ateam
into chilla.local:/home/mydev/mysql-5.1-ateam
libmysqld/lib_sql.cc:
Auto merged
libmysqld/libmysqld.c:
Auto merged
mysql-test/r/func_sapdb.result:
Auto merged
mysql-test/r/func_time.result:
Auto merged
mysql-test/r/gis-rtree.result:
Auto merged
mysql-test/r/myisam.result:
Auto merged
mysql-test/r/symlink.result:
Auto merged
mysql-test/t/func_time.test:
Auto merged
mysql-test/t/key.test:
Auto merged
mysql-test/t/myisam.test:
Auto merged
scripts/make_binary_distribution.sh:
Auto merged
sql/field.cc:
Auto merged
sql-common/client.c:
Auto merged
sql/opt_sum.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/table.cc:
Auto merged
storage/myisam/mi_check.c:
Auto merged
storage/myisam/mi_create.c:
Auto merged
storage/myisam/mi_delete_table.c:
Auto merged
storage/myisam/mi_dynrec.c:
Auto merged
storage/myisam/mi_key.c:
Auto merged
storage/myisam/mi_rkey.c:
Auto merged
storage/myisam/rt_index.c:
Auto merged
storage/myisam/rt_mbr.c:
Auto merged
support-files/mysql.spec.sh:
Auto merged
mysql-test/r/ctype_utf8.result:
Manual merge
mysql-test/r/key.result:
Manual merge
mysql-test/t/ctype_utf8.test:
Manual merge
sql/item_timefunc.cc:
Manual merge
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 08d87f9d083..160f6eb2602 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -125,6 +125,8 @@ static void mysql_close_free(MYSQL *mysql); static int wait_for_data(my_socket fd, uint timeout); #endif +CHARSET_INFO *default_client_charset_info = &my_charset_latin1; + /**************************************************************************** A modified version of connect(). my_connect() allows you to specify @@ -1426,7 +1428,7 @@ mysql_init(MYSQL *mysql) bzero((char*) (mysql), sizeof(*(mysql))); mysql->options.connect_timeout= CONNECT_TIMEOUT; mysql->last_used_con= mysql->next_slave= mysql->master = mysql; - mysql->charset=default_charset_info; + mysql->charset=default_client_charset_info; strmov(mysql->net.sqlstate, not_error_sqlstate); /* By default, we are a replication pivot. The caller must reset it @@ -1655,6 +1657,50 @@ static MYSQL_METHODS client_methods= #endif }; +C_MODE_START +int mysql_init_character_set(MYSQL *mysql) +{ + NET *net= &mysql->net; + /* Set character set */ + if (!mysql->options.charset_name && + !(mysql->options.charset_name= + my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME)))) + return 1; + + { + const char *save= charsets_dir; + if (mysql->options.charset_dir) + charsets_dir=mysql->options.charset_dir; + mysql->charset=get_charset_by_csname(mysql->options.charset_name, + MY_CS_PRIMARY, MYF(MY_WME)); + charsets_dir= save; + } + + if (!mysql->charset) + { + net->last_errno=CR_CANT_READ_CHARSET; + strmov(net->sqlstate, unknown_sqlstate); + if (mysql->options.charset_dir) + my_snprintf(net->last_error, sizeof(net->last_error)-1, + ER(net->last_errno), + mysql->options.charset_name, + mysql->options.charset_dir); + else + { + char cs_dir_name[FN_REFLEN]; + get_charsets_dir(cs_dir_name); + my_snprintf(net->last_error, sizeof(net->last_error)-1, + ER(net->last_errno), + mysql->options.charset_name, + cs_dir_name); + } + return 1; + } + return 0; +} +C_MODE_END + + MYSQL * CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, @@ -1992,42 +2038,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, goto error; } - /* Set character set */ - if (!mysql->options.charset_name && - !(mysql->options.charset_name= - my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME)))) - goto error; - - { - const char *save= charsets_dir; - if (mysql->options.charset_dir) - charsets_dir=mysql->options.charset_dir; - mysql->charset=get_charset_by_csname(mysql->options.charset_name, - MY_CS_PRIMARY, MYF(MY_WME)); - charsets_dir= save; - } - - if (!mysql->charset) - { - net->last_errno=CR_CANT_READ_CHARSET; - strmov(net->sqlstate, unknown_sqlstate); - if (mysql->options.charset_dir) - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), - mysql->options.charset_name, - mysql->options.charset_dir); - else - { - char cs_dir_name[FN_REFLEN]; - get_charsets_dir(cs_dir_name); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), - mysql->options.charset_name, - cs_dir_name); - } + if (mysql_init_character_set(mysql)) goto error; - } - /* Save connection information */ if (!my_multi_malloc(MYF(0), |