Skip to content

Commit bd7f7b1

Browse files
committed
MDEV-371 Unique Index for long columns
post-merge fixes
1 parent f600078 commit bd7f7b1

11 files changed

+133
-134
lines changed

mysql-test/main/long_unique.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,13 +1387,13 @@ create table t1(a blob unique) partition by hash(a);
13871387
ERROR HY000: A BLOB field is not allowed in partition function
13881388
#key length > 2^16 -1
13891389
create table t1(a blob, unique(a(65536)));
1390-
ERROR HY000: Max key segment length is 65535
1390+
ERROR 42000: Specified key part was too long; max key part length is 65535 bytes
13911391
create table t1(a blob, unique(a(65535)));
13921392
show create table t1;
13931393
Table Create Table
13941394
t1 CREATE TABLE `t1` (
13951395
`a` blob DEFAULT NULL,
1396-
UNIQUE KEY `a` (`a`) USING HASH
1396+
UNIQUE KEY `a` (`a`(65535)) USING HASH
13971397
) ENGINE=MyISAM DEFAULT CHARSET=latin1
13981398
drop table t1;
13991399
#64 indexes

mysql-test/main/long_unique.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
let datadir=`select @@datadir`;
22
--source include/have_partition.inc
33

4+
#
5+
# MDEV-371 Unique indexes for blobs
6+
#
7+
48
--echo #Structure of tests
59
--echo #First we will check all option for
610
--echo #table containing single unique column
@@ -475,7 +479,7 @@ drop table t1;
475479
--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
476480
create table t1(a blob unique) partition by hash(a);
477481
--echo #key length > 2^16 -1
478-
--error ER_TOO_LONG_HASH_KEYSEG
482+
--error ER_TOO_LONG_KEYPART
479483
create table t1(a blob, unique(a(65536)));
480484
create table t1(a blob, unique(a(65535)));
481485
show create table t1;

mysql-test/main/long_unique_debug.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
--source include/have_debug.inc
2-
--source include/have_innodb.inc
2+
3+
#
4+
# MDEV-371 Unique indexes for blobs
5+
#
6+
37
--echo #In this test case we will check what will happen in the case of hash collision
48

59
SET debug_dbug="d,same_long_unique_hash";

mysql-test/main/long_unique_innodb.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ insert into t1 values('RUC');
33
insert into t1 values ('RUC');
44
ERROR 23000: Duplicate entry 'RUC' for key 'a'
55
drop table t1;
6+
create table t1 (a blob unique , c int unique) engine=innodb;
7+
show create table t1;
8+
Table Create Table
9+
t1 CREATE TABLE `t1` (
10+
`a` blob DEFAULT NULL,
11+
`c` int(11) DEFAULT NULL,
12+
UNIQUE KEY `a` (`a`) USING HASH,
13+
UNIQUE KEY `c` (`c`)
14+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
15+
drop table t1;
616
#test for concurrent insert of long unique in innodb
717
create table t1(a blob unique) engine= InnoDB;
818
show create table t1;

mysql-test/main/long_unique_innodb.test

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
--source include/have_innodb.inc
22

3+
#
4+
# MDEV-371 Unique indexes for blobs
5+
#
6+
37
create table t1(a blob unique) engine= InnoDB;
48
insert into t1 values('RUC');
59
--error ER_DUP_ENTRY
610
insert into t1 values ('RUC');
711
drop table t1;
812

13+
create table t1 (a blob unique , c int unique) engine=innodb;
14+
show create table t1;
15+
drop table t1;
16+
917
--echo #test for concurrent insert of long unique in innodb
1018
create table t1(a blob unique) engine= InnoDB;
1119
show create table t1;
@@ -33,7 +41,6 @@ insert into t1 values('RC');
3341
commit;
3442
set transaction isolation level READ COMMITTED;
3543
start transaction;
36-
--error ER_DUP_ENTRY
3744
--error ER_LOCK_WAIT_TIMEOUT
3845
insert into t1 values ('RC');
3946
commit;
@@ -47,7 +54,6 @@ insert into t1 values('RR');
4754
commit;
4855
set transaction isolation level REPEATABLE READ;
4956
start transaction;
50-
--error ER_DUP_ENTRY
5157
--error ER_LOCK_WAIT_TIMEOUT
5258
insert into t1 values ('RR');
5359

@@ -60,7 +66,6 @@ insert into t1 values('S');
6066
commit;
6167
set transaction isolation level SERIALIZABLE;
6268
start transaction;
63-
--error ER_DUP_ENTRY
6469
--error ER_LOCK_WAIT_TIMEOUT
6570
insert into t1 values ('S');
6671
commit;

mysql-test/main/long_unique_update.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#
2+
# MDEV-371 Unique indexes for blobs
3+
#
14
--echo #structure of tests;
25
--echo #1 test of table containing single unique blob column;
36
--echo #2 test of table containing another unique int/ varchar etc column;

mysql-test/main/long_unique_using_hash.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#
2+
# MDEV-371 Unique indexes for blobs
3+
#
14

25
create table t1(a blob , unique(a) using hash);
36
--query_vertical show keys from t1;

sql/share/errmsg-utf8.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7950,8 +7950,7 @@ ER_PERIOD_NOT_FOUND
79507950
eng "Period %`s is not found in table"
79517951
ER_PERIOD_COLUMNS_UPDATED
79527952
eng "Column %`s used in period %`s specified in update SET list"
7953-
79547953
ER_PERIOD_CONSTRAINT_DROP
79557954
eng "Can't DROP CONSTRAINT `%s`. Use DROP PERIOD `%s` for this"
7956-
ER_TOO_LONG_HASH_KEYSEG
7957-
eng "Max key segment length is 65535"
7955+
ER_TOO_LONG_KEYPART 42000 S1009
7956+
eng "Specified key part was too long; max key part length is %u bytes"

sql/sql_show.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,9 +2352,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
23522352
if (key_part->field &&
23532353
(key_part->length !=
23542354
table->field[key_part->fieldnr-1]->key_length() &&
2355-
!(key_info->flags & (HA_FULLTEXT | HA_SPATIAL))) &&
2356-
(key_info->algorithm != HA_KEY_ALG_LONG_HASH ||
2357-
key_info->algorithm == HA_KEY_ALG_LONG_HASH && key_part->length))
2355+
!(key_info->flags & (HA_FULLTEXT | HA_SPATIAL))))
23582356
{
23592357
packet->append_parenthesized((long) key_part->length /
23602358
key_part->field->charset()->mbmaxlen);
@@ -6644,9 +6642,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
66446642
if (!(key_info->flags & HA_FULLTEXT) &&
66456643
(key_part->field &&
66466644
key_part->length !=
6647-
show_table->s->field[key_part->fieldnr-1]->key_length()) &&
6648-
(key_info->algorithm != HA_KEY_ALG_LONG_HASH ||
6649-
key_info->algorithm == HA_KEY_ALG_LONG_HASH && key_part->length))
6645+
show_table->s->field[key_part->fieldnr-1]->key_length()))
66506646
{
66516647
table->field[10]->store((longlong) key_part->length /
66526648
key_part->field->charset()->mbmaxlen, TRUE);

0 commit comments

Comments
 (0)