summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <Li-Bing.Song@sun.com>2009-08-10 11:46:55 +0800
committerunknown <Li-Bing.Song@sun.com>2009-08-10 11:46:55 +0800
commit0306a1c6c5239be6e44c6e8985c1501ef292b65e (patch)
tree25b740a0bde0f38bc5792d0d27ba15f150c605fa /mysql-test
parent046267cf370e42440bcea1e15baa09c210ae330d (diff)
downloadmariadb-git-0306a1c6c5239be6e44c6e8985c1501ef292b65e.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 'mysql-test')
-rw-r--r--mysql-test/include/rpl_loaddata_charset.inc35
-rw-r--r--mysql-test/r/rpl_loaddata_charset.result41
-rw-r--r--mysql-test/std_data/loaddata_utf8.dat3
-rw-r--r--mysql-test/t/rpl_loaddata_charset.test17
4 files changed, 96 insertions, 0 deletions
diff --git a/mysql-test/include/rpl_loaddata_charset.inc b/mysql-test/include/rpl_loaddata_charset.inc
new file mode 100644
index 00000000000..f94ff4ed069
--- /dev/null
+++ b/mysql-test/include/rpl_loaddata_charset.inc
@@ -0,0 +1,35 @@
+connection master;
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest;
+--enable_warnings
+
+CREATE DATABASE mysqltest CHARSET UTF8;
+USE mysqltest;
+CREATE TABLE t (cl varchar(100)) CHARSET UTF8;
+
+if (!$LOAD_LOCAL)
+{
+ LOAD DATA INFILE '../std_data_ln/loaddata_utf8.dat' INTO TABLE t
+ FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
+}
+if ($LOAD_LOCAL)
+{
+ LOAD DATA LOCAL INFILE './std_data/loaddata_utf8.dat' INTO TABLE t
+ FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
+}
+
+save_master_pos;
+echo ----------content on master----------;
+SELECT hex(cl) FROM t;
+
+connection slave;
+sync_with_master;
+echo ----------content on slave----------;
+USE mysqltest;
+SELECT hex(cl) FROM t;
+
+connection master;
+DROP DATABASE mysqltest;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/mysql-test/r/rpl_loaddata_charset.result b/mysql-test/r/rpl_loaddata_charset.result
index 929d06e74cf..47fee19cf5d 100644
--- a/mysql-test/r/rpl_loaddata_charset.result
+++ b/mysql-test/r/rpl_loaddata_charset.result
@@ -35,3 +35,44 @@ C3BF
D0AA
D0AA
drop table t1;
+-------------test bug#45516------------------
+DROP DATABASE IF EXISTS mysqltest;
+CREATE DATABASE mysqltest CHARSET UTF8;
+USE mysqltest;
+CREATE TABLE t (cl varchar(100)) CHARSET UTF8;
+LOAD DATA LOCAL INFILE './std_data/loaddata_utf8.dat' INTO TABLE t
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
+----------content on master----------
+SELECT hex(cl) FROM t;
+hex(cl)
+E4B880E4BA8CE4B889
+E59B9BE4BA94E585AD
+E4B883E585ABE4B99D
+----------content on slave----------
+USE mysqltest;
+SELECT hex(cl) FROM t;
+hex(cl)
+E4B880E4BA8CE4B889
+E59B9BE4BA94E585AD
+E4B883E585ABE4B99D
+DROP DATABASE mysqltest;
+DROP DATABASE IF EXISTS mysqltest;
+CREATE DATABASE mysqltest CHARSET UTF8;
+USE mysqltest;
+CREATE TABLE t (cl varchar(100)) CHARSET UTF8;
+LOAD DATA INFILE '../std_data_ln/loaddata_utf8.dat' INTO TABLE t
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
+----------content on master----------
+SELECT hex(cl) FROM t;
+hex(cl)
+E4B880E4BA8CE4B889
+E59B9BE4BA94E585AD
+E4B883E585ABE4B99D
+----------content on slave----------
+USE mysqltest;
+SELECT hex(cl) FROM t;
+hex(cl)
+E4B880E4BA8CE4B889
+E59B9BE4BA94E585AD
+E4B883E585ABE4B99D
+DROP DATABASE mysqltest;
diff --git a/mysql-test/std_data/loaddata_utf8.dat b/mysql-test/std_data/loaddata_utf8.dat
new file mode 100644
index 00000000000..fc7a28229d4
--- /dev/null
+++ b/mysql-test/std_data/loaddata_utf8.dat
@@ -0,0 +1,3 @@
+一二三
+四五六
+七八九
diff --git a/mysql-test/t/rpl_loaddata_charset.test b/mysql-test/t/rpl_loaddata_charset.test
index 7f2389cb9f6..05dbdd01b39 100644
--- a/mysql-test/t/rpl_loaddata_charset.test
+++ b/mysql-test/t/rpl_loaddata_charset.test
@@ -31,3 +31,20 @@ select hex(a) from t1;
connection master;
drop table t1;
sync_slave_with_master;
+
+#
+# Bug#45516
+# When slave SQL thread executing LOAD DATA command, the
+# thd->variables.collation_database was not set properly to the default
+# database charset
+#
+
+echo -------------test bug#45516------------------;
+
+# LOAD DATA INFILE
+let $LOAD_LOCAL=1;
+source include/rpl_loaddata_charset.inc;
+
+# LOAD DATA LOCAL INFILE
+let $LOAD_LOCAL=0;
+source include/rpl_loaddata_charset.inc;