Skip to content

Commit

Permalink
cleanup: add Item::convert_time_to_datetime() helper
Browse files Browse the repository at this point in the history
will be used in following commits
  • Loading branch information
vuvova committed Mar 14, 2018
1 parent 75ac578 commit e0d3d40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 3 additions & 7 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,9 @@ bool Item::get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate)
if (get_date(ltime, fuzzydate | time_flag))
return true;
if (ltime->time_type == MYSQL_TIMESTAMP_TIME &&
!(fuzzydate & TIME_TIME_ONLY))
{
MYSQL_TIME tmp;
if (time_to_datetime_with_warn(thd, ltime, &tmp, fuzzydate))
return null_value= true;
*ltime= tmp;
}
!(fuzzydate & TIME_TIME_ONLY) &&
convert_time_to_datetime(thd, ltime, fuzzydate))
return true;
return false;
}

Expand Down
9 changes: 9 additions & 0 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "sql_const.h" /* RAND_TABLE_BIT, MAX_FIELD_NAME */
#include "field.h" /* Derivation */
#include "sql_type.h"
#include "sql_time.h"

C_MODE_START
#include <ma_dyncol.h>
Expand Down Expand Up @@ -1361,6 +1362,14 @@ class Item: public Value_source,
bool get_time(MYSQL_TIME *ltime)
{ return get_date(ltime, TIME_TIME_ONLY | TIME_INVALID_DATES); }
// Get date with automatic TIME->DATETIME conversion
bool convert_time_to_datetime(THD *thd, MYSQL_TIME *ltime, ulonglong fuzzydate)
{
MYSQL_TIME tmp;
if (time_to_datetime_with_warn(thd, ltime, &tmp, fuzzydate))
return null_value= true;
*ltime= tmp;
return false;
}
bool get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate);
/*
Get time with automatic DATE/DATETIME to TIME conversion.
Expand Down

0 comments on commit e0d3d40

Please sign in to comment.