mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Merge commit '43882e764d6867c6855b1ff057758a3f08b25c55' into 10.4
This commit is contained in:
@ -4153,53 +4153,24 @@ bool Type_handler_real_result::
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
MAX/MIN for the traditional numeric types preserve the exact data type
|
||||
from Fields, but do not preserve the exact type from Items:
|
||||
MAX(float_field) -> FLOAT
|
||||
MAX(smallint_field) -> LONGLONG
|
||||
MAX(COALESCE(float_field)) -> DOUBLE
|
||||
MAX(COALESCE(smallint_field)) -> LONGLONG
|
||||
QQ: Items should probably be fixed to preserve the exact type.
|
||||
*/
|
||||
bool Type_handler_numeric::
|
||||
Item_sum_hybrid_fix_length_and_dec_numeric(Item_sum_hybrid *func,
|
||||
const Type_handler *handler)
|
||||
const
|
||||
{
|
||||
Item *item= func->arguments()[0];
|
||||
Item *item2= item->real_item();
|
||||
func->Type_std_attributes::set(item);
|
||||
/* MIN/MAX can return NULL for empty set indepedent of the used column */
|
||||
func->maybe_null= func->null_value= true;
|
||||
if (item2->type() == Item::FIELD_ITEM)
|
||||
func->set_handler(item2->type_handler());
|
||||
else
|
||||
func->set_handler(handler);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_int_result::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
return Item_sum_hybrid_fix_length_and_dec_numeric(func,
|
||||
&type_handler_longlong);
|
||||
return func->fix_length_and_dec_numeric(&type_handler_longlong);
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_bool::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
return Item_sum_hybrid_fix_length_and_dec_numeric(func, &type_handler_bool);
|
||||
return func->fix_length_and_dec_numeric(&type_handler_bool);
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_real_result::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
(void) Item_sum_hybrid_fix_length_and_dec_numeric(func,
|
||||
&type_handler_double);
|
||||
(void) func->fix_length_and_dec_numeric(&type_handler_double);
|
||||
func->max_length= func->float_length(func->decimals);
|
||||
return false;
|
||||
}
|
||||
@ -4208,53 +4179,21 @@ bool Type_handler_real_result::
|
||||
bool Type_handler_decimal_result::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
return Item_sum_hybrid_fix_length_and_dec_numeric(func,
|
||||
&type_handler_newdecimal);
|
||||
return func->fix_length_and_dec_numeric(&type_handler_newdecimal);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
MAX(str_field) converts ENUM/SET to CHAR, and preserve all other types
|
||||
for Fields.
|
||||
QQ: This works differently from UNION, which preserve the exact data
|
||||
type for ENUM/SET if the joined ENUM/SET fields are equally defined.
|
||||
Perhaps should be fixed.
|
||||
MAX(str_item) chooses the best suitable string type.
|
||||
*/
|
||||
bool Type_handler_string_result::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
Item *item= func->arguments()[0];
|
||||
Item *item2= item->real_item();
|
||||
func->Type_std_attributes::set(item);
|
||||
func->maybe_null= func->null_value= true;
|
||||
if (item2->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
// Fields: convert ENUM/SET to CHAR, preserve the type otherwise.
|
||||
func->set_handler(item->type_handler());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Items: choose VARCHAR/BLOB/MEDIUMBLOB/LONGBLOB, depending on length.
|
||||
func->set_handler(type_handler_varchar.
|
||||
type_handler_adjusted_to_max_octet_length(func->max_length,
|
||||
func->collation.collation));
|
||||
}
|
||||
return false;
|
||||
return func->fix_length_and_dec_string();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Traditional temporal types always preserve the type of the argument.
|
||||
*/
|
||||
bool Type_handler_temporal_result::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
Item *item= func->arguments()[0];
|
||||
func->Type_std_attributes::set(item);
|
||||
func->maybe_null= func->null_value= true;
|
||||
func->set_handler(item->type_handler());
|
||||
return false;
|
||||
return func->fix_length_and_dec_generic();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user