Skip to content

Commit

Permalink
fix parsing int24 in binary result (go-mysql-org#368)
Browse files Browse the repository at this point in the history
Signed-off-by: siddontang <[email protected]>
  • Loading branch information
siddontang authored Mar 3, 2019
1 parent 3242b1d commit 670f74e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
all: build

GO111MODULE=on
export export

build:
go build -o bin/go-mysqlbinlog cmd/go-mysqlbinlog/main.go
Expand Down
14 changes: 3 additions & 11 deletions mysql/resultset.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func (p RowData) ParseText(f []*Field) ([]interface{}, error) {
return data, nil
}

// ParseBinary parses the binary format of data
// see https://dev.mysql.com/doc/internals/en/binary-protocol-value.html
func (p RowData) ParseBinary(f []*Field) ([]interface{}, error) {
data := make([]interface{}, len(f))

Expand Down Expand Up @@ -109,17 +111,7 @@ func (p RowData) ParseBinary(f []*Field) ([]interface{}, error) {
pos += 2
continue

case MYSQL_TYPE_INT24:
if isUnsigned {
data[i] = ParseBinaryUint24(p[pos : pos+3])
} else {
data[i] = ParseBinaryInt24(p[pos : pos+3])
}
//3 byte
pos += 3
continue

case MYSQL_TYPE_LONG:
case MYSQL_TYPE_INT24, MYSQL_TYPE_LONG:
if isUnsigned {
data[i] = ParseBinaryUint32(p[pos : pos+4])
} else {
Expand Down

0 comments on commit 670f74e

Please sign in to comment.