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
6 changes: 5 additions & 1 deletion go/mysql/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,11 @@ func (c *Conn) handleNextCommand(handler Handler) error {
// Clean up and reset the connection
c.recycleReadPacket()
c.discardCursor()
handler.ComResetConnection(c)
err = handler.ComResetConnection(c)
if err != nil {
log.Errorf("Error resetting connection (ID %d): %v", c.ConnectionID, err)
c.writeErrorPacketFromError(err)
}
// Reset prepared statements
c.PrepareData = make(map[uint32]*PrepareData)
err = c.writeOKPacket(0, 0, 0, 0)
Expand Down
6 changes: 5 additions & 1 deletion go/mysql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ type Handler interface {
WarningCount(c *Conn) uint16

// ComResetConnection is called when a connection receives a COM_RESET_CONNECTION signal.
ComResetConnection(c *Conn)
// This is used to reset the session state (e.g. clearing user vars, resetting session vars, releasing
// locks, releasing cached prepared statements, etc). One of the primary use cases for COM_RESET_CONNECTION
// is to reset a pooled connection's session state so that it can be safely returned to the connection pool
// and given to another application process to reuse.
ComResetConnection(c *Conn) error

// ParserOptionsForConnection returns any parser options that should be used for the given connection. For
// example, if the connection has enabled ANSI_QUOTES or ANSI SQL_MODE, then the parser needs to know that
Expand Down
4 changes: 2 additions & 2 deletions go/mysql/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ func (th *testHandler) ComStmtExecute(c *Conn, prepare *PrepareData, callback fu
}
}

func (th *testHandler) ComResetConnection(c *Conn) {

func (th *testHandler) ComResetConnection(c *Conn) error {
return nil
}

func (th *testHandler) WarningCount(c *Conn) uint16 {
Expand Down