1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Bug#32848: Data type conversion bug in union subselects in MySQL 5.0.38

There were two problems when inferring the correct field types resulting from
UNION queries.
- If the type is NULL for all corresponding fields in the UNION, the resulting 
  type would be NULL, while the type is BINARY(0) if there is just a single 
  SELECT NULL.
- If one SELECT in the UNION uses a subselect, a temporary table is created
  to represent the subselect, and the result type defaults to a STRING type,
  hiding the fact that the type was unknown(just a NULL value).
Fixed by remembering whenever a field was created from a NULL value and pass
type NULL to the type coercion if that is the case, and creating a string field
as result of UNION only if the type would otherwise be NULL.
This commit is contained in:
mhansson/martin@linux-st28.site
2007-12-11 20:15:03 +01:00
parent 7f67efccef
commit 867a786549
6 changed files with 66 additions and 1 deletions

View File

@@ -8974,6 +8974,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
*((*copy_func)++) = item; // Save for copy_funcs
if (modify_item)
item->set_result_field(new_field);
if (item->type() == MYSQL_TYPE_NULL)
new_field->is_created_from_null_item= TRUE;
return new_field;
}