[Commits] Rev 2915: A proper fix for bug #57688. in file:///home/igor/maria/maria-5.1-release-bug57688/

igor at askmonty.org igor at askmonty.org
Thu Nov 25 05:59:45 EET 2010


At file:///home/igor/maria/maria-5.1-release-bug57688/

------------------------------------------------------------
revno: 2915
revision-id: igor at askmonty.org-20101125035940-j30uso51crv9e8ls
parent: knielsen at knielsen-hq.org-20101124175131-ph5yv8esqpy60g67
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.1-release-bug57688
timestamp: Wed 2010-11-24 19:59:40 -0800
message:
  A proper fix for bug #57688.
  Introduced a new flag in the class Item. The flag is set
  to 1 only for items that are used in GROUP BY lists of
  queries with ROLLUP.
  
  Also corrected modifications in simplify_joins that
  had been added in the patch for bug 56814.
-------------- next part --------------
=== modified file 'mysql-test/r/group_by.result'
--- a/mysql-test/r/group_by.result	2010-08-27 14:12:44 +0000
+++ b/mysql-test/r/group_by.result	2010-11-25 03:59:40 +0000
@@ -1862,4 +1862,14 @@
 SUBSTRING(a,1,10)	LENGTH(a)
 1111111111	1300
 DROP TABLE t1;
+#
+# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field
+#
+CREATE TABLE t1(f1 INT NOT NULL);
+INSERT INTO t1 VALUES (16777214),(0);
+SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2
+ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1;
+COUNT(*)
+2
+DROP TABLE t1;
 # End of 5.1 tests

=== modified file 'mysql-test/r/join_outer.result'
--- a/mysql-test/r/join_outer.result	2010-09-26 16:12:34 +0000
+++ b/mysql-test/r/join_outer.result	2010-11-25 03:59:40 +0000
@@ -1508,4 +1508,34 @@
 Handler_read_rnd	0
 Handler_read_rnd_next	1048581
 drop table t1,t2,t3;
+#
+# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field
+#
+CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1));
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2));
+INSERT INTO t1 VALUES (4);
+INSERT INTO t2 VALUES (3, 3);
+INSERT INTO t2 VALUES (7, 7);
+EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4
+GROUP BY t2.f1, t2.f2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	system	PRIMARY	NULL	NULL	NULL	1	Using temporary; Using filesort
+1	SIMPLE	t2	ref	PRIMARY	PRIMARY	4	const	1	Using index
+SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4
+GROUP BY t2.f1, t2.f2;
+f1	f1	f2
+4	NULL	NULL
+EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
+GROUP BY t2.f1, t2.f2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	system	PRIMARY	NULL	NULL	NULL	1	Using filesort
+1	SIMPLE	t2	ref	PRIMARY	PRIMARY	4	const	1	Using where; Using index
+SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
+GROUP BY t2.f1, t2.f2;
+f1	f1	f2
+DROP TABLE t1,t2;
 End of 5.1 tests

=== modified file 'mysql-test/t/group_by.test'
--- a/mysql-test/t/group_by.test	2010-08-27 14:12:44 +0000
+++ b/mysql-test/t/group_by.test	2010-11-25 03:59:40 +0000
@@ -1252,5 +1252,16 @@
 SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
 DROP TABLE t1;
 
-
+--echo #
+--echo # Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field
+--echo #
+
+CREATE TABLE t1(f1 INT NOT NULL);
+INSERT INTO t1 VALUES (16777214),(0);
+
+SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2
+ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1;
+
+DROP TABLE t1;
+ 
 --echo # End of 5.1 tests

=== modified file 'mysql-test/t/join_outer.test'
--- a/mysql-test/t/join_outer.test	2010-09-26 16:12:34 +0000
+++ b/mysql-test/t/join_outer.test	2010-11-25 03:59:40 +0000
@@ -1073,4 +1073,33 @@
 
 drop table t1,t2,t3;
 
+--echo #
+--echo # Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field
+--echo #
+
+CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1));
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2));
+
+INSERT INTO t1 VALUES (4);
+INSERT INTO t2 VALUES (3, 3);
+INSERT INTO t2 VALUES (7, 7);
+
+EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4
+GROUP BY t2.f1, t2.f2;
+
+SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4
+GROUP BY t2.f1, t2.f2;
+
+EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
+GROUP BY t2.f1, t2.f2;
+
+SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1
+WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL
+GROUP BY t2.f1, t2.f2;
+
+DROP TABLE t1,t2;
+
 --echo End of 5.1 tests

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2010-11-23 21:39:59 +0000
+++ b/sql/item.cc	2010-11-25 03:59:40 +0000
@@ -380,6 +380,7 @@
 {
   marker= 0;
   maybe_null=null_value=with_sum_func=unsigned_flag=0;
+  in_rollup= 0;
   decimals= 0; max_length= 0;
   with_subselect= 0;
   cmp_context= IMPOSSIBLE_RESULT;
@@ -420,6 +421,7 @@
   marker(item->marker),
   decimals(item->decimals),
   maybe_null(item->maybe_null),
+  in_rollup(item->in_rollup),
   null_value(item->null_value),
   unsigned_flag(item->unsigned_flag),
   with_sum_func(item->with_sum_func),

=== modified file 'sql/item.h'
--- a/sql/item.h	2010-11-16 10:32:36 +0000
+++ b/sql/item.h	2010-11-25 03:59:40 +0000
@@ -518,6 +518,8 @@
   int8 marker;
   uint8 decimals;
   my_bool maybe_null;			/* If item may be null */
+  my_bool in_rollup;                    /* If used in GROUP BY list
+                                           of a query with ROLLUP */ 
   my_bool null_value;			/* if item is null */
   my_bool unsigned_flag;
   my_bool with_sum_func;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-11-23 21:39:59 +0000
+++ b/sql/sql_select.cc	2010-11-25 03:59:40 +0000
@@ -8909,6 +8909,8 @@
         For some of the inner tables there are conjunctive predicates
         that reject nulls => the outer join can be replaced by an inner join.
       */
+      if (table->outer_join && !table->embedding && table->table)
+        table->table->maybe_null= FALSE;
       table->outer_join= 0;
       if (table->on_expr)
       {
@@ -8995,6 +8997,8 @@
       while ((tbl= it++))
       {
         tbl->embedding= table->embedding;
+        if (!tbl->embedding && !tbl->on_expr && tbl->table)
+          tbl->table->maybe_null= FALSE;
         tbl->join_list= table->join_list;
       }
       li.replace(nested_join->join_list);
@@ -9872,7 +9876,7 @@
       If item have to be able to store NULLs but underlaid field can't do it,
       create_tmp_field_from_field() can't be used for tmp field creation.
     */
-    if (field->maybe_null && !field->field->maybe_null())
+    if (field->maybe_null && field->in_rollup && !field->field->maybe_null())
     {
       result= create_tmp_field_from_item(thd, item, table, NULL,
                                          modify_item, convert_blob_length);
@@ -16325,6 +16329,7 @@
     if (arg_changed)
     {
       expr->maybe_null= 1;
+      expr->in_rollup= 1;
       *changed= TRUE;
     }
   }
@@ -16388,6 +16393,7 @@
       if (*group_tmp->item == item)
       {
         item->maybe_null= 1;
+        item->in_rollup= 1;
         found_in_group= 1;
         break;
       }



More information about the commits mailing list