List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:October 4 2010 8:25am
Subject:bzr commit into mysql-5.5-runtime branch (jon.hauglid:3151) Bug#51099
View as plain text  
#At file:///export/home/x/mysql-5.5-runtime-bug51099/ based on revid:dmitry.lenev@stripped

 3151 Jon Olav Hauglid	2010-10-04
      Bug #51099 Assertion in mysql_multi_delete_prepare()
      
      This assert was triggered if DELETE was done on a view that
      referenced another view which in turn (directly or indirectly)
      referenced more than one table.
      
      Delete from a view referencing more than one table (a join view)
      is not supported and is supposed to give ER_VIEW_DELETE_MERGE_VIEW
      error. Before this error was reported from the multi table 
      delete code, an assert verified that the view from the DELETE statement
      had more than one underlying table. However, this assert did not take
      into account that the view could refer to another view which in turn
      referenced the actual tables.
      
      This patch fixes the problem by adjusting the assert to take this
      possibility into account. This problem was only noticeable on debug
      builds of the server. On release builds, ER_VIEW_DELETE_MERGE_VIEW
      was correctly reported.
      
      Test case added to delete.test.

    modified:
      mysql-test/r/delete.result
      mysql-test/t/delete.test
      sql/sql_delete.cc
=== modified file 'mysql-test/r/delete.result'
--- a/mysql-test/r/delete.result	2010-08-30 22:22:01 +0000
+++ b/mysql-test/r/delete.result	2010-10-04 08:25:04 +0000
@@ -509,3 +509,18 @@ CREATE TABLE t3 LIKE t1;
 DELETE FROM t1.*, test.t2.*, a.* USING t1, t2, t3 AS a;
 DROP TABLE t1, t2, t3;
 End of 5.1 tests
+#
+# Bug#51099 Assertion in mysql_multi_delete_prepare()
+#
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1, v2;
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(b INT);
+CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
+CREATE VIEW v2 AS SELECT a FROM v1;
+DELETE FROM v2;
+ERROR HY000: Can not delete from join view 'test.v2'
+DELETE v2 FROM v2;
+ERROR HY000: Can not delete from join view 'test.v2'
+DROP VIEW v2, v1;
+DROP TABLE t1, t2;

=== modified file 'mysql-test/t/delete.test'
--- a/mysql-test/t/delete.test	2010-08-30 22:22:01 +0000
+++ b/mysql-test/t/delete.test	2010-10-04 08:25:04 +0000
@@ -554,3 +554,29 @@ DELETE FROM t1.*, test.t2.*, a.* USING t
 DROP TABLE t1, t2, t3;
 
 --echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug#51099 Assertion in mysql_multi_delete_prepare()
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1, v2;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(b INT);
+CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
+CREATE VIEW v2 AS SELECT a FROM v1;
+
+# This is a normal delete
+--error ER_VIEW_DELETE_MERGE_VIEW
+DELETE FROM v2;
+# This is a multi table delete, check that we get the same error
+# This caused the assertion.
+--error ER_VIEW_DELETE_MERGE_VIEW
+DELETE v2 FROM v2;
+
+DROP VIEW v2, v1;
+DROP TABLE t1, t2;

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2010-07-28 11:17:19 +0000
+++ b/sql/sql_delete.cc	2010-10-04 08:25:04 +0000
@@ -525,9 +525,7 @@ int mysql_multi_delete_prepare(THD *thd)
     if (!(target_tbl->table= target_tbl->correspondent_table->table))
     {
       DBUG_ASSERT(target_tbl->correspondent_table->view &&
-                  target_tbl->correspondent_table->merge_underlying_list &&
-                  target_tbl->correspondent_table->merge_underlying_list->
-                  next_local);
+                  target_tbl->correspondent_table->multitable_view);
       my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
                target_tbl->correspondent_table->view_db.str,
                target_tbl->correspondent_table->view_name.str);


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20101004082504-0cilpxssqycki8d1.bundle
Thread
bzr commit into mysql-5.5-runtime branch (jon.hauglid:3151) Bug#51099Jon Olav Hauglid4 Oct