diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2017-07-21 18:02:53 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2017-07-21 20:20:14 +0300 |
commit | 4bdf9318b6bab1bf8d3718c50f87871a4ae5ec9b (patch) | |
tree | 532546459dc47c60921c382e572279adeaea0b3a | |
parent | 2a1035b004dfabcf3a7113be632b0030721a44d6 (diff) | |
download | mariadb-git-bb-10.2-mdev13355.tar.gz |
MDEV-13355: Assertion `using_unique_constraint || group_buff <= param->group_buff...bb-10.2-mdev13355
The code in OIN::optimize_inner() has this call
calc_group_buffer(this, group_list)
the call is however bypassed when the optimizer figures out that the JOIN
has "Impossible WHERE".
If we attempt to calculate the value of a window function afterwards,
we will get a crash when trying to create a temporary table.
So, put a call to calc_group_buffer() here as well. It's a bit surprising
that all these steps are done for a query that will produce zero rows
but we are just following the approach taken by the fix for mdev-11999
here.
-rw-r--r-- | mysql-test/r/win.result | 16 | ||||
-rw-r--r-- | mysql-test/t/win.test | 17 | ||||
-rw-r--r-- | sql/sql_select.cc | 1 |
3 files changed, 33 insertions, 1 deletions
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index c6707bd51bc..9b4ebe60997 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3173,3 +3173,19 @@ Nth_value(i,1) OVER() 1 1 DROP TABLE t1; +# +# MDEV-13355: Assertion `using_unique_constraint || group_buff <= param->group_buff + +# param->group_length' failed in create_tmp_table +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +SELECT * FROM ( +SELECT +ROW_NUMBER() OVER(), i +FROM t1 +WHERE 1=0 +GROUP BY i +) AS sq +; +ROW_NUMBER() OVER() i +DROP TABLE t1; diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index 77ca755378d..9de4fd66fc5 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -1953,4 +1953,19 @@ UNION ALL ( SELECT Nth_value(i,2) OVER() FROM t1 LIMIT 0 ) ; DROP TABLE t1; - +--echo # +--echo # MDEV-13355: Assertion `using_unique_constraint || group_buff <= param->group_buff + +--echo # param->group_length' failed in create_tmp_table +--echo # +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); + +SELECT * FROM ( + SELECT + ROW_NUMBER() OVER(), i + FROM t1 + WHERE 1=0 + GROUP BY i +) AS sq +; +DROP TABLE t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 90f5e11dd16..f27f1024e73 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2176,6 +2176,7 @@ setup_subq_exit: choose_tableless_subquery_plan(); if (select_lex->have_window_funcs()) { + calc_group_buffer(this, group_list); if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)))) DBUG_RETURN(1); need_tmp= 1; |