Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic on unsigned tinyint (#2649) #2655

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cdc/sink/codec/avro.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ func columnToAvroNativeData(col *model.Column, tz *time.Location) (interface{},
case mysql.TypeBit:
return handleUnsignedInt64()
case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24:
if col.Flag.IsUnsigned() {
return int32(col.Value.(uint64)), "int", nil
}
return int32(col.Value.(int64)), "int", nil
case mysql.TypeLong:
if col.Flag.IsUnsigned() {
Expand Down
1 change: 1 addition & 0 deletions cdc/sink/codec/avro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (s *avroBatchEncoderSuite) TestAvroEncode(c *check.C) {
{Name: "id", Type: mysql.TypeLong, Flag: model.HandleKeyFlag, Value: int64(1)},
{Name: "name", Type: mysql.TypeVarchar, Value: "Bob"},
{Name: "tiny", Type: mysql.TypeTiny, Value: int64(255)},
{Name: "utiny", Type: mysql.TypeTiny, Flag: model.UnsignedFlag, Value: uint64(100)},
{Name: "comment", Type: mysql.TypeBlob, Value: []byte("测试")},
},
}
Expand Down