Commit 314c3774 authored by unknown's avatar unknown

Fixed bug lp:888456

Analysis:
The class member QUICK_GROUP_MIN_MAX_SELECT::seen_first_key
was not reset between subquery re-executions. Thus each
subsequent execution continued from the group that was
reached by the previous subquery execution. As a result
loose scan reached end of file much earlier, and returned
empty result where it shouldn't.

Solution:
Reset seen_first_key before each re-execution of the
loose scan.
parent 1f3e5403
......@@ -2780,4 +2780,21 @@ ORDER BY min_a;
min_a
NULL
DROP TABLE t1;
#
# LP BUG#888456 Wrong result with DISTINCT , ANY , subquery_cache=off , NOT NULL
#
CREATE TABLE t1 ( a int NOT NULL) ;
INSERT INTO t1 VALUES (28),(29),(9);
CREATE TABLE t2 ( a int, KEY (a)) ;
INSERT INTO t2 VALUES (1),(1),(1),(4),(4),(5),(5),(8),(8),(9);
explain select (select t2.a from t2 where t2.a >= t1.a group by t2.a) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 DEPENDENT SUBQUERY t2 range a a 5 NULL 6 Using where; Using index for group-by
select (select t2.a from t2 where t2.a >= t1.a group by t2.a) from t1;
(select t2.a from t2 where t2.a >= t1.a group by t2.a)
NULL
NULL
9
drop table t1, t2;
End of 5.1 tests
......@@ -1099,5 +1099,19 @@ ORDER BY min_a;
DROP TABLE t1;
--echo #
--echo # LP BUG#888456 Wrong result with DISTINCT , ANY , subquery_cache=off , NOT NULL
--echo #
CREATE TABLE t1 ( a int NOT NULL) ;
INSERT INTO t1 VALUES (28),(29),(9);
CREATE TABLE t2 ( a int, KEY (a)) ;
INSERT INTO t2 VALUES (1),(1),(1),(4),(4),(5),(5),(8),(8),(9);
explain select (select t2.a from t2 where t2.a >= t1.a group by t2.a) from t1;
select (select t2.a from t2 where t2.a >= t1.a group by t2.a) from t1;
drop table t1, t2;
--echo End of 5.1 tests
......@@ -10627,6 +10627,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void)
int result;
DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::reset");
seen_first_key= FALSE;
if (!head->key_read)
{
doing_key_read= 1;
......
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