diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index adf92909709e5580e5308a545b6e946de96ae6f6..c9a79e50cc339e4e381a7bbad6e4ddbb6e85fae3 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2529,3 +2529,13 @@ Warnings: Warning 1052 Column 'x' in group statement is ambiguous DROP VIEW v1; DROP TABLE t1; +drop table if exists t1; +drop view if exists v1; +create table t1 (id int); +create view v1 as select * from t1; +drop table t1; +show create view v1; +drop view v1; +// +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache `test`.`t1`.`id` AS `id` from `t1` diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 77a903e2d3c108dcfd46ae8a3fb8b1a3ac6a27a9..b7e678c6f7795b8fd558cdaf5c3c87805eb821e9 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2370,3 +2370,18 @@ SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; DROP VIEW v1; DROP TABLE t1; + +# +# BUG#15943: mysql_next_result hangs on invalid SHOW CREATE VIEW +# + +delimiter //; +drop table if exists t1; +drop view if exists v1; +create table t1 (id int); +create view v1 as select * from t1; +drop table t1; +show create view v1; +drop view v1; +// +delimiter ;// diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1b854a005ceb12c45be7ae947160218a170844cc..8920efa87ab1666789d2da1542061612587e08d8 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -365,12 +365,15 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) { 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); + thd->clear_error(); + push_warning_printf(thd,MYSQL_ERROR::WARN_LEVEL_WARN, ER_VIEW_INVALID, ER(ER_VIEW_INVALID),