Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions go/mysql/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ func (c *Conn) handleNextCommand(ctx context.Context, handler Handler) error {
return err
}
case ComStmtSendLongData:
stmtID, paramID, chunkData, ok := c.parseComStmtSendLongData(data)
stmtID, paramID, chunk, ok := c.parseComStmtSendLongData(data)
c.recycleReadPacket()
if !ok {
err := fmt.Errorf("error parsing statement send long data from client %v, returning error: %v", c.ConnectionID, data)
Expand All @@ -1259,9 +1259,6 @@ func (c *Conn) handleNextCommand(ctx context.Context, handler Handler) error {
return err
}

chunk := make([]byte, len(chunkData))
copy(chunk, chunkData)

key := fmt.Sprintf("v%d", paramID+1)
if val, ok := prepare.BindVars[key]; ok {
val.Value = append(val.Value, chunk...)
Expand Down Expand Up @@ -1427,13 +1424,14 @@ func (c *Conn) handleComRegisterReplica(handler Handler, data []byte) (kontinue
return true
}

c.recycleReadPacket()

replicaHost, replicaPort, replicaUser, replicaPassword, err := c.parseComRegisterReplica(data)
if err != nil {
log.Errorf("conn %v: parseComRegisterReplica failed: %v", c.ID(), err)
return false
}

c.recycleReadPacket()

if err := binlogReplicaHandler.ComRegisterReplica(c, replicaHost, replicaPort, replicaUser, replicaPassword); err != nil {
c.writeErrorPacketFromError(err)
return false
Expand All @@ -1452,7 +1450,6 @@ func (c *Conn) handleComBinlogDumpGTID(handler Handler, data []byte) (kontinue b
return true
}

c.recycleReadPacket()
kontinue = true

c.startWriterBuffering()
Expand All @@ -1468,6 +1465,7 @@ func (c *Conn) handleComBinlogDumpGTID(handler Handler, data []byte) (kontinue b
log.Errorf("conn %v: parseComBinlogDumpGTID failed: %v", c.ID(), err)
return false
}
c.recycleReadPacket()
if err := binlogReplicaHandler.ComBinlogDumpGTID(c, logFile, logPos, position.GTIDSet); err != nil {
log.Error(err.Error())
c.writeErrorPacketFromError(err)
Expand Down
6 changes: 5 additions & 1 deletion go/mysql/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,11 @@ func (c *Conn) parseComStmtSendLongData(data []byte) (uint32, uint16, []byte, bo
return 0, 0, nil, false
}

return statementID, paramID, data[pos:], true
chunkData := data[pos:]
chunk := make([]byte, len(chunkData))
copy(chunk, chunkData)

return statementID, paramID, chunk, true
}

func (c *Conn) parseComStmtClose(data []byte) (uint32, bool) {
Expand Down