Skip to content

Commit c6c9248

Browse files
authored
Merge pull request #7 from RiveryIO/feature/eitam/add_nil_based_value_to_date
Change mysql_MYSQL_TYPE_TIMESTAMP2 and MYSQL_TYPE_TIMESTAMP to be def…
2 parents eb2ea8e + 007d419 commit c6c9248

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

replication/row_event.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
10591059
n = 4
10601060
t := binary.LittleEndian.Uint32(data)
10611061
if t == 0 {
1062-
v = formatZeroTime(0, 0)
1062+
v = nil
10631063
} else {
10641064
v = e.parseFracTime(fracTime{
10651065
Time: time.Unix(int64(t), 0),
@@ -1068,13 +1068,17 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
10681068
})
10691069
}
10701070
case MYSQL_TYPE_TIMESTAMP2:
1071-
v, n, err = decodeTimestamp2(data, meta, e.timestampStringLocation)
1072-
v = e.parseFracTime(v)
1071+
if meta == 0 {
1072+
v = nil
1073+
} else {
1074+
v, n, err = decodeTimestamp2(data, meta, e.timestampStringLocation)
1075+
v = e.parseFracTime(v)
1076+
}
10731077
case MYSQL_TYPE_DATETIME:
10741078
n = 8
10751079
i64 := binary.LittleEndian.Uint64(data)
10761080
if i64 == 0 {
1077-
v = formatZeroTime(0, 0)
1081+
v = nil
10781082
} else {
10791083
d := i64 / 1000000
10801084
t := i64 % 1000000

0 commit comments

Comments
 (0)