MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:February 10 2010 6:11pm
Subject:bzr commit into mysql-5.1-bugteam branch (davi:3376) Bug#48449
View as plain text  
# At a local mysql-5.1-bugteam repository of davi

 3376 Davi Arnaut	2010-02-10
      Bug#48449: hang on show create view after upgrading when view contains function of view
      
      SHOW CREATE TABLE on a view (v1) that contains a function whose
      statement uses another view (v2), could trigger a infinite loop
      if the view referenced within the function causes a warning to
      be raised while opening the said view (v2).
      
      The problem was a infinite loop over the stack of internal error
      handlers. The problem would be triggered if the stack contained
      two or more handlers and the first two handlers didn't handle the
      raised condition. In this case, the loop variable would always
      point to the second handler in the stack.
      
      The solution is to correct the loop variable assignment so that
      the loop is able to iterate over all handlers in the stack.
     @ mysql-test/r/view.result
        Add test case result for Bug#48449.
     @ mysql-test/std_data/bug48449.frm
        Add a incomplete view definition that causes a warning to be
        issued.
     @ mysql-test/t/view.test
        Add test case for Bug#48449
     @ sql/sql_class.cc
        Iterate over all handlers in the stack.

    added:
      mysql-test/std_data/bug48449.frm
    modified:
      mysql-test/r/view.result
      mysql-test/t/view.test
      sql/sql_class.cc
=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2009-08-31 14:09:09 +0000
+++ b/mysql-test/r/view.result	2010-02-10 18:11:08 +0000
@@ -3844,6 +3844,30 @@ CREATE VIEW v1 AS SELECT a FROM t1;
 ALTER TABLE v1;
 DROP VIEW v1;
 DROP TABLE t1;
+#
+# Bug#48449: hang on show create view after upgrading when
+#            view contains function of view
+#
+DROP VIEW IF EXISTS v1,v2;
+DROP TABLE IF EXISTS t1,t2;
+DROP FUNCTION IF EXISTS f1;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+SELECT a FROM v2 INTO @a;
+RETURN @a;
+END//
+# Trigger pre-locking when opening v2.
+CREATE VIEW v1 AS SELECT f1() FROM t1;
+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 `f1`() AS `f1()` from `t1`	latin1	latin1_swedish_ci
+Warnings:
+Note	1599	View `test`.`v2` has no creation context
+DROP VIEW v1,v2;
+DROP TABLE t1,t2;
+DROP FUNCTION f1;
 # -----------------------------------------------------------------
 # -- End of 5.1 tests.
 # -----------------------------------------------------------------

=== added file 'mysql-test/std_data/bug48449.frm'
--- a/mysql-test/std_data/bug48449.frm	1970-01-01 00:00:00 +0000
+++ b/mysql-test/std_data/bug48449.frm	2010-02-10 18:11:08 +0000
@@ -0,0 +1,12 @@
+TYPE=VIEW
+query=select `test`.`t2`.`a` AS `a` from `test`.`t2`
+md5=5e6eaf216e7b016fcedfd4e1113517af
+updatable=1
+algorithm=0
+definer_user=root
+definer_host=localhost
+suid=2
+with_check_option=0
+timestamp=2010-01-01 15:00:00
+create-version=1
+source=select * from t2

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2009-08-31 14:09:09 +0000
+++ b/mysql-test/t/view.test	2010-02-10 18:11:08 +0000
@@ -3869,6 +3869,39 @@ ALTER TABLE v1;
 DROP VIEW v1;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#48449: hang on show create view after upgrading when
+--echo #            view contains function of view
+--echo #
+
+--disable_warnings
+DROP VIEW IF EXISTS v1,v2;
+DROP TABLE IF EXISTS t1,t2;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+
+delimiter //;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+  SELECT a FROM v2 INTO @a;
+  RETURN @a;
+END//
+delimiter ;//
+
+--echo # Trigger pre-locking when opening v2.
+CREATE VIEW v1 AS SELECT f1() FROM t1;
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/bug48449.frm $MYSQLD_DATADIR/test/v2.frm;
+
+SHOW CREATE VIEW v1;
+
+DROP VIEW v1,v2;
+DROP TABLE t1,t2;
+DROP FUNCTION f1;
 
 --echo # -----------------------------------------------------------------
 --echo # -- End of 5.1 tests.

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2009-12-08 09:26:11 +0000
+++ b/sql/sql_class.cc	2010-02-10 18:11:08 +0000
@@ -725,15 +725,12 @@ void THD::push_internal_handler(Internal
 bool THD::handle_error(uint sql_errno, const char *message,
                        MYSQL_ERROR::enum_warning_level level)
 {
-  if (!m_internal_handler)
-    return FALSE;
-
   for (Internal_error_handler *error_handler= m_internal_handler;
        error_handler;
-       error_handler= m_internal_handler->m_prev_internal_handler)
+       error_handler= error_handler->m_prev_internal_handler)
   {
     if (error_handler->handle_error(sql_errno, message, level, this))
-    return TRUE;
+      return TRUE;
   }
 
   return FALSE;


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20100210181108-3dmp8u8ntetuxr0k.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (davi:3376) Bug#48449Davi Arnaut10 Feb