Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mysql-test/main/cte_nonrecursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -2683,3 +2683,11 @@ cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a)
select * from cte;
ERROR 42S02: Table 'test.t' doesn't exist
# End of 10.4 tests
#
# Start of 12.2 tests
#
#
# MDEV-38099: Assertion failed in st_select_lex::optimize_unflattened_subqueries
#
SELECT (WITH cte AS (SELECT RAND()) SELECT * FROM cte);
# End of 12.2 tests
13 changes: 13 additions & 0 deletions mysql-test/main/cte_nonrecursive.test
Original file line number Diff line number Diff line change
Expand Up @@ -2026,3 +2026,16 @@ drop table t,s;
eval $q1;

--echo # End of 10.4 tests

--echo #
--echo # Start of 12.2 tests
--echo #

--echo #
--echo # MDEV-38099: Assertion failed in st_select_lex::optimize_unflattened_subqueries
--echo #
--disable_result_log
SELECT (WITH cte AS (SELECT RAND()) SELECT * FROM cte);
--enable_result_log

--echo # End of 12.2 tests
2 changes: 2 additions & 0 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11130,6 +11130,8 @@ void st_select_lex::register_unit(SELECT_LEX_UNIT *unit,
slave= unit;
unit->master= this;
uncacheable|= unit->uncacheable;
if (master && (unit->uncacheable & UNCACHEABLE_RAND))
master->uncacheable|= UNCACHEABLE_RAND;

for(SELECT_LEX *sel= unit->first_select();sel; sel= sel->next_select())
{
Expand Down
Loading