Commit 55934580 authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-12015.

Corrected an assertion in JOIN::create_postjoin_aggr_table():
JOIN::join_tab[0] can be the first aggregation table if
the query uses window functions.
parent 1b4f694a
......@@ -2842,3 +2842,14 @@ max(i) min(i) f
16 14 2
20 17 3
drop table t1;
#
# MDEV-12015: window function over select with WHERE
# that is always FALSE
#
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (3), (1), (2);
SELECT i, ROW_NUMBER() OVER () FROM t1 WHERE 1 = 2;
i ROW_NUMBER() OVER ()
SELECT i, COUNT(*) OVER () FROM t1 WHERE 1 = 2;
i COUNT(*) OVER ()
DROP TABLE t1;
......@@ -1636,3 +1636,18 @@ select max(i), min(i), min(max(i)-min(i)) over (partition by count(i)) f
group by b;
drop table t1;
--echo #
--echo # MDEV-12015: window function over select with WHERE
--echo # that is always FALSE
--echo #
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (3), (1), (2);
SELECT i, ROW_NUMBER() OVER () FROM t1 WHERE 1 = 2;
SELECT i, COUNT(*) OVER () FROM t1 WHERE 1 = 2;
DROP TABLE t1;
......@@ -2779,8 +2779,8 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
tmp_table_param.using_outer_summary_function=
tab->tmp_table_param->using_outer_summary_function;
tab->join= this;
DBUG_ASSERT(tab > tab->join->join_tab || !tables_list);
if (tables_list)
DBUG_ASSERT(tab > join_tab || select_lex->have_window_funcs());
if (tab > join_tab)
(tab - 1)->next_select= sub_select_postjoin_aggr;
tab->aggr= new (thd->mem_root) AGGR_OP(tab);
if (!tab->aggr)
......
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