diff --git a/binlog/event_rows.go b/binlog/event_rows.go index d69f9c3..91c5f8a 100644 --- a/binlog/event_rows.go +++ b/binlog/event_rows.go @@ -174,9 +174,7 @@ func (e *RowsEvent) decodeValue(buf *buffer.Buffer, ct mysql.ColumnType, meta ui case mysql.ColumnTypeNewDecimal: precision := int(meta >> 8) decimals := int(meta & 0xFF) - dec, n := mysql.DecodeDecimal(buf.Cur(), precision, decimals) - buf.Skip(n) - return dec + return buf.ReadDecimal(precision, decimals) // Date and Time case mysql.ColumnTypeYear: diff --git a/buffer/buffer.go b/buffer/buffer.go index dd1676b..a92af6d 100644 --- a/buffer/buffer.go +++ b/buffer/buffer.go @@ -170,3 +170,15 @@ func (b *Buffer) WriteStringLenEnc(s string) { func (b *Buffer) WriteStringEOF(s string) { b.pos += copy(b.data[b.pos:], s) } + +// +// Special types +// + +// ReadDecimal decodes a decimal value from the buffer anf then advances cursor +// accordingly. +func (b *Buffer) ReadDecimal(precision, decimals int) mysql.Decimal { + dec, n := mysql.DecodeDecimal(b.Cur(), precision, decimals) + b.Skip(n) + return dec +}