mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Bug #44399 : crash with statement using TEXT columns, aggregates, GROUP BY, and
HAVING
When calculating GROUP BY the server caches some expressions. It does
that by allocating a string slot (Item_copy_string) and assigning the
value of the expression to it. This effectively means that the result
type of the expression can be changed from whatever it was to a string.
As this substitution takes place after the compile-time result type
calculation for IN but before the run-time type calculations,
it causes the type calculations in the IN function done at run time
to get unexpected results different from what was prepared at compile time.
In the CASE ... WHEN ... THEN ... statement there was a similar problem
and it was solved by artificially adding a STRING argument to the set of
types of the IN/CASE arguments at compile time, so if any of the
arguments of the CASE function changes its type to a string it will
still be covered by the information prepared at compile time.
This commit is contained in:
@@ -13855,7 +13855,7 @@ SORT_FIELD *make_unireg_sortorder(ORDER *order, uint *length,
|
||||
pos->field= ((Item_sum*) item)->get_tmp_table_field();
|
||||
else if (item->type() == Item::COPY_STR_ITEM)
|
||||
{ // Blob patch
|
||||
pos->item= ((Item_copy_string*) item)->item;
|
||||
pos->item= ((Item_copy*) item)->get_item();
|
||||
}
|
||||
else
|
||||
pos->item= *order->item;
|
||||
@@ -14926,7 +14926,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
|
||||
pos= item;
|
||||
if (item->field->flags & BLOB_FLAG)
|
||||
{
|
||||
if (!(pos= new Item_copy_string(pos)))
|
||||
if (!(pos= Item_copy::create(pos)))
|
||||
goto err;
|
||||
/*
|
||||
Item_copy_string::copy for function can call
|
||||
@@ -14980,7 +14980,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
|
||||
on how the value is to be used: In some cases this may be an
|
||||
argument in a group function, like: IF(ISNULL(col),0,COUNT(*))
|
||||
*/
|
||||
if (!(pos=new Item_copy_string(pos)))
|
||||
if (!(pos= Item_copy::create(pos)))
|
||||
goto err;
|
||||
if (i < border) // HAVING, ORDER and GROUP BY
|
||||
{
|
||||
@@ -15033,8 +15033,8 @@ copy_fields(TMP_TABLE_PARAM *param)
|
||||
(*ptr->do_copy)(ptr);
|
||||
|
||||
List_iterator_fast<Item> it(param->copy_funcs);
|
||||
Item_copy_string *item;
|
||||
while ((item = (Item_copy_string*) it++))
|
||||
Item_copy *item;
|
||||
while ((item = (Item_copy*) it++))
|
||||
item->copy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user