Commit 35d327fd authored by Nikita Malyavin's avatar Nikita Malyavin

MDEV-22599 WITHOUT OVERLAPS does not work with prefix indexes

cmp_max is used instead of cmp to compare key_parts
parent 0c595bde
......@@ -185,6 +185,7 @@ id u s e
5 6 2003-05-01 2003-07-01
7 8 2003-05-01 2003-07-01
9 10 2003-05-01 2003-07-01
drop sequence seq;
create or replace table t(id int, s date, e date,
period for p(s,e));
insert into t values (1, '2003-01-01', '2003-03-01'),
......@@ -281,4 +282,18 @@ Warnings:
Warning 1062 Duplicate entry '1-2020-03-05-2020-03-01' for key 'x'
load data infile 'tmp_t.txt' replace into table t;
ERROR 42000: This version of MariaDB doesn't yet support 'WITHOUT OVERLAPS'
create or replace database test;
# MDEV-22599 WITHOUT OVERLAPS does not work with prefix indexes
create or replace table t1 (a varchar(6), s timestamp, e timestamp,
period for p(s,e),
unique(a(3), p without overlaps));
insert into t1 values ('foo', '2012-01-01', '2015-12-31');
insert into t1 values ('foobar', '2013-01-01', '2014-01-01');
ERROR 23000: Duplicate entry 'foo-2014-01-01 00:00:00-2013-01-01 00:00:00' for key 'a'
insert into t1 values ('bar', '2012-01-01', '2015-12-31'),
('baz', '2013-01-01', '2014-01-01');
select * from t1;
a s e
foo 2012-01-01 00:00:00 2015-12-31 00:00:00
bar 2012-01-01 00:00:00 2015-12-31 00:00:00
baz 2013-01-01 00:00:00 2014-01-01 00:00:00
drop table t, t1;
......@@ -163,6 +163,7 @@ update t set id= nextval(seq), u= nextval(seq), s='2003-05-01', e='2003-07-01'
--sorted_result
select * from t;
drop sequence seq;
create or replace table t(id int, s date, e date,
period for p(s,e));
......@@ -270,4 +271,18 @@ load data infile 'tmp_t.txt' replace into table t;
remove_file $MYSQLD_DATADIR/test/tmp_t.txt;
create or replace database test;
--echo # MDEV-22599 WITHOUT OVERLAPS does not work with prefix indexes
create or replace table t1 (a varchar(6), s timestamp, e timestamp,
period for p(s,e),
unique(a(3), p without overlaps));
insert into t1 values ('foo', '2012-01-01', '2015-12-31');
--error ER_DUP_ENTRY
insert into t1 values ('foobar', '2013-01-01', '2014-01-01');
insert into t1 values ('bar', '2012-01-01', '2015-12-31'),
('baz', '2013-01-01', '2014-01-01');
select * from t1;
drop table t, t1;
......@@ -8759,7 +8759,8 @@ bool TABLE::check_period_overlaps(const KEY &key,
if (key.key_part[part_nr].null_bit)
if (f->is_null_in_record(lhs) || f->is_null_in_record(rhs))
return false;
if (f->cmp(f->ptr_in_record(lhs), f->ptr_in_record(rhs)) != 0)
uint kp_len= key.key_part[part_nr].length;
if (f->cmp_max(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