List:Internals« Previous MessageNext Message »
From:igor Date:June 7 2005 12:06pm
Subject:bk commit into 4.1 tree (igor:1.2317) BUG#11088
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2317 05/06/07 03:05:57 igor@stripped +5 -0
  sql_select.cc, item_buff.cc, item.h:
    Fixed bug #11088: a crash for queries with GROUP BY a BLOB column
    + COUNT(DISTINCT...) due to an attempt to allocate a too large
    buffer for the BLOB field.
    Now the size of the buffer is limited by max_sort_length.
  group_by.test, group_by.result:
    Added a test case for bug #11088.

  sql/sql_select.cc
    1.408 05/06/07 03:04:21 igor@stripped +1 -1
    Fixed bug #11088: a crash for queries with GROUP BY a BLOB column
    + COUNT(DISTINCT...) due to an attempt to allocate a too large
    buffer for the BLOB fields.
    Now the size of the buffer is limited by max_sort_length.

  sql/item_buff.cc
    1.9 05/06/07 03:02:45 igor@stripped +7 -2
    Fixed bug #11088: a crash for queries with GROUP BY a BLOB column
    + COUNT(DISTINCT...) due to an attempt to allocate a too large
    buffer for the BLOB fields.
    Now the size of the buffer is limited by max_sort_length.

  sql/item.h
    1.182 05/06/07 02:58:26 igor@stripped +2 -2
    Fixed bug #11088: a crash for queries with GROUP BY a BLOB column
    + COUNT(DISTINCT...) due to an attempt to allocate a too large
    buffer for the BLOB fields.
    Now the size of the buffer is limited by max_sort_length.

  mysql-test/t/group_by.test
    1.36 05/06/07 02:57:40 igor@stripped +17 -0
    Added a test case for bug #11088.

  mysql-test/r/group_by.result
    1.46 05/06/07 02:57:06 igor@stripped +11 -0
    Added a test case for bug #11088.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	igor
# Host:	rurik.mysql.com
# Root:	/home/igor/dev/mysql-4.1-0

--- 1.181/sql/item.h	Mon May 16 07:06:49 2005
+++ 1.182/sql/item.h	Tue Jun  7 02:58:26 2005
@@ -1118,7 +1118,7 @@
   Item *item;
   String value,tmp_value;
 public:
-  Item_str_buff(Item *arg) :item(arg),value(arg->max_length) {}
+  Item_str_buff(THD *thd, Item *arg);
   bool cmp(void);
   ~Item_str_buff();				// Deallocate String:s
 };
@@ -1385,7 +1385,7 @@
 };
 
 
-extern Item_buff *new_Item_buff(Item *item);
+extern Item_buff *new_Item_buff(THD *thd, Item *item);
 extern Item_result item_cmp_type(Item_result a,Item_result b);
 extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
 extern bool field_is_equal_to_item(Field *field,Item *item);

--- 1.8/sql/item_buff.cc	Tue Aug  5 00:52:34 2003
+++ 1.9/sql/item_buff.cc	Tue Jun  7 03:02:45 2005
@@ -23,13 +23,13 @@
 ** Create right type of item_buffer for an item
 */
 
-Item_buff *new_Item_buff(Item *item)
+Item_buff *new_Item_buff(THD *thd, Item *item)
 {
   if (item->type() == Item::FIELD_ITEM &&
       !(((Item_field *) item)->field->flags & BLOB_FLAG))
     return new Item_field_buff((Item_field *) item);
   if (item->result_type() == STRING_RESULT)
-    return new Item_str_buff((Item_field *) item);
+    return new Item_str_buff(thd, (Item_field *) item);
   if (item->result_type() == INT_RESULT)
     return new Item_int_buff((Item_field *) item);
   return new Item_real_buff(item);
@@ -42,12 +42,17 @@
 ** Return true if values have changed
 */
 
+Item_str_buff::Item_str_buff(THD *thd, Item *arg)
+  :item(arg), value(min(arg->max_length, thd->variables. max_sort_length))
+{}
+
 bool Item_str_buff::cmp(void)
 {
   String *res;
   bool tmp;
 
   res=item->val_str(&tmp_value);
+  res->length(min(res->length(), value.alloced_length()));
   if (null_value != item->null_value)
   {
     if ((null_value= item->null_value))

--- 1.407/sql/sql_select.cc	Sun Jun  5 10:38:42 2005
+++ 1.408/sql/sql_select.cc	Tue Jun  7 03:04:21 2005
@@ -8656,7 +8656,7 @@
   {
     for (; group ; group=group->next)
     {
-      Item_buff *tmp=new_Item_buff(*group->item);
+      Item_buff *tmp=new_Item_buff(join->thd, *group->item);
       if (!tmp || join->group_fields.push_front(tmp))
 	return TRUE;
     }

--- 1.45/mysql-test/r/group_by.result	Sun Apr 17 20:26:19 2005
+++ 1.46/mysql-test/r/group_by.result	Tue Jun  7 02:57:06 2005
@@ -711,3 +711,14 @@
 min(b)
 3000000000
 drop table t1;
+CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext);
+INSERT INTO t1 VALUES
+(1, 7, 'cache-dtc-af05.proxy.aol.com'),
+(2, 3, 'what.ever.com'),
+(3, 7, 'cache-dtc-af05.proxy.aol.com'),
+(4, 7, 'cache-dtc-af05.proxy.aol.com');
+SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
+WHERE hostname LIKE '%aol%'
+    GROUP BY hostname;
+hostname	no
+cache-dtc-af05.proxy.aol.com	1

--- 1.35/mysql-test/t/group_by.test	Sun Apr 17 20:26:20 2005
+++ 1.36/mysql-test/t/group_by.test	Tue Jun  7 02:57:40 2005
@@ -522,3 +522,20 @@
 select * from t1;
 select min(b) from t1;
 drop table t1;
+
+#
+# Test for bug #11088: GROUP BY a BLOB colimn with COUNT(DISTINCT column1) 
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext);
+
+INSERT INTO t1 VALUES
+  (1, 7, 'cache-dtc-af05.proxy.aol.com'),
+  (2, 3, 'what.ever.com'),
+  (3, 7, 'cache-dtc-af05.proxy.aol.com'),
+  (4, 7, 'cache-dtc-af05.proxy.aol.com');
+
+SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
+  WHERE hostname LIKE '%aol%'
+    GROUP BY hostname;
+
Thread
bk commit into 4.1 tree (igor:1.2317) BUG#11088igor7 Jun