mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Bug #6019 - SELECT tries to use too short prefix index on utf8 data
Field_string::pack should respect max_length as Field_string::pack_key does
This commit is contained in:
@@ -798,4 +798,8 @@ insert into t1 values(1,'foo'),(2,'foobar');
|
||||
select * from t1 where b like 'foob%';
|
||||
a b
|
||||
2 foobar
|
||||
alter table t1 engine=bdb;
|
||||
select * from t1 where b like 'foob%';
|
||||
a b
|
||||
2 foobar
|
||||
drop table t1;
|
||||
|
||||
@@ -643,4 +643,8 @@ create table t1 (
|
||||
--enable_warnings
|
||||
insert into t1 values(1,'foo'),(2,'foobar');
|
||||
select * from t1 where b like 'foob%';
|
||||
--disable_warnings
|
||||
alter table t1 engine=bdb;
|
||||
select * from t1 where b like 'foob%';
|
||||
--enable_warnings
|
||||
drop table t1;
|
||||
|
||||
16
sql/field.cc
16
sql/field.cc
@@ -4425,23 +4425,7 @@ void Field_string::sql_type(String &res) const
|
||||
res.length(length);
|
||||
}
|
||||
|
||||
|
||||
char *Field_string::pack(char *to, const char *from, uint max_length)
|
||||
{
|
||||
const char *end=from+min(field_length,max_length);
|
||||
uint length;
|
||||
while (end > from && end[-1] == ' ')
|
||||
end--;
|
||||
length= (end-from);
|
||||
*to++= (char) (uchar) length;
|
||||
if (field_length > 255)
|
||||
*to++= (char) (uchar) (length >> 8);
|
||||
memcpy(to, from, (int) length);
|
||||
return to+length;
|
||||
}
|
||||
|
||||
|
||||
char *Field_string::pack_key(char *to, const char *from, uint max_length)
|
||||
{
|
||||
uint length= min(field_length,max_length);
|
||||
uint char_length= max_length/field_charset->mbmaxlen;
|
||||
|
||||
@@ -927,7 +927,6 @@ public:
|
||||
void sort_string(char *buff,uint length);
|
||||
void sql_type(String &str) const;
|
||||
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
|
||||
char *pack_key(char *to, const char *from, uint max_length);
|
||||
const char *unpack(char* to, const char *from);
|
||||
int pack_cmp(const char *a,const char *b,uint key_length);
|
||||
int pack_cmp(const char *b,uint key_length);
|
||||
|
||||
Reference in New Issue
Block a user