summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <gluh@gluh.mysql.r18.ru>2004-12-16 16:31:36 +0300
committerunknown <gluh@gluh.mysql.r18.ru>2004-12-16 16:31:36 +0300
commit05bbcee9e6b47e1dac257696ff539c1c45fa1c4d (patch)
tree9092e19720261600bd1d7610193da9f4fcd1781a
parent7845f99abf1d36e972970c0fc9431956a8f4b63a (diff)
downloadmariadb-git-05bbcee9e6b47e1dac257696ff539c1c45fa1c4d.tar.gz
Fix for bug#7212: information_schema: "Can't find file" errors if storage engine gone(after review)
-rw-r--r--mysql-test/r/information_schema.result25
-rw-r--r--mysql-test/r/view.result10
-rw-r--r--mysql-test/t/information_schema.test21
-rw-r--r--mysql-test/t/view.test2
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sql_derived.cc12
-rw-r--r--sql/sql_show.cc54
-rw-r--r--sql/table.cc5
8 files changed, 117 insertions, 14 deletions
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 6c427f7fe1d..660c0e7b1bb 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -590,3 +590,28 @@ TABLES
TABLE_PRIVILEGES
TABLE_CONSTRAINTS
TABLE_NAMES
+use test;
+create function sub1(i int) returns int
+return i+1;
+create table t1(f1 int);
+create view t2 (c) as select f1 from t1;
+create view t3 (c) as select sub1(1);
+create table t4(f1 int, KEY f1_key (f1));
+drop table t1;
+drop function sub1;
+select column_name from information_schema.columns
+where table_schema='test';
+column_name
+f1
+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 index_name from information_schema.statistics where table_schema='test';
+index_name
+f1_key
+select constraint_name from information_schema.table_constraints
+where table_schema='test';
+constraint_name
+drop view t2;
+drop view t3;
+drop table t4;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 41de883a4d6..366d799fde3 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -983,10 +983,10 @@ create view v1 as select * from t1;
drop table t1;
create table t1 (col1 char(5),newcol2 char(5));
insert into v1 values('a','aa');
-ERROR HY000: View 'test.v1' references invalid table(s) or column(s)
+ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s)
drop table t1;
select * from v1;
-ERROR HY000: View 'test.v1' references invalid table(s) or column(s)
+ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s)
drop view v1;
create view v1 (a,a) as select 'a','a';
ERROR 42S21: Duplicate column name 'a'
@@ -1217,11 +1217,11 @@ create table t1 (s1 int);
create view v1 as select x1() from t1;
drop function x1;
select * from v1;
-ERROR 42000: FUNCTION test.x1 does not exist
+ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s)
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
-v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL FUNCTION test.x1 does not exist
+v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL View 'test.v1' references invalid table(s) or column(s) or function(s)
drop view v1;
drop table t1;
create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1;
@@ -1655,7 +1655,7 @@ test.t1 check status OK
drop table t1;
check table v1;
Table Op Msg_type Msg_text
-test.v1 check error View 'test.v1' references invalid table(s) or column(s)
+test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s)
drop view v1;
create table t1 (a int);
create table t2 (a int);
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index b909e8b8e53..b5570851c0f 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -292,3 +292,24 @@ use test;
show tables;
use information_schema;
show tables like "T%";
+
+#
+# Bug#7212: information_schema: "Can't find file" errors if storage engine gone
+#
+use test;
+create function sub1(i int) returns int
+ return i+1;
+create table t1(f1 int);
+create view t2 (c) as select f1 from t1;
+create view t3 (c) as select sub1(1);
+create table t4(f1 int, KEY f1_key (f1));
+drop table t1;
+drop function sub1;
+select column_name from information_schema.columns
+where table_schema='test';
+select index_name from information_schema.statistics where table_schema='test';
+select constraint_name from information_schema.table_constraints
+where table_schema='test';
+drop view t2;
+drop view t3;
+drop table t4;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 65f464fc77b..cb398fed856 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -1169,7 +1169,7 @@ create function x1 () returns int return 5;
create table t1 (s1 int);
create view v1 as select x1() from t1;
drop function x1;
--- error 1305
+-- error 1356
select * from v1;
--replace_column 12 # 13 #
--replace_result "2147483647 " "21474836479 "
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 714b18b39f2..6908135b577 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5464,7 +5464,7 @@ ER_WARN_VIEW_WITHOUT_KEY
serbian "View '%-.64s.%-.64s' references invalid table(s) or column(s)"
ukr "View, що оновлюеться, не м╕стить повного ключа таблиц╕(ь), що викор╕стана в ньюому"
ER_VIEW_INVALID
- eng "View '%-.64s.%-.64s' references invalid table(s) or column(s)"
+ eng "View '%-.64s.%-.64s' references invalid table(s) or column(s) or function(s)"
rus "View '%-.64s.%-.64s' ссылается на несуществующие таблицы или столбцы"
serbian "Can't drop a %s from within another stored routine"
ukr "View '%-.64s.%-.64s' посила╓тся на не╕снуюч╕ таблиц╕ або стовбц╕"
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 69511018880..7cea1c6fcee 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -140,6 +140,18 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
derived_result->set_table(table);
exit:
+ /* Hide "Unknown column" or "Unknown function" error */
+ if (orig_table_list->view)
+ {
+ if (thd->net.last_errno == ER_BAD_FIELD_ERROR ||
+ thd->net.last_errno == ER_SP_DOES_NOT_EXIST)
+ {
+ thd->clear_error();
+ my_error(ER_VIEW_INVALID, MYF(0), orig_table_list->db,
+ orig_table_list->real_name);
+ }
+ }
+
/*
if it is preparation PS only or commands that need only VIEW structure
then we do not need real data and we can skip execution (and parameters
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index e50c68dd289..81903df8dc7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2374,12 +2374,24 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
const char *file_name)
{
TIME time;
- const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
+ LEX *lex= thd->lex;
+ const char *wild= lex->wild ? lex->wild->ptr() : NullS;
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_column_record");
if (res)
{
- DBUG_RETURN(1);
+ if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS)
+ {
+ /*
+ I.e. we are in SELECT FROM INFORMATION_SCHEMA.COLUMS
+ rather than in SHOW COLUMNS
+ */
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ thd->net.last_errno, thd->net.last_error);
+ thd->clear_error();
+ res= 0;
+ }
+ DBUG_RETURN(res);
}
TABLE *show_table= tables->table;
@@ -2745,7 +2757,23 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
{
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_stat_record");
- if (!res && !tables->view)
+ if (res)
+ {
+ if (thd->lex->orig_sql_command != SQLCOM_SHOW_KEYS)
+ {
+ /*
+ I.e. we are in SELECT FROM INFORMATION_SCHEMA.STATISTICS
+ rather than in SHOW KEYS
+ */
+ if (!tables->view)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ thd->net.last_errno, thd->net.last_error);
+ thd->clear_error();
+ res= 0;
+ }
+ DBUG_RETURN(res);
+ }
+ else if (!tables->view)
{
TABLE *show_table= tables->table;
KEY *key_info=show_table->key_info;
@@ -2868,7 +2896,15 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables,
const char *file_name)
{
DBUG_ENTER("get_schema_constraints_record");
- if (!res && !tables->view)
+ if (res)
+ {
+ 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);
+ }
+ else if (!tables->view)
{
List<FOREIGN_KEY_INFO> f_key_list;
TABLE *show_table= tables->table;
@@ -2925,7 +2961,15 @@ static int get_schema_key_column_usage_record(THD *thd,
{
DBUG_ENTER("get_schema_key_column_usage_record");
CHARSET_INFO *cs= system_charset_info;
- if (!res && !tables->view)
+ if (res)
+ {
+ 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);
+ }
+ else if (!tables->view)
{
List<FOREIGN_KEY_INFO> f_key_list;
TABLE *show_table= tables->table;
diff --git a/sql/table.cc b/sql/table.cc
index b4a07448b14..b54cc351dff 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1845,8 +1845,9 @@ ok:
DBUG_RETURN(0);
err:
- /* Hide "Unknown column" error */
- if (thd->net.last_errno == ER_BAD_FIELD_ERROR)
+ /* Hide "Unknown column" or "Unknown function" error */
+ if (thd->net.last_errno == ER_BAD_FIELD_ERROR ||
+ thd->net.last_errno == ER_SP_DOES_NOT_EXIST)
{
thd->clear_error();
my_error(ER_VIEW_INVALID, MYF(0), view_db.str, view_name.str);