Commit 556a9202 authored by Alexander Barkov's avatar Alexander Barkov

Cleanup: moving timestamp_to_TIME() as a method to THD

parent 17bbab5f
......@@ -1819,30 +1819,11 @@ int Field::store(const char *to, size_t length, CHARSET_INFO *cs,
}
static int timestamp_to_TIME(THD *thd, MYSQL_TIME *ltime, my_time_t ts,
ulong sec_part, ulonglong fuzzydate)
{
thd->time_zone_used= 1;
if (ts == 0 && sec_part == 0)
{
if (fuzzydate & TIME_NO_ZERO_DATE)
return 1;
set_zero_time(ltime, MYSQL_TIMESTAMP_DATETIME);
}
else
{
thd->variables.time_zone->gmt_sec_to_TIME(ltime, ts);
ltime->second_part= sec_part;
}
return 0;
}
int Field::store_timestamp(my_time_t ts, ulong sec_part)
{
MYSQL_TIME ltime;
THD *thd= get_thd();
timestamp_to_TIME(thd, &ltime, ts, sec_part, 0);
thd->timestamp_to_TIME(&ltime, ts, sec_part, 0);
return store_time_dec(&ltime, decimals());
}
......@@ -5316,7 +5297,7 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
ulong sec_part;
my_time_t ts= get_timestamp(&sec_part);
return timestamp_to_TIME(get_thd(), ltime, ts, sec_part, fuzzydate);
return get_thd()->timestamp_to_TIME(ltime, ts, sec_part, fuzzydate);
}
......
......@@ -7788,3 +7788,22 @@ Query_arena_stmt::~Query_arena_stmt()
if (arena)
thd->restore_active_arena(arena, &backup);
}
bool THD::timestamp_to_TIME(MYSQL_TIME *ltime, my_time_t ts,
ulong sec_part, ulonglong fuzzydate)
{
time_zone_used= 1;
if (ts == 0 && sec_part == 0)
{
if (fuzzydate & TIME_NO_ZERO_DATE)
return 1;
set_zero_time(ltime, MYSQL_TIMESTAMP_DATETIME);
}
else
{
variables.time_zone->gmt_sec_to_TIME(ltime, ts);
ltime->second_part= sec_part;
}
return 0;
}
......@@ -3427,6 +3427,8 @@ class THD :public Statement,
return !MY_TEST(variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES);
}
const Type_handler *type_handler_for_date() const;
bool timestamp_to_TIME(MYSQL_TIME *ltime, my_time_t ts,
ulong sec_part, ulonglong fuzzydate);
inline my_time_t query_start() { query_start_used=1; return start_time; }
inline ulong query_start_sec_part()
{ query_start_sec_part_used=1; return start_time_sec_part; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment