1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
Alexander Barkov
2018-10-01 12:34:03 +04:00
parent f79bab3ae6
commit e5aebc1408
7 changed files with 46 additions and 11 deletions

View File

@ -285,7 +285,9 @@ public:
*warn= MYSQL_TIME_WARN_OUT_OF_RANGE;
return true;
}
return number_to_datetime(m_sec, m_usec, to, ulonglong(flags), warn) == -1;
return number_to_datetime(m_sec, m_usec, to,
ulonglong(flags & TIME_MODE_FOR_XXX_TO_DATE),
warn) == -1;
}
// Convert elapsed seconds to TIME
bool sec_to_time(MYSQL_TIME *ltime, uint dec) const
@ -1230,7 +1232,9 @@ public:
bool check_date(date_mode_t flags, int *warnings) const
{
DBUG_ASSERT(is_valid_datetime_slow());
return ::check_date(this, (year || month || day), ulonglong(flags), warnings);
return ::check_date(this, (year || month || day),
ulonglong(flags & TIME_MODE_FOR_XXX_TO_DATE),
warnings);
}
bool check_date(date_mode_t flags) const
{