MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Oystein.Grovlen Date:April 6 2010 11:54am
Subject:bzr commit into mysql-next-mr-bugfixing branch (oystein.grovlen:3060)
Bug#44303
View as plain text  
#At file:///home/oysteing/mysql/mysql-next-mr-opt-backporting/ based on revid:oystein.grovlen@stripped

 3060 oystein.grovlen@stripped	2010-04-06
      Bug#44303 Assertion failures in Field_new_decimal::store_decimal when executing
                materialized InsideOut semijoin
      
      (Backporting of revid:oystein.grovlen@stripped)
      
      When inner tables of semijoin is materialized, field values are copied back
      from the materialized table to the record buffer of the source tables.
      The problem was that the write_set of the source tables were not set up to
      allow such copying.  
     @ mysql-test/r/subselect_mat.result
        Update result file with new test case for Bug#44303.
     @ mysql-test/t/subselect_mat.test
        Test for Bug#44303.  A semijoin where InsideOut strategy with materialization
        of inner table is used.
     @ sql/sql_select.cc
        setup_sj_materialization():  If field values are to be copied back from 
        a materialized table to the record buffer of source tables, set write_set
        for source tables so that this copying is allowed.
        
        Fixed some comments to make it clear that the source tables are not actually
        updated, just the record buffers.

    modified:
      mysql-test/r/subselect_mat.result
      mysql-test/t/subselect_mat.test
      sql/sql_select.cc
=== modified file 'mysql-test/r/subselect_mat.result'
--- a/mysql-test/r/subselect_mat.result	2010-03-22 13:01:49 +0000
+++ b/mysql-test/r/subselect_mat.result	2010-04-06 11:54:47 +0000
@@ -1185,3 +1185,19 @@ a	b
 execute st1;
 a	b
 drop table t1;
+CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM;
+INSERT INTO t1 (f1, f2) VALUES (1, 1.789);
+INSERT INTO t1 (f1, f2) VALUES (13, 1.454);
+INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1, 1.789);
+INSERT INTO t2 VALUES (13, 1.454);
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	3	Using where; Using join buffer
+SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+COUNT(*)
+2
+DROP TABLE t1, t2;

=== modified file 'mysql-test/t/subselect_mat.test'
--- a/mysql-test/t/subselect_mat.test	2010-03-22 13:01:49 +0000
+++ b/mysql-test/t/subselect_mat.test	2010-04-06 11:54:47 +0000
@@ -855,3 +855,22 @@ prepare st1 from "select a,b from t1 whe
 execute st1;
 execute st1;
 drop table t1;
+
+#
+# Bug #44303 Assertion failures in Field_new_decimal::store_decimal
+#            when executing materialized InsideOut semijoin
+# 
+CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM;
+INSERT INTO t1 (f1, f2) VALUES (1, 1.789);
+INSERT INTO t1 (f1, f2) VALUES (13, 1.454);
+INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
+
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1, 1.789);
+INSERT INTO t2 VALUES (13, 1.454);
+
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+
+DROP TABLE t1, t2;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-04-06 10:44:10 +0000
+++ b/sql/sql_select.cc	2010-04-06 11:54:47 +0000
@@ -9554,9 +9554,10 @@ bool setup_sj_materialization(JOIN_TAB *
   else
   {
     /*
-      We'll be doing full scan of the temptable.
-      Setup copying of temptable columns back to their source tables. We
-      need this because IN-equalities refer to the original tables.
+      We'll be doing full scan of the temptable.  
+      Setup copying of temptable columns back to the record buffers
+      for their source tables. We need this because IN-equalities
+      refer to the original tables.
 
       EXAMPLE
 
@@ -9577,7 +9578,7 @@ bool setup_sj_materialization(JOIN_TAB *
 
       At the moment, our solution is to copy back: when we get the next
       temptable record, we copy its columns to their corresponding columns
-      in the source tables. 
+      in the record buffers for the source tables. 
     */
     sjm->copy_field= new Copy_field[sjm->sjm_table_cols.elements];
     it.rewind();
@@ -9627,6 +9628,8 @@ bool setup_sj_materialization(JOIN_TAB *
         }
       }
       sjm->copy_field[i].set(copy_to, sjm->table->field[i], FALSE);
+      /* The write_set for source tables must be set up to allow the copying */
+      bitmap_set_bit(copy_to->table->write_set, copy_to->field_index);
     }
   }
 


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-next-mr-bugfixing branch (oystein.grovlen:3060)Bug#44303Oystein.Grovlen6 Apr