mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge branch '11.2' into 11.4
This commit is contained in:
124
sql/sql_type.cc
124
sql/sql_type.cc
@ -41,6 +41,7 @@ Named_type_handler<Type_handler_bool> type_handler_bool("boolean");
|
||||
Named_type_handler<Type_handler_tiny> type_handler_stiny("tinyint");
|
||||
Named_type_handler<Type_handler_short> type_handler_sshort("smallint");
|
||||
Named_type_handler<Type_handler_long> type_handler_slong("int");
|
||||
Named_type_handler<Type_handler_long_ge0> type_handler_slong_ge0("int");
|
||||
Named_type_handler<Type_handler_int24> type_handler_sint24("mediumint");
|
||||
Named_type_handler<Type_handler_longlong> type_handler_slonglong("bigint");
|
||||
Named_type_handler<Type_handler_utiny> type_handler_utiny("tiny unsigned");
|
||||
@ -4627,6 +4628,10 @@ bool Type_handler_general_purpose_int::
|
||||
bool unsigned_flag= items[0]->unsigned_flag;
|
||||
for (uint i= 1; i < nitems; i++)
|
||||
{
|
||||
/*
|
||||
TODO: avoid creating DECIMAL for a mix of ulong and slong_ge0.
|
||||
It's too late for 10.5. Let's do it in a higher version.
|
||||
*/
|
||||
if (unsigned_flag != items[i]->unsigned_flag)
|
||||
{
|
||||
// Convert a mixture of signed and unsigned int to decimal
|
||||
@ -4636,6 +4641,21 @@ bool Type_handler_general_purpose_int::
|
||||
}
|
||||
}
|
||||
func->aggregate_attributes_int(items, nitems);
|
||||
for (uint i= 0; i < nitems; i++)
|
||||
{
|
||||
if (items[i]->type_handler() == &type_handler_slong_ge0)
|
||||
{
|
||||
/*
|
||||
A slong_ge0 argument found.
|
||||
We need to add an extra character for the sign.
|
||||
TODO: rewrite aggregate_attributes_int() to find
|
||||
the maximum decimal_precision() instead of the maximum max_length.
|
||||
This change is too late for 10.5, so let's do it in a higher version.
|
||||
*/
|
||||
uint digits_and_sign= items[i]->decimal_precision() + 1;
|
||||
set_if_bigger(func->max_length, digits_and_sign);
|
||||
}
|
||||
}
|
||||
handler->set_handler(func->unsigned_flag ?
|
||||
handler->type_handler()->type_handler_unsigned() :
|
||||
handler->type_handler()->type_handler_signed());
|
||||
@ -4931,6 +4951,13 @@ bool Type_handler_real_result::
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
bool Type_handler_long_ge0::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
return func->fix_length_and_dec_sint_ge0();
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_int_result::
|
||||
Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const
|
||||
{
|
||||
@ -6373,6 +6400,14 @@ bool Type_handler_int_result::
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_long_ge0::
|
||||
Item_func_round_fix_length_and_dec(Item_func_round *item) const
|
||||
{
|
||||
item->fix_arg_slong_ge0();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_year::
|
||||
Item_func_round_fix_length_and_dec(Item_func_round *item) const
|
||||
{
|
||||
@ -6594,6 +6629,14 @@ bool Type_handler_int_result::
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_long_ge0::
|
||||
Item_func_abs_fix_length_and_dec(Item_func_abs *item) const
|
||||
{
|
||||
item->fix_length_and_dec_sint_ge0();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_real_result::
|
||||
Item_func_abs_fix_length_and_dec(Item_func_abs *item) const
|
||||
{
|
||||
@ -6704,6 +6747,22 @@ bool Type_handler::
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_long_ge0::
|
||||
Item_func_signed_fix_length_and_dec(Item_func_signed *item) const
|
||||
{
|
||||
item->fix_length_and_dec_sint_ge0();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_long_ge0::
|
||||
Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const
|
||||
{
|
||||
item->fix_length_and_dec_sint_ge0();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_string_result::
|
||||
Item_func_signed_fix_length_and_dec(Item_func_signed *item) const
|
||||
{
|
||||
@ -7189,6 +7248,18 @@ decimal_digits_t Type_handler_int_result::Item_decimal_precision(const Item *ite
|
||||
return (decimal_digits_t) MY_MIN(prec, DECIMAL_MAX_PRECISION);
|
||||
}
|
||||
|
||||
decimal_digits_t Type_handler_long_ge0::Item_decimal_precision(const Item *item) const
|
||||
{
|
||||
DBUG_ASSERT(item->max_length);
|
||||
DBUG_ASSERT(!item->decimals);
|
||||
/*
|
||||
Unlinke in Type_handler_long, Type_handler_long_ge does
|
||||
not reserve one character for the sign. All max_length
|
||||
characters are digits.
|
||||
*/
|
||||
return MY_MIN(item->max_length, DECIMAL_MAX_PRECISION);
|
||||
}
|
||||
|
||||
decimal_digits_t Type_handler_time_common::Item_decimal_precision(const Item *item) const
|
||||
{
|
||||
return (decimal_digits_t) (7 + MY_MIN(item->decimals, TIME_SECOND_PART_DIGITS));
|
||||
@ -8288,6 +8359,26 @@ Field *Type_handler_long::
|
||||
}
|
||||
|
||||
|
||||
Field *Type_handler_long_ge0::
|
||||
make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *mem_root,
|
||||
const LEX_CSTRING *name,
|
||||
const Record_addr &rec, const Bit_addr &bit,
|
||||
const Column_definition_attributes *attr,
|
||||
uint32 flags) const
|
||||
{
|
||||
/*
|
||||
We're converting signed long_ge0 to signed long.
|
||||
So add one character for the sign.
|
||||
*/
|
||||
return new (mem_root)
|
||||
Field_long(rec.ptr(), (uint32) attr->length + 1/*sign*/,
|
||||
rec.null_ptr(), rec.null_bit(),
|
||||
attr->unireg_check, name,
|
||||
f_is_zerofill(attr->pack_flag) != 0,
|
||||
f_is_dec(attr->pack_flag) == 0);
|
||||
}
|
||||
|
||||
|
||||
Field *Type_handler_longlong::
|
||||
make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *mem_root,
|
||||
const LEX_CSTRING *name,
|
||||
@ -8946,41 +9037,48 @@ bool Type_handler_string_result::union_element_finalize(Item_type_holder* item)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void Type_handler_var_string::
|
||||
Column_definition_implicit_upgrade(Column_definition *c) const
|
||||
|
||||
const Type_handler *
|
||||
Type_handler_var_string::type_handler_for_implicit_upgrade() const
|
||||
{
|
||||
// Change old VARCHAR to new VARCHAR
|
||||
c->set_handler(&type_handler_varchar);
|
||||
return &type_handler_varchar;
|
||||
}
|
||||
|
||||
|
||||
void Type_handler::
|
||||
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
|
||||
{
|
||||
old->set_handler(this);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_time_common::
|
||||
Column_definition_implicit_upgrade(Column_definition *c) const
|
||||
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
|
||||
{
|
||||
if (opt_mysql56_temporal_format)
|
||||
c->set_handler(&type_handler_time2);
|
||||
old->set_handler(&type_handler_time2);
|
||||
else
|
||||
c->set_handler(&type_handler_time);
|
||||
old->set_handler(&type_handler_time);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_datetime_common::
|
||||
Column_definition_implicit_upgrade(Column_definition *c) const
|
||||
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
|
||||
{
|
||||
if (opt_mysql56_temporal_format)
|
||||
c->set_handler(&type_handler_datetime2);
|
||||
old->set_handler(&type_handler_datetime2);
|
||||
else
|
||||
c->set_handler(&type_handler_datetime);
|
||||
old->set_handler(&type_handler_datetime);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_timestamp_common::
|
||||
Column_definition_implicit_upgrade(Column_definition *c) const
|
||||
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
|
||||
{
|
||||
if (opt_mysql56_temporal_format)
|
||||
c->set_handler(&type_handler_timestamp2);
|
||||
old->set_handler(&type_handler_timestamp2);
|
||||
else
|
||||
c->set_handler(&type_handler_timestamp);
|
||||
old->set_handler(&type_handler_timestamp);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user