summaryrefslogtreecommitdiff
path: root/sql/sql_time.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2015-07-08 19:20:07 +0400
committerAlexander Barkov <bar@mariadb.org>2015-07-08 19:20:07 +0400
commit77803703431d79f5dcc2b23b3f878dfdbaf01c2b (patch)
treef372def78612580f0089ff4ce976fd8911b57198 /sql/sql_time.h
parent8154ef4b16fe140a42f3e90903192bb3b0fec041 (diff)
downloadmariadb-git-77803703431d79f5dcc2b23b3f878dfdbaf01c2b.tar.gz
MDEV-8336 The meaning of NO_ZERO_DATE is not clear for DATETIME.
In some cases NO_ZERO_DATE did not allow datetime values with zero date part and non-zero time part (e.g. '0000-00-00 10:20:30.123456'). Allowing values of this kind in all known pieces of the code.
Diffstat (limited to 'sql/sql_time.h')
-rw-r--r--sql/sql_time.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/sql/sql_time.h b/sql/sql_time.h
index dc8e4668e1e..8e13ee1870a 100644
--- a/sql/sql_time.h
+++ b/sql/sql_time.h
@@ -143,13 +143,24 @@ extern DATE_TIME_FORMAT global_time_format;
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
extern LEX_STRING interval_type_to_name[];
-
static inline bool
-non_zero_date(const MYSQL_TIME *ltime)
+non_zero_hhmmssuu(const MYSQL_TIME *ltime)
+{
+ return ltime->hour || ltime->minute || ltime->second || ltime->second_part;
+}
+static inline bool
+non_zero_YYMMDD(const MYSQL_TIME *ltime)
{
return ltime->year || ltime->month || ltime->day;
}
static inline bool
+non_zero_date(const MYSQL_TIME *ltime)
+{
+ return non_zero_YYMMDD(ltime) ||
+ (ltime->time_type == MYSQL_TIMESTAMP_DATETIME &&
+ non_zero_hhmmssuu(ltime));
+}
+static inline bool
check_date(const MYSQL_TIME *ltime, ulonglong flags, int *was_cut)
{
return check_date(ltime, non_zero_date(ltime), flags, was_cut);