diff options
author | unknown <serg@serg.mylan> | 2004-10-26 20:31:41 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-10-26 20:31:41 +0200 |
commit | c882c26101149a3e06f27670cc14ef62c0cc2ab9 (patch) | |
tree | c7421140b78475bb87fd5eeb15e3a9107b07d93c | |
parent | 28db20e481276cb44cb637c8cc9975608046c5f3 (diff) | |
download | mariadb-git-c882c26101149a3e06f27670cc14ef62c0cc2ab9.tar.gz |
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
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 4 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 4 | ||||
-rw-r--r-- | sql/field.cc | 16 | ||||
-rw-r--r-- | sql/field.h | 1 |
4 files changed, 8 insertions, 17 deletions
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index e65eb96cb68..68e3247ee16 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -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; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 238cd6daef3..c6954af8cf4 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -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; diff --git a/sql/field.cc b/sql/field.cc index aae507cd0ec..29ebf02f9f3 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4425,24 +4425,8 @@ 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; if (length > char_length) diff --git a/sql/field.h b/sql/field.h index 69410f4e6af..8887da1dc0f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -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); |