summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <Li-Bing.Song@sun.com>2009-08-12 11:54:05 +0800
committerunknown <Li-Bing.Song@sun.com>2009-08-12 11:54:05 +0800
commit0d821fafe99fbaf362529f8237b4a61a6394c0fb (patch)
tree0ded16cb38fd34669a6d7bfcdbd59037cd6b0ec0 /sql
parentd33a57a694ec9ccf8a0d4f901b86ee4bbe5a6019 (diff)
downloadmariadb-git-0d821fafe99fbaf362529f8237b4a61a6394c0fb.tar.gz
BUG#45516 SQL thread does not use database charset properly
Replication SQL thread does not set database default charset to thd->variables.collation_database properly, when executing LOAD DATA binlog. This bug can be repeated by using "LOAD DATA" command in STATEMENT mode. This patch adds code to find the default character set of the current database then assign it to thd->db_charset when slave server begins to execute a relay log. The test of this bug is added into rpl_loaddata_charset.test
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 9b0f8e97a28..40e29e58ab6 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1918,6 +1918,8 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli,
{
const char *new_db= rewrite_db(db);
int expected_error,actual_error= 0;
+ HA_CREATE_INFO db_options;
+
/*
Colleagues: please never free(thd->catalog) in MySQL. This would lead to
bugs as here thd->catalog is a part of an alloced block, not an entire
@@ -1926,6 +1928,14 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli,
*/
thd->catalog= catalog_len ? (char *) catalog : (char *)"";
thd->set_db(new_db, (uint) strlen(new_db)); /* allocates a copy of 'db' */
+
+ /*
+ Setting the character set and collation of the current database thd->db.
+ */
+ load_db_opt_by_name(thd, thd->db, &db_options);
+ if (db_options.default_table_charset)
+ thd->db_charset= db_options.default_table_charset;
+
thd->variables.auto_increment_increment= auto_increment_increment;
thd->variables.auto_increment_offset= auto_increment_offset;