[Commits] Rev 3499: Fixed LP bug #972973. in file:///home/igor/maria/maria-5.3-merge/

Igor Babaev igor at askmonty.org
Sat Apr 7 12:29:05 EEST 2012


At file:///home/igor/maria/maria-5.3-merge/

------------------------------------------------------------
revno: 3499
revision-id: igor at askmonty.org-20120407092904-nnwqfwtt2g5ia8gr
parent: igor at askmonty.org-20120406234039-wtrzx55zwxorps30
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.3-merge
timestamp: Sat 2012-04-07 02:29:04 -0700
message:
  Fixed LP bug #972973.
  When the function free_tmp_table deletes the handler object for
  a temporary table the field TABLE::file for this table should be
  set to NULL. Otherwise an assertion failure may occur.
-------------- next part --------------
=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2012-04-06 22:08:09 +0000
+++ b/mysql-test/r/view.result	2012-04-07 09:29:04 +0000
@@ -4453,6 +4453,25 @@
 DROP TRIGGER tr;
 DROP VIEW v;
 DROP TABLE t1,t2,t3;
+#
+# BUG#972943: Assertion failure with INSERT SELECT within a trigger 
+#             that uses derived table and materialized view
+#
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,0), (2,8);
+CREATE ALGORITHM=TEMPTABLE VIEW v1
+AS SELECT * FROM t1;
+CREATE TABLE t2 (c int);
+CREATE TABLE t3 (d int, e int);
+CREATE TRIGGER tr BEFORE INSERT ON t2 FOR EACH ROW
+INSERT INTO t3
+SELECT t1.*
+FROM (SELECT * FROM t1 WHERE b IN (SELECT b FROM v1)) AS alias1, t1
+WHERE t1.a = 3 OR t1.a > 5;
+INSERT INTO t2 VALUES (1);
+DROP TRIGGER tr;
+DROP VIEW v1;
+DROP TABLE t1,t2,t3;
 # -----------------------------------------------------------------
 # -- End of 5.3 tests.
 # -----------------------------------------------------------------

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2012-04-06 22:08:09 +0000
+++ b/mysql-test/t/view.test	2012-04-07 09:29:04 +0000
@@ -4394,6 +4394,32 @@
 DROP VIEW v;
 DROP TABLE t1,t2,t3;
 
+--echo #
+--echo # BUG#972943: Assertion failure with INSERT SELECT within a trigger 
+--echo #             that uses derived table and materialized view
+--echo #
+
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,0), (2,8);
+
+CREATE ALGORITHM=TEMPTABLE VIEW v1
+  AS SELECT * FROM t1;
+
+CREATE TABLE t2 (c int);
+CREATE TABLE t3 (d int, e int);
+
+CREATE TRIGGER tr BEFORE INSERT ON t2 FOR EACH ROW
+  INSERT INTO t3
+  SELECT t1.*
+    FROM (SELECT * FROM t1 WHERE b IN (SELECT b FROM v1)) AS alias1, t1
+    WHERE t1.a = 3 OR t1.a > 5;
+
+INSERT INTO t2 VALUES (1);
+
+DROP TRIGGER tr;
+DROP VIEW v1;
+DROP TABLE t1,t2,t3;
+
 --echo # -----------------------------------------------------------------
 --echo # -- End of 5.3 tests.
 --echo # -----------------------------------------------------------------

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2012-04-05 21:07:18 +0000
+++ b/sql/item_subselect.cc	2012-04-07 09:29:04 +0000
@@ -2727,7 +2727,7 @@
 {
   DBUG_ENTER("subselect_uniquesubquery_engine::cleanup");
   /* Tell handler we don't need the index anymore */
-  if (tab->table->file->inited)
+  if (tab->table->file && tab->table->file->inited)
     tab->table->file->ha_index_end();
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-04-05 21:07:18 +0000
+++ b/sql/sql_select.cc	2012-04-07 09:29:04 +0000
@@ -15116,6 +15116,7 @@
     else
       entry->file->ha_delete_table(entry->s->table_name.str);
     delete entry->file;
+    entry->file= 0;
   }
 
   /* free blobs */



More information about the commits mailing list