Skip to content

Commit 1f7446e

Browse files
spetruniavuvova
authored andcommitted
MDEV-37422: SIGSEGV / Assert for vcol substitution in GROUP BY WITH ROLLUP
Variant 2: Do not do virtual column substitution in GROUP BY when WITH ROLLUP is present. Approved by: Yuchen Pei <ycp@mariadb.com>
1 parent cd3df71 commit 1f7446e

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

mysql-test/suite/vcol/r/order_by_group_by_subst.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,19 @@ a b
222222
5 4
223223
5 5
224224
drop table t1, t2;
225+
#
226+
# MDEV-37422: SIGSEGV failed in base_list_iterator::replace, Assertion `n < m_size'
227+
# in Baounds_checked_array, ASAN use-after-poison in JOIN::rollup_make_fields
228+
#
229+
CREATE TABLE t1 (
230+
a INT,
231+
b INT,
232+
a1 INT GENERATED ALWAYS AS (a) VIRTUAL,
233+
INDEX (a1)
234+
) ENGINE=INNODB;
235+
SELECT * FROM t1 GROUP BY a WITH ROLLUP;
236+
a b a1
237+
drop table t1;
238+
#
239+
# End of 12.1 tests
240+
#

mysql-test/suite/vcol/t/order_by_group_by_subst.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,22 @@ insert into t1 (a) select seq from seq_1_to_5;
168168
insert into t2 (b) select seq from seq_1_to_5;
169169
SELECT a, b FROM t1, t2 GROUP BY a, b HAVING a>2 and b>2;
170170
drop table t1, t2;
171+
172+
--echo #
173+
--echo # MDEV-37422: SIGSEGV failed in base_list_iterator::replace, Assertion `n < m_size'
174+
--echo # in Baounds_checked_array, ASAN use-after-poison in JOIN::rollup_make_fields
175+
--echo #
176+
--source include/have_innodb.inc
177+
CREATE TABLE t1 (
178+
a INT,
179+
b INT,
180+
a1 INT GENERATED ALWAYS AS (a) VIRTUAL,
181+
INDEX (a1)
182+
) ENGINE=INNODB;
183+
184+
SELECT * FROM t1 GROUP BY a WITH ROLLUP;
185+
drop table t1;
186+
187+
--echo #
188+
--echo # End of 12.1 tests
189+
--echo #

sql/opt_vcol_substitution.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ bool substitute_indexed_vcols_for_join(JOIN *join)
303303
ctx.subst_count= 0;
304304
if (join->order)
305305
subst_vcols_in_order(&ctx, join->order, join, false);
306-
if (join->group_list)
306+
/*
307+
Do not do substitution for WITH ROLLUP as that breaks some of its data
308+
structures.
309+
*/
310+
if (join->group_list && join->rollup.state == st_rollup::STATE_NONE)
307311
subst_vcols_in_order(&ctx, join->group_list, join, true);
308312
if (ctx.subst_count)
309313
{

0 commit comments

Comments
 (0)