mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge branch '11.4' into 11.5
This commit is contained in:
126
sql/sql_type.cc
126
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("tinyint unsigned");
|
||||
@ -4630,6 +4631,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
|
||||
@ -4639,6 +4644,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());
|
||||
@ -4936,6 +4956,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
|
||||
{
|
||||
@ -6378,6 +6405,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
|
||||
{
|
||||
@ -6599,6 +6634,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
|
||||
{
|
||||
@ -6709,6 +6752,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
|
||||
{
|
||||
@ -7194,6 +7253,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));
|
||||
@ -7781,7 +7852,7 @@ Type_handler_datetime_common::convert_item_for_comparison(
|
||||
Sql_condition **cond_hdl)
|
||||
{
|
||||
hit++;
|
||||
return *level == Sql_condition::WARN_LEVEL_WARN;
|
||||
return *level >= Sql_condition::WARN_LEVEL_WARN;
|
||||
}
|
||||
} cnt_handler;
|
||||
|
||||
@ -8293,6 +8364,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,
|
||||
@ -8951,41 +9042,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