From f792cf3e3857040667746e662aad9a0ef4dea676 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2008 11:10:40 +0400 Subject: [PATCH 01/20] Bug#32510 LIKE search fails with indexed 'eucjpms' and 'ujis' char column Problem: some collation handlers called incorrect version of my_like_range_xxx(), which led to wrong min_str and max_str, so like range optimizer threw away good records. Fix: changing the wrong handlers to call proper version of my_like_range_xxx(). mysql-test/r/ctype_big5.result: Adding test mysql-test/r/ctype_cp932.result: Adding test mysql-test/r/ctype_eucjpms.result: Adding test mysql-test/r/ctype_euckr.result: Adding test mysql-test/r/ctype_gb2312.result: Adding test mysql-test/r/ctype_gbk.result: Adding test mysql-test/r/ctype_sjis.result: Adding test mysql-test/r/ctype_uca.result: Adding test mysql-test/r/ctype_ucs.result: Adding test mysql-test/r/ctype_ujis.result: Adding test mysql-test/t/ctype_big5.test: Adding test mysql-test/t/ctype_cp932.test: Adding test mysql-test/t/ctype_eucjpms.test: Adding test mysql-test/t/ctype_euckr.test: Adding test mysql-test/t/ctype_gb2312.test: Adding test mysql-test/t/ctype_gbk.test: Adding test mysql-test/t/ctype_sjis.test: Adding test mysql-test/t/ctype_uca.test: Adding test mysql-test/t/ctype_ucs.test: Adding test mysql-test/t/ctype_ujis.test: Adding test strings/ctype-euc_kr.c: Changing like_range function strings/ctype-eucjpms.c: Changing like_range function strings/ctype-gb2312.c: Changing like_range function strings/ctype-ucs2.c: Changing like_range function strings/ctype-ujis.c: Changing like_range function mysql-test/include/ctype_like_range_f1f2.inc: New BitKeeper file ``mysql-test/include/ctype_like_range_f1f2.inc'' --- mysql-test/include/ctype_like_range_f1f2.inc | 25 ++++++++++++++ mysql-test/r/ctype_big5.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_cp932.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_eucjpms.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_euckr.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_gb2312.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_gbk.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_sjis.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_uca.result | 17 ++++++++++ mysql-test/r/ctype_ucs.result | 34 ++++++++++++++++++++ mysql-test/r/ctype_ujis.result | 34 ++++++++++++++++++++ mysql-test/t/ctype_big5.test | 2 ++ mysql-test/t/ctype_cp932.test | 2 ++ mysql-test/t/ctype_eucjpms.test | 3 +- mysql-test/t/ctype_euckr.test | 2 ++ mysql-test/t/ctype_gb2312.test | 2 ++ mysql-test/t/ctype_gbk.test | 2 ++ mysql-test/t/ctype_sjis.test | 2 ++ mysql-test/t/ctype_uca.test | 3 +- mysql-test/t/ctype_ucs.test | 2 ++ mysql-test/t/ctype_ujis.test | 2 ++ strings/ctype-euc_kr.c | 2 +- strings/ctype-eucjpms.c | 2 +- strings/ctype-gb2312.c | 2 +- strings/ctype-ucs2.c | 2 +- strings/ctype-ujis.c | 2 +- 26 files changed, 373 insertions(+), 7 deletions(-) create mode 100644 mysql-test/include/ctype_like_range_f1f2.inc diff --git a/mysql-test/include/ctype_like_range_f1f2.inc b/mysql-test/include/ctype_like_range_f1f2.inc new file mode 100644 index 00000000000..54ea1b4c665 --- /dev/null +++ b/mysql-test/include/ctype_like_range_f1f2.inc @@ -0,0 +1,25 @@ +# +# Bug#32510 LIKE search fails with indexed 'eucjpms' and 'ujis' char column +# +# Testing my_ctype_like_range_xxx +# (used in LIKE optimization for an indexed column) +# + +# Create table using @@character_set_connection and @@collation_connection +# for the string columns. + +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); + +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); + +# Check pattern (important for ucs2, utf16, utf32) +SELECT hex(concat(repeat(0xF1F2, 10), '%')); + +--echo 3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +DROP TABLE t1; diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index b190273cc64..d61051588b3 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -120,6 +120,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='big5_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -170,6 +187,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET NAMES big5; CREATE TABLE t1 (a text) character set big5; INSERT INTO t1 VALUES (''); diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result index e3598f00777..5c70da37142 100755 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/ctype_cp932.result @@ -11325,6 +11325,23 @@ cp932_japanese_ci 6109 cp932_japanese_ci 61 cp932_japanese_ci 6120 drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='cp932_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -11335,6 +11352,23 @@ cp932_bin 6109 cp932_bin 61 cp932_bin 6120 drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; create table t2 (a char(1)); insert into t2 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'); insert into t2 values ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F'); diff --git a/mysql-test/r/ctype_eucjpms.result b/mysql-test/r/ctype_eucjpms.result index ad9666d0c86..21aa38b7fe6 100755 --- a/mysql-test/r/ctype_eucjpms.result +++ b/mysql-test/r/ctype_eucjpms.result @@ -9809,6 +9809,23 @@ eucjpms_japanese_ci 6109 eucjpms_japanese_ci 61 eucjpms_japanese_ci 6120 drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='eucjpms_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -9819,6 +9836,23 @@ eucjpms_bin 6109 eucjpms_bin 61 eucjpms_bin 6120 drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; select hex(convert(_eucjpms 0xA5FE41 using ucs2)); hex(convert(_eucjpms 0xA5FE41 using ucs2)) 003F0041 diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result index ee786202c01..3c31495539d 100644 --- a/mysql-test/r/ctype_euckr.result +++ b/mysql-test/r/ctype_euckr.result @@ -120,6 +120,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='euckr_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -170,6 +187,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET NAMES euckr; CREATE TABLE t1 (a text) character set euckr; INSERT INTO t1 VALUES (0xA2E6),(0xFEF7); diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result index 90c94c3b299..eaf644d2075 100644 --- a/mysql-test/r/ctype_gb2312.result +++ b/mysql-test/r/ctype_gb2312.result @@ -120,6 +120,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='gb2312_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -170,6 +187,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET NAMES gb2312; CREATE TABLE t1 (a text) character set gb2312; INSERT INTO t1 VALUES (0xA2A1),(0xD7FE); diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index fe90c7bff29..9c782ff8040 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -120,6 +120,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='gbk_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -170,6 +187,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET NAMES gbk; CREATE TABLE t1 (a text) character set gbk; INSERT INTO t1 VALUES (0xA3A0),(0xA1A1); diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result index dab5991b505..37750120b31 100644 --- a/mysql-test/r/ctype_sjis.result +++ b/mysql-test/r/ctype_sjis.result @@ -121,6 +121,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='sjis_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -171,6 +188,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET NAMES sjis; SELECT HEX('@\') FROM DUAL; HEX('@\') diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index ae9146fc9db..a11de9739ff 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2811,5 +2811,22 @@ NULL NULL NULL drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F20025 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; set names utf8; End for 5.0 tests diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 5a84dd0c3c0..53c96b325d0 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -613,6 +613,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F20025 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET NAMES latin1; SET collation_connection='ucs2_bin'; create table t1 select repeat('a',4000) a; @@ -642,6 +659,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F20025 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; select hex(substr(_ucs2 0x00e400e50068,1)); hex(substr(_ucs2 0x00e400e50068,1)) 00E400E50068 diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result index 091d96c56d3..9f3346a8bbf 100644 --- a/mysql-test/r/ctype_ujis.result +++ b/mysql-test/r/ctype_ujis.result @@ -2257,6 +2257,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='ujis_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -2307,6 +2324,23 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; select hex(convert(_ujis 0xA5FE41 using ucs2)); hex(convert(_ujis 0xA5FE41 using ucs2)) 003F0041 diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test index 5f3357e0406..0ed21091110 100644 --- a/mysql-test/t/ctype_big5.test +++ b/mysql-test/t/ctype_big5.test @@ -16,10 +16,12 @@ SET collation_connection='big5_chinese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='big5_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc # # Bugs#9357: TEXT columns break string with special word in BIG5 charset. diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test index 633f3af0d2b..aced1754e66 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -400,8 +400,10 @@ DROP TABLE t4; SET collation_connection='cp932_japanese_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='cp932_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_like_range_f1f2.inc # # Bug#29333 myisam corruption with diff --git a/mysql-test/t/ctype_eucjpms.test b/mysql-test/t/ctype_eucjpms.test index 8f813fbd82b..ec358d94900 100644 --- a/mysql-test/t/ctype_eucjpms.test +++ b/mysql-test/t/ctype_eucjpms.test @@ -361,9 +361,10 @@ DROP TABLE t1; SET collation_connection='eucjpms_japanese_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='eucjpms_bin'; -- source include/ctype_filesort.inc - +-- source include/ctype_like_range_f1f2.inc # # Bugs#15375: Unassigned multibyte codes are broken diff --git a/mysql-test/t/ctype_euckr.test b/mysql-test/t/ctype_euckr.test index 05e4b04eded..0aba830e725 100644 --- a/mysql-test/t/ctype_euckr.test +++ b/mysql-test/t/ctype_euckr.test @@ -16,10 +16,12 @@ SET collation_connection='euckr_korean_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='euckr_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc # # Bug#15377 Valid multibyte sequences are truncated on INSERT diff --git a/mysql-test/t/ctype_gb2312.test b/mysql-test/t/ctype_gb2312.test index 835818d441c..86d1c7f72c9 100644 --- a/mysql-test/t/ctype_gb2312.test +++ b/mysql-test/t/ctype_gb2312.test @@ -16,10 +16,12 @@ SET collation_connection='gb2312_chinese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='gb2312_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc # # Bug#15377 Valid multibyte sequences are truncated on INSERT diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test index 5ff138fa97b..3ea696338dc 100644 --- a/mysql-test/t/ctype_gbk.test +++ b/mysql-test/t/ctype_gbk.test @@ -16,10 +16,12 @@ SET collation_connection='gbk_chinese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='gbk_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc # # Bug#11987 mysql will truncate the text when diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test index 01e0b334554..27cbdff451b 100644 --- a/mysql-test/t/ctype_sjis.test +++ b/mysql-test/t/ctype_sjis.test @@ -68,10 +68,12 @@ SET collation_connection='sjis_japanese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='sjis_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc # Check parsing of string literals in SJIS with multibyte characters that # have an embedded \ in them. (Bug #8303) diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 0d917428efb..27f833c0695 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -539,7 +539,8 @@ select * from t1 where a like 'c%'; drop table t1; set collation_connection=ucs2_unicode_ci; ---source include/ctype_regex.inc +-- source include/ctype_regex.inc +-- source include/ctype_like_range_f1f2.inc set names utf8; -- echo End for 5.0 tests diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index b837f53a17f..50c7a4fca5d 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -373,10 +373,12 @@ drop table t1; SET collation_connection='ucs2_general_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc SET NAMES latin1; SET collation_connection='ucs2_bin'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc # # Bug#10344 Some string functions fail for UCS2 diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index 14b37569b11..7d191931934 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -1147,10 +1147,12 @@ SET collation_connection='ujis_japanese_ci'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc SET collation_connection='ujis_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc +-- source include/ctype_like_range_f1f2.inc # # Bugs#15375: Unassigned multibyte codes are broken diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 511a81f0cd4..0e10f50fce0 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8695,7 +8695,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ my_strnxfrmlen_simple, - my_like_range_simple, /* like_range */ + my_like_range_mb, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, my_instr_mb, diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 8343211015c..d96b34d2838 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8643,7 +8643,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ my_strnxfrmlen_simple, - my_like_range_simple,/* like_range */ + my_like_range_mb, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, my_instr_mb, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 267299ace7f..6ffe29430db 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5725,7 +5725,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ my_strnxfrmlen_simple, - my_like_range_simple, /* like_range */ + my_like_range_mb, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, /* instr */ my_instr_mb, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index b5353c55e4c..f391e4977b3 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1666,7 +1666,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = my_strnncollsp_ucs2_bin, my_strnxfrm_ucs2_bin, my_strnxfrmlen_simple, - my_like_range_simple, + my_like_range_ucs2, my_wildcmp_ucs2_bin, my_strcasecmp_ucs2_bin, my_instr_mb, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index cd1ab7da425..4a75244807d 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8511,7 +8511,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ my_strnxfrmlen_simple, - my_like_range_simple,/* like_range */ + my_like_range_mb, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, my_instr_mb, From 77b84b12e69e05a891f57cac157506c37dd60d0a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2008 16:35:41 +0200 Subject: [PATCH 02/20] Bug #32790 crash in trigger.test with InnoDB for a table the reason for the failure were incorrect asserts. Removing asserts altogether as there is no the implication does not hold (as explained in the comments for the file). sql/sql_delete.cc: removing two asserts because they can not hold basing on the definition of `normal_tables'. The one does not specify in a non-transactional table, which must be in the list of tables to be deleted, is modified indeed. So, it's possible to have normal_tables == true and deleted == true both but that would be yet a transactional table got modified (and then thd->transaction.stmt.modified_non_trans_table remains false default). --- sql/sql_delete.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index a28a39a769d..52e3ab73de0 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -730,8 +730,6 @@ void multi_delete::send_error(uint errcode,const char *err) } thd->transaction.all.modified_non_trans_table= true; } - DBUG_ASSERT(!normal_tables || !deleted || - thd->transaction.stmt.modified_non_trans_table); DBUG_VOID_RETURN; } @@ -839,8 +837,6 @@ bool multi_delete::send_eof() { query_cache_invalidate3(thd, delete_tables, 1); } - DBUG_ASSERT(!normal_tables || !deleted || - thd->transaction.stmt.modified_non_trans_table); if ((local_error == 0) || thd->transaction.stmt.modified_non_trans_table) { if (mysql_bin_log.is_open()) From 6210278628b834bfd599d461b0f5b515d4f085ee Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2008 16:37:41 +0200 Subject: [PATCH 03/20] Bug#33329 extraneous ROLLBACK in binlog on connection does not use trans tables There had been two issues. Rollback statement was recorded in binlog even though a multi-update had not modified any non-transactional table. The reason for this artifact was a false initial value of multi_update::transactional_tables. Yet another artifact that explained on the bug page is that `ha_autocommit_or_rollback' works differently depending on whether a transaction engine has been compiled in. Fixed: with setting multi_update::transactional_tables to zero at initialization time. Multi-update on non-trans table won't cause ROLLBACK in binlog with either compilation option. The 2nd mentioned artifact comprises a self-standing issue (to be reported separately). mysql-test/r/multi_update.result: results changed - there is no ROLLBACK in binlog anymore as it should be sql/sql_update.cc: A wrong assumption on that there were modified transactional table, which is nonsense at the very beginning of the query execution. --- mysql-test/r/multi_update.result | 4 ++-- sql/sql_update.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 8a0eacd9eeb..7a12fc87bdc 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -545,7 +545,7 @@ a b 4 4 show master status /* there must be the UPDATE query event */; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 328 +master-bin.000001 189 delete from t1; delete from t2; insert into t1 values (1,2),(3,4),(4,4); @@ -555,7 +555,7 @@ UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a; ERROR 23000: Duplicate entry '4' for key 1 show master status /* there must be the UPDATE query event */; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 343 +master-bin.000001 204 drop table t1, t2; drop table if exists t1, t2, t3; CREATE TABLE t1 (a int, PRIMARY KEY (a)); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 84349a40977..e5017058659 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -979,7 +979,7 @@ multi_update::multi_update(TABLE_LIST *table_list, tmp_tables(0), updated(0), found(0), fields(field_list), values(value_list), table_count(0), copy_field(0), handle_duplicates(handle_duplicates_arg), do_update(1), trans_safe(1), - transactional_tables(1), ignore(ignore_arg), error_handled(0) + transactional_tables(0), ignore(ignore_arg), error_handled(0) {} From e4e7f8c385439b8aa30d4821127cbc2b9ed5ded7 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Feb 2008 21:03:10 +0200 Subject: [PATCH 04/20] bug#34427 slave misses rendezvous in rpl_variables There was no instruction in the test that enforces the slave successfully connect to the master. The way the test was been written allowed the slave to had been late for rendezvous so that about-connecting time queries to the master failed and are error-logged to had been seen in Warnings of pb. Fixed with adding a sychronization primitive to the test. No test case is possible, observe error logs on pb. Todo: revise need of rpl_report.pl's rules due to failing execution of queries from get_master_verion_and_clock(). Any test should try to use a synchornization primitive like the current fix makes and do not let the slave to miss successful connecting. mysql-test/t/rpl_variables.test: Completing the test's body with a synch macro to not let the slave to miss the successful connecting to the master. --- mysql-test/t/rpl_variables.test | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysql-test/t/rpl_variables.test b/mysql-test/t/rpl_variables.test index d0801e524e4..4e2d07cad54 100644 --- a/mysql-test/t/rpl_variables.test +++ b/mysql-test/t/rpl_variables.test @@ -1,5 +1,7 @@ source include/master-slave.inc; +connection master; + # Init for rstore of variable values set @my_slave_net_timeout =@@global.slave_net_timeout; @@ -18,3 +20,8 @@ show variables like 'slave_skip_errors'; # Restore touched values set global slave_net_timeout =@my_slave_net_timeout; + +# bug#34427 slave misses rendezvous +# don't let the master be shut down until the slave has connected +sync_slave_with_master; + From 530591ff8ec92648cd1d75479efb023e22df822c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Feb 2008 16:28:33 +0400 Subject: [PATCH 05/20] Bug#27877 incorrect german order in utf8_general_ci Problem: incorrect sort order for "U+00DF SHARP S". Fix: changing sort order for U+00DF to be equal to 's', like the manual says. mysql-test/r/ctype_latin1_de.result: Adding test mysql-test/r/ctype_uca.result: Adding test mysql-test/r/ctype_ucs.result: Adding test mysql-test/r/ctype_utf8.result: Adding test mysql-test/t/ctype_latin1_de.test: Adding test mysql-test/t/ctype_uca.test: Adding test mysql-test/t/ctype_ucs.test: Adding test mysql-test/t/ctype_utf8.test: Adding test strings/ctype-utf8.c: Changing weight for "U+00DF SHARP S" mysql-test/include/ctype_german.inc: New BitKeeper file ``mysql-test/include/ctype_german.inc'' --- mysql-test/include/ctype_german.inc | 40 +++++++++++++++++++++++++++++ mysql-test/r/ctype_latin1_de.result | 35 +++++++++++++++++++++++++ mysql-test/r/ctype_uca.result | 35 +++++++++++++++++++++++++ mysql-test/r/ctype_ucs.result | 35 +++++++++++++++++++++++++ mysql-test/r/ctype_utf8.result | 35 +++++++++++++++++++++++++ mysql-test/t/ctype_latin1_de.test | 1 + mysql-test/t/ctype_uca.test | 1 + mysql-test/t/ctype_ucs.test | 1 + mysql-test/t/ctype_utf8.test | 1 + strings/ctype-utf8.c | 2 +- 10 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 mysql-test/include/ctype_german.inc diff --git a/mysql-test/include/ctype_german.inc b/mysql-test/include/ctype_german.inc new file mode 100644 index 00000000000..14d09358bea --- /dev/null +++ b/mysql-test/include/ctype_german.inc @@ -0,0 +1,40 @@ +# +# Bug #27877 incorrect german order in utf8_general_ci +# +# Testing if "SHARP S" is equal to "S", +# like in latin1_german1_ci, utf8_general_ci, ucs2_general_ci +# Or if "SHART S" is equal to "SS", +# like in latin1_german2_ci, utf8_unicode_ci, ucs2_unicode_ci +# +# Also testing A-uml, O-uml, U-uml +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Create a table with a varchar(x) column, +# using current values of +# @@character_set_connection and @@collation_connection. +# + +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +delete from t1; + +# +# Populate data +# + +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); + +# +# Check order +# +select s1, hex(s1) from t1 order by s1, binary s1; +select group_concat(s1 order by binary s1) from t1 group by s1; +drop table t1; diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result index 5733877237d..f826199bb1f 100644 --- a/mysql-test/r/ctype_latin1_de.result +++ b/mysql-test/r/ctype_latin1_de.result @@ -326,6 +326,41 @@ latin1_german2_ci 6109 latin1_german2_ci 61 latin1_german2_ci 6120 drop table t1; +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +latin1_german2_ci +delete from t1; +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 61 +ae 6165 + E4 +o 6F +oe 6F65 + F6 +s 73 +ss 7373 + DF +u 75 +ue 7565 + FC +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a +ae, +o +oe, +s +ss, +u +ue, +drop table t1; SET NAMES latin1; CREATE TABLE t1 ( col1 varchar(255) NOT NULL default '' diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 92b76802d0b..999c20ce9e8 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2647,6 +2647,41 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf8_unicode_ci +delete from t1; +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 61 +ä C3A4 +ae 6165 +o 6F +ö C3B6 +oe 6F65 +s 73 +ss 7373 +ß C39F +u 75 +ü C3BC +ue 7565 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a,ä +ae +o,ö +oe +s +ss,ß +u,ü +ue +drop table t1; CREATE TABLE t1 (id int, a varchar(30) character set utf8); INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131); INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049); diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index bd76f2a859f..8ec32d5bace 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -613,6 +613,41 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +ucs2_general_ci +delete from t1; +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 0061 + 00E4 +ae 00610065 +o 006F + 00F6 +oe 006F0065 +s 0073 + 00DF +ss 00730073 +u 0075 + 00FC +ue 00750065 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a, +ae +o, +oe +s, +ss +u, +ue +drop table t1; SET NAMES latin1; SET collation_connection='ucs2_bin'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 5c90c3b5e0b..12e6c9bb492 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -939,6 +939,41 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf8_general_ci +delete from t1; +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 61 +ä C3A4 +ae 6165 +o 6F +ö C3B6 +oe 6F65 +s 73 +ß C39F +ss 7373 +u 75 +ü C3BC +ue 7565 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a,ä +ae +o,ö +oe +s,ß +ss +u,ü +ue +drop table t1; SET collation_connection='utf8_bin'; create table t1 select repeat('a',4000) a; delete from t1; diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test index d6a11a22857..1efbfa4a3ae 100644 --- a/mysql-test/t/ctype_latin1_de.test +++ b/mysql-test/t/ctype_latin1_de.test @@ -116,6 +116,7 @@ SELECT FIELD('ue',s1), FIELD(' DROP TABLE t1; -- source include/ctype_filesort.inc +-- source include/ctype_german.inc # # Bug#7878 with utf8_general_ci, equals (=) has problem with diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 0d917428efb..5749c7e4861 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -458,6 +458,7 @@ drop table t1; SET collation_connection='utf8_unicode_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_german.inc # End of 4.1 tests diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 3af5bfa54f9..08b3cb45395 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -373,6 +373,7 @@ drop table t1; SET collation_connection='ucs2_general_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_german.inc SET NAMES latin1; SET collation_connection='ucs2_bin'; -- source include/ctype_filesort.inc diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index d18a7d22a0e..2e23ac3661c 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -721,6 +721,7 @@ select hex(soundex(_utf8 0xD091D092D093)); SET collation_connection='utf8_general_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_german.inc SET collation_connection='utf8_bin'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 2b248f1eed5..2afb1930f3d 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -155,7 +155,7 @@ static MY_UNICASE_INFO plane00[]={ {0x00D8,0x00F8,0x00D8}, {0x00D9,0x00F9,0x0055}, {0x00DA,0x00FA,0x0055}, {0x00DB,0x00FB,0x0055}, {0x00DC,0x00FC,0x0055}, {0x00DD,0x00FD,0x0059}, - {0x00DE,0x00FE,0x00DE}, {0x00DF,0x00DF,0x00DF}, + {0x00DE,0x00FE,0x00DE}, {0x00DF,0x00DF,0x0053}, {0x00C0,0x00E0,0x0041}, {0x00C1,0x00E1,0x0041}, {0x00C2,0x00E2,0x0041}, {0x00C3,0x00E3,0x0041}, {0x00C4,0x00E4,0x0041}, {0x00C5,0x00E5,0x0041}, From 2942c1ea4d7bb89917da8ab4a301ad2cbb1f6f9a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Feb 2008 15:14:24 +0100 Subject: [PATCH 06/20] Problem: pushbuild has sporadic errors during startup of rpl_ndb_rep_ignore Reason: previous test, rpl_ndb_2multi_eng, does not sync slave with master after cleanup, so tables are sometimes left on slave Fix: sync_slave_with_master mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test: Wait until drop table is replicated to slave before terminating. (The extra table caused sporadic errors in the next test case, causing pushbuild to fail.) --- mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test b/mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test index 7f19245c0b9..1677aaf8277 100644 --- a/mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test +++ b/mysql-test/extra/rpl_tests/rpl_ndb_2multi_eng.test @@ -342,5 +342,6 @@ SHOW CREATE TABLE t1; --echo --- Do Cleanup --- DROP TABLE IF EXISTS t1; +sync_slave_with_master; # End of 5.1 test case From 914ae26cf926332a91f838bc274db82f62981445 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Feb 2008 17:22:04 +0100 Subject: [PATCH 07/20] Moved mysql-test/suite/rpl/rpl_variables.test into mysql-test/t/variables.test, because: - mysql-test/suite/rpl/t/rpl_variables.test does not replicate anything, so should not be in the rpl suite. - mysql-test/t/variables.test is the place for testing variable-related problems and features. - I will soon commit a patch containing a test case that tests replication of variables. It would be good if I could call the test case mysql-test/suite/rpl/t/rpl_variables.test. I'm making place for that now. mysql-test/t/variables-master.opt: Rename: mysql-test/suite/rpl/t/rpl_variables-master.opt -> mysql-test/t/variables-master.opt BitKeeper/deleted/.del-rpl_variables.test: Delete: mysql-test/suite/rpl/t/rpl_variables.test BitKeeper/deleted/.del-rpl_variables.result: Delete: mysql-test/suite/rpl/r/rpl_variables.result mysql-test/r/variables.result: Moved mysql-test/suite/rpl/t/rpl_variables.test into mysql-test/t/variables.test . Result file needs to be updated. mysql-test/t/variables.test: Moved mysql-test/suite/rpl/t/rpl_variables.test into mysql-test/t/variables.test . --- mysql-test/r/variables.result | 14 +++++++++++++ mysql-test/suite/rpl/r/rpl_variables.result | 19 ------------------ mysql-test/suite/rpl/t/rpl_variables.test | 20 ------------------- .../variables-master.opt} | 0 mysql-test/t/variables.test | 19 ++++++++++++++++++ 5 files changed, 33 insertions(+), 39 deletions(-) delete mode 100644 mysql-test/suite/rpl/r/rpl_variables.result delete mode 100644 mysql-test/suite/rpl/t/rpl_variables.test rename mysql-test/{suite/rpl/t/rpl_variables-master.opt => t/variables-master.opt} (100%) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index e5c3c860c93..395ba0eab48 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -22,6 +22,7 @@ set @my_query_cache_limit =@@global.query_cache_limit; set @my_query_cache_type =@@global.query_cache_type; set @my_rpl_recovery_rank =@@global.rpl_recovery_rank; set @my_server_id =@@global.server_id; +set @my_slave_net_timeout =@@global.slave_net_timeout; set @my_slow_launch_time =@@global.slow_launch_time; set @my_storage_engine =@@global.storage_engine; set @my_thread_cache_size =@@global.thread_cache_size; @@ -981,6 +982,17 @@ show variables like 'hostname'; Variable_name Value hostname # End of 5.0 tests +set global slave_net_timeout=100; +set global sql_slave_skip_counter=100; +show variables like 'slave_compressed_protocol'; +Variable_name Value +slave_compressed_protocol OFF +show variables like 'slave_load_tmpdir'; +Variable_name Value +slave_load_tmpdir SLAVE_LOAD_TMPDIR +show variables like 'slave_skip_errors'; +Variable_name Value +slave_skip_errors 3,100,137,643,1752 set global binlog_cache_size =@my_binlog_cache_size; set global connect_timeout =@my_connect_timeout; set global delayed_insert_timeout =@my_delayed_insert_timeout; @@ -1006,7 +1018,9 @@ set global query_cache_limit =@my_query_cache_limit; set global query_cache_type =@my_query_cache_type; set global rpl_recovery_rank =@my_rpl_recovery_rank; set global server_id =@my_server_id; +set global slave_net_timeout =@my_slave_net_timeout; set global slow_launch_time =@my_slow_launch_time; +set global sql_slave_skip_counter =0; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; show global variables where Variable_name='table_definition_cache' or diff --git a/mysql-test/suite/rpl/r/rpl_variables.result b/mysql-test/suite/rpl/r/rpl_variables.result deleted file mode 100644 index 605a48859a0..00000000000 --- a/mysql-test/suite/rpl/r/rpl_variables.result +++ /dev/null @@ -1,19 +0,0 @@ -stop slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -reset master; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -start slave; -set @my_slave_net_timeout =@@global.slave_net_timeout; -set global slave_net_timeout=100; -set global sql_slave_skip_counter=100; -show variables like 'slave_compressed_protocol'; -Variable_name Value -slave_compressed_protocol OFF -show variables like 'slave_load_tmpdir'; -Variable_name Value -slave_load_tmpdir SLAVE_LOAD_TMPDIR -show variables like 'slave_skip_errors'; -Variable_name Value -slave_skip_errors 3,100,137,643,1752 -set global slave_net_timeout=default; diff --git a/mysql-test/suite/rpl/t/rpl_variables.test b/mysql-test/suite/rpl/t/rpl_variables.test deleted file mode 100644 index 84dc3acfe6e..00000000000 --- a/mysql-test/suite/rpl/t/rpl_variables.test +++ /dev/null @@ -1,20 +0,0 @@ -source include/master-slave.inc; - -# Init for rstore of variable values -set @my_slave_net_timeout =@@global.slave_net_timeout; - -set global slave_net_timeout=100; -set global sql_slave_skip_counter=100; - -# End of 4.1 tests - -# BUG #7800: Add various-slave related variables to SHOW VARIABLES -show variables like 'slave_compressed_protocol'; ---replace_column 2 SLAVE_LOAD_TMPDIR -show variables like 'slave_load_tmpdir'; -# We just set some arbitrary values in variables-master.opt so we can test -# that a list of values works correctly -show variables like 'slave_skip_errors'; - -# Cleanup -set global slave_net_timeout=default; diff --git a/mysql-test/suite/rpl/t/rpl_variables-master.opt b/mysql-test/t/variables-master.opt similarity index 100% rename from mysql-test/suite/rpl/t/rpl_variables-master.opt rename to mysql-test/t/variables-master.opt diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 51f8d6db1db..404a98d1827 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -31,6 +31,7 @@ set @my_query_cache_limit =@@global.query_cache_limit; set @my_query_cache_type =@@global.query_cache_type; set @my_rpl_recovery_rank =@@global.rpl_recovery_rank; set @my_server_id =@@global.server_id; +set @my_slave_net_timeout =@@global.slave_net_timeout; set @my_slow_launch_time =@@global.slow_launch_time; set @my_storage_engine =@@global.storage_engine; set @my_thread_cache_size =@@global.thread_cache_size; @@ -737,6 +738,20 @@ show variables like 'hostname'; --echo End of 5.0 tests +# +# BUG #7800: SHOW VARIABLES does not show slave-related configuration +# +set global slave_net_timeout=100; +set global sql_slave_skip_counter=100; + +show variables like 'slave_compressed_protocol'; +--replace_column 2 SLAVE_LOAD_TMPDIR +show variables like 'slave_load_tmpdir'; +# We just set some arbitrary values in variables-master.opt so we can test +# that a list of values is printed correctly. +show variables like 'slave_skip_errors'; + +# # This is at the very after the versioned tests, since it involves doing # cleanup # @@ -768,7 +783,11 @@ set global query_cache_limit =@my_query_cache_limit; set global query_cache_type =@my_query_cache_type; set global rpl_recovery_rank =@my_rpl_recovery_rank; set global server_id =@my_server_id; +set global slave_net_timeout =@my_slave_net_timeout; set global slow_launch_time =@my_slow_launch_time; +# sql_slave_skip_counter is write-only, so we can't save previous +# value and restore it here. That's ok, because it's normally 0. +set global sql_slave_skip_counter =0; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; From ded528ca1249f35f55f9d7b52d95c96e94734495 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Feb 2008 14:09:41 +0200 Subject: [PATCH 08/20] Bug #33931 assertion at write_ignored_events_info_to_relay_log if init_slave_thread() fails and bug#33932 assertion at handle_slave_sql if init_slave_thread() fails the asserts were caused by bug33931: having thd deleted at time of executing err: code plus a missed initialization; bug33932: initialization of slave_is_running member was missed; fixed with relocating mi members initialization and removing delete thd It is safe to do as deletion happens later explicitly in the caller of init_slave_thread(). Todo: at merging the test is better to be moved into suite/bugs for 5.x (when x>0). sql/slave.cc: adding the bugs simulating code; relocating some assignments to satisfy the asserts; mysql-test/r/rpl_bug33931.result: the new result file mysql-test/t/rpl_bug33931-slave.opt: option to spark the simulation code mysql-test/t/rpl_bug33931.test: tests check that slave does not crash as before. Slave threads must be in NO running state in the end. --- mysql-test/r/rpl_bug33931.result | 38 +++++++++++++++++++++++++++++ mysql-test/t/rpl_bug33931-slave.opt | 1 + mysql-test/t/rpl_bug33931.test | 37 ++++++++++++++++++++++++++++ sql/slave.cc | 18 +++++++++++--- 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/rpl_bug33931.result create mode 100644 mysql-test/t/rpl_bug33931-slave.opt create mode 100644 mysql-test/t/rpl_bug33931.test diff --git a/mysql-test/r/rpl_bug33931.result b/mysql-test/r/rpl_bug33931.result new file mode 100644 index 00000000000..519bd73aa6a --- /dev/null +++ b/mysql-test/r/rpl_bug33931.result @@ -0,0 +1,38 @@ +reset master; +stop slave; +reset slave; +start slave; +show slave status; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File +Read_Master_Log_Pos 4 +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File +Slave_IO_Running No +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 0 +Relay_Log_Space # +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # diff --git a/mysql-test/t/rpl_bug33931-slave.opt b/mysql-test/t/rpl_bug33931-slave.opt new file mode 100644 index 00000000000..55fe328a41d --- /dev/null +++ b/mysql-test/t/rpl_bug33931-slave.opt @@ -0,0 +1 @@ +--loose-debug=d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init diff --git a/mysql-test/t/rpl_bug33931.test b/mysql-test/t/rpl_bug33931.test new file mode 100644 index 00000000000..788f79d4c1c --- /dev/null +++ b/mysql-test/t/rpl_bug33931.test @@ -0,0 +1,37 @@ +# Test for +# Bug #33931 assertion at write_ignored_events_info_to_relay_log if init_slave_thread() fails +# Bug #33932 assertion at handle_slave_sql if init_slave_thread() fails + +source include/have_debug.inc; +source include/have_log_bin.inc; + +connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,); +connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,); + + +connection master; +reset master; + +connection slave; +--disable_warnings +stop slave; +--enable_warnings +reset slave; +start slave; + +connection master; +save_master_pos; +connection slave; + +# +# slave is going to stop because of emulated failures +# but there won't be any crashes nor asserts hit. +# +source include/wait_for_slave_to_stop.inc; + +--replace_result $MASTER_MYPORT MASTER_PORT +--replace_column 1 # 8 # 9 # 23 # 33 # +query_vertical show slave status; + +# no clean-up is needed + diff --git a/sql/slave.cc b/sql/slave.cc index 4a65e9aaa85..272d6f117e9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2895,6 +2895,9 @@ void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli) static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) { DBUG_ENTER("init_slave_thread"); +#if !defined(DBUG_OFF) + int simulate_error= 0; +#endif thd->system_thread = (thd_type == SLAVE_THD_SQL) ? SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO; thd->security_ctx->skip_grants(); @@ -2914,10 +2917,17 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->thread_id = thread_id++; pthread_mutex_unlock(&LOCK_thread_count); + DBUG_EXECUTE_IF("simulate_io_slave_error_on_init", + simulate_error|= (1 << SLAVE_THD_IO);); + DBUG_EXECUTE_IF("simulate_sql_slave_error_on_init", + simulate_error|= (1 << SLAVE_THD_SQL);); +#if !defined(DBUG_OFF) + if (init_thr_lock() || thd->store_globals() || simulate_error & (1<< thd_type)) +#else if (init_thr_lock() || thd->store_globals()) +#endif { thd->cleanup(); - delete thd; DBUG_RETURN(-1); } @@ -3515,6 +3525,7 @@ slave_begin: thd= new THD; // note that contructor of THD uses DBUG_ ! THD_CHECK_SENTRY(thd); + mi->io_thd = thd; pthread_detach_this_thread(); thd->thread_stack= (char*) &thd; // remember where our stack is @@ -3525,7 +3536,6 @@ slave_begin: sql_print_error("Failed during slave I/O thread initialization"); goto err; } - mi->io_thd = thd; pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); @@ -3865,9 +3875,11 @@ slave_begin: thd = new THD; // note that contructor of THD uses DBUG_ ! thd->thread_stack = (char*)&thd; // remember where our stack is + rli->sql_thd= thd; /* Inform waiting threads that slave has started */ rli->slave_run_id++; + rli->slave_running = 1; pthread_detach_this_thread(); if (init_slave_thread(thd, SLAVE_THD_SQL)) @@ -3882,7 +3894,6 @@ slave_begin: goto err; } thd->init_for_queries(); - rli->sql_thd= thd; thd->temporary_tables = rli->save_temporary_tables; // restore temp tables pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); @@ -3895,7 +3906,6 @@ slave_begin: start receiving data so we realize we are not caught up and Seconds_Behind_Master grows. No big deal. */ - rli->slave_running = 1; rli->abort_slave = 0; pthread_mutex_unlock(&rli->run_lock); pthread_cond_broadcast(&rli->start_cond); From 68114c88fbf87055c861796bef476fe879e58f0e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Feb 2008 17:39:23 +0100 Subject: [PATCH 09/20] BUG#32991: Races in mysqldump.test (or mysqldump.test fails sporadically) This is *not* a fix to the bug. I'm only disabling the failing part of mysqldump.test until the bug is fixed. Whoever fixes it, please re-enable the test. mysql-test/r/mysqldump.result: Disabling part of the test case until BUG#32991 is fixed. Result file updated accordingly. mysql-test/t/mysqldump.test: Disabling this part of the test case until BUG#32991 is fixed. --- mysql-test/r/mysqldump.result | 175 ---------------------------------- mysql-test/t/mysqldump.test | 6 ++ 2 files changed, 6 insertions(+), 175 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index d07aed5317a..a73ec61dad3 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3870,181 +3870,6 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; DROP TABLE t1; -create table t1 (a text , b text); -create table t2 (a text , b text); -insert t1 values ("Duck, Duck", "goose"); -insert t1 values ("Duck, Duck", "pidgeon"); -insert t2 values ("We the people", "in order to perform"); -insert t2 values ("a more perfect", "union"); -select * from t1; -a b -Duck, Duck goose -Duck, Duck pidgeon -select * from t2; -a b -We the people in order to perform -a more perfect union -test.t1: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 -test.t2: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 -select * from t1; -a b -Duck, Duck goose -Duck, Duck pidgeon -Duck, Duck goose -Duck, Duck pidgeon -select * from t2; -a b -We the people in order to perform -a more perfect union -We the people in order to perform -a more perfect union -create table words(a varchar(255)); -create table words2(b varchar(255)); -select * from t1; -a b -Duck, Duck goose -Duck, Duck pidgeon -Duck, Duck goose -Duck, Duck pidgeon -Duck, Duck goose -Duck, Duck pidgeon -select * from t2; -a b -We the people in order to perform -a more perfect union -We the people in order to perform -a more perfect union -We the people in order to perform -a more perfect union -select * from words; -a -Aarhus -Aaron -Ababa -aback -abaft -abandon -abandoned -abandoning -abandonment -abandons -Aarhus -Aaron -Ababa -aback -abaft -abandon -abandoned -abandoning -abandonment -abandons -abase -abased -abasement -abasements -abases -abash -abashed -abashes -abashing -abasing -abate -abated -abatement -abatements -abater -abates -abating -Abba -abbe -abbey -abbeys -abbot -abbots -Abbott -abbreviate -abbreviated -abbreviates -abbreviating -abbreviation -abbreviations -Abby -abdomen -abdomens -abdominal -abduct -abducted -abduction -abductions -abductor -abductors -abducts -Abe -abed -Abel -Abelian -Abelson -Aberdeen -Abernathy -aberrant -aberration -select * from words2; -b -abase -abased -abasement -abasements -abases -abash -abashed -abashes -abashing -abasing -abate -abated -abatement -abatements -abater -abates -abating -Abba -abbe -abbey -abbeys -abbot -abbots -Abbott -abbreviate -abbreviated -abbreviates -abbreviating -abbreviation -abbreviations -Abby -abdomen -abdomens -abdominal -abduct -abducted -abduction -abductions -abductor -abductors -abducts -Abe -abed -Abel -Abelian -Abelson -Aberdeen -Abernathy -aberrant -aberration -drop table words; -mysql-import: Error: 1146, Table 'test.words' doesn't exist, when using table: words -drop table t1; -drop table t2; -drop table words2; # # BUG# 16853: mysqldump doesn't show events # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 0e4e9989ffa..87613232011 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1613,6 +1613,10 @@ DROP TABLE t1; # # Added for use-thread option # + +# THIS PART OF THE TEST IS DISABLED UNTIL BUG#32991 IS FIXED +if ($bug32991_fixed) { + create table t1 (a text , b text); create table t2 (a text , b text); insert t1 values ("Duck, Duck", "goose"); @@ -1650,6 +1654,8 @@ drop table t2; drop table words2; +} + --echo # --echo # BUG# 16853: mysqldump doesn't show events --echo # From 50bd4a438e72fdf6f46e2d714b2f13999fa460b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Feb 2008 16:28:32 +0200 Subject: [PATCH 10/20] bug#33329 extraneous ROLLBACK in binlog on connection does not use trans tables changes for an assert and an updated results file. mysql-test/r/mix_innodb_myisam_binlog.result: results file changed as there is no ROLLBACK query in binlog as it must be. sql/sql_update.cc: refining assert as the initial value of transactional_tables has been changed to zero. --- mysql-test/r/mix_innodb_myisam_binlog.result | 2 +- sql/sql_update.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index e1968ac7ef8..b1d328a61dc 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -447,7 +447,7 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */; ERROR 23000: Duplicate entry '2' for key 1 show master status /* the offset must denote there is the query */; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 369 +master-bin.000001 230 select count(*) from t1 /* must be 4 */; count(*) 4 diff --git a/sql/sql_update.cc b/sql/sql_update.cc index e5017058659..9c82bde9497 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1482,7 +1482,7 @@ void multi_update::send_error(uint errcode,const char *err) if (trans_safe) { - DBUG_ASSERT(transactional_tables); + DBUG_ASSERT(!updated || transactional_tables); (void) ha_autocommit_or_rollback(thd, 1); } else From 40176e196253b8b79156e6e8258f80fc7ea60903 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Feb 2008 12:56:44 +0100 Subject: [PATCH 11/20] Bug #34458 Extreneous use of templates in server code Replacing a template function with a normal static function. The template parameter, which previously was the class to find a binlogging function in, is now passed as a pointer to the actual binlogging function instead. The patch requires change of indention, but that is submitted as a separate patch. sql/handler.cc: Replacing template function with a normal static function. --- sql/handler.cc | 62 +++++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 95d63740039..5b0a2693865 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3843,11 +3843,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat) - table is not mysql.event */ -/* The Sun compiler cannot instantiate the template below if this is - declared static, but it works by putting it into an anonymous - namespace. */ -namespace { - bool check_table_binlog_row_based(THD *thd, TABLE *table) + static bool check_table_binlog_row_based(THD *thd, TABLE *table) { if (table->s->cached_row_logging_check == -1) { @@ -3864,7 +3860,6 @@ namespace { (thd->options & OPTION_BIN_LOG) && mysql_bin_log.is_open()); } -} /** @brief Write table maps for all (manually or automatically) locked tables @@ -3888,9 +3883,8 @@ namespace { THD::lock THD::locked_tables */ -namespace -{ - int write_locked_table_maps(THD *thd) + + static int write_locked_table_maps(THD *thd) { DBUG_ENTER("write_locked_table_maps"); DBUG_PRINT("enter", ("thd: 0x%lx thd->lock: 0x%lx thd->locked_tables: 0x%lx " @@ -3935,10 +3929,14 @@ namespace DBUG_RETURN(0); } - template int - binlog_log_row(TABLE* table, - const uchar *before_record, - const uchar *after_record) + +typedef bool Log_func(THD*, TABLE*, bool, MY_BITMAP*, + uint, const uchar*, const uchar*); + + static int binlog_log_row(TABLE* table, + const uchar *before_record, + const uchar *after_record, + Log_func *log_func) { if (table->no_replicate) return 0; @@ -3965,15 +3963,10 @@ namespace { bitmap_set_all(&cols); if (likely(!(error= write_locked_table_maps(thd)))) - { - error= - RowsEventT::binlog_row_logging_function(thd, table, - table->file-> - has_transactions(), - &cols, table->s->fields, - before_record, - after_record); - } + error= (*log_func)(thd, table, table->file->has_transactions(), + &cols, table->s->fields, + before_record, after_record); + if (!use_bitbuf) bitmap_free(&cols); } @@ -3981,22 +3974,6 @@ namespace return error ? HA_ERR_RBR_LOGGING_FAILED : 0; } - /* - Instantiate the versions we need for the above template function, - because we have -fno-implicit-template as compiling option. - */ - - template int - binlog_log_row(TABLE *, const uchar *, const uchar *); - - template int - binlog_log_row(TABLE *, const uchar *, const uchar *); - - template int - binlog_log_row(TABLE *, const uchar *, const uchar *); -} - - int handler::ha_external_lock(THD *thd, int lock_type) { DBUG_ENTER("handler::ha_external_lock"); @@ -4041,10 +4018,11 @@ int handler::ha_reset() int handler::ha_write_row(uchar *buf) { int error; + Log_func *log_func= Write_rows_log_event::binlog_row_logging_function; DBUG_ENTER("handler::ha_write_row"); if (unlikely(error= write_row(buf))) DBUG_RETURN(error); - if (unlikely(error= binlog_log_row(table, 0, buf))) + if (unlikely(error= binlog_log_row(table, 0, buf, log_func))) DBUG_RETURN(error); /* purecov: inspected */ DBUG_RETURN(0); } @@ -4053,6 +4031,7 @@ int handler::ha_write_row(uchar *buf) int handler::ha_update_row(const uchar *old_data, uchar *new_data) { int error; + Log_func *log_func= Update_rows_log_event::binlog_row_logging_function; /* Some storage engines require that the new record is in record[0] @@ -4062,7 +4041,7 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data) if (unlikely(error= update_row(old_data, new_data))) return error; - if (unlikely(error= binlog_log_row(table, old_data, new_data))) + if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func))) return error; return 0; } @@ -4070,9 +4049,10 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data) int handler::ha_delete_row(const uchar *buf) { int error; + Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function; if (unlikely(error= delete_row(buf))) return error; - if (unlikely(error= binlog_log_row(table, buf, 0))) + if (unlikely(error= binlog_log_row(table, buf, 0, log_func))) return error; return 0; } From 450ed5aea667515c2b7f076f2c1b0a2ca0e6e01e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Feb 2008 13:06:28 +0100 Subject: [PATCH 12/20] Bug #34458 Extreneous use of templates in server code Patch to remove white-space left over after removing anonymous namespace. sql/handler.cc: Removing indentation and whitespace. --- sql/handler.cc | 173 +++++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 86 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 5b0a2693865..a7a3d8ef53f 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3843,24 +3843,25 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat) - table is not mysql.event */ - static bool check_table_binlog_row_based(THD *thd, TABLE *table) +static bool check_table_binlog_row_based(THD *thd, TABLE *table) +{ + if (table->s->cached_row_logging_check == -1) { - if (table->s->cached_row_logging_check == -1) - { - int const check(table->s->tmp_table == NO_TMP_TABLE && - binlog_filter->db_ok(table->s->db.str)); - table->s->cached_row_logging_check= check; - } - - DBUG_ASSERT(table->s->cached_row_logging_check == 0 || - table->s->cached_row_logging_check == 1); - - return (thd->current_stmt_binlog_row_based && - table->s->cached_row_logging_check && - (thd->options & OPTION_BIN_LOG) && - mysql_bin_log.is_open()); + int const check(table->s->tmp_table == NO_TMP_TABLE && + binlog_filter->db_ok(table->s->db.str)); + table->s->cached_row_logging_check= check; } + DBUG_ASSERT(table->s->cached_row_logging_check == 0 || + table->s->cached_row_logging_check == 1); + + return (thd->current_stmt_binlog_row_based && + table->s->cached_row_logging_check && + (thd->options & OPTION_BIN_LOG) && + mysql_bin_log.is_open()); +} + + /** @brief Write table maps for all (manually or automatically) locked tables to the binary log. @@ -3874,7 +3875,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat) that are locked by the thread 'thd'. Either manually locked (stored in THD::locked_tables) and automatically locked (stored in THD::lock) are considered. - + RETURN VALUE 0 All OK 1 Failed to write all table maps @@ -3884,95 +3885,95 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat) THD::locked_tables */ - static int write_locked_table_maps(THD *thd) +static int write_locked_table_maps(THD *thd) +{ + DBUG_ENTER("write_locked_table_maps"); + DBUG_PRINT("enter", ("thd: 0x%lx thd->lock: 0x%lx thd->locked_tables: 0x%lx " + "thd->extra_lock: 0x%lx", + (long) thd, (long) thd->lock, + (long) thd->locked_tables, (long) thd->extra_lock)); + + if (thd->get_binlog_table_maps() == 0) { - DBUG_ENTER("write_locked_table_maps"); - DBUG_PRINT("enter", ("thd: 0x%lx thd->lock: 0x%lx thd->locked_tables: 0x%lx " - "thd->extra_lock: 0x%lx", - (long) thd, (long) thd->lock, - (long) thd->locked_tables, (long) thd->extra_lock)); - - if (thd->get_binlog_table_maps() == 0) + MYSQL_LOCK *locks[3]; + locks[0]= thd->extra_lock; + locks[1]= thd->lock; + locks[2]= thd->locked_tables; + for (uint i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i ) { - MYSQL_LOCK *locks[3]; - locks[0]= thd->extra_lock; - locks[1]= thd->lock; - locks[2]= thd->locked_tables; - for (uint i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i ) - { - MYSQL_LOCK const *const lock= locks[i]; - if (lock == NULL) - continue; + MYSQL_LOCK const *const lock= locks[i]; + if (lock == NULL) + continue; - TABLE **const end_ptr= lock->table + lock->table_count; - for (TABLE **table_ptr= lock->table ; - table_ptr != end_ptr ; - ++table_ptr) + TABLE **const end_ptr= lock->table + lock->table_count; + for (TABLE **table_ptr= lock->table ; + table_ptr != end_ptr ; + ++table_ptr) + { + TABLE *const table= *table_ptr; + DBUG_PRINT("info", ("Checking table %s", table->s->table_name.str)); + if (table->current_lock == F_WRLCK && + check_table_binlog_row_based(thd, table)) { - TABLE *const table= *table_ptr; - DBUG_PRINT("info", ("Checking table %s", table->s->table_name.str)); - if (table->current_lock == F_WRLCK && - check_table_binlog_row_based(thd, table)) - { - int const has_trans= table->file->has_transactions(); - int const error= thd->binlog_write_table_map(table, has_trans); - /* - If an error occurs, it is the responsibility of the caller to - roll back the transaction. - */ - if (unlikely(error)) - DBUG_RETURN(1); - } + int const has_trans= table->file->has_transactions(); + int const error= thd->binlog_write_table_map(table, has_trans); + /* + If an error occurs, it is the responsibility of the caller to + roll back the transaction. + */ + if (unlikely(error)) + DBUG_RETURN(1); } } } - DBUG_RETURN(0); } + DBUG_RETURN(0); +} typedef bool Log_func(THD*, TABLE*, bool, MY_BITMAP*, uint, const uchar*, const uchar*); - static int binlog_log_row(TABLE* table, - const uchar *before_record, - const uchar *after_record, - Log_func *log_func) +static int binlog_log_row(TABLE* table, + const uchar *before_record, + const uchar *after_record, + Log_func *log_func) +{ + if (table->no_replicate) + return 0; + bool error= 0; + THD *const thd= table->in_use; + + if (check_table_binlog_row_based(thd, table)) { - if (table->no_replicate) - return 0; - bool error= 0; - THD *const thd= table->in_use; + MY_BITMAP cols; + /* Potential buffer on the stack for the bitmap */ + uint32 bitbuf[BITMAP_STACKBUF_SIZE/sizeof(uint32)]; + uint n_fields= table->s->fields; + my_bool use_bitbuf= n_fields <= sizeof(bitbuf)*8; - if (check_table_binlog_row_based(thd, table)) + /* + If there are no table maps written to the binary log, this is + the first row handled in this statement. In that case, we need + to write table maps for all locked tables to the binary log. + */ + if (likely(!(error= bitmap_init(&cols, + use_bitbuf ? bitbuf : NULL, + (n_fields + 7) & ~7UL, + FALSE)))) { - MY_BITMAP cols; - /* Potential buffer on the stack for the bitmap */ - uint32 bitbuf[BITMAP_STACKBUF_SIZE/sizeof(uint32)]; - uint n_fields= table->s->fields; - my_bool use_bitbuf= n_fields <= sizeof(bitbuf)*8; + bitmap_set_all(&cols); + if (likely(!(error= write_locked_table_maps(thd)))) + error= (*log_func)(thd, table, table->file->has_transactions(), + &cols, table->s->fields, + before_record, after_record); - /* - If there are no table maps written to the binary log, this is - the first row handled in this statement. In that case, we need - to write table maps for all locked tables to the binary log. - */ - if (likely(!(error= bitmap_init(&cols, - use_bitbuf ? bitbuf : NULL, - (n_fields + 7) & ~7UL, - FALSE)))) - { - bitmap_set_all(&cols); - if (likely(!(error= write_locked_table_maps(thd)))) - error= (*log_func)(thd, table, table->file->has_transactions(), - &cols, table->s->fields, - before_record, after_record); - - if (!use_bitbuf) - bitmap_free(&cols); - } + if (!use_bitbuf) + bitmap_free(&cols); } - return error ? HA_ERR_RBR_LOGGING_FAILED : 0; } + return error ? HA_ERR_RBR_LOGGING_FAILED : 0; +} int handler::ha_external_lock(THD *thd, int lock_type) { From 3f0a603c9619f8cc45b8261d65ca737507212da0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Feb 2008 12:54:04 +0000 Subject: [PATCH 13/20] Problem: After I moved rpl/t/rpl_variables.test into t/variables.test, t/variables.test fails on embedded server. Moved out that part again, to a new test called t/variables-notembedded.test. mysql-test/t/variables-notembedded.test: BitKeeper file /home/sven/bk/debug-max/5.1-new-rpl/mysql-test/t/variables-notembedded.test mysql-test/r/variables-notembedded.result: Add -master.opt file to have a list of variables for slave_skip_errors. mysql-test/r/variables.result: Variable variables not available in embedded mode to a new test, variables-notembedded.test mysql-test/t/variables-notembedded-master.opt: Add --loose before --slave-skip-errors, so that it works if mtr is run with --embedded mysql-test/t/variables.test: Variable variables not available in embedded mode to a new test, variables-notembedded.test. Result file updated accordingly. --- mysql-test/r/variables-notembedded.result | 17 +++++++++++ mysql-test/r/variables.result | 14 --------- mysql-test/t/variables-master.opt | 1 - mysql-test/t/variables-notembedded-master.opt | 1 + mysql-test/t/variables-notembedded.test | 30 +++++++++++++++++++ mysql-test/t/variables.test | 19 ------------ 6 files changed, 48 insertions(+), 34 deletions(-) create mode 100644 mysql-test/r/variables-notembedded.result delete mode 100644 mysql-test/t/variables-master.opt create mode 100644 mysql-test/t/variables-notembedded-master.opt create mode 100644 mysql-test/t/variables-notembedded.test diff --git a/mysql-test/r/variables-notembedded.result b/mysql-test/r/variables-notembedded.result new file mode 100644 index 00000000000..48a1719e2c7 --- /dev/null +++ b/mysql-test/r/variables-notembedded.result @@ -0,0 +1,17 @@ +---- Init ---- +set @my_slave_net_timeout =@@global.slave_net_timeout; +---- Test ---- +set global slave_net_timeout=100; +set global sql_slave_skip_counter=100; +show variables like 'slave_compressed_protocol'; +Variable_name Value +slave_compressed_protocol OFF +show variables like 'slave_load_tmpdir'; +Variable_name Value +slave_load_tmpdir SLAVE_LOAD_TMPDIR +show variables like 'slave_skip_errors'; +Variable_name Value +slave_skip_errors 3,100,137,643,1752 +---- Clean Up ---- +set global slave_net_timeout=default; +set global sql_slave_skip_counter= 0; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 395ba0eab48..e5c3c860c93 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -22,7 +22,6 @@ set @my_query_cache_limit =@@global.query_cache_limit; set @my_query_cache_type =@@global.query_cache_type; set @my_rpl_recovery_rank =@@global.rpl_recovery_rank; set @my_server_id =@@global.server_id; -set @my_slave_net_timeout =@@global.slave_net_timeout; set @my_slow_launch_time =@@global.slow_launch_time; set @my_storage_engine =@@global.storage_engine; set @my_thread_cache_size =@@global.thread_cache_size; @@ -982,17 +981,6 @@ show variables like 'hostname'; Variable_name Value hostname # End of 5.0 tests -set global slave_net_timeout=100; -set global sql_slave_skip_counter=100; -show variables like 'slave_compressed_protocol'; -Variable_name Value -slave_compressed_protocol OFF -show variables like 'slave_load_tmpdir'; -Variable_name Value -slave_load_tmpdir SLAVE_LOAD_TMPDIR -show variables like 'slave_skip_errors'; -Variable_name Value -slave_skip_errors 3,100,137,643,1752 set global binlog_cache_size =@my_binlog_cache_size; set global connect_timeout =@my_connect_timeout; set global delayed_insert_timeout =@my_delayed_insert_timeout; @@ -1018,9 +1006,7 @@ set global query_cache_limit =@my_query_cache_limit; set global query_cache_type =@my_query_cache_type; set global rpl_recovery_rank =@my_rpl_recovery_rank; set global server_id =@my_server_id; -set global slave_net_timeout =@my_slave_net_timeout; set global slow_launch_time =@my_slow_launch_time; -set global sql_slave_skip_counter =0; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; show global variables where Variable_name='table_definition_cache' or diff --git a/mysql-test/t/variables-master.opt b/mysql-test/t/variables-master.opt deleted file mode 100644 index a668c6bfbe8..00000000000 --- a/mysql-test/t/variables-master.opt +++ /dev/null @@ -1 +0,0 @@ ---slave-skip-errors=3,100,137,643,1752 diff --git a/mysql-test/t/variables-notembedded-master.opt b/mysql-test/t/variables-notembedded-master.opt new file mode 100644 index 00000000000..a684e591d10 --- /dev/null +++ b/mysql-test/t/variables-notembedded-master.opt @@ -0,0 +1 @@ +--loose-slave-skip-errors=3,100,137,643,1752 diff --git a/mysql-test/t/variables-notembedded.test b/mysql-test/t/variables-notembedded.test new file mode 100644 index 00000000000..79011a89b36 --- /dev/null +++ b/mysql-test/t/variables-notembedded.test @@ -0,0 +1,30 @@ +# Tests that variables work correctly (setting and showing). This +# test is like the main.variables test, but for variables not +# available in embedded mode. + +source include/not_embedded.inc; + +--echo ---- Init ---- +# Backup global variables so they can be restored at end of test. +set @my_slave_net_timeout =@@global.slave_net_timeout; + +--echo ---- Test ---- +set global slave_net_timeout=100; +set global sql_slave_skip_counter=100; + +# End of 4.1 tests + +# BUG #7800: Add various-slave related variables to SHOW VARIABLES +show variables like 'slave_compressed_protocol'; +--replace_column 2 SLAVE_LOAD_TMPDIR +show variables like 'slave_load_tmpdir'; +# We just set some arbitrary values in variables-master.opt so we can test +# that a list of values works correctly +show variables like 'slave_skip_errors'; + +--echo ---- Clean Up ---- + +set global slave_net_timeout=default; +# sql_slave_skip_counter is write-only, so we can't save previous +# value and restore it here. That's ok, because it's normally 0. +set global sql_slave_skip_counter= 0; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 404a98d1827..51f8d6db1db 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -31,7 +31,6 @@ set @my_query_cache_limit =@@global.query_cache_limit; set @my_query_cache_type =@@global.query_cache_type; set @my_rpl_recovery_rank =@@global.rpl_recovery_rank; set @my_server_id =@@global.server_id; -set @my_slave_net_timeout =@@global.slave_net_timeout; set @my_slow_launch_time =@@global.slow_launch_time; set @my_storage_engine =@@global.storage_engine; set @my_thread_cache_size =@@global.thread_cache_size; @@ -738,20 +737,6 @@ show variables like 'hostname'; --echo End of 5.0 tests -# -# BUG #7800: SHOW VARIABLES does not show slave-related configuration -# -set global slave_net_timeout=100; -set global sql_slave_skip_counter=100; - -show variables like 'slave_compressed_protocol'; ---replace_column 2 SLAVE_LOAD_TMPDIR -show variables like 'slave_load_tmpdir'; -# We just set some arbitrary values in variables-master.opt so we can test -# that a list of values is printed correctly. -show variables like 'slave_skip_errors'; - -# # This is at the very after the versioned tests, since it involves doing # cleanup # @@ -783,11 +768,7 @@ set global query_cache_limit =@my_query_cache_limit; set global query_cache_type =@my_query_cache_type; set global rpl_recovery_rank =@my_rpl_recovery_rank; set global server_id =@my_server_id; -set global slave_net_timeout =@my_slave_net_timeout; set global slow_launch_time =@my_slow_launch_time; -# sql_slave_skip_counter is write-only, so we can't save previous -# value and restore it here. That's ok, because it's normally 0. -set global sql_slave_skip_counter =0; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; From 6e11dd40b0b11eab8813c9247c247480923be831 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Feb 2008 15:16:39 +0100 Subject: [PATCH 14/20] Updating result files. mysql-test/r/multi_update.result: Result change. mysql-test/r/rpl_bug33931.result: Result change. mysql-test/suite/ndb/r/ndb_binlog_format.result: Result change. --- mysql-test/r/multi_update.result | 4 ++-- mysql-test/r/rpl_bug33931.result | 5 +++++ mysql-test/suite/ndb/r/ndb_binlog_format.result | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index d96927deed5..421a63cd54c 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -627,7 +627,7 @@ a b 4 4 show master status /* there must be the UPDATE query event */; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 336 +master-bin.000001 197 delete from t1; delete from t2; insert into t1 values (1,2),(3,4),(4,4); @@ -637,7 +637,7 @@ UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a; ERROR 23000: Duplicate entry '4' for key 'PRIMARY' show master status /* there must be the UPDATE query event */; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 351 +master-bin.000001 212 drop table t1, t2; set @@session.binlog_format= @sav_binlog_format; drop table if exists t1, t2, t3; diff --git a/mysql-test/r/rpl_bug33931.result b/mysql-test/r/rpl_bug33931.result index 519bd73aa6a..4043f04215b 100644 --- a/mysql-test/r/rpl_bug33931.result +++ b/mysql-test/r/rpl_bug33931.result @@ -36,3 +36,8 @@ Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # +Master_SSL_Verify_Server_Cert No +Last_IO_Errno 0 +Last_IO_Error +Last_SQL_Errno 0 +Last_SQL_Error diff --git a/mysql-test/suite/ndb/r/ndb_binlog_format.result b/mysql-test/suite/ndb/r/ndb_binlog_format.result index b42a528a460..30c2ca872ed 100644 --- a/mysql-test/suite/ndb/r/ndb_binlog_format.result +++ b/mysql-test/suite/ndb/r/ndb_binlog_format.result @@ -18,9 +18,7 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (1,2), (2 master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2) master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c -master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2) master-bin.000001 # Query # # use `test`; UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f From ace6d43164995d20116b95fa4329030ba3a4913e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Feb 2008 15:48:17 +0100 Subject: [PATCH 15/20] Fixed broken result file. --- mysql-test/suite/bugs/r/rpl_bug31583.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/bugs/r/rpl_bug31583.result b/mysql-test/suite/bugs/r/rpl_bug31583.result index a5e38e9b2d8..74846607313 100644 --- a/mysql-test/suite/bugs/r/rpl_bug31583.result +++ b/mysql-test/suite/bugs/r/rpl_bug31583.result @@ -13,3 +13,4 @@ a b SELECT * FROM t1 ORDER BY a; a b 3 -3 +DROP TABLE t1; From 5d1e8e12c3a2c606eb5072bc7c85fc719fbf30fb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Feb 2008 19:59:48 +0100 Subject: [PATCH 16/20] Removing deliberately generated errors for rpl_bug33931 test and moving test to replication suite. mysql-test/suite/rpl/t/rpl_bug33931-slave.opt: Rename: mysql-test/t/rpl_bug33931-slave.opt -> mysql-test/suite/rpl/t/rpl_bug33931-slave.opt mysql-test/suite/rpl/t/rpl_bug33931.test: Rename: mysql-test/t/rpl_bug33931.test -> mysql-test/suite/rpl/t/rpl_bug33931.test mysql-test/suite/rpl/r/rpl_bug33931.result: Rename: mysql-test/r/rpl_bug33931.result -> mysql-test/suite/rpl/r/rpl_bug33931.result mysql-test/lib/mtr_report.pl: Removing deliberately generated errors for rpl_bug33931 test. --- mysql-test/lib/mtr_report.pl | 5 +++++ mysql-test/{ => suite/rpl}/r/rpl_bug33931.result | 0 mysql-test/{ => suite/rpl}/t/rpl_bug33931-slave.opt | 0 mysql-test/{ => suite/rpl}/t/rpl_bug33931.test | 0 4 files changed, 5 insertions(+) rename mysql-test/{ => suite/rpl}/r/rpl_bug33931.result (100%) rename mysql-test/{ => suite/rpl}/t/rpl_bug33931-slave.opt (100%) rename mysql-test/{ => suite/rpl}/t/rpl_bug33931.test (100%) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index ecfdc00eaf9..2aeda9933f0 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -383,6 +383,11 @@ sub mtr_report_stats ($) { (/Failed to write to mysql\.\w+_log/ )) or + # rpl_bug33931 has deliberate failures + ($testname eq 'rpl.rpl_bug33931' and + (/Failed during slave.*thread initialization/ + )) or + # rpl_temporary has an error on slave that can be ignored ($testname eq 'rpl.rpl_temporary' and (/Slave: Can\'t find record in \'user\' Error_code: 1032/ diff --git a/mysql-test/r/rpl_bug33931.result b/mysql-test/suite/rpl/r/rpl_bug33931.result similarity index 100% rename from mysql-test/r/rpl_bug33931.result rename to mysql-test/suite/rpl/r/rpl_bug33931.result diff --git a/mysql-test/t/rpl_bug33931-slave.opt b/mysql-test/suite/rpl/t/rpl_bug33931-slave.opt similarity index 100% rename from mysql-test/t/rpl_bug33931-slave.opt rename to mysql-test/suite/rpl/t/rpl_bug33931-slave.opt diff --git a/mysql-test/t/rpl_bug33931.test b/mysql-test/suite/rpl/t/rpl_bug33931.test similarity index 100% rename from mysql-test/t/rpl_bug33931.test rename to mysql-test/suite/rpl/t/rpl_bug33931.test From 6988f45e6b9fc6546133cfe1e48607bf787bf0de Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Feb 2008 14:52:21 +0100 Subject: [PATCH 17/20] WL#4078: Document binary format of binlog entries Minor update with corrections and notes on the binlog format. This only affects comments, not code. sql/log_event.h: Fixes in documentation of binlog format. --- sql/log_event.h | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/sql/log_event.h b/sql/log_event.h index 4e151d6cde9..c46827253a3 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -670,18 +670,18 @@ typedef struct st_print_event_info Any @c Log_event saved on disk consists of the following three components. - * Common-Header - * Post-Header - * Body + - Common-Header + - Post-Header + - Body The Common-Header, documented in the table @ref Table_common_header "below", always has the same form and length within one version of - MySQL. Each event type specifies a form and length of the - Post-Header common to all events of the type. The Body may be of - different form and length even for different events of the same - type. The binary formats of Post-Header and Body are documented - separately in each subclass. The binary format of Common-Header is - as follows. + MySQL. Each event type specifies a format and length of the + Post-Header. The length of the Common-Header is the same for all + events of the same type. The Body may be of different format and + length even for different events of the same type. The binary + formats of Post-Header and Body are documented separately in each + subclass. The binary format of Common-Header is as follows. @@ -750,8 +750,8 @@ typedef struct st_print_event_info - Some events use a special format for efficient representation of unsigned integers, called Packed Integer. A Packed Integer has the capacity of storing up to 8-byte integers, while small integers - still can use 1, 3, or 4 bytes. The first byte indicates how many - bytes are used by the integer, according to the following table: + still can use 1, 3, or 4 bytes. The value of the first byte + determines how to read the number, according to the following table:
Common-Header
@@ -763,7 +763,7 @@ typedef struct st_print_event_info - @@ -1174,6 +1174,10 @@ protected: @section Query_log_event_binary_format Binary format + See @ref Log_event_binary_format "Binary format for log events" for + a general discussion and introduction to the binary format of binlog + events. + The Post-Header has five components:
Format of Packed Integer
0-250The first byte is the number (in range 0-250), and no more + The first byte is the number (in the range 0-250), and no more bytes are used.
@@ -1407,7 +1411,7 @@ protected: query "SELECT id, character_set_name, collation_name FROM COLLATIONS". - Cf. Q_CHARSET_DATABASE_NUMBER below. + Cf. Q_CHARSET_DATABASE_CODE below. This field is always written. @@ -1442,7 +1446,7 @@ protected: - + @@ -1480,7 +1484,7 @@ protected: Q_CATALOG_CODE will never be written by a new master, but can still be understood by a new slave. - * See Q_CHARSET_DATABASE_NUMBER in the table above. + * See Q_CHARSET_DATABASE_CODE in the table above. */ class Query_log_event: public Log_event @@ -1919,6 +1923,8 @@ private: @subsection Load_log_event_notes_on_previous_versions Notes on Previous Versions + This event type is understood by current versions, but only + generated by MySQL 3.23 and earlier. */ class Load_log_event: public Log_event { From 46db2da52fa4b6305006ebc42a291b48deea2a10 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Feb 2008 15:22:14 +0100 Subject: [PATCH 18/20] Removed the unused function int THD::binlog_flush_transaction_cache() --- sql/log.cc | 29 ----------------------------- sql/sql_class.h | 1 - 2 files changed, 30 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 9b5b2ae5a6c..f12cedfbf05 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3403,35 +3403,6 @@ void THD::binlog_set_stmt_begin() { trx_data->before_stmt_pos= pos; } -int THD::binlog_flush_transaction_cache() -{ - DBUG_ENTER("binlog_flush_transaction_cache"); - binlog_trx_data *trx_data= (binlog_trx_data*) - thd_get_ha_data(this, binlog_hton); - DBUG_PRINT("enter", ("trx_data=0x%lu", (ulong) trx_data)); - if (trx_data) - DBUG_PRINT("enter", ("trx_data->before_stmt_pos=%lu", - (ulong) trx_data->before_stmt_pos)); - - /* - Write the transaction cache to the binary log. We don't flush and - sync the log file since we don't know if more will be written to - it. If the caller want the log file sync:ed, the caller has to do - it. - - The transaction data is only reset upon a successful write of the - cache to the binary log. - */ - - if (trx_data && likely(mysql_bin_log.is_open())) { - if (int error= mysql_bin_log.write_cache(&trx_data->trans_log, true, true)) - DBUG_RETURN(error); - trx_data->reset(); - } - - DBUG_RETURN(0); -} - /* Write a table map to the binary log. diff --git a/sql/sql_class.h b/sql/sql_class.h index 5f2b50f48b8..b660c615920 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1243,7 +1243,6 @@ public: Public interface to write RBR events to the binlog */ void binlog_start_trans_and_stmt(); - int binlog_flush_transaction_cache(); void binlog_set_stmt_begin(); int binlog_write_table_map(TABLE *table, bool is_transactional); int binlog_write_row(TABLE* table, bool is_transactional, From e19c8e2ebfdb5c2a50e71d4192681b8b4bd4efad Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Feb 2008 23:18:01 +0200 Subject: [PATCH 19/20] Bug #31316 Report server id clashes in SHOW SLAVE STATUS "Server_IO_State" field Critical error messages from get_master_version_and_clock() were written only to the slave errorlog while Show slave status did not display any incident happened. Although the artifact was reported for a particular --replicate-same-server-id related issue the fix refines all critical error reporting with deploying rli->report(). The test for the bug covers only --replicate-same-server-id error reporting. mysql-test/suite/rpl/r/rpl_server_id1.result: new results reflecting changes mysql-test/suite/rpl/t/rpl_server_id1.test: Preserving the idea of the test unnecessary queries and the sleep are eliminated. In the end the slave must stop with the error displayable via $$$. sql/slave.cc: improving get_master_version_and_clock() code to report a critical incident via rli->report() that takes care of bothe the error log and the slave's status info placeholders. A critical error that force the IO slave thread to terminate is handled immediately (goto err). --- mysql-test/suite/rpl/r/rpl_server_id1.result | 23 ++++------ mysql-test/suite/rpl/t/rpl_server_id1.test | 19 ++++---- sql/slave.cc | 47 +++++++++++++++----- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_server_id1.result b/mysql-test/suite/rpl/r/rpl_server_id1.result index 9894910aaf6..6a5c86d84bd 100644 --- a/mysql-test/suite/rpl/r/rpl_server_id1.result +++ b/mysql-test/suite/rpl/r/rpl_server_id1.result @@ -4,10 +4,11 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -create table t1 (n int); reset master; stop slave; change master to master_port=SLAVE_PORT; +start slave; +*** must be having the replicate-same-server-id IO thread error *** show slave status; Slave_IO_State Master_Host 127.0.0.1 @@ -20,15 +21,15 @@ Relay_Log_File slave-relay-bin.000001 Relay_Log_Pos 4 Relay_Master_Log_File Slave_IO_Running No -Slave_SQL_Running No +Slave_SQL_Running # Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table # Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table # -Last_Errno 0 -Last_Error +Last_Errno # +Last_Error # Skip_Counter 0 Exec_Master_Log_Pos 0 Relay_Log_Space 106 @@ -43,13 +44,7 @@ Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master NULL Master_SSL_Verify_Server_Cert No -Last_IO_Errno # -Last_IO_Error # -Last_SQL_Errno 0 -Last_SQL_Error -start slave; -insert into t1 values (1); -show status like "slave_running"; -Variable_name Value -Slave_running OFF -drop table t1; +Last_IO_Errno 1593 +Last_IO_Error Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it). +Last_SQL_Errno # +Last_SQL_Error # diff --git a/mysql-test/suite/rpl/t/rpl_server_id1.test b/mysql-test/suite/rpl/t/rpl_server_id1.test index 2db1f6e364d..b412f303b7e 100644 --- a/mysql-test/suite/rpl/t/rpl_server_id1.test +++ b/mysql-test/suite/rpl/t/rpl_server_id1.test @@ -6,21 +6,20 @@ source include/master-slave.inc; connection slave; -create table t1 (n int); reset master; + # replicate ourselves stop slave; --replace_result $SLAVE_MYPORT SLAVE_PORT eval change master to master_port=$SLAVE_MYPORT; ---replace_result $SLAVE_MYPORT SLAVE_PORT ---replace_column 16 # 18 # 35 # 36 # -query_vertical show slave status; start slave; -insert into t1 values (1); -# can't MASTER_POS_WAIT(), it does not work in this weird setup -# (when slave is its own master without --replicate-same-server-id) -sleep 2; # enough time for the event to be replicated (it should not) -show status like "slave_running"; -drop table t1; + +--echo *** must be having the replicate-same-server-id IO thread error *** + +source include/wait_for_slave_io_to_stop.inc; + +--replace_result $SLAVE_MYPORT SLAVE_PORT +--replace_column 12 # 16 # 19 # 20 # 18 # 37 # 38 # +query_vertical show slave status; # End of 4.1 tests diff --git a/sql/slave.cc b/sql/slave.cc index ea0dde942da..1880dcf0d43 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -747,7 +747,11 @@ int init_intvar_from_file(int* var, IO_CACHE* f, int default_val) static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) { + char err_buff[MAX_SLAVE_ERRMSG]; const char* errmsg= 0; + int err_code= 0; + MYSQL_RES *master_res= 0; + MYSQL_ROW master_row; DBUG_ENTER("get_master_version_and_clock"); /* @@ -758,7 +762,11 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) mi->rli.relay_log.description_event_for_queue= 0; if (!my_isdigit(&my_charset_bin,*mysql->server_version)) + { errmsg = "Master reported unrecognized MySQL version"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } else { /* @@ -770,6 +778,8 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) case '1': case '2': errmsg = "Master reported unrecognized MySQL version"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); break; case '3': mi->rli.relay_log.description_event_for_queue= new @@ -802,26 +812,21 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) */ if (errmsg) - { - sql_print_error(errmsg); - DBUG_RETURN(1); - } + goto err; /* as we are here, we tried to allocate the event */ if (!mi->rli.relay_log.description_event_for_queue) { - mi->report(ERROR_LEVEL, ER_SLAVE_CREATE_EVENT_FAILURE, - ER(ER_SLAVE_CREATE_EVENT_FAILURE), - "default Format_description_log_event"); - DBUG_RETURN(1); + errmsg= "default Format_description_log_event"; + err_code= ER_SLAVE_CREATE_EVENT_FAILURE; + sprintf(err_buff, ER(err_code), errmsg); + goto err; } /* Compare the master and slave's clock. Do not die if master's clock is unavailable (very old master not supporting UNIX_TIMESTAMP()?). */ - MYSQL_RES *master_res= 0; - MYSQL_ROW master_row; if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT UNIX_TIMESTAMP()")) && (master_res= mysql_store_result(mysql)) && @@ -858,11 +863,17 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) if ((master_row= mysql_fetch_row(master_res)) && (::server_id == strtoul(master_row[1], 0, 10)) && !mi->rli.replicate_same_server_id) + { errmsg= "The slave I/O thread stops because master and slave have equal \ MySQL server ids; these ids must be different for replication to work (or \ the --replicate-same-server-id option must be used on slave but this does \ not always make sense; please check the manual before using it)."; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } mysql_free_result(master_res); + if (errmsg) + goto err; } /* @@ -893,10 +904,16 @@ not always make sense; please check the manual before using it)."; { if ((master_row= mysql_fetch_row(master_res)) && strcmp(master_row[0], global_system_variables.collation_server->name)) + { errmsg= "The slave I/O thread stops because master and slave have \ different values for the COLLATION_SERVER global variable. The values must \ be equal for replication to work"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } mysql_free_result(master_res); + if (errmsg) + goto err; } /* @@ -921,16 +938,24 @@ be equal for replication to work"; if ((master_row= mysql_fetch_row(master_res)) && strcmp(master_row[0], global_system_variables.time_zone->get_name()->ptr())) + { errmsg= "The slave I/O thread stops because master and slave have \ different values for the TIME_ZONE global variable. The values must \ be equal for replication to work"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } mysql_free_result(master_res); + + if (errmsg) + goto err; } err: if (errmsg) { - sql_print_error(errmsg); + DBUG_ASSERT(err_code != 0); + mi->report(ERROR_LEVEL, err_code, err_buff); DBUG_RETURN(1); } From 760282f4082a144a2169cb1a621084ab71d9dc70 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Feb 2008 06:29:35 +0100 Subject: [PATCH 20/20] Fixing result after merge. mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result: Result change. --- .../binlog/r/binlog_row_ctype_cp932.result | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result b/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result index 655100203b5..a288923b03c 100644 --- a/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result +++ b/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result @@ -11399,6 +11399,23 @@ cp932_japanese_ci 6109 cp932_japanese_ci 61 cp932_japanese_ci 6120 drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; SET collation_connection='cp932_bin'; create table t1 select repeat('a',4000) a; delete from t1; @@ -11409,6 +11426,23 @@ cp932_bin 6109 cp932_bin 61 cp932_bin 6120 drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 +DROP TABLE t1; create table t2 (a char(1)); insert into t2 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'); insert into t2 values ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
charset_database_numberQ_CHARSET_DATABASE_NUMBER == 8Q_CHARSET_DATABASE_CODE == 8 2 byte integer The value of the collation_database system variable (in the @@ -1457,11 +1461,11 @@ protected: In newer versions, "CREATE TABLE" has been changed to take the character set from the database of the created table, rather than - the database of the current database. This makes a difference - when creating a table in another database than the current one. - "LOAD DATA INFILE" has not yet changed to do this, but there are - plans to eventually do it, and to make collation_database - read-only. + the character set of the current database. This makes a + difference when creating a table in another database than the + current one. "LOAD DATA INFILE" has not yet changed to do this, + but there are plans to eventually do it, and to make + collation_database read-only. This field is written if it is not 0.