Commit 53427592 authored by unknown's avatar unknown

Fix for bug#13818 SHOW CREATE VIEW / TABLE and information_schema.views fail

                  for invalid view
 Permit SHOW CREATE VIEW, SHOW CREATE TABLE, and retrieval of metadata from
 information_schema for invalid views


mysql-test/r/information_schema.result:
  Fix for bug#13818 SHOW CREATE VIEW / TABLE and information_schema.views fail 
                    for invalid view
   test case
mysql-test/t/information_schema.test:
  Fix for bug#13818 SHOW CREATE VIEW / TABLE and information_schema.views fail 
                    for invalid view
   test case
parent 5d425f93
......@@ -647,12 +647,16 @@ drop function sub1;
select table_name from information_schema.views
where table_schema='test';
table_name
v2
v3
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
select table_name from information_schema.views
where table_schema='test';
table_name
v2
v3
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
......@@ -669,6 +673,16 @@ f1_key
select constraint_name from information_schema.table_constraints
where table_schema='test';
constraint_name
show create view v2;
View Create View
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `test`.`t1`.`f1` AS `c` from `t1`
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
show create table v3;
View Create View
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select sql_no_cache `test`.`sub1`(1) AS `c`
Warnings:
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
drop view v2;
drop view v3;
drop table t4;
......
......@@ -379,6 +379,8 @@ 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';
show create view v2;
show create table v3;
drop view v2;
drop view v3;
drop table t4;
......
......@@ -362,7 +362,21 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
/* Only one table for now, but VIEW can involve several tables */
if (open_normal_and_derived_tables(thd, table_list, 0))
{
if (!table_list->view || thd->net.last_errno != ER_VIEW_INVALID)
DBUG_RETURN(TRUE);
/*
Clear all messages with 'error' level status and
issue a warning with 'warning' level status in
case of invalid view and last error is ER_VIEW_INVALID
*/
mysql_reset_errors(thd, true);
push_warning_printf(thd,MYSQL_ERROR::WARN_LEVEL_WARN,
ER_VIEW_INVALID,
ER(ER_VIEW_INVALID),
table_list->view_db.str,
table_list->view_name.str);
}
/* TODO: add environment variables show when it become possible */
if (thd->lex->only_view && !table_list->view)
......@@ -2992,8 +3006,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
DBUG_ENTER("get_schema_views_record");
char definer[HOSTNAME_LENGTH + USERNAME_LENGTH + 2];
uint definer_len;
if (!res)
{
if (tables->view)
{
restore_record(table, s->default_values);
......@@ -3023,16 +3036,14 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
table->field[7]->store(STRING_WITH_LEN("DEFINER"), cs);
else
table->field[7]->store(STRING_WITH_LEN("INVOKER"), cs);
DBUG_RETURN(schema_table_store_record(thd, table));
}
}
else
{
if (tables->view)
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
if (res)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
thd->net.last_errno, thd->net.last_error);
thd->clear_error();
}
if (res)
thd->clear_error();
DBUG_RETURN(0);
}
......
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