Commit 6a827daf authored by Sergey Petrunya's avatar Sergey Petrunya

Fix for the previous cset: Field::store_TIME() accepts microseconds fraction, not millisecond.

parent fd53cbbf
......@@ -567,20 +567,27 @@ class TimestampDataConverter : public ColumnDataConverter
public:
void cassandra_to_mariadb(const char *cass_data, int cass_data_len)
{
/* Cassandra data is milliseconds-since-epoch in network byte order */
int64_t tmp;
DBUG_ASSERT(cass_data_len==8);
flip64(cass_data, (char*)&tmp);
((Field_timestamp*)field)->store_TIME(tmp / 1000, tmp % 1000);
/*
store_TIME's arguments:
- seconds since epoch
- microsecond fraction of a second.
*/
((Field_timestamp*)field)->store_TIME(tmp / 1000, (tmp % 1000)*1000);
}
void mariadb_to_cassandra(char **cass_data, int *cass_data_len)
{
my_time_t ts_time;
ulong ts_millis;
ulong ts_microsec;
int64_t tmp;
ts_time= ((Field_timestamp*)field)->get_timestamp(&ts_millis);
ts_time= ((Field_timestamp*)field)->get_timestamp(&ts_microsec);
tmp= ts_time * 1000 + ts_millis;
/* Cassandra needs milliseconds-since-epoch */
tmp= ts_time * 1000 + ts_microsec/1000;
flip64((const char*)&tmp, (char*)&buf);
*cass_data= (char*)&buf;
......
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