diff options
-rw-r--r-- | mysql-test/r/olap.result | 9 | ||||
-rw-r--r-- | mysql-test/t/olap.test | 15 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 |
3 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index a392de613f8..91cd15295c3 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -645,3 +645,12 @@ a LENGTH(a) COUNT(*) NULL NULL 2 DROP VIEW v1; DROP TABLE t1; +CREATE TABLE t1 (a int, KEY (a)); +INSERT INTO t1 VALUES (3), (1), (4), (1), (3), (1), (1); +SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t; +a SUM(a) +1 4 +3 6 +4 4 +NULL 14 +DROP TABLE t1; diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 4e5e7b72fc8..e6cbfe3166c 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -327,3 +327,18 @@ SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; + +# +# Bug #26830: derived table with ROLLUP +# + +CREATE TABLE t1 (a int, KEY (a)); +INSERT INTO t1 VALUES (3), (1), (4), (1), (3), (1), (1); + +SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t; + +DROP TABLE t1; + + + + diff --git a/sql/opt_range.cc b/sql/opt_range.cc index dfb3af87c29..0e284850cbe 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7504,7 +7504,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) if ((join->tables != 1) || /* The query must reference one table. */ ((!join->group_list) && /* Neither GROUP BY nor a DISTINCT query. */ (!join->select_distinct)) || - (thd->lex->select_lex.olap == ROLLUP_TYPE)) /* Check (B3) for ROLLUP */ + (join->select_lex->olap == ROLLUP_TYPE)) /* Check (B3) for ROLLUP */ DBUG_RETURN(NULL); if (table->s->keys == 0) /* There are no indexes to use. */ DBUG_RETURN(NULL); |