diff --git a/sql/field.cc b/sql/field.cc index c6ebbd1f9ce..dff8fa489dc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5397,15 +5397,8 @@ my_time_t Field_timestampf::get_timestamp(const uchar *pos, ulong *sec_part) const { struct timeval tm; - if (sec_part) - { - my_timestamp_from_binary(&tm, pos ? pos : ptr, dec); - *sec_part= tm.tv_usec; - } - else - { - my_timestamp_from_binary(&tm, pos ? pos : ptr, 0); - } + my_timestamp_from_binary(&tm, pos, dec); + *sec_part= tm.tv_usec; return tm.tv_sec; } diff --git a/sql/field.h b/sql/field.h index 5be1ab735e6..93541695353 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1008,8 +1008,12 @@ public: } bool set_explicit_default(Item *value); - virtual my_time_t get_timestamp(const uchar *pos= NULL, ulong *sec_part= NULL) const + virtual my_time_t get_timestamp(const uchar *pos, ulong *sec_part) const { DBUG_ASSERT(0); return 0; } + my_time_t get_timestamp(ulong *sec_part) const + { + return get_timestamp(ptr, sec_part); + } /** Evaluates the @c UPDATE default function, if one exists, and stores the @@ -2509,7 +2513,7 @@ public: return res; } /* Get TIMESTAMP field value as seconds since begging of Unix Epoch */ - virtual my_time_t get_timestamp(const uchar *pos, ulong *sec_part) const; + my_time_t get_timestamp(const uchar *pos, ulong *sec_part) const; my_time_t get_timestamp(ulong *sec_part) const { return get_timestamp(ptr, sec_part); @@ -2641,7 +2645,11 @@ public: void set_max(); bool is_max(); void store_TIME(my_time_t timestamp, ulong sec_part); - my_time_t get_timestamp(const uchar *pos= NULL, ulong *sec_part= NULL) const; + my_time_t get_timestamp(const uchar *pos, ulong *sec_part) const; + my_time_t get_timestamp(ulong *sec_part) const + { + return get_timestamp(ptr, sec_part); + } uint size_of() const { return sizeof(*this); } }; diff --git a/sql/log_event.cc b/sql/log_event.cc index 102fbc251e3..397d1b6bef5 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -12509,9 +12509,10 @@ Rows_log_event::write_row(rpl_group_info *rgi, // Set vers fields when replicating from not system-versioned table. if (m_type == WRITE_ROWS_EVENT_V1 && table->versioned_by_sql()) { + ulong sec_part; bitmap_set_bit(table->read_set, table->vers_start_field()->field_index); // Check whether a row came from unversioned table and fix vers fields. - if (table->vers_start_field()->get_timestamp() == 0) + if (table->vers_start_field()->get_timestamp(&sec_part) == 0 && sec_part == 0) { bitmap_set_bit(table->write_set, table->vers_start_field()->field_index); bitmap_set_bit(table->write_set, table->vers_end_field()->field_index); diff --git a/sql/partition_element.h b/sql/partition_element.h index fc486abffc2..da08a15b2ce 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -130,14 +130,16 @@ public: my_time_t min_time() { mysql_rwlock_rdlock(&lock); - my_time_t res= min_value.get_timestamp(); + ulong sec_part; + my_time_t res= min_value.get_timestamp(&sec_part); mysql_rwlock_unlock(&lock); return res; } my_time_t max_time() { mysql_rwlock_rdlock(&lock); - my_time_t res= max_value.get_timestamp(); + ulong sec_part; + my_time_t res= max_value.get_timestamp(&sec_part); mysql_rwlock_unlock(&lock); return res; } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 5e43dece66e..700b25419e8 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3197,8 +3197,9 @@ int vers_get_partition_id(partition_info *part_info, table->s->busy_rotation= true; mysql_mutex_unlock(&table->s->LOCK_rotation); // transaction is not yet pushed to VTQ, so we use now-time + ulong sec_part; my_time_t end_ts= sys_trx_end->table->versioned_by_engine() ? - my_time_t(0) : sys_trx_end->get_timestamp(); + my_time_t(0) : sys_trx_end->get_timestamp(&sec_part); if (part_info->vers_limit_exceed() || part_info->vers_interval_exceed(end_ts)) { part_info->vers_part_rotate(thd);