Skip to content

Commit 3573816

Browse files
authored
Merge pull request #170 from altmannmarcelo/time_issue
Time issue
2 parents 6bb9853 + a381a9f commit 3573816

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/binlog/misc.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ pub fn time_from_packed(mut tmp: i64) -> Value {
7373
};
7474
let hms = my_packed_time_get_int_part(tmp);
7575
let h = ((hms >> 12) as u32) % (1 << 10);
76+
let d = h / 24;
77+
let h = h % 24;
7678
let m = ((hms >> 6) as u32) % (1 << 6);
7779
let s = ((hms) as u32) % (1 << 6);
7880
let u = my_packed_time_get_frac_part(tmp);
79-
Value::Time(neg, 0, h as u8, m as u8, s as u8, u as u32)
81+
Value::Time(neg, d, h as u8, m as u8, s as u8, u as u32)
8082
}
8183

8284
pub fn my_datetime_packed_from_binary<T: io::Read>(mut input: T, dec: u32) -> io::Result<i64> {

src/binlog/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,26 @@ mod tests {
11901190
}
11911191
}
11921192

1193+
if file_path.file_name().unwrap() == "time_issue.000001" {
1194+
let event_data = ev.read_data().unwrap();
1195+
match event_data {
1196+
Some(EventData::RowsEvent(ev)) => {
1197+
let table_map_event =
1198+
binlog_file.reader().get_tme(ev.table_id()).unwrap();
1199+
let row = ev.rows(table_map_event).next().unwrap().unwrap();
1200+
let after_image = row.1.unwrap();
1201+
after_image.columns().iter().enumerate().for_each(|(i, _)| {
1202+
match after_image.as_ref(i).unwrap() {
1203+
BinlogValue::Value(val) => {
1204+
assert_eq!(val, &Value::Time(true, 21, 3, 48, 27, 0));
1205+
}
1206+
_ => panic!("Expected a value"),
1207+
}
1208+
});
1209+
}
1210+
_ => (),
1211+
}
1212+
}
11931213
ev_pos = ev_end;
11941214
}
11951215
}
472 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)