Skip to content

Commit fe73560

Browse files
Dag Wanvikdahlerlend
authored andcommitted
Bug#36008133 Assertion `false' failed in
replace_embedded_rollup_references_with_tmp_fields Regression cause by Bug#35390341 Assertion `m_count > 0 && m_count > m_frame_null_count' failed. That issue involved setting a user variable inside the argument of a window function, which in turn was evaluated using the window frame buffer (Window::m_needs_frame_buffering) row optimizable (Window::m_row_optimizable). The first solution had an unfortunate side-effect as seen by the present bug: here, the window function doesn't have an argument containing the setting of a user variable, it is the other way around: the setting of a user variable requires the value of a window function. Solution: refine the criterion for when we evaluate the setting of user variable before windowing to only include the case of a wf containing a setting (Bug#35390341). Change-Id: Idc6824adf4bd123775a14b92bfe54824acf105c8
1 parent e6f067c commit fe73560

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

mysql-test/r/window_functions_bugs.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,15 @@ SELECT @a;
18361836
0
18371837
DROP TABLE t1;
18381838
#
1839+
# Bug#36008133 Assertion `false' failed in replace_embedded_rollup_references_with_tmp_fields
1840+
#
1841+
CREATE TABLE t1(f1 INTEGER);
1842+
SELECT @A := (CUME_DIST() OVER () + f1 + RANK() OVER ()) FROM t1 GROUP BY f1 WITH ROLLUP;
1843+
@A := (CUME_DIST() OVER () + f1 + RANK() OVER ())
1844+
Warnings:
1845+
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
1846+
DROP TABLE t1;
1847+
#
18391848
# Bug#35537311 nth_value window function assertion error
18401849
#
18411850
CREATE TABLE t0(c1 TINYINT UNSIGNED, c5 BIT);

mysql-test/t/window_functions_bugs.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,13 @@ SELECT @a;
12701270

12711271
DROP TABLE t1;
12721272

1273+
--echo #
1274+
--echo # Bug#36008133 Assertion `false' failed in replace_embedded_rollup_references_with_tmp_fields
1275+
--echo #
1276+
CREATE TABLE t1(f1 INTEGER);
1277+
SELECT @A := (CUME_DIST() OVER () + f1 + RANK() OVER ()) FROM t1 GROUP BY f1 WITH ROLLUP;
1278+
DROP TABLE t1;
1279+
12731280
--echo #
12741281
--echo # Bug#35537311 nth_value window function assertion error
12751282
--echo #

sql/sql_executor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4309,7 +4309,7 @@ bool change_to_use_tmp_fields(mem_root_deque<Item *> *fields, THD *thd,
43094309
new_item = item->get_tmp_table_item(thd);
43104310
else if (item->type() == Item::FUNC_ITEM &&
43114311
((Item_func *)item)->functype() == Item_func::SUSERVAR_FUNC &&
4312-
!windowing) {
4312+
(!windowing || item->has_wf())) {
43134313
field = item->get_tmp_table_field();
43144314
if (field != nullptr) {
43154315
/*

0 commit comments

Comments
 (0)