[Commits] Rev 3376: Fixed LP bug #910083. in file:///home/igor/maria/maria-5.3-bug910083/

Igor Babaev igor at askmonty.org
Tue Jan 3 06:06:37 EET 2012


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

------------------------------------------------------------
revno: 3376
revision-id: igor at askmonty.org-20120103040636-nc6o55vsxqadd1n0
parent: psergey at askmonty.org-20111230211905-he458ysn3sse6wlm
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.3-bug910083
timestamp: Mon 2012-01-02 20:06:36 -0800
message:
  Fixed LP bug #910083.
  The patch for bug 685411 erroneously removed a call of engine->set_thd()
  from Item_subselect::fix_fields().
-------------- next part --------------
=== modified file 'mysql-test/r/trigger.result'
--- a/mysql-test/r/trigger.result	2011-11-24 16:48:58 +0000
+++ b/mysql-test/r/trigger.result	2012-01-03 04:06:36 +0000
@@ -2134,3 +2134,47 @@
 2
 drop table t1,t2;
 End of 5.2 tests.
+#
+# BUG #910083: materialized subquery in a trigger
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch='materialization=on';
+CREATE TABLE t1 (a int);
+CREATE TABLE t2 (b int);
+CREATE TRIGGER tr AFTER UPDATE ON t1 FOR EACH ROW
+UPDATE t2 SET b = (SELECT COUNT(a) FROM t1);
+INSERT INTO t1
+VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9);
+INSERT INTO t2
+VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0);
+UPDATE t1 SET a = 3;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT * FROM t2;
+b
+9
+9
+9
+9
+9
+9
+9
+9
+9
+UPDATE t1 SET a = 2;
+SELECT * FROM t2;
+b
+9
+9
+9
+9
+9
+9
+9
+9
+9
+SET optimizer_switch=@save_optimizer_switch;
+DROP TRIGGER tr;
+DROP TABLE t1, t2;
+End of 5.3 tests.

=== modified file 'mysql-test/t/trigger.test'
--- a/mysql-test/t/trigger.test	2011-10-06 13:56:59 +0000
+++ b/mysql-test/t/trigger.test	2012-01-03 04:06:36 +0000
@@ -2434,3 +2434,43 @@
 drop table t1,t2;
 
 --echo End of 5.2 tests.
+
+--echo #
+--echo # BUG #910083: materialized subquery in a trigger
+--echo #
+
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch='materialization=on';
+
+CREATE TABLE t1 (a int);
+CREATE TABLE t2 (b int);
+
+CREATE TRIGGER tr AFTER UPDATE ON t1 FOR EACH ROW
+  UPDATE t2 SET b = (SELECT COUNT(a) FROM t1);
+
+INSERT INTO t1
+  VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+INSERT INTO t2
+  VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0);
+
+send
+  UPDATE t1 SET a = 3;
+
+connect(con1,localhost,root,,);
+  SELECT COUNT(*) FROM t1;
+disconnect con1;
+
+connection default;
+reap;
+SELECT * FROM t2;
+UPDATE t1 SET a = 2;
+SELECT * FROM t2;
+
+SET optimizer_switch=@save_optimizer_switch;
+
+DROP TRIGGER tr;
+DROP TABLE t1, t2;
+
+--echo End of 5.3 tests.
+

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2011-12-19 21:05:44 +0000
+++ b/sql/item_subselect.cc	2012-01-03 04:06:36 +0000
@@ -211,8 +211,7 @@
   bool res;
 
   DBUG_ASSERT(fixed == 0);
-  /* There is no reason to get a different THD. */
-  DBUG_ASSERT(thd == thd_param);
+  engine->set_thd((thd= thd_param));
   if (!done_first_fix_fields)
   {
     done_first_fix_fields= TRUE;



More information about the commits mailing list