[Commits] Rev 3503: LP BUG#978847 fixed. in file:///home/bell/maria/bzr/work-maria-5.3-lpb978847/

sanja at montyprogram.com sanja at montyprogram.com
Wed Apr 18 23:38:40 EEST 2012


At file:///home/bell/maria/bzr/work-maria-5.3-lpb978847/

------------------------------------------------------------
revno: 3503
revision-id: sanja at montyprogram.com-20120418203839-2vetqw7m8r7t9pmp
parent: wlad at montyprogram.com-20120416213538-761a4vkzg1sokgo2
committer: sanja at montyprogram.com
branch nick: work-maria-5.3-lpb978847
timestamp: Wed 2012-04-18 23:38:39 +0300
message:
  LP BUG#978847 fixed.
  
  Fixed incorrect type casting which made all fields (except very first) changes to materialized table incorrect.
  Saved list of view/derived table used items after expanding '*'.
-------------- next part --------------
=== modified file 'mysql-test/r/derived_view.result'
--- a/mysql-test/r/derived_view.result	2012-04-05 20:32:57 +0000
+++ b/mysql-test/r/derived_view.result	2012-04-18 20:38:39 +0000
@@ -2034,6 +2034,59 @@ a
 drop table t1,t2;
 set optimizer_switch=@save968720_optimizer_switch;
 #
+# LP BUG#978847 Server crashes in Item_ref::real_item on
+# INSERT .. SELECT with FROM subquery and derived_merge=ON
+SET @save978847_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'derived_merge=on';
+CREATE TABLE t1 ( a INT, b INT );
+INSERT INTO t1 VALUES (2,1),(3,2);
+select * from t1;
+a	b
+2	1
+3	2
+INSERT INTO t1 SELECT * FROM
+( SELECT * FROM t1 ) AS alias;
+select * from t1;
+a	b
+2	1
+3	2
+2	1
+3	2
+prepare stmt1 from  'INSERT INTO t1 SELECT SQL_BIG_RESULT * FROM
+  ( SELECT * FROM t1 ) AS alias';
+execute stmt1;
+select * from t1;
+a	b
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+execute stmt1;
+select * from t1;
+a	b
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+2	1
+3	2
+drop table t1;
+set optimizer_switch=@save978847_optimizer_switch;
+#
 # end of 5.3 tests
 #
 set optimizer_switch=@exit_optimizer_switch;

=== modified file 'mysql-test/t/derived_view.test'
--- a/mysql-test/t/derived_view.test	2012-04-05 20:32:57 +0000
+++ b/mysql-test/t/derived_view.test	2012-04-18 20:38:39 +0000
@@ -1414,6 +1414,30 @@ drop table t1,t2;
 set optimizer_switch=@save968720_optimizer_switch;
 
 --echo #
+--echo # LP BUG#978847 Server crashes in Item_ref::real_item on
+--echo # INSERT .. SELECT with FROM subquery and derived_merge=ON
+SET @save978847_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'derived_merge=on';
+
+CREATE TABLE t1 ( a INT, b INT );
+INSERT INTO t1 VALUES (2,1),(3,2);
+
+select * from t1;
+INSERT INTO t1 SELECT * FROM
+  ( SELECT * FROM t1 ) AS alias;
+select * from t1;
+prepare stmt1 from  'INSERT INTO t1 SELECT SQL_BIG_RESULT * FROM
+  ( SELECT * FROM t1 ) AS alias';
+execute stmt1;
+select * from t1;
+execute stmt1;
+select * from t1;
+
+drop table t1;
+
+set optimizer_switch=@save978847_optimizer_switch;
+
+--echo #
 --echo # end of 5.3 tests
 --echo #
 

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2012-04-06 23:40:39 +0000
+++ b/sql/sql_base.cc	2012-04-18 20:38:39 +0000
@@ -8326,6 +8326,11 @@ insert_fields(THD *thd, Name_resolution_
         }
       }
 #endif
+      /*
+         field_iterator.create_item() builds used_items which we
+         have to save because changes made once and they are persistent
+      */
+      tables->persistent_used_items= tables->used_items;
 
       if ((field= field_iterator.field()))
       {

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2012-04-05 20:32:57 +0000
+++ b/sql/table.cc	2012-04-18 20:38:39 +0000
@@ -6088,7 +6088,8 @@ bool TABLE_LIST::change_refs_to_fields()
       We need to restore the pointers after the execution of the
       prepared statement.
     */
-    thd->change_item_tree((Item **)&ref->ref, (Item*)materialized_items + idx);
+    thd->change_item_tree((Item **)&ref->ref,
+                          (Item*)(materialized_items + idx));
   }
 
   return FALSE;



More information about the commits mailing list