Commit 27a26acb authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5700 Cannot SHOW CREATE VIEW if underlying tabels are ALTERed

parent 2eaaeaea
......@@ -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
......
......@@ -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
#
......
......@@ -937,9 +937,12 @@ class Show_create_error_handler : public Internal_error_handler {
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 @@ class Show_create_error_handler : public Internal_error_handler {
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;
}
......
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