From 0e7f1ae3a0bad32c64b16e1603e74ce09526b0b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Dec 2004 17:44:36 +0300 Subject: [PATCH] Fix for bug#7211: information_schema: crash if bad view(after review) --- mysql-test/r/information_schema.result | 12 ++++++++++++ mysql-test/t/information_schema.test | 5 +++++ sql/sql_show.cc | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 660c0e7b1bb..d421ac1d184 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -599,6 +599,18 @@ create view t3 (c) as select sub1(1); create table t4(f1 int, KEY f1_key (f1)); drop table t1; drop function sub1; +select table_name from information_schema.views +where table_schema='test'; +table_name +Warnings: +Warning 1356 View 'test.t2' references invalid table(s) or column(s) or function(s) +Warning 1356 View 'test.t3' references invalid table(s) or column(s) or function(s) +select table_name from information_schema.views +where table_schema='test'; +table_name +Warnings: +Warning 1356 View 'test.t2' references invalid table(s) or column(s) or function(s) +Warning 1356 View 'test.t3' references invalid table(s) or column(s) or function(s) select column_name from information_schema.columns where table_schema='test'; column_name diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index b5570851c0f..0fe7636e500 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -295,6 +295,7 @@ show tables like "T%"; # # Bug#7212: information_schema: "Can't find file" errors if storage engine gone +# Bug#7211: information_schema: crash if bad view # use test; create function sub1(i int) returns int @@ -305,6 +306,10 @@ create view t3 (c) as select sub1(1); create table t4(f1 int, KEY f1_key (f1)); drop table t1; drop function sub1; +select table_name from information_schema.views +where table_schema='test'; +select table_name from information_schema.views +where table_schema='test'; select column_name from information_schema.columns where table_schema='test'; select index_name from information_schema.statistics where table_schema='test'; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 81903df8dc7..5a135faf52f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2871,7 +2871,14 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, table->file->write_row(table->record[0]); } } - DBUG_RETURN(res); + else + { + if (tables->view) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + thd->net.last_errno, thd->net.last_error); + thd->clear_error(); + } + DBUG_RETURN(0); }