diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 7a7dbf92ee3..64aee1fd078 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -846,6 +846,24 @@ Warnings: Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them drop view v1; drop table t1; +create table t1 (a varchar(20)); +create view v1 as select a from t1; +alter table t1 change a aa int; +select * from v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +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 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL +v1 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) or definer/invoker of view lack rights to use them +Warnings: +Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci +Warnings: +Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1; +drop table t1; create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1; show create view v1; View Create View character_set_client collation_connection diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 017887223a3..a814132e165 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -749,6 +749,21 @@ show table status; drop view v1; drop table t1; +# +# VIEW over non-existing column +# +create table t1 (a varchar(20)); +create view v1 as select a from t1; +alter table t1 change a aa int; +--error ER_VIEW_INVALID +select * from v1; +--replace_column 8 # 12 # 13 # +show table status; +show create view v1; +drop view v1; +drop table t1; + + # # VIEW with floating point (long number) as column # diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1890daa4215..feeb96f280d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -937,9 +937,12 @@ public: is_handled= TRUE; break; + case ER_BAD_FIELD_ERROR: + case ER_SP_DOES_NOT_EXIST: case ER_NO_SUCH_TABLE: case ER_NO_SUCH_TABLE_IN_ENGINE: - /* Established behavior: warn if underlying tables are missing. */ + /* Established behavior: warn if underlying tables, columns, or functions + are missing. */ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_VIEW_INVALID, ER(ER_VIEW_INVALID), @@ -948,15 +951,6 @@ public: is_handled= TRUE; break; - case ER_SP_DOES_NOT_EXIST: - /* Established behavior: warn if underlying functions are missing. */ - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_VIEW_INVALID, - ER(ER_VIEW_INVALID), - m_top_view->get_db_name(), - m_top_view->get_table_name()); - is_handled= TRUE; - break; default: is_handled= FALSE; }