1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fix for BUG#12941: in create_tmp_field(), if the passed item is an Item_ref, put newly

created item into item->result_field, not *(item->ref)->result_field.


mysql-test/r/view.result:
  Tescase for BUG#12941
mysql-test/t/view.test:
  Tescase for BUG#12941
This commit is contained in:
unknown
2005-09-07 11:50:41 +04:00
parent b48e721d2f
commit 3003e5a0eb
3 changed files with 79 additions and 10 deletions

View File

@ -8054,12 +8054,17 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
bool table_cant_handle_bit_fields,
uint convert_blob_length)
{
Item::Type orig_type;
Item *orig_item;
if (type != Item::FIELD_ITEM &&
item->real_item()->type() == Item::FIELD_ITEM &&
(item->type() != Item::REF_ITEM ||
!((Item_ref *) item)->depended_from))
{
orig_item= item;
item= item->real_item();
orig_type= type;
type= Item::FIELD_ITEM;
}
switch (type) {
@ -8075,29 +8080,34 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case Item::DEFAULT_VALUE_ITEM:
{
Item_field *field= (Item_field*) item;
bool orig_modify= modify_item;
Field *result;
if (orig_type == Item::REF_ITEM)
modify_item= 0;
/*
If item have to be able to store NULLs but underlaid field can't do it,
create_tmp_field_from_field() can't be used for tmp field creation.
*/
if (field->maybe_null && !field->field->maybe_null())
{
Field *res= create_tmp_field_from_item(thd, item, table, NULL,
result= create_tmp_field_from_item(thd, item, table, NULL,
modify_item, convert_blob_length);
*from_field= field->field;
if (res && modify_item)
((Item_field*)item)->result_field= res;
return res;
}
if (table_cant_handle_bit_fields &&
field->field->type() == FIELD_TYPE_BIT)
return create_tmp_field_from_item(thd, item, table, copy_func,
if (result && modify_item)
((Item_field*)item)->result_field= result;
}
else if (table_cant_handle_bit_fields && field->field->type() == FIELD_TYPE_BIT)
result= create_tmp_field_from_item(thd, item, table, copy_func,
modify_item, convert_blob_length);
return create_tmp_field_from_field(thd, (*from_field= field->field),
else
result= create_tmp_field_from_field(thd, (*from_field= field->field),
item->name, table,
modify_item ? (Item_field*) item :
NULL,
convert_blob_length);
if (orig_type == Item::REF_ITEM && orig_modify)
((Item_ref*)orig_item)->set_result_field(result);
return result;
}
/* Fall through */
case Item::FUNC_ITEM: