diff options
author | unknown <ramil@mysql.com> | 2005-05-31 10:54:33 +0500 |
---|---|---|
committer | unknown <ramil@mysql.com> | 2005-05-31 10:54:33 +0500 |
commit | 7b4385f4725f99ed5115b0f89174fc358498cfe0 (patch) | |
tree | e3a1e7be70be749ea74564b9a60faa1fe0e91b3e /sql/item_sum.cc | |
parent | 25841aa9addc20fc28c0392d5447b984b2bc230b (diff) | |
download | mariadb-git-7b4385f4725f99ed5115b0f89174fc358498cfe0.tar.gz |
a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some rows).
sql/item_sum.cc:
a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some rows).
Code changed in order to work with rollup extension.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r-- | sql/item_sum.cc | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index fb88fca9a2d..0e252259f53 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1566,7 +1566,6 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, { 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 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, 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 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) { 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 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) 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 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)), { 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 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)), 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 @@ void Item_func_group_concat::clear() 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 @@ bool Item_func_group_concat::add() 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 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) 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; @@ -1967,6 +1947,11 @@ bool Item_func_group_concat::setup(THD *thd) 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 */ |