diff options
author | Alexander Barkov <bar@mariadb.org> | 2013-07-10 11:49:17 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2013-07-10 11:49:17 +0400 |
commit | 5b0774ee1c5a32ef694ce18413fa003bc6646c48 (patch) | |
tree | 8fb45c65fcf34d2f7e7288a8971a1a38c1200a3a /include/my_time.h | |
parent | 99019afccc2b60ba0f65df70c1f59288744b3608 (diff) | |
download | mariadb-git-5b0774ee1c5a32ef694ce18413fa003bc6646c48.tar.gz |
Adding support for MySQL-5.6 temporal column types:
TIME, DATETIME, TIMESTAMP
added:
mysql-test/r/type_temporal_mysql56.result
mysql-test/std_data/mysql56datetime.MYD
mysql-test/std_data/mysql56datetime.MYI
mysql-test/std_data/mysql56datetime.frm
mysql-test/std_data/mysql56time.MYD
mysql-test/std_data/mysql56time.MYI
mysql-test/std_data/mysql56time.frm
mysql-test/std_data/mysql56timestamp.MYD
mysql-test/std_data/mysql56timestamp.MYI
mysql-test/std_data/mysql56timestamp.frm
mysql-test/suite/rpl/r/rpl_temporal_mysql56.result
mysql-test/suite/rpl/t/rpl_temporal_mysql56.test
mysql-test/t/type_temporal_mysql56.test
sql/compat56.cc
sql/compat56.h
modified:
client/mysqlbinlog.cc
include/my_time.h
include/mysql.h.pp
include/mysql_com.h
mysql-test/r/statistics.result
mysql-test/r/strict.result
mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
sql-common/my_time.c
sql/CMakeLists.txt
sql/field.cc
sql/field.h
sql/item.cc
sql/item_strfunc.cc
sql/item_sum.cc
sql/item_timefunc.cc
sql/log_event.cc
sql/opt_range.cc
sql/opt_table_elimination.cc
sql/protocol.cc
sql/rpl_utility.cc
sql/rpl_utility.h
sql/sql_partition.cc
sql/sql_prepare.cc
sql/sql_select.cc
sql/sql_table.cc
sql/table.cc
storage/perfschema/pfs_engine_table.cc
Diffstat (limited to 'include/my_time.h')
-rw-r--r-- | include/my_time.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/include/my_time.h b/include/my_time.h index 046b5c94923..d8a8d0b5ed3 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -111,6 +111,8 @@ longlong pack_time(MYSQL_TIME *my_time); MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time); int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning); +my_bool check_datetime_range(const MYSQL_TIME *ltime); + long calc_daynr(uint year,uint month,uint day); uint calc_days_in_year(uint year); @@ -163,6 +165,8 @@ int my_date_to_str(const MYSQL_TIME *l_time, char *to); int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, uint digits); int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, uint digits); +int my_timeval_to_str(const struct timeval *tm, char *to, uint dec); + static inline longlong sec_part_shift(longlong second_part, uint digits) { return second_part / (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; @@ -171,12 +175,23 @@ static inline longlong sec_part_unshift(longlong second_part, uint digits) { return second_part * (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; } -static inline ulong sec_part_truncate(ulong second_part, uint digits) + +/* Date/time rounding and truncation functions */ +static inline long my_time_fraction_remainder(long nr, uint decimals) +{ + DBUG_ASSERT(decimals <= TIME_SECOND_PART_DIGITS); + return nr % (long) log_10_int[TIME_SECOND_PART_DIGITS - decimals]; +} +static inline void my_time_trunc(MYSQL_TIME *ltime, uint decimals) +{ + ltime->second_part-= my_time_fraction_remainder(ltime->second_part, decimals); +} +static inline void my_timeval_trunc(struct timeval *tv, uint decimals) { - /* the cast here should be unnecessary! */ - return second_part - second_part % (ulong)log_10_int[TIME_SECOND_PART_DIGITS - digits]; + tv->tv_usec-= my_time_fraction_remainder(tv->tv_usec, decimals); } + #define hrtime_to_my_time(X) ((my_time_t)hrtime_to_time(X)) /* |