Commit ee92b709 authored by Nikita Malyavin's avatar Nikita Malyavin

MDEV-30415 PERIOD false positive overlap wtih utf8mb4_unicode_nopad_ci

A wrong UNIQUE violation is caused here by camparing strings
'def' and 'def ' (with space), under utf8mb4_unicode_nopad_ci collation,
which means "don't count in paddings when comparing".

Field::cmp_prefix uses a comparison through collation, so cmp_binary should
be used instead.
parent 2ba6f3d4
......@@ -351,3 +351,18 @@ primary key(id, p without overlaps)
) engine=heap partition by hash(id);
update t set id = 1;
drop table t, t1;
# MDEV-30415 PERIOD false positive overlap wtih utf8mb4_unicode_nopad_ci
create table `t1` (
datetime_column_name_1 datetime(6) not null,
datetime_column_name_2 datetime(6) not null,
text_column_name text collate utf8mb4_unicode_nopad_ci not null,
period for p (datetime_column_name_1, datetime_column_name_2),
unique key index_name (text_column_name(191), p without overlaps)
) engine=innodb default charset=utf8mb4 collate=utf8mb4_unicode_nopad_ci;
insert into t1 values ('2000-01-01', '2001-01-01', 'def '),
('2000-01-01', '2001-01-01', 'def');
truncate t1;
insert into t1 values ('2000-01-01', '2001-01-01', 'def'),
('2000-01-01', '2001-01-01', 'def '),
('2000-01-01', '2001-01-01', 'def ');
drop table t1;
......@@ -344,3 +344,23 @@ create or replace table t (id int, s date, e date, period for p(s,e),
update t set id = 1;
drop table t, t1;
--echo # MDEV-30415 PERIOD false positive overlap wtih utf8mb4_unicode_nopad_ci
create table `t1` (
datetime_column_name_1 datetime(6) not null,
datetime_column_name_2 datetime(6) not null,
text_column_name text collate utf8mb4_unicode_nopad_ci not null,
period for p (datetime_column_name_1, datetime_column_name_2),
unique key index_name (text_column_name(191), p without overlaps)
) engine=innodb default charset=utf8mb4 collate=utf8mb4_unicode_nopad_ci;
insert into t1 values ('2000-01-01', '2001-01-01', 'def '),
('2000-01-01', '2001-01-01', 'def');
truncate t1;
insert into t1 values ('2000-01-01', '2001-01-01', 'def'),
('2000-01-01', '2001-01-01', 'def '),
('2000-01-01', '2001-01-01', 'def ');
drop table t1;
......@@ -9025,7 +9025,7 @@ bool TABLE::check_period_overlaps(const KEY &key,
if (f->is_null_in_record(lhs) || f->is_null_in_record(rhs))
return false;
uint kp_len= key.key_part[part_nr].length;
if (f->cmp_prefix(f->ptr_in_record(lhs), f->ptr_in_record(rhs),
if (f->cmp_binary(f->ptr_in_record(lhs), f->ptr_in_record(rhs),
kp_len) != 0)
return false;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment