mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-13355: Assertion `using_unique_constraint || group_buff <= param->group_buff...
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user