diff options
author | Igor Babaev <igor@askmonty.org> | 2011-11-18 04:41:25 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2011-11-18 04:41:25 -0800 |
commit | 3433cf3e4fc9656248db08ae548937629199d158 (patch) | |
tree | 89897a89bf7c80bb00d4e50b87bc25b5324b9bef | |
parent | e31887b59286ddeba161cede29a8a1c8ddba035a (diff) | |
download | mariadb-git-3433cf3e4fc9656248db08ae548937629199d158.tar.gz |
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.
-rw-r--r-- | mysql-test/r/range_vs_index_merge.result | 13 | ||||
-rw-r--r-- | mysql-test/r/range_vs_index_merge_innodb.result | 13 | ||||
-rwxr-xr-x | mysql-test/t/range_vs_index_merge.test | 21 | ||||
-rw-r--r-- | sql/opt_range.cc | 4 |
4 files changed, 47 insertions, 4 deletions
diff --git a/mysql-test/r/range_vs_index_merge.result b/mysql-test/r/range_vs_index_merge.result index f1838bc9aae..cd5f0848ea7 100644 --- a/mysql-test/r/range_vs_index_merge.result +++ b/mysql-test/r/range_vs_index_merge.result @@ -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'; diff --git a/mysql-test/r/range_vs_index_merge_innodb.result b/mysql-test/r/range_vs_index_merge_innodb.result index 82297158c8c..62199e9b4ab 100644 --- a/mysql-test/r/range_vs_index_merge_innodb.result +++ b/mysql-test/r/range_vs_index_merge_innodb.result @@ -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; diff --git a/mysql-test/t/range_vs_index_merge.test b/mysql-test/t/range_vs_index_merge.test index 2ffa2d8eb49..f1bf9d9026f 100755 --- a/mysql-test/t/range_vs_index_merge.test +++ b/mysql-test/t/range_vs_index_merge.test @@ -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'; + diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 121c923845f..229c1e2861b 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -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); |