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 | |
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')
-rw-r--r-- | include/my_time.h | 21 | ||||
-rw-r--r-- | include/mysql.h.pp | 3 | ||||
-rw-r--r-- | include/mysql_com.h | 10 |
3 files changed, 31 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)) /* diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 02eb62655df..4b0edf56a72 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -49,6 +49,9 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_BIT, + MYSQL_TYPE_TIMESTAMP2, + MYSQL_TYPE_DATETIME2, + MYSQL_TYPE_TIME2, MYSQL_TYPE_NEWDECIMAL=246, MYSQL_TYPE_ENUM=247, MYSQL_TYPE_SET=248, diff --git a/include/mysql_com.h b/include/mysql_com.h index 0573bbe5f80..6e8350b0d75 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -400,6 +400,16 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_BIT, + /* + mysql-5.6 compatibility temporal types. + They're only used internally for reading RBR + mysql-5.6 binary log events and mysql-5.6 frm files. + They're never sent to the client. + */ + MYSQL_TYPE_TIMESTAMP2, + MYSQL_TYPE_DATETIME2, + MYSQL_TYPE_TIME2, + MYSQL_TYPE_NEWDECIMAL=246, MYSQL_TYPE_ENUM=247, MYSQL_TYPE_SET=248, |