Commit fdfeb4be authored by Sergei Golubchik's avatar Sergei Golubchik

small optimization in Field_time_hires.

Fix Field_time_hires::reset()
parent c3f665dc
......@@ -5364,11 +5364,15 @@ void Field_time::sql_type(String &res) const
res.set_ascii(STRING_WITH_LEN("time"));
}
static const longlong t_shift= ((TIME_MAX_VALUE_SECONDS+1)*TIME_SECOND_PART_FACTOR);
int Field_time_hires::reset()
{
store_bigendian(zero_point, ptr, Field_time_hires::pack_length());
return 0;
}
void Field_time_hires::store_TIME(MYSQL_TIME *ltime)
{
ulonglong packed= sec_part_shift(pack_time(ltime), dec) +
sec_part_shift(t_shift, dec);
ulonglong packed= sec_part_shift(pack_time(ltime), dec) + zero_point;
store_bigendian(packed, ptr, Field_time_hires::pack_length());
}
......@@ -5425,8 +5429,7 @@ bool Field_time_hires::get_date(MYSQL_TIME *ltime, uint fuzzydate)
uint32 len= pack_length();
longlong packed= read_bigendian(ptr, len);
if (packed)
packed= sec_part_unshift(packed - sec_part_shift(t_shift, dec), dec);
packed= sec_part_unshift(packed - zero_point, dec);
unpack_time(packed, ltime);
/*
......
......@@ -1420,6 +1420,7 @@ class Field_time :public Field_temporal {
class Field_time_hires :public Field_time {
uint dec;
longlong zero_point;
void store_TIME(MYSQL_TIME *ltime);
public:
Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
......@@ -1431,6 +1432,8 @@ class Field_time_hires :public Field_time {
{
DBUG_ASSERT(dec);
DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
zero_point= sec_part_shift(
((TIME_MAX_VALUE_SECONDS+1)*TIME_SECOND_PART_FACTOR), dec);
}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint decimals() const { return dec; }
......@@ -1438,6 +1441,7 @@ class Field_time_hires :public Field_time {
longlong val_int(void);
double val_real(void);
String *val_str(String*,String *);
int reset(void);
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
bool send_binary(Protocol *protocol);
int cmp(const uchar *,const uchar *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment