List:Internals« Previous MessageNext Message »
From:ramil Date:May 31 2005 7:54am
Subject:bk commit into 4.1 tree (ramil:1.2303) BUG#7405
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of ram. When ram 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.2303 05/05/31 10:54:33 ramil@stripped +3 -0
  a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some
rows).

  sql/item_sum.cc
    1.136 05/05/31 10:54:29 ramil@stripped +14 -29
    a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some
rows).
    Code changed in order to work with rollup extension.

  mysql-test/t/func_gconcat.test
    1.26 05/05/31 10:54:28 ramil@stripped +12 -0
    a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some
rows).

  mysql-test/r/func_gconcat.result
    1.35 05/05/31 10:54:28 ramil@stripped +23 -0
    a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some
rows).

# 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:	ramil
# Host:	gw.mysql.r18.ru
# Root:	/usr/home/ram/work/4.1.b7405

--- 1.135/sql/item_sum.cc	2005-05-26 15:09:09 +05:00
+++ 1.136/sql/item_sum.cc	2005-05-31 10:54:29 +05:00
@@ -1566,7 +1566,6 @@
 {
   Item_func_group_concat* grp_item= (Item_func_group_concat*)arg;
   Item **field_item, **end;
-  char *record= (char*) grp_item->table->record[0];
 
   for (field_item= grp_item->args, end= field_item + grp_item->arg_count_field;
        field_item < end;
@@ -1581,7 +1580,7 @@
     if (field)
     {
       int res;
-      uint offset= (uint) (field->ptr - record);
+      uint offset= field->offset();
       if ((res= field->key_cmp(key1 + offset, key2 + offset)))
 	return res;
     }
@@ -1599,7 +1598,6 @@
 {
   Item_func_group_concat* grp_item= (Item_func_group_concat*) arg;
   ORDER **order_item, **end;
-  char *record= (char*) grp_item->table->record[0];
 
   for (order_item= grp_item->order, end=order_item+ grp_item->arg_count_order;
        order_item < end;
@@ -1615,7 +1613,7 @@
     if (field)
     {
       int res;
-      uint offset= (uint) (field->ptr - record);
+      uint offset= field->offset();
       if ((res= field->key_cmp(key1 + offset, key2 + offset)))
         return (*order_item)->asc ? res : -res;
     }
@@ -1657,7 +1655,6 @@
 {
   char buff[MAX_FIELD_WIDTH];
   String tmp((char *)&buff,sizeof(buff),default_charset_info), tmp2;
-  char *record= (char*) item->table->record[0];
 
   if (item->result.length())
     item->result.append(*item->separator);
@@ -1677,9 +1674,8 @@
       Field *field= show_item->get_tmp_table_field();
       String *res;
       char *save_ptr= field->ptr;
-      uint offset= (uint) (save_ptr - record);
-      DBUG_ASSERT(offset < item->table->reclength);
-      field->ptr= (char *) key + offset;
+      DBUG_ASSERT(field->offset() < item->table->reclength);
+      field->ptr= (char *) key + field->offset();
       res= field->val_str(&tmp,&tmp2);
       item->result.append(*res);
       field->ptr= save_ptr;
@@ -1852,12 +1848,6 @@
   result.copy();
   null_value= TRUE;
   warning_for_row= FALSE;
-  if (table)
-  {
-    table->file->extra(HA_EXTRA_NO_CACHE);
-    table->file->delete_all_rows();
-    table->file->extra(HA_EXTRA_WRITE_CACHE);
-  }
   if (tree_mode)
     reset_tree(tree);
 }
@@ -1870,19 +1860,13 @@
   copy_fields(tmp_table_param);
   copy_funcs(tmp_table_param->items_to_copy);
 
-  for (uint i= 0; i < arg_count_field; i++)
+  for (Item **arg= args, **arg_end= args + arg_count_field;
+       arg < arg_end; arg++)
   {
-    Item *show_item= args[i];
-    if (!show_item->const_item())
-    {
-      /*
-	Here we use real_item as we want the original field data that should
-	be written to table->record[0]
-      */
-      Field *f= show_item->real_item()->get_tmp_table_field();
-      if (f->is_null())
+    if (!(*arg)->const_item() &&
+        (*arg)->get_tmp_table_field()->is_null_in_record(
+          (const uchar*) table->record[0]))
 	return 0;				// Skip row if it contains null
-    }
   }
 
   null_value= FALSE;
@@ -1945,10 +1929,6 @@
   null_value= 1;
   max_length= group_concat_max_len;
   thd->allow_sum_func= 1;			
-  if (!(tmp_table_param= new TMP_TABLE_PARAM))
-    return 1;
-  /* We'll convert all blobs to varchar fields in the temporary table */
-  tmp_table_param->convert_blob_length= group_concat_max_len;
   tables_list= tables;
   fixed= 1;
   return 0;
@@ -1966,6 +1946,11 @@
 
   if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
     DBUG_RETURN(1);
+
+  if (!(tmp_table_param= new TMP_TABLE_PARAM))
+    return 1;
+  /* We'll convert all blobs to varchar fields in the temporary table */
+  tmp_table_param->convert_blob_length= group_concat_max_len;
 
   /*
     push all not constant fields to list and create temp table

--- 1.34/mysql-test/r/func_gconcat.result	2005-03-16 17:44:22 +04:00
+++ 1.35/mysql-test/r/func_gconcat.result	2005-05-31 10:54:28 +05:00
@@ -469,3 +469,26 @@
 1	1,1
 2	2,2
 drop table r2;
+create table t1 (d int, a int, b int, c int);
+insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3);
+select a, group_concat(b) from t1 group by a with rollup;
+a	group_concat(b)
+1	3,4,2,1,2
+2	7,3,3
+NULL	3,4,2,1,2,7,3,3
+select a, group_concat(distinct b) from t1 group by a with rollup;
+a	group_concat(distinct b)
+1	3,4,2,1
+2	7,3
+NULL	3,4,2,1,7
+select a, group_concat(b order by b) from t1 group by a with rollup;
+a	group_concat(b order by b)
+1	1,2,2,3,4
+2	3,3,7
+NULL	1,2,2,3,3,3,4,7
+select a, group_concat(distinct b order by b) from t1 group by a with rollup;
+a	group_concat(distinct b order by b)
+1	1,2,3,4
+2	3,7
+NULL	1,2,3,4,7
+drop table t1;

--- 1.25/mysql-test/t/func_gconcat.test	2005-03-16 17:44:22 +04:00
+++ 1.26/mysql-test/t/func_gconcat.test	2005-05-31 10:54:28 +05:00
@@ -292,3 +292,15 @@
 insert into r2 values (1,1), (2,2);
 select  b x, (select group_concat(x) from r2) from  r2;
 drop table r2;
+
+#
+# Bug #7405: problems with rollup
+#
+
+create table t1 (d int, a int, b int, c int);
+insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3);
+select a, group_concat(b) from t1 group by a with rollup;
+select a, group_concat(distinct b) from t1 group by a with rollup;
+select a, group_concat(b order by b) from t1 group by a with rollup;
+select a, group_concat(distinct b order by b) from t1 group by a with rollup;
+drop table t1;
Thread
bk commit into 4.1 tree (ramil:1.2303) BUG#7405ramil31 May