summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorunknown <holyfoot@mysql.com>2006-06-26 22:32:02 +0500
committerunknown <holyfoot@mysql.com>2006-06-26 22:32:02 +0500
commit87257abe59af21274e6388418567edd6579de0c5 (patch)
treed80a7a0f57c15f731dd1554355161803f69d5c95 /sql-common
parent80bb69ed8fbfce3659868fc22bce32ac4d034d58 (diff)
parent31ffea2a08dee857f930936d4d0e38354065c16e (diff)
downloadmariadb-git-87257abe59af21274e6388418567edd6579de0c5.tar.gz
merging
libmysqld/libmysqld.c: Auto merged sql/item_geofunc.h: Auto merged sql/sql_parse.cc: Auto merged
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c86
1 files changed, 49 insertions, 37 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 26ebc9cc6b0..56a5862c90e 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -130,6 +130,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
@@ -1431,7 +1433,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
@@ -1660,7 +1662,51 @@ static MYSQL_METHODS client_methods=
#endif
};
-MYSQL *
+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 * STDCALL
CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag)
@@ -1997,42 +2043,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),