Fix for bug#18224 VIEW on information_schema crashes the server

  additional check for subselect
parent a184a00e
...@@ -281,6 +281,13 @@ sub1 sub1 ...@@ -281,6 +281,13 @@ sub1 sub1
select count(*) from information_schema.ROUTINES; select count(*) from information_schema.ROUTINES;
count(*) count(*)
2 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; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION ROUTINE_NAME ROUTINE_DEFINITION
show create function sub1; show create function sub1;
......
...@@ -142,6 +142,11 @@ select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a, ...@@ -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; mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1;
select count(*) from information_schema.ROUTINES; 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,,); connect (user1,localhost,mysqltest_1,,);
connection user1; connection user1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
......
...@@ -3864,7 +3864,8 @@ bool get_schema_tables_result(JOIN *join) ...@@ -3864,7 +3864,8 @@ bool get_schema_tables_result(JOIN *join)
TABLE_LIST *table_list= tab->table->pos_in_table_list; TABLE_LIST *table_list= tab->table->pos_in_table_list;
if (table_list->schema_table && thd->fill_derived_tables()) 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 schema table is already processed and
the statement is not a subselect. the statement is not a subselect.
......
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