| 11 | ) |
| 12 | |
| 13 | type Handler interface { |
| 14 | // close conn |
| 15 | CloseConn(c *Conn) error |
| 16 | // handle COM_INIT_DB command, you can check whether the dbName is valid, or other. |
| 17 | UseDB(conn *Conn, dbName string) error |
| 18 | // handle COM_QUERY command, like SELECT, INSERT, UPDATE, etc... |
| 19 | // If Result has a Resultset (SELECT, SHOW, etc...), we will send this as the response, otherwise, we will send Result |
| 20 | HandleQuery(conn *Conn, query string) (*Result, error) |
| 21 | // handle COM_FILED_LIST command |
| 22 | HandleFieldList(conn *Conn, table string, fieldWildcard string) ([]*Field, error) |
| 23 | // handle COM_STMT_PREPARE, params is the param number for this statement, columns is the column number |
| 24 | // context will be used later for statement execute |
| 25 | HandleStmtPrepare(conn *Conn, query string) (params int, columns int, context any, err error) |
| 26 | // handle COM_STMT_EXECUTE, context is the previous one set in prepare |
| 27 | // query is the statement prepare query, and args is the params for this statement |
| 28 | HandleStmtExecute(conn *Conn, context any, query string, args []any) (*Result, error) |
| 29 | // handle COM_STMT_CLOSE, context is the previous one set in prepare |
| 30 | // this handler has no response |
| 31 | HandleStmtClose(conn *Conn, context any) error |
| 32 | // handle any other command that is not currently handled by the library, |
| 33 | // default implementation for this method will return an ER_UNKNOWN_ERROR |
| 34 | HandleOtherCommand(conn *Conn, cmd byte, data []byte) error |
| 35 | } |
| 36 | |
| 37 | func (c *Conn) HandleCommand() error { |
| 38 | if c.Conn == nil { |
no outgoing calls
no test coverage detected