diff options
author | unknown <igor@rurik.mysql.com> | 2006-06-20 19:57:21 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2006-06-20 19:57:21 -0700 |
commit | 69977fa50b5718106828c70a2d93e7c93579b2ac (patch) | |
tree | f11d15c22a771479b818063644dc2507f3c7b027 /mysql-test | |
parent | 846c46ea4d916cf3adfacdee67bf5d0a191e07b5 (diff) | |
download | mariadb-git-69977fa50b5718106828c70a2d93e7c93579b2ac.tar.gz |
Fixed bug #16674.
The length of the prefix of the pattern string in the LIKE predicate that
determined the index range to be scanned was calculated incorrectly for
multi-byte character sets.
As a result of this in 4. 1 the the scanned range was wider then necessary
if the prefix contained not only one-byte characters.
In 5.0 additionally it caused missing some rows from the result set.
mysql-test/r/ctype_utf8.result:
Added test cases for bug #16674.
mysql-test/t/ctype_utf8.test:
Added test cases for bug #16674.
strings/ctype-mb.c:
Fixed bug #16674.
The length of the prefix of the pattern string in the LIKE predicate that
determined the index range to be scanned was calculated incorrectly for
multi-byte character sets.
As a result of this in 4. 1 the the scanned range was wider then necessary
if the prefix contained not only one-byte characters.
In 5.0 additionally it caused missing some rows from the result set.
The function my_like_range_mb was fixed to calculate the length of
the prefix in a pattern string correctly in all cases.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 67 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 55 |
2 files changed, 122 insertions, 0 deletions
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 69d7577ee77..dff4476993c 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1124,3 +1124,70 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +SET NAMES utf8; +CREATE TABLE t1 ( +a CHAR(13) DEFAULT '', +INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO t1 VALUES +('Käli Käli 2-4'), ('Käli Käli 2-4'), +('Käli Käli 2+4'), ('Käli Käli 2+4'), +('Käli Käli 2-6'), ('Käli Käli 2-6'); +CREATE TABLE t2 ( +a CHAR(13) DEFAULT '', +INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +INSERT INTO t2 VALUES +('Kali Kali 2-4'), ('Kali Kali 2-4'), +('Kali Kali 2+4'), ('Kali Kali 2+4'), +('Kali Kali 2-6'), ('Kali Kali 2-6'); +SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +a +Käli Käli 2+4 +Käli Käli 2+4 +SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +a +Kali Kali 2+4 +Kali Kali 2+4 +EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 40 NULL 2 Using where; Using index +EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 40 const 2 Using where; Using index +EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range a a 14 NULL 2 Using where; Using index +EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref a a 14 const 2 Using where; Using index +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a char(255) DEFAULT '', +KEY(a(10)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +DROP TABLE t1; +CREATE TABLE t1 ( +a char(255) DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +ALTER TABLE t1 ADD KEY (a(10)); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +DROP TABLE t1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 5044f7979f1..47436956354 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -926,4 +926,59 @@ INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbb check table t1; drop table t1; +# +# Bug#16674: LIKE predicate for a utf8 character set column +# + +SET NAMES utf8; + +CREATE TABLE t1 ( + a CHAR(13) DEFAULT '', + INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO t1 VALUES + ('Käli Käli 2-4'), ('Käli Käli 2-4'), + ('Käli Käli 2+4'), ('Käli Käli 2+4'), + ('Käli Käli 2-6'), ('Käli Käli 2-6'); + +CREATE TABLE t2 ( + a CHAR(13) DEFAULT '', + INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; + +INSERT INTO t2 VALUES + ('Kali Kali 2-4'), ('Kali Kali 2-4'), + ('Kali Kali 2+4'), ('Kali Kali 2+4'), + ('Kali Kali 2-6'), ('Kali Kali 2-6'); + +SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; + +EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4'; +EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4'; + +DROP TABLE t1,t2; + +CREATE TABLE t1 ( + a char(255) DEFAULT '', + KEY(a(10)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +DROP TABLE t1; + +CREATE TABLE t1 ( + a char(255) DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +ALTER TABLE t1 ADD KEY (a(10)); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +DROP TABLE t1; + # End of 4.1 tests |