Skip to content

Commit ee40064

Browse files
author
Vladislav Kolesnikov
committed
Add HandleStmtClose Handler interface method
1 parent 1a1e7fd commit ee40064

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
var
2-
bin
2+
bin
3+
.idea

server/command.go

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ type Handler interface {
2222
//handle COM_STMT_EXECUTE, context is the previous one set in prepare
2323
//query is the statement prepare query, and args is the params for this statement
2424
HandleStmtExecute(context interface{}, query string, args []interface{}) (*Result, error)
25+
//handle COM_STMT_CLOSE, context is the previous one set in prepare
26+
//this handler has no response
27+
HandleStmtClose(context interface{}) (error)
2528
}
2629

2730
func (c *Conn) HandleCommand() error {

server/server_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ func (h *testHandler) HandleStmtPrepare(sql string) (params int, columns int, ct
108108
return params, columns, nil, err
109109
}
110110

111+
func (h *testHandler) HandleStmtClose(context interface{}) error {
112+
return nil
113+
}
114+
111115
func (h *testHandler) HandleStmtExecute(ctx interface{}, query string, args []interface{}) (*mysql.Result, error) {
112116
return h.handleQuery(query, true)
113117
}

server/stmt.go

+9
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ func (c *Conn) handleStmtClose(data []byte) error {
348348

349349
id := binary.LittleEndian.Uint32(data[0:4])
350350

351+
stmt, ok := c.stmts[id]
352+
if !ok {
353+
return nil
354+
}
355+
356+
if err := c.h.HandleStmtClose(stmt.Context); err != nil {
357+
return err
358+
}
359+
351360
delete(c.stmts, id)
352361

353362
return nil

0 commit comments

Comments
 (0)