Commit 67180d65 authored by Igor Babaev's avatar Igor Babaev

Fixed LP bug #684117.

A crash may happenin the cases when the range optimizer tried to OR
two index merge such that the second one contained less range trees
than the first one.
The bug was introduced by the patch of MWL#24: 
"index_merge: fair choice between index_merge union and range access".

parent 81dab936
......@@ -1386,3 +1386,15 @@ WHERE c = 'i' OR b IN ( 'Arkansas' , 'd' , 'pdib' , 'can' ) OR
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,idx1,idx2,idx3 idx3,idx2,PRIMARY,idx1 67,13,4,3 NULL 8 Using sort_union(idx3,idx2,PRIMARY,idx1); Using where
DROP TABLE t1;
CREATE TABLE t1 (
f1 int, f2 int, f3 int, f4 int, f5 int,
PRIMARY KEY (f4), KEY (f1), KEY (f2), KEY (f3)
) ;
INSERT INTO t1 VALUES (0,0,NULL,9,5), (0,0,1,9425,NULL);
SELECT f5 FROM t1
WHERE f2 != 1 OR f1 IS NULL OR f4 = 4 OR
f2 AND (f4 BETWEEN 6 AND 255 OR f3 IS NULL);
f5
5
NULL
DROP TABLE t1;
......@@ -1387,4 +1387,16 @@ WHERE c = 'i' OR b IN ( 'Arkansas' , 'd' , 'pdib' , 'can' ) OR
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,idx1,idx2,idx3 idx3,idx2,idx1,PRIMARY 67,13,3,4 NULL 9 Using sort_union(idx3,idx2,idx1,PRIMARY); Using where
DROP TABLE t1;
CREATE TABLE t1 (
f1 int, f2 int, f3 int, f4 int, f5 int,
PRIMARY KEY (f4), KEY (f1), KEY (f2), KEY (f3)
) ;
INSERT INTO t1 VALUES (0,0,NULL,9,5), (0,0,1,9425,NULL);
SELECT f5 FROM t1
WHERE f2 != 1 OR f1 IS NULL OR f4 = 4 OR
f2 AND (f4 BETWEEN 6 AND 255 OR f3 IS NULL);
f5
5
NULL
DROP TABLE t1;
SET SESSION STORAGE_ENGINE=DEFAULT;
......@@ -918,3 +918,20 @@ SELECT COUNT(*) FROM t1
(pk BETWEEN 120 AND 79 + 255 OR a IN ( 4 , 179 , 1 ) ) AND a > 8 ;
DROP TABLE t1;
#
# Bug #684117: ORing of two index merge that caused a crash
#
CREATE TABLE t1 (
f1 int, f2 int, f3 int, f4 int, f5 int,
PRIMARY KEY (f4), KEY (f1), KEY (f2), KEY (f3)
) ;
INSERT INTO t1 VALUES (0,0,NULL,9,5), (0,0,1,9425,NULL);
SELECT f5 FROM t1
WHERE f2 != 1 OR f1 IS NULL OR f4 = 4 OR
f2 AND (f4 BETWEEN 6 AND 255 OR f3 IS NULL);
DROP TABLE t1;
......@@ -1187,7 +1187,8 @@ int SEL_IMERGE::or_sel_imerge_with_checks(RANGE_OPT_PARAM *param,
{
*is_last_check_pass= TRUE;
SEL_TREE** tree= imerge->trees;
for (uint i= 0; i < n_trees; i++, tree++)
SEL_TREE** tree_end= imerge->trees_next;
for ( ; tree < tree_end; tree++)
{
uint rc;
bool is_last= TRUE;
......
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