Commit 833aa97c authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-11818.

When a query containing a WITH clause is printed by EXPLAIN
EXTENDED command there should not be any data expansion in
the query specifications of the WITH elements of this WITH
clause.
parent a1315a65
......@@ -927,3 +927,15 @@ Sergei Golubchik Development DE
Claudio Nanni Support ES
Sergei Petrunia Development RU
drop table employees;
#
# MDEV-11818: EXPLAIN EXTENDED for a query with optimized away CTE table
#
CREATE TABLE t1 (i INT, c VARCHAR(3));
INSERT INTO t1 VALUES (1,'foo');
EXPLAIN EXTENDED
WITH cte AS ( SELECT * FROM t1 ) SELECT i FROM cte;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
Note 1003 with cte as (select `test`.`t1`.`i` AS `i`,`test`.`t1`.`c` AS `c` from `test`.`t1`)select 1 AS `i` from dual
DROP TABLE t1;
......@@ -609,3 +609,15 @@ where
and T2.name <> T1.name);
drop table employees;
--echo #
--echo # MDEV-11818: EXPLAIN EXTENDED for a query with optimized away CTE table
--echo #
CREATE TABLE t1 (i INT, c VARCHAR(3));
INSERT INTO t1 VALUES (1,'foo');
EXPLAIN EXTENDED
WITH cte AS ( SELECT * FROM t1 ) SELECT i FROM cte;
DROP TABLE t1;
......@@ -1246,6 +1246,12 @@ bool st_select_lex::check_subqueries_with_recursive_references()
void With_clause::print(String *str, enum_query_type query_type)
{
/*
Any with clause contains just definitions of CTE tables.
No data expansion is applied to these definitions.
*/
query_type= (enum_query_type) (query_type | QT_NO_DATA_EXPANSION);
str->append(STRING_WITH_LEN("with "));
if (with_recursive)
str->append(STRING_WITH_LEN("recursive "));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment