mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-15205 Remove mysql_type_to_time_type()
This commit is contained in:
13
sql/field.cc
13
sql/field.cc
@@ -5489,11 +5489,9 @@ void Field_temporal::set_warnings(Sql_condition::enum_warning_level trunc_level,
|
|||||||
a DATE field and non-zero time part is thrown away.
|
a DATE field and non-zero time part is thrown away.
|
||||||
*/
|
*/
|
||||||
if (was_cut & MYSQL_TIME_WARN_TRUNCATED)
|
if (was_cut & MYSQL_TIME_WARN_TRUNCATED)
|
||||||
set_datetime_warning(trunc_level, WARN_DATA_TRUNCATED,
|
set_datetime_warning(trunc_level, WARN_DATA_TRUNCATED, str, ts_type, 1);
|
||||||
str, mysql_type_to_time_type(type()), 1);
|
|
||||||
if (was_cut & MYSQL_TIME_WARN_OUT_OF_RANGE)
|
if (was_cut & MYSQL_TIME_WARN_OUT_OF_RANGE)
|
||||||
set_datetime_warning(ER_WARN_DATA_OUT_OF_RANGE,
|
set_datetime_warning(ER_WARN_DATA_OUT_OF_RANGE, str, ts_type, 1);
|
||||||
str, mysql_type_to_time_type(type()), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5529,14 +5527,15 @@ int Field_temporal_with_date::store_TIME_with_warning(MYSQL_TIME *ltime,
|
|||||||
}
|
}
|
||||||
else if (!MYSQL_TIME_WARN_HAVE_WARNINGS(was_cut) &&
|
else if (!MYSQL_TIME_WARN_HAVE_WARNINGS(was_cut) &&
|
||||||
(MYSQL_TIME_WARN_HAVE_NOTES(was_cut) ||
|
(MYSQL_TIME_WARN_HAVE_NOTES(was_cut) ||
|
||||||
(mysql_type_to_time_type(type()) == MYSQL_TIMESTAMP_DATE &&
|
(type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_DATE &&
|
||||||
(ltime->hour || ltime->minute || ltime->second || ltime->second_part))))
|
(ltime->hour || ltime->minute || ltime->second || ltime->second_part))))
|
||||||
{
|
{
|
||||||
trunc_level= Sql_condition::WARN_LEVEL_NOTE;
|
trunc_level= Sql_condition::WARN_LEVEL_NOTE;
|
||||||
was_cut|= MYSQL_TIME_WARN_TRUNCATED;
|
was_cut|= MYSQL_TIME_WARN_TRUNCATED;
|
||||||
ret= 3;
|
ret= 3;
|
||||||
}
|
}
|
||||||
set_warnings(trunc_level, str, was_cut, mysql_type_to_time_type(type()));
|
set_warnings(trunc_level, str, was_cut,
|
||||||
|
type_handler()->mysql_timestamp_type());
|
||||||
store_TIME(ltime);
|
store_TIME(ltime);
|
||||||
return was_cut ? ret : 0;
|
return was_cut ? ret : 0;
|
||||||
}
|
}
|
||||||
@@ -5626,7 +5625,7 @@ my_decimal *Field_temporal::val_decimal(my_decimal *d)
|
|||||||
if (get_date(<ime, 0))
|
if (get_date(<ime, 0))
|
||||||
{
|
{
|
||||||
bzero(<ime, sizeof(ltime));
|
bzero(<ime, sizeof(ltime));
|
||||||
ltime.time_type= mysql_type_to_time_type(type());
|
ltime.time_type= type_handler()->mysql_timestamp_type();
|
||||||
}
|
}
|
||||||
return TIME_to_my_decimal(<ime, d);
|
return TIME_to_my_decimal(<ime, d);
|
||||||
}
|
}
|
||||||
|
31
sql/field.h
31
sql/field.h
@@ -488,37 +488,6 @@ inline enum_field_types real_type_to_type(enum_field_types real_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline enum enum_mysql_timestamp_type
|
|
||||||
mysql_type_to_time_type(enum enum_field_types mysql_type)
|
|
||||||
{
|
|
||||||
switch(mysql_type) {
|
|
||||||
case MYSQL_TYPE_TIME2:
|
|
||||||
case MYSQL_TYPE_TIME: return MYSQL_TIMESTAMP_TIME;
|
|
||||||
case MYSQL_TYPE_TIMESTAMP2:
|
|
||||||
case MYSQL_TYPE_TIMESTAMP:
|
|
||||||
case MYSQL_TYPE_DATETIME2:
|
|
||||||
case MYSQL_TYPE_DATETIME: return MYSQL_TIMESTAMP_DATETIME;
|
|
||||||
case MYSQL_TYPE_NEWDATE:
|
|
||||||
case MYSQL_TYPE_DATE: return MYSQL_TIMESTAMP_DATE;
|
|
||||||
default: return MYSQL_TIMESTAMP_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Tests if field type is temporal, i.e. represents
|
|
||||||
DATE, TIME, DATETIME or TIMESTAMP types in SQL.
|
|
||||||
|
|
||||||
@param type Field type, as returned by field->type().
|
|
||||||
@retval true If field type is temporal
|
|
||||||
@retval false If field type is not temporal
|
|
||||||
*/
|
|
||||||
inline bool is_temporal_type(enum_field_types type)
|
|
||||||
{
|
|
||||||
return mysql_type_to_time_type(type) != MYSQL_TIMESTAMP_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
enum enum_vcol_info_type
|
enum enum_vcol_info_type
|
||||||
{
|
{
|
||||||
VCOL_GENERATED_VIRTUAL, VCOL_GENERATED_STORED,
|
VCOL_GENERATED_VIRTUAL, VCOL_GENERATED_STORED,
|
||||||
|
@@ -357,19 +357,19 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part,
|
|||||||
{
|
{
|
||||||
int was_cut;
|
int was_cut;
|
||||||
longlong res;
|
longlong res;
|
||||||
enum_field_types f_type;
|
enum_mysql_timestamp_type ts_type;
|
||||||
bool have_warnings;
|
bool have_warnings;
|
||||||
|
|
||||||
if (fuzzydate & TIME_TIME_ONLY)
|
if (fuzzydate & TIME_TIME_ONLY)
|
||||||
{
|
{
|
||||||
fuzzydate= TIME_TIME_ONLY; // clear other flags
|
fuzzydate= TIME_TIME_ONLY; // clear other flags
|
||||||
f_type= MYSQL_TYPE_TIME;
|
ts_type= MYSQL_TIMESTAMP_TIME;
|
||||||
res= number_to_time(neg, nr, sec_part, ltime, &was_cut);
|
res= number_to_time(neg, nr, sec_part, ltime, &was_cut);
|
||||||
have_warnings= MYSQL_TIME_WARN_HAVE_WARNINGS(was_cut);
|
have_warnings= MYSQL_TIME_WARN_HAVE_WARNINGS(was_cut);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f_type= MYSQL_TYPE_DATETIME;
|
ts_type= MYSQL_TIMESTAMP_DATETIME;
|
||||||
if (neg)
|
if (neg)
|
||||||
{
|
{
|
||||||
res= -1;
|
res= -1;
|
||||||
@@ -385,8 +385,7 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part,
|
|||||||
{
|
{
|
||||||
make_truncated_value_warning(current_thd,
|
make_truncated_value_warning(current_thd,
|
||||||
Sql_condition::WARN_LEVEL_WARN, str,
|
Sql_condition::WARN_LEVEL_WARN, str,
|
||||||
res < 0 ? MYSQL_TIMESTAMP_ERROR
|
res < 0 ? MYSQL_TIMESTAMP_ERROR : ts_type,
|
||||||
: mysql_type_to_time_type(f_type),
|
|
||||||
field_name);
|
field_name);
|
||||||
}
|
}
|
||||||
return res < 0;
|
return res < 0;
|
||||||
|
Reference in New Issue
Block a user