summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2005-05-14 12:38:12 +0400
committerkonstantin@mysql.com <>2005-05-14 12:38:12 +0400
commit89bd09fed2565f0e509a9d81ca7e9782ff1f8ea1 (patch)
tree301d852032306dc5560a6076b889c4d7c3d6da7d /libmysql
parent3ff39b3704b4b0023ab107217ec36fe578f26e4d (diff)
parent6c981c0b8005a1577c7dfd93eb656a5da46ef9f0 (diff)
downloadmariadb-git-89bd09fed2565f0e509a9d81ca7e9782ff1f8ea1.tar.gz
Manual merge (again)
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/libmysql.c37
-rw-r--r--libmysql/libmysql.def1
2 files changed, 36 insertions, 2 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 3e6b29b7602..f070d95780c 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1495,6 +1495,36 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql)
return mysql->charset->csname;
}
+int STDCALL mysql_set_character_set(MYSQL *mysql, char *cs_name)
+{
+ struct charset_info_st *cs;
+ const char *save_csdir = charsets_dir;
+
+ if (mysql->options.charset_dir)
+ charsets_dir = mysql->options.charset_dir;
+
+ if ( (cs = get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))) )
+ {
+ char buff[MY_CS_NAME_SIZE + 10];
+ charsets_dir = save_csdir;
+ sprintf(buff, "SET NAMES %s", cs_name);
+ if (!mysql_query(mysql, buff)) {
+ mysql->charset = cs;
+ }
+ } else {
+ char cs_dir_name[FN_REFLEN];
+ get_charsets_dir(cs_dir_name);
+ mysql->net.last_errno=CR_CANT_READ_CHARSET;
+ strmov(mysql->net.sqlstate, unknown_sqlstate);
+ my_snprintf(mysql->net.last_error, sizeof(mysql->net.last_error)-1,
+ ER(mysql->net.last_errno),
+ cs_name,
+ cs_dir_name);
+
+ }
+ charsets_dir = save_csdir;
+ return mysql->net.last_errno;
+}
uint STDCALL mysql_thread_safe(void)
{
@@ -4375,9 +4405,12 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
/*
We only need to check that stmt->field_count - if it is not null
stmt->bind was initialized in mysql_stmt_prepare
- */
+ stmt->bind overlaps with bind if mysql_stmt_bind_param
+ is called from mysql_stmt_store_result.
+ */
- memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count);
+ if (stmt->bind != bind)
+ memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count);
for (param= stmt->bind, end= param + bind_count, field= stmt->fields ;
param < end ;
diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def
index 414ac4afd85..a597ee37682 100644
--- a/libmysql/libmysql.def
+++ b/libmysql/libmysql.def
@@ -148,6 +148,7 @@ EXPORTS
mysql_embedded
mysql_server_init
mysql_server_end
+ mysql_set_character_set
get_defaults_files
get_charset_by_csname
get_charsets_dir