summaryrefslogtreecommitdiff
path: root/sql-common/my_time.c
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2014-03-07 00:21:25 +0400
committerAlexander Barkov <bar@mnogosearch.org>2014-03-07 00:21:25 +0400
commit89e171535563dcdf1eeb309e54abc4da2f5dd539 (patch)
tree79331d73d127f4226b274e86f476ba1f86c721e9 /sql-common/my_time.c
parentb95c8ce530cbbd92b232324dc2c4376615bd1b5d (diff)
downloadmariadb-git-89e171535563dcdf1eeb309e54abc4da2f5dd539.tar.gz
MDEV-5372 Make "CAST(time_expr AS DATETIME)" compatible with MySQL-5.6 (and the SQL Standard)
Diffstat (limited to 'sql-common/my_time.c')
-rw-r--r--sql-common/my_time.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 429506f4034..0942544d0be 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -81,6 +81,8 @@ uint calc_days_in_year(uint year)
my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
ulonglong flags, int *was_cut)
{
+ if (ltime->time_type == MYSQL_TIMESTAMP_TIME)
+ return FALSE;
if (not_zero_date)
{
if (((flags & TIME_NO_ZERO_IN_DATE) &&
@@ -917,7 +919,8 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, uint *error_code)
#endif
tmp= (time_t) (((calc_daynr((uint) t->year, (uint) t->month, (uint) t->day) -
- (long) days_at_timestart)*86400L + (long) t->hour*3600L +
+ (long) days_at_timestart) * SECONDS_IN_24H +
+ (long) t->hour*3600L +
(long) (t->minute*60 + t->second)) + (time_t) my_time_zone -
3600);
@@ -976,7 +979,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, uint *error_code)
/* shift back, if we were dealing with boundary dates */
- tmp+= shift*86400L;
+ tmp+= shift * SECONDS_IN_24H;
/*
This is possible for dates, which slightly exceed boundaries.