mirror of
https://github.com/zr-hebo/sniffer-agent.git
synced 2025-10-09 22:29:50 +08:00
develop
This commit is contained in:
@@ -55,19 +55,19 @@ func parseResponseHeader(payload []byte) (ok, val int64, err error) {
|
|||||||
fmt.Printf("%#v\n", val)
|
fmt.Printf("%#v\n", val)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
switch {
|
if payload[0] == PACKET_OK && len(payload)>=7 {
|
||||||
case payload[0] == PACKET_OK && len(payload)>=7:
|
|
||||||
case payload[0] == PACKET_EOF && len(payload)<=9:
|
|
||||||
// set ok and mysql affected rows number
|
|
||||||
ok = 1
|
ok = 1
|
||||||
val = lenencInt(payload)
|
val = lenencInt(payload[1:])
|
||||||
|
|
||||||
case payload[0] == PACKET_ERR && len(payload)>3:
|
} else if len(payload) > 4 {
|
||||||
|
payload = payload[4:]
|
||||||
|
if payload[0] == PACKET_ERR && len(payload)>3 {
|
||||||
// set not ok and mysql execute error-code
|
// set not ok and mysql execute error-code
|
||||||
ok = 0
|
ok = 0
|
||||||
val = int64(bytesToIntSmallEndian(payload[1:3]))
|
val = int64(bytesToIntSmallEndian(payload[1:3]))
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
} else {
|
||||||
err = fmt.Errorf("invalid response packet")
|
err = fmt.Errorf("invalid response packet")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@@ -158,7 +158,7 @@ func (ms *MysqlSession) readFromServer(respSeq int64, bytes []byte) (ok, val int
|
|||||||
ms.prepareInfo.prepareStmtID = bytesToInt(contents[1:5])
|
ms.prepareInfo.prepareStmtID = bytesToInt(contents[1:5])
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseResponseHeader(contents)
|
return parseResponseHeader(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fmt.Errorf("not need packet")
|
err = fmt.Errorf("not need packet")
|
||||||
|
Reference in New Issue
Block a user