Skip to content

Commit 7107693

Browse files
authored
fix bug: year==0 will be resolved to the wrong value: 1900 (go-mysql-org#497)
1 parent 4e4aae4 commit 7107693

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

replication/row_event.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,12 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
787787

788788
case MYSQL_TYPE_YEAR:
789789
n = 1
790-
v = int(data[0]) + 1900
790+
year := int(data[0])
791+
if year == 0 {
792+
v = year
793+
} else {
794+
v = year + 1900
795+
}
791796
case MYSQL_TYPE_ENUM:
792797
l := meta & 0xFF
793798
switch l {

0 commit comments

Comments
 (0)