From 559abcf5d973213727e2dda42ee1577b4914564e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Feb 2006 19:53:34 +0300 Subject: [PATCH 1/2] Fixes bug #15943. resets error flag for show create view command, to allow proper processing of multiple sql statements sent as a single command. mysql-test/r/view.result: result file update for #15943 test case mysql-test/t/view.test: test case added for bug #15943 --- mysql-test/r/view.result | 10 ++++++++++ mysql-test/t/view.test | 15 +++++++++++++++ sql/sql_show.cc | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index e209e393d00..6b96bf7ca17 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2538,3 +2538,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 ed44bf3b7c0..dcd2b4de8dc 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2380,3 +2380,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 1b854a005ce..37a922cf103 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -365,6 +365,13 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) { if (!table_list->view || thd->net.last_errno != ER_VIEW_INVALID) DBUG_RETURN(TRUE); + + /* + Need this for proper processing of multiple sql statements + sent as single command + */ + thd->net.report_error= 0; + /* Clear all messages with 'error' level status and issue a warning with 'warning' level status in From fefdd728ff508e18e85af9ee93944f3f368ff8d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 27 Feb 2006 16:52:14 +0300 Subject: [PATCH 2/2] Postfix for #15943. Explicit call of thd->clear_error() is added. --- sql/sql_show.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 37a922cf103..8920efa87ab 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -366,18 +366,14 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if (!table_list->view || thd->net.last_errno != ER_VIEW_INVALID) DBUG_RETURN(TRUE); - /* - Need this for proper processing of multiple sql statements - sent as single command - */ - thd->net.report_error= 0; - /* 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),