diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 1c845c73e4b..2324fc7440d 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -281,6 +281,13 @@ sub1 sub1 select count(*) from information_schema.ROUTINES; count(*) 2 +create view v1 as select routine_schema, routine_name from information_schema.routines +order by routine_schema, routine_name; +select * from v1; +routine_schema routine_name +test sel2 +test sub1 +drop view v1; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; ROUTINE_NAME ROUTINE_DEFINITION show create function sub1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 5e0d57e10dd..35f6a511d98 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -142,6 +142,11 @@ select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a, mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1; select count(*) from information_schema.ROUTINES; +create view v1 as select routine_schema, routine_name from information_schema.routines +order by routine_schema, routine_name; +select * from v1; +drop view v1; + connect (user1,localhost,mysqltest_1,,); connection user1; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4b5b4d0dc0e..6350fceae74 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3864,7 +3864,8 @@ bool get_schema_tables_result(JOIN *join) TABLE_LIST *table_list= tab->table->pos_in_table_list; if (table_list->schema_table && thd->fill_derived_tables()) { - bool is_subselect= (&lex->unit != lex->current_select->master_unit()); + bool is_subselect= (&lex->unit != lex->current_select->master_unit() && + lex->current_select->master_unit()->item); /* The schema table is already processed and the statement is not a subselect.