List:Internals« Previous MessageNext Message »
From:Lu Jingdong Date:November 21 2007 10:17am
Subject:Patch for bug #32482
View as plain text  
This patch for bug #32482: crash with GROUP BY alias_of_user_variable 
WITH ROLLUP
http://bugs.mysql.com/bug.php?id=32482

diff -Nur sql/item_func.cc.orig  sql/item_func.cc
--- sql/item_func.cc.orig       2007-11-21 16:47:59.000000000 +0800
+++ sql/item_func.cc    2007-11-21 16:48:28.000000000 +0800
@@ -3836,8 +3836,11 @@
 bool Item_func_set_user_var::register_field_in_read_map(uchar *arg)
 {
   TABLE *table= (TABLE *) arg;
-  if (result_field->table == table || !table)
-    bitmap_set_bit(result_field->table->read_set, 
result_field->field_index);
+  if (result_field)
+  {
+    if (result_field->table == table || !table)
+      bitmap_set_bit(result_field->table->read_set, 
result_field->field_index);
+  }
   return 0;
 }

Test and result:
mysql> create table foo (bar int);
Query OK, 0 rows affected (0.08 sec)

mysql> insert into foo (bar) values (1), (2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select @i := 0 as j from foo group by j with rollup;
+------+
| j    |
+------+
|    0 |
| NULL |
+------+
2 rows in set (0.08 sec)

Thread
Patch for bug #32482Lu Jingdong21 Nov