Commit 188de43d authored by Sergey Petrunya's avatar Sergey Petrunya

- Fixed BUG#623285: Crash in quick_range_seq_next() in maria-5.3-dsmrr-cpk

- Relax overly-strict assert added in previous commit
- Run generic MRR testsuite for Maria engine, too.
parent ac3756a1
drop table if exists t1, t2, t3;
set @mrr_buffer_size_save= @@mrr_buffer_size;
set @save_storage_engine= @@storage_engine;
set storage_engine=Maria;
create table t1(a int);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2(a int);
insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C;
create table t3 (
a char(8) not null, b char(8) not null, filler char(200),
key(a)
);
insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A;
insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'),
'filler-1' from t2 A;
insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'),
'filler-2' from t2 A;
select a,filler from t3 where a >= 'c-9011=w';
a filler
select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w';
a filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1011=w filler-1
c-1012=w filler-1
c-1013=w filler-1
c-1014=w filler-1
c-1015=w filler-1
c-1011=w filler-2
c-1012=w filler-2
c-1013=w filler-2
c-1014=w filler-2
c-1015=w filler-2
select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
(a>='c-1014=w' and a <= 'c-1015=w');
a filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1011=w filler-1
c-1012=w filler-1
c-1013=w filler-1
c-1014=w filler-1
c-1015=w filler-1
c-1011=w filler-2
c-1012=w filler-2
c-1013=w filler-2
c-1014=w filler-2
c-1015=w filler-2
insert into t3 values ('c-1013=z', 'c-1013=z', 'err');
insert into t3 values ('a-1014=w', 'a-1014=w', 'err');
select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
(a>='c-1014=w' and a <= 'c-1015=w');
a filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1011=w filler-1
c-1012=w filler-1
c-1013=w filler-1
c-1014=w filler-1
c-1015=w filler-1
c-1011=w filler-2
c-1012=w filler-2
c-1013=w filler-2
c-1014=w filler-2
c-1015=w filler-2
delete from t3 where b in ('c-1013=z', 'a-1014=w');
select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
a='c-1014=w' or a='c-1015=w';
a filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1011=w filler-1
c-1012=w filler-1
c-1013=w filler-1
c-1014=w filler-1
c-1015=w filler-1
c-1011=w filler-2
c-1012=w filler-2
c-1013=w filler-2
c-1014=w filler-2
c-1015=w filler-2
insert into t3 values ('c-1013=w', 'del-me', 'inserted');
select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
a='c-1014=w' or a='c-1015=w';
a filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1011=w filler-1
c-1012=w filler-1
c-1013=w filler-1
c-1014=w filler-1
c-1015=w filler-1
c-1011=w filler-2
c-1012=w filler-2
c-1013=w filler-2
c-1014=w filler-2
c-1015=w filler-2
c-1013=w inserted
delete from t3 where b='del-me';
alter table t3 add primary key(b);
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or
b IN ('c-1019=w', 'c-1020=w', 'c-1021=w',
'c-1022=w', 'c-1023=w', 'c-1024=w');
b filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1016=w filler
c-1017=w filler
c-1018=w filler
c-1019=w filler
c-1020=w filler
c-1021=w filler
c-1022=w filler
c-1023=w filler
c-1024=w filler
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or
b IN ('c-1021=w', 'c-1022=w', 'c-1023=w');
b filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1016=w filler
c-1017=w filler
c-1018=w filler
c-1019=w filler
c-1020=w filler
c-1021=w filler
c-1022=w filler
c-1023=w filler
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or
b IN ('c-1019=w', 'c-1020=w') or
(b>='c-1021=w' and b<= 'c-1023=w');
b filler
c-1011=w filler
c-1012=w filler
c-1013=w filler
c-1014=w filler
c-1015=w filler
c-1016=w filler
c-1017=w filler
c-1018=w filler
c-1019=w filler
c-1020=w filler
c-1021=w filler
c-1022=w filler
c-1023=w filler
create table t4 (a varchar(10), b int, c char(10), filler char(200),
key idx1 (a, b, c));
insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15;
insert into t4 (a,b,c,filler)
select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15;
insert into t4 (a,b,c,filler)
select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15;
insert into t4 (a,b,c,filler)
select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15;
insert into t4 (a,b,c,filler)
select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500;
explain
select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
or c='no-such-row2');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 range idx1 idx1 29 NULL 16 Using index condition; Using MRR
select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
or c='no-such-row2');
a b c filler
NULL NULL NULL NULL-15
NULL NULL NULL NULL-14
NULL NULL NULL NULL-13
NULL NULL NULL NULL-12
NULL NULL NULL NULL-11
NULL NULL NULL NULL-10
NULL NULL NULL NULL-9
NULL NULL NULL NULL-8
NULL NULL NULL NULL-7
NULL NULL NULL NULL-6
NULL NULL NULL NULL-5
NULL NULL NULL NULL-4
NULL NULL NULL NULL-3
NULL NULL NULL NULL-2
NULL NULL NULL NULL-1
explain
select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 range idx1 idx1 29 NULL 32 Using index condition; Using MRR
select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
a b c filler
b-1 NULL c-1 NULL-15
b-1 NULL c-1 NULL-14
b-1 NULL c-1 NULL-13
b-1 NULL c-1 NULL-12
b-1 NULL c-1 NULL-11
b-1 NULL c-1 NULL-10
b-1 NULL c-1 NULL-9
b-1 NULL c-1 NULL-8
b-1 NULL c-1 NULL-7
b-1 NULL c-1 NULL-6
b-1 NULL c-1 NULL-5
b-1 NULL c-1 NULL-4
b-1 NULL c-1 NULL-3
b-1 NULL c-1 NULL-2
b-1 NULL c-1 NULL-1
bb-1 NULL cc-2 NULL-15
bb-1 NULL cc-2 NULL-14
bb-1 NULL cc-2 NULL-13
bb-1 NULL cc-2 NULL-12
bb-1 NULL cc-2 NULL-11
bb-1 NULL cc-2 NULL-10
bb-1 NULL cc-2 NULL-9
bb-1 NULL cc-2 NULL-8
bb-1 NULL cc-2 NULL-7
bb-1 NULL cc-2 NULL-6
bb-1 NULL cc-2 NULL-5
bb-1 NULL cc-2 NULL-4
bb-1 NULL cc-2 NULL-3
bb-1 NULL cc-2 NULL-2
bb-1 NULL cc-2 NULL-1
select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
a b c filler
b-1 NULL c-1 NULL-15
b-1 NULL c-1 NULL-14
b-1 NULL c-1 NULL-13
b-1 NULL c-1 NULL-12
b-1 NULL c-1 NULL-11
b-1 NULL c-1 NULL-10
b-1 NULL c-1 NULL-9
b-1 NULL c-1 NULL-8
b-1 NULL c-1 NULL-7
b-1 NULL c-1 NULL-6
b-1 NULL c-1 NULL-5
b-1 NULL c-1 NULL-4
b-1 NULL c-1 NULL-3
b-1 NULL c-1 NULL-2
b-1 NULL c-1 NULL-1
bb-1 NULL cc-2 NULL-15
bb-1 NULL cc-2 NULL-14
bb-1 NULL cc-2 NULL-13
bb-1 NULL cc-2 NULL-12
bb-1 NULL cc-2 NULL-11
bb-1 NULL cc-2 NULL-10
bb-1 NULL cc-2 NULL-9
bb-1 NULL cc-2 NULL-8
bb-1 NULL cc-2 NULL-7
bb-1 NULL cc-2 NULL-6
bb-1 NULL cc-2 NULL-5
bb-1 NULL cc-2 NULL-4
bb-1 NULL cc-2 NULL-3
bb-1 NULL cc-2 NULL-2
bb-1 NULL cc-2 NULL-1
drop table t1, t2, t3, t4;
create table t1 (a int, b int not null,unique key (a,b),index(b));
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
create table t2 like t1;
insert into t2 select * from t1;
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
select * from t1 where a is null;
a b c
NULL 7 0
NULL 9 0
NULL 9 0
select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
a b c
NULL 9 0
NULL 9 0
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
a b c
NULL 7 0
NULL 9 0
NULL 9 0
drop table t1, t2;
set storage_engine= @save_storage_engine;
set @@mrr_buffer_size= @mrr_buffer_size_save;
#
# Crash in quick_range_seq_next() in maria-5.3-dsmrr-cpk with join_cache_level = {8,1}
#
set @save_join_cache_level= @@join_cache_level;
SET SESSION join_cache_level = 8;
CREATE TABLE `t1` (
`col_int_key` int(11) DEFAULT NULL,
`col_datetime_key` datetime DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t1` VALUES (6,'2005-10-07 00:00:00','e','e');
INSERT INTO `t1` VALUES (51,'2000-07-15 05:00:34','f','f');
CREATE TABLE `t2` (
`col_int_key` int(11) DEFAULT NULL,
`col_datetime_key` datetime DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t2` VALUES (2,'2004-10-11 18:13:16','w','w');
INSERT INTO `t2` VALUES (2,'1900-01-01 00:00:00','d','d');
SELECT table2 .`col_datetime_key`
FROM t2 JOIN ( t1 table2 JOIN t2 table3 ON table3 .`col_varchar_key` < table2 .`col_varchar_key` ) ON table3 .`col_varchar_nokey` ;
col_datetime_key
drop table t1, t2;
set join_cache_level=@save_join_cache_level;
-- source include/have_maria.inc
#
# MRR/Maria tests.
#
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings
set @mrr_buffer_size_save= @@mrr_buffer_size;
set @save_storage_engine= @@storage_engine;
set storage_engine=Maria;
-- source include/mrr_tests.inc
set storage_engine= @save_storage_engine;
set @@mrr_buffer_size= @mrr_buffer_size_save;
--echo #
--echo # Crash in quick_range_seq_next() in maria-5.3-dsmrr-cpk with join_cache_level = {8,1}
--echo #
set @save_join_cache_level= @@join_cache_level;
SET SESSION join_cache_level = 8;
CREATE TABLE `t1` (
`col_int_key` int(11) DEFAULT NULL,
`col_datetime_key` datetime DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t1` VALUES (6,'2005-10-07 00:00:00','e','e');
INSERT INTO `t1` VALUES (51,'2000-07-15 05:00:34','f','f');
CREATE TABLE `t2` (
`col_int_key` int(11) DEFAULT NULL,
`col_datetime_key` datetime DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t2` VALUES (2,'2004-10-11 18:13:16','w','w');
INSERT INTO `t2` VALUES (2,'1900-01-01 00:00:00','d','d');
SELECT table2 .`col_datetime_key`
FROM t2 JOIN ( t1 table2 JOIN t2 table3 ON table3 .`col_varchar_key` < table2 .`col_varchar_key` ) ON table3 .`col_varchar_nokey` ;
drop table t1, t2;
set join_cache_level=@save_join_cache_level;
......@@ -591,6 +591,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
h2= NULL;
int res= (h->inited == handler::INDEX && h->ha_index_end());
h2= save_h2;
use_default_impl= FALSE;
if (res)
goto error;
}
......
......@@ -153,7 +153,7 @@ public:
- it is adjacent to buffer space we're using
- it is on the end towards which we grow.
*/
DBUG_ASSERT(unused_end > unused_start);
DBUG_ASSERT(unused_end >= unused_start);
TRASH(unused_start, unused_end - unused_start);
if (direction == 1 && end == unused_start)
{
......
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