mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge remote-tracking branch 'origin/10.4' into 10.5
This commit is contained in:
100
sql/sql_type.cc
100
sql/sql_type.cc
@ -734,6 +734,23 @@ uint Interval_DDhhmmssff::fsp(THD *thd, Item *item)
|
||||
}
|
||||
|
||||
|
||||
bool Time::to_native(Native *to, uint decimals) const
|
||||
{
|
||||
if (!is_valid_time())
|
||||
{
|
||||
to->length(0);
|
||||
return true;
|
||||
}
|
||||
uint len= my_time_binary_length(decimals);
|
||||
if (to->reserve(len))
|
||||
return true;
|
||||
longlong tmp= TIME_to_longlong_time_packed(get_mysql_time());
|
||||
my_time_packed_to_binary(tmp, (uchar*) to->ptr(), decimals);
|
||||
to->length(len);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Time::make_from_item(THD *thd, int *warn, Item *item, const Options opt)
|
||||
{
|
||||
*warn= 0;
|
||||
@ -918,6 +935,28 @@ void Time::make_from_time(int *warn, const MYSQL_TIME *from)
|
||||
}
|
||||
|
||||
|
||||
uint Time::binary_length_to_precision(uint length)
|
||||
{
|
||||
switch (length) {
|
||||
case 3: return 0;
|
||||
case 4: return 2;
|
||||
case 5: return 4;
|
||||
case 6: return 6;
|
||||
}
|
||||
DBUG_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Time::Time(const Native &native)
|
||||
{
|
||||
uint dec= binary_length_to_precision(native.length());
|
||||
longlong tmp= my_time_packed_from_binary((const uchar *) native.ptr(), dec);
|
||||
TIME_from_longlong_time_packed(this, tmp);
|
||||
DBUG_ASSERT(is_valid_time());
|
||||
}
|
||||
|
||||
|
||||
Time::Time(int *warn, const MYSQL_TIME *from, long curdays)
|
||||
{
|
||||
switch (from->time_type) {
|
||||
@ -1685,6 +1724,13 @@ Type_handler_timestamp_common::type_handler_for_native_format() const
|
||||
}
|
||||
|
||||
|
||||
const Type_handler *
|
||||
Type_handler_time_common::type_handler_for_native_format() const
|
||||
{
|
||||
return &type_handler_time2;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
const Type_handler *Type_handler_typelib::type_handler_for_item_field() const
|
||||
@ -8820,6 +8866,51 @@ Type_handler_time_common::create_literal_item(THD *thd,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Type_handler_time_common::Item_val_native_with_conversion(THD *thd,
|
||||
Item *item,
|
||||
Native *to) const
|
||||
{
|
||||
if (item->type_handler()->type_handler_for_native_format() ==
|
||||
&type_handler_time2)
|
||||
return item->val_native(thd, to);
|
||||
return Time(thd, item).to_native(to, item->time_precision(thd));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Type_handler_time_common::Item_val_native_with_conversion_result(THD *thd,
|
||||
Item *item,
|
||||
Native *to)
|
||||
const
|
||||
{
|
||||
if (item->type_handler()->type_handler_for_native_format() ==
|
||||
&type_handler_time2)
|
||||
return item->val_native_result(thd, to);
|
||||
MYSQL_TIME ltime;
|
||||
if (item->get_date_result(thd, <ime, Time::Options(thd)))
|
||||
return true;
|
||||
int warn;
|
||||
return Time(&warn, <ime, 0).to_native(to, item->time_precision(thd));
|
||||
}
|
||||
|
||||
|
||||
int Type_handler_time_common::cmp_native(const Native &a,
|
||||
const Native &b) const
|
||||
{
|
||||
// Optimize a simple case: equal fractional precision:
|
||||
if (a.length() == b.length())
|
||||
return memcmp(a.ptr(), b.ptr(), a.length());
|
||||
longlong lla= Time(a).to_packed();
|
||||
longlong llb= Time(b).to_packed();
|
||||
if (lla < llb)
|
||||
return -1;
|
||||
if (lla> llb)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool Type_handler_timestamp_common::TIME_to_native(THD *thd,
|
||||
const MYSQL_TIME *ltime,
|
||||
Native *to,
|
||||
@ -8930,6 +9021,15 @@ Type_handler_timestamp_common::Item_param_val_native(THD *thd,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Type_handler_time_common::Item_param_val_native(THD *thd,
|
||||
Item_param *item,
|
||||
Native *to) const
|
||||
{
|
||||
return Time(thd, item).to_native(to, item->decimals);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
bool Type_handler::validate_implicit_default_value(THD *thd,
|
||||
|
Reference in New Issue
Block a user