MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Anurag Shekhar Date:April 17 2009 11:34am
Subject:bzr commit into mysql-6.0-bugteam branch (anurag.shekhar:3218)
Bug#44040
View as plain text  
#At file:///home/anurag/mysqlsrc/mysql-6.0-bugteam/ based on revid:sergey.glukhov@stripped

 3218 Anurag Shekhar	2009-04-17
      Bug#44040 MySQL allows creating a MERGE table upon VIEWs but
                 crashes when using it.
      
      In 6.0 the crash occured in myisammrg_attach_children_callback
      while checking the table version for compatiblity.
      
      Due to code changes the fix in 6.0 is in method open_table but fix
      is same. A check isntroduced to check if view is a child table of
      a merge table and returned error if it is.
     @ mysql-test/r/merge.result
        Updated result for new test case.
     @ mysql-test/t/merge.test
        Added new test case for this bug.
     @ sql/sql_base.cc
        Added a check to check if parent_l attribute of a view 
        is set. A non null value for this attribute indicates that
        the view is a child table of a merge table, which is not 
        allowed.

    modified:
      mysql-test/r/merge.result
      mysql-test/t/merge.test
      sql/sql_base.cc
=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result	2009-04-17 09:58:42 +0000
+++ b/mysql-test/r/merge.result	2009-04-17 11:34:43 +0000
@@ -2015,6 +2015,18 @@ insert into m1 (col1) values (1);
 insert into m1 (col1) values (1);
 ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
 drop table m1, t1;
+CREATE TABLE t1 (
+col1 INT(10)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
+CREATE VIEW v1 as SELECT * FROM t1;
+CREATE TABLE m1 (
+col1 INT(10)
+)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1);
+#Select should detect that the child table is a view and fail.
+SELECT * FROM m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+DROP VIEW v1;
+DROP TABLE m1, t1;
 End of 5.1 tests
 #
 # An additional test case for Bug#27430 Crash in subquery code

=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test	2009-04-17 09:58:42 +0000
+++ b/mysql-test/t/merge.test	2009-04-17 11:34:43 +0000
@@ -1376,6 +1376,27 @@ insert into m1 (col1) values (1);
 insert into m1 (col1) values (1);
 
 drop table m1, t1;
+
+#
+#Bug #44040   MySQL allows creating a MERGE table upon VIEWs but crashes 
+#when using it
+#
+
+CREATE TABLE t1 (
+        col1 INT(10)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
+
+CREATE VIEW v1 as SELECT * FROM t1;
+CREATE TABLE m1 (
+        col1 INT(10)
+)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1);
+
+--echo #Select should detect that the child table is a view and fail.
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+
+DROP VIEW v1;
+DROP TABLE m1, t1;
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2009-04-17 09:58:42 +0000
+++ b/sql/sql_base.cc	2009-04-17 11:34:43 +0000
@@ -2629,6 +2629,17 @@ bool open_table(THD *thd, TABLE_LIST *ta
 
     if (share->is_view)
     {
+
+      /*
+        If parent_l of the table_list is non null then a merge table
+        has this view as child table, which is not supported.
+      */
+      if (table_list->parent_l)
+      {
+        my_error(ER_WRONG_MRG_TABLE, MYF(0));
+        goto err_unlock;
+      }
+      
       /*
         This table is a view. Validate its metadata version: in particular,
         that it was a view when the statement was prepared.


Attachment: [text/bzr-bundle] bzr/anurag.shekhar@sun.com-20090417113443-9a5qhnjfies7x2by.bundle
Thread
bzr commit into mysql-6.0-bugteam branch (anurag.shekhar:3218)Bug#44040Anurag Shekhar17 Apr