From f792cf3e3857040667746e662aad9a0ef4dea676 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Feb 2008 11:10:40 +0400 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 ded528ca1249f35f55f9d7b52d95c96e94734495 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Feb 2008 14:09:41 +0200 Subject: [PATCH 5/7] 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 50bd4a438e72fdf6f46e2d714b2f13999fa460b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Feb 2008 16:28:32 +0200 Subject: [PATCH 6/7] 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 9ffaa745358b6b72cd6a778f01874a325f198198 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 2 Mar 2008 21:20:36 +0300 Subject: [PATCH 7/7] Bug#22438 mysql-test/r/mysqldump.result: updated result mysql-test/t/mysqldump.test: hide master_log_pos number --- mysql-test/r/mysqldump.result | 2 +- mysql-test/t/mysqldump.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index ca0aa399a56..b484cf7c51d 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3306,7 +3306,7 @@ grant RELOAD on *.* to mysqltest_1@localhost; mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; -CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=537; +CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=#; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `t1` ( diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 6dba0a590d0..88053ae95fb 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1348,6 +1348,7 @@ grant RELOAD on *.* to mysqltest_1@localhost; grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; # Execute mysqldump, should now succeed +--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=#/ --exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 # Clean up