1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

func_group.test, func_group.result:

Added a test case for bug #9210.
sql_select.cc:
  Fixed bug #9210.
  The function calc_group_buffer did not cover the case
  when the GROUP BY expression was decimal.
  Slightly optimized the other code.


sql/sql_select.cc:
  Fixed bug #9210.
  The function calc_group_buffer did not cover the case
  when the GROUP by expression was decimal.
  Slightly optimized the other code.
mysql-test/t/func_group.test:
  Added a test case for bug #9210.
This commit is contained in:
unknown
2005-03-19 23:12:50 -08:00
parent 648d40ea66
commit 2ba3544f0e
3 changed files with 111 additions and 19 deletions

View File

@ -11891,7 +11891,8 @@ calc_group_buffer(JOIN *join,ORDER *group)
join->group= 1;
for (; group ; group=group->next)
{
Field *field=(*group->item)->get_tmp_table_field();
Item *group_item= *group->item;
Field *field= group_item->get_tmp_table_field();
if (field)
{
if (field->type() == FIELD_TYPE_BLOB)
@ -11901,27 +11902,36 @@ calc_group_buffer(JOIN *join,ORDER *group)
else
key_length+= field->pack_length();
}
else if ((*group->item)->result_type() == REAL_RESULT)
key_length+=sizeof(double);
else if ((*group->item)->result_type() == INT_RESULT)
key_length+=sizeof(longlong);
else if ((*group->item)->result_type() == STRING_RESULT)
{
/*
Group strings are taken as varstrings and require an length field.
A field is not yet created by create_tmp_field()
and the sizes should match up.
*/
key_length+= (*group->item)->max_length + HA_KEY_BLOB_LENGTH;
}
else
{
/* This case should never be choosen */
DBUG_ASSERT(0);
join->thd->fatal_error();
{
switch (group_item->result_type()) {
case REAL_RESULT:
key_length+= sizeof(double);
break;
case INT_RESULT:
key_length+= sizeof(longlong);
break;
case DECIMAL_RESULT:
key_length+= my_decimal_get_binary_size(group_item->max_length -
(group_item->decimals ? 1 : 0),
group_item->decimals);
break;
case STRING_RESULT:
/*
Group strings are taken as varstrings and require an length field.
A field is not yet created by create_tmp_field()
and the sizes should match up.
*/
key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
break;
default:
/* This case should never be choosen */
DBUG_ASSERT(0);
join->thd->fatal_error();
}
}
parts++;
if ((*group->item)->maybe_null)
if (group_item->maybe_null)
null_parts++;
}
join->tmp_table_param.group_length=key_length+null_parts;