Skip to content

Commit

Permalink
Revert (MDEV-18888)2b06de8064660c5c, fix it in different way And add …
Browse files Browse the repository at this point in the history
…test case for MDEV-18953
  • Loading branch information
mariadb-SachinSetiya committed Mar 23, 2019
1 parent ef33e26 commit 0c56764
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 0 additions & 2 deletions mysql-test/main/disabled.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions mysql-test/main/long_unique_bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,19 @@ data
f
o
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;
15 changes: 15 additions & 0 deletions mysql-test/main/long_unique_bugs.test
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,18 @@ SELECT * FROM t1;
DROP TABLE t1;
--let $datadir= `select @@datadir`
--remove_file $datadir/test/load.data

#
# 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;
10 changes: 3 additions & 7 deletions sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,8 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
new (mem_root) Item_field(thd, keypart->field),
new (mem_root) Item_int(thd, length));
list_item->fix_fields(thd, NULL);
keypart->field->vcol_info=
table->field[keypart->field->field_index]->vcol_info;
}
else
list_item= new (mem_root) Item_field(thd, keypart->field);
Expand Down Expand Up @@ -3710,14 +3712,8 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
for ( ; key_part < key_part_end; key_part++)
{
Field *field= key_part->field= outparam->field[key_part->fieldnr - 1];
/*
There's no need to create a prefix
Field for HA_KEY_ALG_LONG_HASH indexes, as they implement prefixing via
Iten_func_left anyway (see parse_vcol_defs())
*/
if (field->key_length() != key_part->length &&
!(field->flags & BLOB_FLAG) &&
key_info->algorithm != HA_KEY_ALG_LONG_HASH)
!(field->flags & BLOB_FLAG))
{
/*
We are using only a prefix of the column as a key:
Expand Down

0 comments on commit 0c56764

Please sign in to comment.