summaryrefslogtreecommitdiff
path: root/sql/sql_time.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2013-06-18 13:14:46 +0400
committerAlexander Barkov <bar@mariadb.org>2013-06-18 13:14:46 +0400
commit7cc77106792a2683f85e57f501c3a3be066a02a5 (patch)
treed59bb3c68d0ccbca49be6c1e9136535906c14473 /sql/sql_time.h
parentbe06b886a255e6d899341f55808172a219a85799 (diff)
parent4085836acf1b70738efe6d33a51e8d2ab9deb63f (diff)
downloadmariadb-git-7cc77106792a2683f85e57f501c3a3be066a02a5.tar.gz
Merging MDEV-4635 from 5.3.
Also, fixing a bug in STR_TO_DATE(). It erroneously returned error in strict mode for dates like '0000-01-01' (zero year, but non-zero month and day). According to the manual: - NO_ZERO_DATE disallows 0000-00-00 (all date parts are zeros) - NO_ZERO_IN_DATE disallows zero month (YYYY-00-DD) or day (YYYY-MM-00). 0000-01-01 is a valid date, even in strict mode. modified: mysql-test/r/func_time.result mysql-test/r/strict.result mysql-test/t/func_time.test mysql-test/t/strict.test sql/item_timefunc.cc sql/sql_time.h pending merges: Alexander Barkov 2013-06-17 MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DAT...
Diffstat (limited to 'sql/sql_time.h')
-rw-r--r--sql/sql_time.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/sql_time.h b/sql/sql_time.h
index c1a75bb2ad3..998d7d78da1 100644
--- a/sql/sql_time.h
+++ b/sql/sql_time.h
@@ -110,4 +110,16 @@ 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)
+{
+ return ltime->year || ltime->month || ltime->day;
+}
+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);
+}
+
#endif /* SQL_TIME_INCLUDED */