Add ReadDecimal helper
This commit is contained in:
parent
57d2b30132
commit
2f12207dbe
|
@ -174,9 +174,7 @@ func (e *RowsEvent) decodeValue(buf *buffer.Buffer, ct mysql.ColumnType, meta ui
|
||||||
case mysql.ColumnTypeNewDecimal:
|
case mysql.ColumnTypeNewDecimal:
|
||||||
precision := int(meta >> 8)
|
precision := int(meta >> 8)
|
||||||
decimals := int(meta & 0xFF)
|
decimals := int(meta & 0xFF)
|
||||||
dec, n := mysql.DecodeDecimal(buf.Cur(), precision, decimals)
|
return buf.ReadDecimal(precision, decimals)
|
||||||
buf.Skip(n)
|
|
||||||
return dec
|
|
||||||
|
|
||||||
// Date and Time
|
// Date and Time
|
||||||
case mysql.ColumnTypeYear:
|
case mysql.ColumnTypeYear:
|
||||||
|
|
|
@ -170,3 +170,15 @@ func (b *Buffer) WriteStringLenEnc(s string) {
|
||||||
func (b *Buffer) WriteStringEOF(s string) {
|
func (b *Buffer) WriteStringEOF(s string) {
|
||||||
b.pos += copy(b.data[b.pos:], s)
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue