summaryrefslogtreecommitdiff
path: root/include/my_time.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-05-19 19:01:46 +0200
committerSergei Golubchik <sergii@pisem.net>2011-05-19 19:01:46 +0200
commit8ddcd0cda8e6e90a58e9ea64f0f3773ea0037f0b (patch)
tree4765748aeb7aafb09e259e1a355e28c11819e9c0 /include/my_time.h
parent5346cb8d2745acd660b301092458e231c9f53319 (diff)
downloadmariadb-git-8ddcd0cda8e6e90a58e9ea64f0f3773ea0037f0b.tar.gz
post-review changes 1
include/my_time.h: remove duplicate defines. cast to ulonglong to avoid overflow sql/field.cc: perform sign extension when reading packed TIME values sql/item_cmpfunc.cc: when converting a string to a date for the purpose of comparing it with another date, we should ignore strict sql mode. sql/item_timefunc.cc: better error message sql/item_timefunc.h: limit decimals appropriately sql/share/errmsg.txt: don't refer to an object as a "column" in error messages that are used not only for columns.
Diffstat (limited to 'include/my_time.h')
-rw-r--r--include/my_time.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/my_time.h b/include/my_time.h
index 5ec51685489..9fcff24918b 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -70,8 +70,10 @@ typedef long my_time_t;
#define TIME_MAX_MINUTE 59
#define TIME_MAX_SECOND 59
#define TIME_MAX_SECOND_PART 999999
+#define TIME_SECOND_PART_FACTOR (TIME_MAX_SECOND_PART+1)
+#define TIME_SECOND_PART_DIGITS 6
#define TIME_MAX_VALUE (TIME_MAX_HOUR*10000 + TIME_MAX_MINUTE*100 + \
- TIME_MAX_SECOND + TIME_MAX_SECOND_PART/1e6)
+ TIME_MAX_SECOND + TIME_MAX_SECOND_PART/(double)TIME_SECOND_PART_FACTOR)
#define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \
TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND)
@@ -139,8 +141,6 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type);
sent using binary protocol fit in this buffer.
*/
#define MAX_DATE_STRING_REP_LENGTH 30
-#define MAX_SEC_PART_VALUE 999999
-#define MAX_SEC_PART_DIGITS 6
#define AUTO_SEC_PART_DIGITS 31 /* same as NOT_FIXED_DEC */
int my_time_to_str(const MYSQL_TIME *l_time, char *to, int digits);
@@ -150,16 +150,16 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, int digits);
static inline longlong sec_part_shift(longlong second_part, int digits)
{
- return second_part / log_10_int[MAX_SEC_PART_DIGITS - digits];
+ return second_part / (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
}
static inline longlong sec_part_unshift(longlong second_part, int digits)
{
- return second_part * log_10_int[MAX_SEC_PART_DIGITS - digits];
+ return second_part * (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
}
static inline ulong sec_part_truncate(ulong second_part, int digits)
{
/* the cast here should be unnecessary! */
- return second_part - second_part % (ulong)log_10_int[MAX_SEC_PART_DIGITS - digits];
+ return second_part - second_part % (ulong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
}
#define hrtime_to_my_time(X) ((my_time_t)hrtime_to_time(X))