Skip to content

Commit

Permalink
restore Field::get_timestamp() prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova authored and midenok committed Dec 5, 2017
1 parent 30841c0 commit a46f585
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
11 changes: 2 additions & 9 deletions sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 11 additions & 3 deletions sql/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,12 @@ class Field: public Value_source
}
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
Expand Down Expand Up @@ -2509,7 +2513,7 @@ class Field_timestamp :public Field_temporal {
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);
Expand Down Expand Up @@ -2641,7 +2645,11 @@ class Field_timestampf :public Field_timestamp_with_dec {
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); }
};

Expand Down
3 changes: 2 additions & 1 deletion sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions sql/partition_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,16 @@ class Vers_min_max_stats : public Sql_alloc
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;
}
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a46f585

Please sign in to comment.