1
0
Fork 0

Remove more debug

This commit is contained in:
Gregory Eremin 2018-11-11 15:03:47 +01:00
parent b1e0b061f0
commit 749b2ed224
1 changed files with 3 additions and 19 deletions

View File

@ -88,15 +88,13 @@ func (e *RowsEvent) Decode(connBuff []byte, fd FormatDescription, td TableDescri
e.Rows = make([][]interface{}, 0) e.Rows = make([][]interface{}, 0)
for { for {
tools.Debug("\n\n=== PARSING ROW\n")
row, err := e.decodeRows(buf, td, e.ColumnBitmap1) row, err := e.decodeRows(buf, td, e.ColumnBitmap1)
if err != nil { if err != nil {
return err return err
} }
e.Rows = append(e.Rows, row) e.Rows = append(e.Rows, row)
if RowsEventHasSecondBitmap(e.Type) { // && buf.More() if RowsEventHasSecondBitmap(e.Type) {
tools.Debug("===== SECOND BITMASK ROUND =====\n")
row, err := e.decodeRows(buf, td, e.ColumnBitmap2) row, err := e.decodeRows(buf, td, e.ColumnBitmap2)
if err != nil { if err != nil {
return err return err
@ -124,32 +122,22 @@ func (e *RowsEvent) decodeRows(buf *tools.Buffer, td TableDescription, bm []byte
row := make([]interface{}, e.ColumnCount) row := make([]interface{}, e.ColumnCount)
for i := 0; i < int(e.ColumnCount); i++ { for i := 0; i < int(e.ColumnCount); i++ {
if !isBitSet(bm, i) { if !isBitSet(bm, i) {
tools.Debugf("Skipped %s, meta %x, BIT NOT SET\n\n",
mysql.ColumnType(td.ColumnTypes[i]).String(), td.ColumnMeta[i],
)
continue continue
} }
isNull := (uint32(nullBM[nullIdx/8]) >> uint32(nullIdx%8)) & 1 isNull := (uint32(nullBM[nullIdx/8]) >> uint32(nullIdx%8)) & 1
nullIdx++ nullIdx++
if isNull > 0 { if isNull > 0 {
tools.Debugf("Parsed %s, meta %x, NULL\n\n",
mysql.ColumnType(td.ColumnTypes[i]).String(), td.ColumnMeta[i],
)
row[i] = nil row[i] = nil
continue continue
} }
row[i] = e.decodeValue(buf, mysql.ColumnType(td.ColumnTypes[i]), td.ColumnMeta[i]) row[i] = e.decodeValue(buf, mysql.ColumnType(td.ColumnTypes[i]), td.ColumnMeta[i])
tools.Debugf("Parsed %s, meta %x, value %++v\n\n",
mysql.ColumnType(td.ColumnTypes[i]).String(), td.ColumnMeta[i], row[i],
)
} }
return row, nil return row, nil
} }
func (e *RowsEvent) decodeValue(buf *tools.Buffer, ct mysql.ColumnType, meta uint16) interface{} { func (e *RowsEvent) decodeValue(buf *tools.Buffer, ct mysql.ColumnType, meta uint16) interface{} {
tools.Debugf("-- PRE-PARSING %s, meta %x\n", ct.String(), meta)
var length int var length int
if ct == mysql.ColumnTypeString { if ct == mysql.ColumnTypeString {
if meta > 0xFF { if meta > 0xFF {
@ -162,13 +150,9 @@ func (e *RowsEvent) decodeValue(buf *tools.Buffer, ct mysql.ColumnType, meta uin
ct = mysql.ColumnType(typeByte) ct = mysql.ColumnType(typeByte)
length = int(lengthByte) length = int(lengthByte)
} }
} else {
length = int(meta)
} }
} }
tools.Debugf("-- PARSING %s, meta %x\n", ct.String(), meta)
switch ct { switch ct {
case mysql.ColumnTypeNull: case mysql.ColumnTypeNull:
return nil return nil
@ -273,12 +257,12 @@ func (e *RowsEvent) decodeValue(buf *tools.Buffer, ct mysql.ColumnType, meta uin
} }
} }
// FIXME: Something is fishy with this whole string decoding. It seems like it
// could be simplified greatly
func readString(buf *tools.Buffer, length int) string { func readString(buf *tools.Buffer, length int) string {
// Length is encoded in 1 byte
if length < 256 { if length < 256 {
return string(buf.ReadStringVarEnc(1)) return string(buf.ReadStringVarEnc(1))
} }
// Length is encoded in 2 bytes
return string(buf.ReadStringVarEnc(2)) return string(buf.ReadStringVarEnc(2))
} }