Skip to content

Instantly share code, notes, and snippets.

@jordan-chalupka
Created May 31, 2020 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordan-chalupka/9d140cff2d323ff759c20b79a383e1db to your computer and use it in GitHub Desktop.
Save jordan-chalupka/9d140cff2d323ff759c20b79a383e1db to your computer and use it in GitHub Desktop.
implements my-sql server handler using impl
//handle COM_INIT_DB command, you can check whether the dbName is valid, or other.
func (Foo) UseDB(dbName string) error {
panic("not implemented") // TODO: Implement
}
//handle COM_QUERY command, like SELECT, INSERT, UPDATE, etc...
//If Result has a Resultset (SELECT, SHOW, etc...), we will send this as the response, otherwise, we will send Result
func (Foo) HandleQuery(query string) (*server.Result, error) {
panic("not implemented") // TODO: Implement
}
//handle COM_FILED_LIST command
func (Foo) HandleFieldList(table string, fieldWildcard string) ([]*server.Field, error) {
panic("not implemented") // TODO: Implement
}
//handle COM_STMT_PREPARE, params is the param number for this statement, columns is the column number
//context will be used later for statement execute
func (Foo) HandleStmtPrepare(query string) (params int, columns int, context interface{}, err error) {
panic("not implemented") // TODO: Implement
}
//handle COM_STMT_EXECUTE, context is the previous one set in prepare
//query is the statement prepare query, and args is the params for this statement
func (Foo) HandleStmtExecute(context interface{}, query string, args []interface{}) (*server.Result, error) {
panic("not implemented") // TODO: Implement
}
//handle COM_STMT_CLOSE, context is the previous one set in prepare
//this handler has no response
func (Foo) HandleStmtClose(context interface{}) error {
panic("not implemented") // TODO: Implement
}
//handle any other command that is not currently handled by the library,
//default implementation for this method will return an ER_UNKNOWN_ERROR
func (Foo) HandleOtherCommand(cmd byte, data []byte) error {
panic("not implemented") // TODO: Implement
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment