summaryrefslogtreecommitdiff
path: root/include
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
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')
-rw-r--r--include/my_sys.h3
-rw-r--r--include/my_time.h12
2 files changed, 8 insertions, 7 deletions
diff --git a/include/my_sys.h b/include/my_sys.h
index ff4083b9fda..96754d2e85d 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -894,6 +894,7 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len);
extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void);
+#define HRTIME_RESOLUTION 1000000
typedef struct {ulonglong val;} my_hrtime_t;
typedef struct {ulonglong val;} my_timediff_t;
void my_time_init();
@@ -904,7 +905,7 @@ extern ulonglong my_getsystime(void);
#define my_micro_time() (my_getsystime()/10)
#define hrtime_to_time(X) ((X).val/1000000)
#define hrtime_from_time(X) ((ulonglong)((X)*1000000ULL))
-#define hrtime_to_double(X) ((X).val/1e6)
+#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION)
#define hrtime_sec_part(X) ((ulong)((X).val%1000000))
#define my_time(X) hrtime_to_time(my_hrtime())
#define my_micro_and_hrtime(X,Y) my_diff_and_hrtime(X,Y)
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))