summaryrefslogtreecommitdiff
path: root/sql/sql_time.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-10-01 12:34:03 +0400
committerAlexander Barkov <bar@mariadb.com>2018-10-01 12:34:03 +0400
commite5aebc1408f1413f6251400956da872c9b4f51b6 (patch)
treea69ac2523b4fea8915cb62490c9033da7cb154f8 /sql/sql_time.h
parentf79bab3ae68393cb2f36fa83546e8ea02b7d0420 (diff)
downloadmariadb-git-e5aebc1408f1413f6251400956da872c9b4f51b6.tar.gz
A cleanup for MDEV-17317 Add THD* parameter into Item::get_date() and stricter data type control to "fuzzydate"
Fixing C++ function check_date() to get the "fuzzydate" as date_mode_t rather than ulonglong, so conversion from date_time_t to ulonglong is now done inside C++ check_date(), and no conversion is needed in the callers' code. As an additional safety, modified the code not to pass TIME_FUZZY_DATE to the low level C functions: - check_date() - str_to_datetime() - str_to_time() - number_to_datetime() because TIME_FUZZY_DATE is known only on the C++ level, C functions do not know it. Soon we'll be adding more flags into the C++ level (i.e. to date_time_t), e.g. for rounding. It's a good idea to prevent passing C++ specific flags into pure C routines before this change. Asserts were added into the affected C functions to verify that the caller passed only known C level flags.
Diffstat (limited to 'sql/sql_time.h')
-rw-r--r--sql/sql_time.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/sql_time.h b/sql/sql_time.h
index f9edf661240..f113962b596 100644
--- a/sql/sql_time.h
+++ b/sql/sql_time.h
@@ -167,9 +167,10 @@ non_zero_date(const MYSQL_TIME *ltime)
non_zero_hhmmssuu(ltime));
}
static inline bool
-check_date(const MYSQL_TIME *ltime, ulonglong flags, int *was_cut)
+check_date(const MYSQL_TIME *ltime, date_mode_t flags, int *was_cut)
{
- return check_date(ltime, non_zero_date(ltime), flags, was_cut);
+ return check_date(ltime, non_zero_date(ltime),
+ ulonglong(flags & TIME_MODE_FOR_XXX_TO_DATE), was_cut);
}
bool check_date_with_warn(THD *thd, const MYSQL_TIME *ltime, date_mode_t fuzzy_date,
timestamp_type ts_type);