Commit 93e5d753 authored by unknown's avatar unknown

Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-5.0

into gluh.mysql.r18.ru:/home/gluh/MySQL/mysql-5.0.n
parents 141379cd 7f4b9c62
...@@ -590,3 +590,28 @@ TABLES ...@@ -590,3 +590,28 @@ TABLES
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_NAMES 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;
...@@ -983,10 +983,10 @@ create view v1 as select * from t1; ...@@ -983,10 +983,10 @@ create view v1 as select * from t1;
drop table t1; drop table t1;
create table t1 (col1 char(5),newcol2 char(5)); create table t1 (col1 char(5),newcol2 char(5));
insert into v1 values('a','aa'); 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; drop table t1;
select * from v1; 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; drop view v1;
create view v1 (a,a) as select 'a','a'; create view v1 (a,a) as select 'a','a';
ERROR 42S21: Duplicate column name 'a' ERROR 42S21: Duplicate column name 'a'
...@@ -1217,11 +1217,11 @@ create table t1 (s1 int); ...@@ -1217,11 +1217,11 @@ create table t1 (s1 int);
create view v1 as select x1() from t1; create view v1 as select x1() from t1;
drop function x1; drop function x1;
select * from v1; 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; 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 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 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 view v1;
drop table t1; drop table t1;
create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1; create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1;
...@@ -1655,7 +1655,7 @@ test.t1 check status OK ...@@ -1655,7 +1655,7 @@ test.t1 check status OK
drop table t1; drop table t1;
check table v1; check table v1;
Table Op Msg_type Msg_text 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; drop view v1;
create table t1 (a int); create table t1 (a int);
create table t2 (a int); create table t2 (a int);
......
...@@ -292,3 +292,24 @@ use test; ...@@ -292,3 +292,24 @@ use test;
show tables; show tables;
use information_schema; use information_schema;
show tables like "T%"; 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;
...@@ -1169,7 +1169,7 @@ create function x1 () returns int return 5; ...@@ -1169,7 +1169,7 @@ create function x1 () returns int return 5;
create table t1 (s1 int); create table t1 (s1 int);
create view v1 as select x1() from t1; create view v1 as select x1() from t1;
drop function x1; drop function x1;
-- error 1305 -- error 1356
select * from v1; select * from v1;
--replace_column 12 # 13 # --replace_column 12 # 13 #
--replace_result "2147483647 " "21474836479 " --replace_result "2147483647 " "21474836479 "
......
...@@ -5464,7 +5464,7 @@ ER_WARN_VIEW_WITHOUT_KEY ...@@ -5464,7 +5464,7 @@ ER_WARN_VIEW_WITHOUT_KEY
serbian "View '%-.64s.%-.64s' references invalid table(s) or column(s)" serbian "View '%-.64s.%-.64s' references invalid table(s) or column(s)"
ukr "View, , ͦ æ(), Ҧ " ukr "View, , ͦ æ(), Ҧ "
ER_VIEW_INVALID 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' " rus "View '%-.64s.%-.64s' "
serbian "Can't drop a %s from within another stored routine" serbian "Can't drop a %s from within another stored routine"
ukr "View '%-.64s.%-.64s' Ŧަ æ æ" ukr "View '%-.64s.%-.64s' Ŧަ æ æ"
......
...@@ -140,6 +140,18 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list) ...@@ -140,6 +140,18 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
derived_result->set_table(table); derived_result->set_table(table);
exit: 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 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 then we do not need real data and we can skip execution (and parameters
......
...@@ -2374,12 +2374,24 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, ...@@ -2374,12 +2374,24 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
const char *file_name) const char *file_name)
{ {
TIME time; 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; CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_column_record"); DBUG_ENTER("get_schema_column_record");
if (res) 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; TABLE *show_table= tables->table;
...@@ -2745,7 +2757,23 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables, ...@@ -2745,7 +2757,23 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
{ {
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_stat_record"); 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; TABLE *show_table= tables->table;
KEY *key_info=show_table->key_info; KEY *key_info=show_table->key_info;
...@@ -2868,7 +2896,15 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables, ...@@ -2868,7 +2896,15 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables,
const char *file_name) const char *file_name)
{ {
DBUG_ENTER("get_schema_constraints_record"); 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; List<FOREIGN_KEY_INFO> f_key_list;
TABLE *show_table= tables->table; TABLE *show_table= tables->table;
...@@ -2925,7 +2961,15 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2925,7 +2961,15 @@ static int get_schema_key_column_usage_record(THD *thd,
{ {
DBUG_ENTER("get_schema_key_column_usage_record"); DBUG_ENTER("get_schema_key_column_usage_record");
CHARSET_INFO *cs= system_charset_info; 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; List<FOREIGN_KEY_INFO> f_key_list;
TABLE *show_table= tables->table; TABLE *show_table= tables->table;
......
...@@ -1845,8 +1845,9 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, ...@@ -1845,8 +1845,9 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
/* Hide "Unknown column" error */ /* Hide "Unknown column" or "Unknown function" error */
if (thd->net.last_errno == ER_BAD_FIELD_ERROR) if (thd->net.last_errno == ER_BAD_FIELD_ERROR ||
thd->net.last_errno == ER_SP_DOES_NOT_EXIST)
{ {
thd->clear_error(); thd->clear_error();
my_error(ER_VIEW_INVALID, MYF(0), view_db.str, view_name.str); my_error(ER_VIEW_INVALID, MYF(0), view_db.str, view_name.str);
......
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