[Commits] Rev 3502: Fix for the previous cset: Field::store_TIME() accepts microseconds fraction, not millisecond. in file:///data0/psergey/dev2/5.5-cassandra-r01/

Sergey Petrunya psergey at askmonty.org
Wed Aug 29 10:14:04 EEST 2012


At file:///data0/psergey/dev2/5.5-cassandra-r01/

------------------------------------------------------------
revno: 3502
revision-id: psergey at askmonty.org-20120829071404-zlqj9qm5co7tc22b
parent: psergey at askmonty.org-20120829070546-c1ej33moh2d1gouu
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.5-cassandra-r01
timestamp: Wed 2012-08-29 11:14:04 +0400
message:
  Fix for the previous cset: Field::store_TIME() accepts microseconds fraction, not millisecond.
=== modified file 'storage/cassandra/ha_cassandra.cc'
--- a/storage/cassandra/ha_cassandra.cc	2012-08-29 07:05:46 +0000
+++ b/storage/cassandra/ha_cassandra.cc	2012-08-29 07:14:04 +0000
@@ -567,20 +567,27 @@
 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);
-
-    tmp= ts_time * 1000 + ts_millis;
+    ts_time= ((Field_timestamp*)field)->get_timestamp(&ts_microsec);
+    
+    /* Cassandra needs milliseconds-since-epoch */
+    tmp= ts_time * 1000 + ts_microsec/1000;
     flip64((const char*)&tmp, (char*)&buf);
 
     *cass_data= (char*)&buf;



More information about the commits mailing list