revision-id: 1fd7d716d99ecbf4de97a5346a77b87bef32ca8d (mariadb-10.2.31-918-g1fd7d71) parent(s): b1ac251bf1668d5d2472c2c520d6db71fb835065 author: Igor Babaev committer: Igor Babaev timestamp: 2021-04-28 23:12:19 -0700 message: MDEV-21603 Crashing SHOW TABLES with derived table in WHERE condition --- mysql-test/r/derived.result | 28 ++++++++++++++++++++++++++++ sql/sql_base.cc | 1 - sql/sql_lex.cc | 2 -- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 2106ba5..c374669 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -1204,5 +1204,33 @@ REPLACE INTO v2 ( SELECT * FROM v4 ) UNION ( SELECT f FROM v2 ); drop view v1,v2,v3,v4; drop table t1,t2,t3; # +# MDEV-21603: materialized derived used in SHOW TABLES +# +create table t1 (nm varchar(32), a int); +insert into t1 values ('1',1),('2',2),('3',3); +use mysql; +show tables +where tables_in_mysql in (select * +from (select nm from test.t1 group by nm) dt); +Tables_in_mysql +show fields from test.t1 +where Field in (select * from (select nm from test.t1 group by nm) dt); +Field Type Null Key Default Extra +insert into test.t1 values ('nm',0); +show fields from test.t1 +where Field in (select * from (select nm from test.t1 group by nm) dt); +Field Type Null Key Default Extra +nm varchar(32) YES NULL +show fields from test.t1 +where Field in +(select * from (select column_name from information_schema.columns +where table_name='t1' + group by column_name) dt); +Field Type Null Key Default Extra +nm varchar(32) YES NULL +a int(11) YES NULL +use test; +drop table t1; +# # End of 10.2 tests # diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3403f9e..16689f8 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4939,7 +4939,6 @@ bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags, uint counter; MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint(); DBUG_ENTER("open_normal_and_derived_tables"); - DBUG_ASSERT(!thd->fill_derived_tables()); if (open_tables(thd, &tables, &counter, flags, &prelocking_strategy) || mysql_handle_derived(thd->lex, dt_phases)) goto end; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index c534ba7..149a2bb 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3095,8 +3095,6 @@ bool LEX::only_view_structure() { switch (sql_command) { case SQLCOM_SHOW_CREATE: - case SQLCOM_SHOW_TABLES: - case SQLCOM_SHOW_FIELDS: case SQLCOM_REVOKE_ALL: case SQLCOM_REVOKE: case SQLCOM_GRANT: