[Commits] 8076c594ce2: MDEV-18953 Hash index on partial char field not working
revision-id: 8076c594ce206222d1daf70d4193095061dd5d2f (mariadb-10.4.3-85-g8076c594ce2) parent(s): de51acd03730311505677eb7212756e7126183b3 author: sachinsetia1001@gmail.com committer: Sachin timestamp: 2019-03-19 16:43:43 +0530 message: MDEV-18953 Hash index on partial char field not working Write cmp_max for Field_string. --- mysql-test/main/disabled.def | 2 -- mysql-test/main/long_unique_bugs.result | 16 ++++++++++++++++ mysql-test/main/long_unique_bugs.test | 15 +++++++++++++++ sql/field.cc | 13 +++++++++++++ sql/field.h | 1 + 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/disabled.def b/mysql-test/main/disabled.def index 9281c73995c..c1cfd229a9b 100644 --- a/mysql-test/main/disabled.def +++ b/mysql-test/main/disabled.def @@ -22,5 +22,3 @@ partition_open_files_limit : open_files_limit check broken by MDEV-18360 mysqlcheck : special tables like proxy , host specific to a system are shown flush_read_lock : special tables like proxy , host specific to a system are shown join_cache : enable after MDEV-17752 is fixed -ctype_utf8mb4_myisam : enable after MDEV-18953 is fixed -ctype_utf8mb4_innodb : enable after MDEV-18953 is fixed diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index b3a1076804b..dec5153ad85 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -186,3 +186,19 @@ c varchar(5000), UNIQUE(c,b(64)) ) ENGINE=InnoDB; drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a using hash (c(1)) +) engine=myisam; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) USING HASH +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry '�' for key 'a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry '�' for key 'a' +drop table t1; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 6257111b3fb..db1cd0fbae4 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -215,3 +215,18 @@ CREATE TABLE t1 ( UNIQUE(c,b(64)) ) ENGINE=InnoDB; drop table t1; + +# +# MDEV-18953 Hash index on partial char field not working +# +create table t1 ( + c char(10) character set utf8mb4, + unique key a using hash (c(1)) +) engine=myisam; +show create table t1; +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 365d485b967..e30a50422a0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3735,6 +3735,19 @@ void Field_tiny::sql_type(String &res) const add_zerofill_and_unsigned(res); } +/* + Compare 2 char fields upto length max_len. + Calling function must make sure that max_len < both field data_length + Currently only used inside of check_duplicate_long_entry_key +*/ +int Field_string::cmp_max(const uchar *a_ptr, const uchar *b_ptr, + uint max_length) +{ + return field_charset->coll->strnncollsp(field_charset, + a_ptr, max_length, + b_ptr, max_length); +} + /**************************************************************************** Field type short int (2 byte) ****************************************************************************/ diff --git a/sql/field.h b/sql/field.h index 475b6907346..097e8d50fdd 100644 --- a/sql/field.h +++ b/sql/field.h @@ -3558,6 +3558,7 @@ class Field_string :public Field_longstr { String *val_str(String*,String *); my_decimal *val_decimal(my_decimal *); int cmp(const uchar *,const uchar *); + int cmp_max(const uchar *, const uchar *, uint max_length); void sort_string(uchar *buff,uint length); void sql_type(String &str) const; virtual uchar *pack(uchar *to, const uchar *from,
participants (1)
-
sachin.setiya@mariadb.com