Commit ff3fd46c authored by evgen@moonbone.local's avatar evgen@moonbone.local

Bug#29461: Sort order of the collation wasn't used when comparing characters

with the space character.

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 the 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 the space character.
parent 5b1e1eea
...@@ -603,3 +603,11 @@ check table t1 extended; ...@@ -603,3 +603,11 @@ check table t1 extended;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
drop table t1; drop table t1;
create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
insert into t1 set a=0x4c20;
insert into t1 set a=0x6c;
insert into t1 set a=0x4c98;
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
...@@ -218,3 +218,14 @@ insert into t1 set f1=0x3F3F1E563F; ...@@ -218,3 +218,14 @@ insert into t1 set f1=0x3F3F1E563F;
insert into t1 set f1=0x3F3F; insert into t1 set f1=0x3F3F;
check table t1 extended; check table t1 extended;
drop table t1; drop table t1;
#
# Bug#29461: Sort order of the collation wasn't used when comparing characters
# with the space character.
#
create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
insert into t1 set a=0x4c20;
insert into t1 set a=0x6c;
insert into t1 set a=0x4c98;
check table t1 extended;
drop table t1;
...@@ -179,7 +179,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, ...@@ -179,7 +179,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length,
} }
for (end= a + a_length-length; a < end ; a++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (map[*a] != ' ')
return (map[*a] < ' ') ? -swap : swap; return (map[*a] < ' ') ? -swap : swap;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment