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 8103e9b856f..9de10a5452b 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -124,6 +124,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; @@ -174,6 +191,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 8974a6a8594..498859bb517 100755 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/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'); 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 bb1b3f5995b..c2a1b70eda9 100644 --- a/mysql-test/r/ctype_euckr.result +++ b/mysql-test/r/ctype_euckr.result @@ -124,6 +124,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; @@ -174,6 +191,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 95246525368..42f6d6c6e3b 100644 --- a/mysql-test/r/ctype_gb2312.result +++ b/mysql-test/r/ctype_gb2312.result @@ -124,6 +124,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; @@ -174,6 +191,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 8437e34be1e..0a326c3bf65 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -124,6 +124,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; @@ -174,6 +191,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 50be0ca53b2..8e67156c400 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2815,5 +2815,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 a6d6c604b9b..71810a3364f 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/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/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/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/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/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index be137079c7a..e704ada657b 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -77,7 +77,8 @@ load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; ERROR 23000: Duplicate entry '2003-03-22' for key 1 -drop table t2; +set @@global.sql_slave_skip_counter=1; +start slave; drop table t2; drop table t1; CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; diff --git a/mysql-test/r/rpl_master_pos_wait.result b/mysql-test/r/rpl_master_pos_wait.result index f0f48de4e07..b831eb9b95a 100644 --- a/mysql-test/r/rpl_master_pos_wait.result +++ b/mysql-test/r/rpl_master_pos_wait.result @@ -16,3 +16,9 @@ select master_pos_wait('master-bin.999999',0); stop slave sql_thread; master_pos_wait('master-bin.999999',0) NULL +"*** must be empty ***" +show slave status; +"*** must be NULL ***" +select master_pos_wait('foo', 98); +master_pos_wait('foo', 98) +NULL diff --git a/mysql-test/r/rpl_slave_status.result b/mysql-test/r/rpl_slave_status.result index 9a4ec4131b0..641a65f5ed7 100644 --- a/mysql-test/r/rpl_slave_status.result +++ b/mysql-test/r/rpl_slave_status.result @@ -53,3 +53,4 @@ Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master NULL drop table t1; +drop table t1; 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 3521a6fc91e..4042a973576 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -404,8 +404,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 3af5bfa54f9..3c977596dca 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/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 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/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index a4781ed4faa..ee80bdfde45 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -147,12 +147,20 @@ terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; connection slave; wait_for_slave_to_stop; -drop table t2; + +# cleanup: + +set @@global.sql_slave_skip_counter=1; +start slave; + connection master; drop table t2; drop table t1; +sync_slave_with_master; + # BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed +connection master; CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; --error 1062 @@ -160,5 +168,6 @@ LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; DROP TABLE t1; -sync_with_master; +sync_slave_with_master; + # End of 4.1 tests diff --git a/mysql-test/t/rpl_master_pos_wait.test b/mysql-test/t/rpl_master_pos_wait.test index 893c8746efc..2f7b18ae04b 100644 --- a/mysql-test/t/rpl_master_pos_wait.test +++ b/mysql-test/t/rpl_master_pos_wait.test @@ -15,4 +15,15 @@ stop slave sql_thread; connection slave; reap; +# +# bug#26622 MASTER_POS_WAIT does not work as documented +# + +connection master; +echo "*** must be empty ***"; +query_vertical show slave status; + +echo "*** must be NULL ***"; +select master_pos_wait('foo', 98); + # End of 4.1 tests diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test index baa7a88b8bb..0e3fd5d9e0d 100644 --- a/mysql-test/t/rpl_skip_error.test +++ b/mysql-test/t/rpl_skip_error.test @@ -15,12 +15,13 @@ select * from t1; connection master; drop table t1; -sync_with_master; +sync_slave_with_master; # End of 4.1 tests # # #28839 Errors in strict mode silently stop SQL thread if --slave-skip-errors exists # +connection master; create table t1(a int primary key); insert into t1 values (1),(2); delete from t1 where @@server_id=1; @@ -36,5 +37,5 @@ select * from t1; show slave status; connection master; drop table t1; -sync_with_master; +sync_slave_with_master; # End of 5.0 tests diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test index b97b769d181..527e230854a 100644 --- a/mysql-test/t/rpl_slave_status.test +++ b/mysql-test/t/rpl_slave_status.test @@ -29,8 +29,12 @@ start slave; --vertical_results show slave status; +# cleanup: slave io thread has been stopped "irrecoverably" +# so we clean up mess manually + connection master; drop table t1; -sync_with_master; +connection slave; +drop table t1; # end of 4.1 tests diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index a7a15aebe7a..516f3a026c9 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -130,7 +130,7 @@ drop table t1,t2; # don't get any memory leaks for this create temporary table t3 (f int); -sync_with_master; +sync_slave_with_master; # The server will now close done @@ -141,7 +141,8 @@ sync_with_master; connection master; create temporary table t4 (f int); create table t5 (f int); -sync_with_master; +sync_slave_with_master; +connection master; # find dumper's $id source include/get_binlog_dump_thread_id.inc; insert into t4 values (1); 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; + diff --git a/sql/slave.cc b/sql/slave.cc index 8a3620080f2..5488b3c312a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -699,7 +699,20 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock, while (*slave_running) // Should always be true { DBUG_PRINT("loop", ("killing slave thread")); - KICK_SLAVE(thd); + + pthread_mutex_lock(&thd->LOCK_delete); +#ifndef DONT_USE_THR_ALARM + /* + Error codes from pthread_kill are: + EINVAL: invalid signal number (can't happen) + ESRCH: thread already killed (can happen, should be ignored) + */ + IF_DBUG(int err= ) pthread_kill(thd->real_id, thr_client_alarm); + DBUG_ASSERT(err != EINVAL); +#endif + thd->awake(THD::NOT_KILLED); + pthread_mutex_unlock(&thd->LOCK_delete); + /* There is a small chance that slave thread might miss the first alarm. To protect againts it, resend the signal until it reacts @@ -2685,7 +2698,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, longlong timeout) { if (!inited) - return -1; + return -2; int event_count = 0; ulong init_abort_pos_wait; int error=0; @@ -2896,6 +2909,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(); @@ -2915,10 +2931,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); } @@ -3516,6 +3539,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 @@ -3526,7 +3550,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); @@ -3866,9 +3889,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)) @@ -3883,7 +3908,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); @@ -3896,7 +3920,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); 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()) diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 1fbc6eb30cf..cf400218cc2 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -35,12 +35,6 @@ extern I_List binlog_do_db, binlog_ignore_db; extern int max_binlog_dump_events; extern my_bool opt_sporadic_binlog_dump_fail; -#define KICK_SLAVE(thd) do { \ - pthread_mutex_lock(&(thd)->LOCK_delete); \ - (thd)->awake(THD::NOT_KILLED); \ - pthread_mutex_unlock(&(thd)->LOCK_delete); \ - } while(0) - int start_slave(THD* thd, MASTER_INFO* mi, bool net_report); int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report); bool change_master(THD* thd, MASTER_INFO* mi); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 84349a40977..9c82bde9497 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) {} @@ -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 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 97e5defdec1..dd8d1395ad4 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1670,7 +1670,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,