Commit 3433cf3e authored by Igor Babaev's avatar Igor Babaev

Fixed LP bug #800184.

The function key_and() erroneously called SEL_ARG::increment_use_count()
when SEL_ARG::incr_refs() should had been called. This could lead to
wrong values of use_count for some SEL_ARG trees.
parent e31887b5
......@@ -1414,4 +1414,17 @@ a b c d
0 75 5 3
SET SESSION optimizer_switch=DEFAULT;
DROP TABLE t1;
CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int, c int, INDEX idx(c,b));
INSERT INTO t1 VALUES (19,1,NULL), (20,5,7);
EXPLAIN
SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,idx PRIMARY 4 NULL 1 Using where
SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
a b c
DROP TABLE t1;
set session optimizer_switch='index_merge_sort_intersection=default';
......@@ -1415,5 +1415,18 @@ a b c d
0 75 5 3
SET SESSION optimizer_switch=DEFAULT;
DROP TABLE t1;
CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int, c int, INDEX idx(c,b));
INSERT INTO t1 VALUES (19,1,NULL), (20,5,7);
EXPLAIN
SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,idx PRIMARY 4 NULL 1 Using where
SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
a b c
DROP TABLE t1;
set session optimizer_switch='index_merge_sort_intersection=default';
SET SESSION STORAGE_ENGINE=DEFAULT;
......@@ -1030,9 +1030,8 @@ SELECT * FROM t1,t2,t3
DROP TABLE t1,t2,t3;
#
# LP bug #823301: index merge union with prossible index scan
# LP bug #823301: index merge sort union with possible index scan
#
#
CREATE TABLE t1 (
a int, b int, c int, d int,
......@@ -1058,5 +1057,23 @@ SET SESSION optimizer_switch=DEFAULT;
DROP TABLE t1;
#
# LP bug #800184: possible index merge sort union
#
CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int, c int, INDEX idx(c,b));
INSERT INTO t1 VALUES (19,1,NULL), (20,5,7);
EXPLAIN
SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
DROP TABLE t1;
#the following command must be the last one in the file
set session optimizer_switch='index_merge_sort_intersection=default';
......@@ -8565,8 +8565,8 @@ key_and(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag)
continue;
SEL_ARG *next=key_and(param, e1->next_key_part, e2->next_key_part,
clone_flag);
e1->increment_use_count(1);
e2->increment_use_count(1);
e1->incr_refs();
e2->incr_refs();
if (!next || next->type != SEL_ARG::IMPOSSIBLE)
{
SEL_ARG *new_arg= e1->clone_and(e2);
......
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