1
0
Fork 0

Add ReadDecimal helper

This commit is contained in:
Gregory Eremin 2018-11-30 11:17:59 +01:00
parent 57d2b30132
commit 2f12207dbe
2 changed files with 13 additions and 3 deletions

View File

@ -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:

View File

@ -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
}