From: Date: June 29 2007 8:01pm Subject: bk commit into 5.0 tree (evgen:1.2504) BUG#29261 List-Archive: http://lists.mysql.com/commits/29974 X-Bug: 29261 Message-Id: <20070629180152.4367B22D879@moonbone.moonbone.local> Below is the list of changes that have just been committed into a local 5.0 repository of evgen. When evgen does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-06-29 22:01:49+04:00, evgen@stripped +3 -0 Bug#29261: Sort order of the collation wasn't used when comparing trailing spaces. When the my_strnncollsp_simple function compares two strings and one is a prefix of another then this function compares characters in the rest of longer key with a space character to find whether the longer key is greater or less. But the sort order of the collation isn't used in this comparison. This may lead to a wrong comparison result, wrongly created index or wrong order of the result set of a query with the ORDER BY clause. Now the my_strnncollsp_simple function uses collation sort order to compare the characters in the rest of longer key with a space character. mysql-test/r/ctype_collate.result@stripped, 2007-06-29 22:00:19+04:00, evgen@stripped +8 -0 Added a test case for the bug#29261: Sort order of the collation wasn't used when comparing trailing spaces. mysql-test/t/ctype_collate.test@stripped, 2007-06-29 22:00:15+04:00, evgen@stripped +11 -0 Added a test case for the bug#29261: Sort order of the collation wasn't used when comparing trailing spaces. strings/ctype-simple.c@stripped, 2007-06-29 21:59:53+04:00, evgen@stripped +1 -1 Bug#29261: Sort order of the collation wasn't used when comparing trailing spaces. Now the my_strnncollsp_simple function uses collation sort order to compare the characters in the rest of longer key with a space character. diff -Nrup a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result --- a/mysql-test/r/ctype_collate.result 2005-04-11 14:08:58 +04:00 +++ b/mysql-test/r/ctype_collate.result 2007-06-29 22:00:19 +04:00 @@ -595,3 +595,11 @@ EXPLAIN SELECT * FROM t1 WHERE s2 LIKE ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where DROP TABLE t1; +create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1)); +insert into t1 set f1=0x3F3F9DC73F; +insert into t1 set f1=0x3F3F1E563F; +insert into t1 set f1=0x3F3F; +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff -Nrup a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test --- a/mysql-test/t/ctype_collate.test 2006-11-20 23:41:40 +03:00 +++ b/mysql-test/t/ctype_collate.test 2007-06-29 22:00:15 +04:00 @@ -207,3 +207,14 @@ EXPLAIN SELECT * FROM t1 WHERE s2 LIKE ' DROP TABLE t1; # End of 4.1 tests + +# +# Bug#29261: Sort order of the collation wasn't used when comparing trailing +# spaces. +# +create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1)); +insert into t1 set f1=0x3F3F9DC73F; +insert into t1 set f1=0x3F3F1E563F; +insert into t1 set f1=0x3F3F; +check table t1 extended; +drop table t1; diff -Nrup a/strings/ctype-simple.c b/strings/ctype-simple.c --- a/strings/ctype-simple.c 2007-01-22 15:10:42 +03:00 +++ b/strings/ctype-simple.c 2007-06-29 21:59:53 +04:00 @@ -180,7 +180,7 @@ int my_strnncollsp_simple(CHARSET_INFO * for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return (*a < ' ') ? -swap : swap; + return (map[*a] < ' ') ? -swap : swap; } } return res;