diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index 5190e4ff4fd1c..00506d1b0d636 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -5622,3 +5622,13 @@ t # # End of 11.6 tests # +# +# Start of 12.2 tests +# +# +# MDEV-38099: Assertion failed in st_select_lex::optimize_unflattened_subqueries +# +SELECT (WITH cte AS (SELECT st_astext(ST_GeomFromText('POLYGON((1 1,2 2,1 1))'))) SELECT * FROM cte); +(WITH cte AS (SELECT st_astext(ST_GeomFromText('POLYGON((1 1,2 2,1 1))'))) SELECT * FROM cte) +POLYGON((1 1,2 2,1 1)) +# End of 12.2 tests diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index fd604a363a68b..d3ae097a237b8 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -3623,3 +3623,14 @@ SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (15 15 --echo # --echo # End of 11.6 tests --echo # + +--echo # +--echo # Start of 12.2 tests +--echo # + +--echo # +--echo # MDEV-38099: Assertion failed in st_select_lex::optimize_unflattened_subqueries +--echo # +SELECT (WITH cte AS (SELECT st_astext(ST_GeomFromText('POLYGON((1 1,2 2,1 1))'))) SELECT * FROM cte); + +--echo # End of 12.2 tests diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 73d97861325ef..7779411ff8a98 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -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()) {