server

package
v0.0.0-...-6ee7c57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*packet.Conn
	// contains filtered or unexported fields
}

Conn acts like a MySQL server connection, you can use MySQL client to communicate with it.

func NewConn

func NewConn(conn net.Conn, user string, password string, h Handler) (*Conn, error)

func (*Conn) ClearInTransaction

func (c *Conn) ClearInTransaction()

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Closed

func (c *Conn) Closed() bool

func (*Conn) ConnectionID

func (c *Conn) ConnectionID() uint32

func (*Conn) GetUser

func (c *Conn) GetUser() string

func (*Conn) HandleCommand

func (c *Conn) HandleCommand() error

func (*Conn) IsAutoCommit

func (c *Conn) IsAutoCommit() bool

func (*Conn) IsInTransaction

func (c *Conn) IsInTransaction() bool

func (*Conn) SetInTransaction

func (c *Conn) SetInTransaction()

type EmptyHandler

type EmptyHandler struct {
}

func (EmptyHandler) HandleFieldList

func (h EmptyHandler) HandleFieldList(table string, fieldWildcard string) ([]*Field, error)

func (EmptyHandler) HandleQuery

func (h EmptyHandler) HandleQuery(query string) (*Result, error)

func (EmptyHandler) HandleStmtClose

func (h EmptyHandler) HandleStmtClose(context interface{}) error

func (EmptyHandler) HandleStmtExecute

func (h EmptyHandler) HandleStmtExecute(context interface{}, query string, args []interface{}) (*Result, error)

func (EmptyHandler) HandleStmtPrepare

func (h EmptyHandler) HandleStmtPrepare(query string) (int, int, interface{}, error)

func (EmptyHandler) UseDB

func (h EmptyHandler) UseDB(dbName string) error

type Handler

type Handler interface {
	//handle COM_INIT_DB command, you can check whether the dbName is valid, or other.
	UseDB(dbName string) error
	//handle COM_QUERY comamnd, like SELECT, INSERT, UPDATE, etc...
	//If Result has a Resultset (SELECT, SHOW, etc...), we will send this as the repsonse, otherwise, we will send Result
	HandleQuery(query string) (*Result, error)
	//handle COM_FILED_LIST command
	HandleFieldList(table string, fieldWildcard string) ([]*Field, error)
	//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
	HandleStmtPrepare(query string) (params int, columns int, context interface{}, err error)
	//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
	HandleStmtExecute(context interface{}, query string, args []interface{}) (*Result, error)
	//handle COM_STMT_CLOSE, context is the previous one set in prepare
	//this handler has no response
	HandleStmtClose(context interface{}) error
}

type Stmt

type Stmt struct {
	ID    uint32
	Query string

	Params  int
	Columns int

	Args []interface{}

	Context interface{}
}

func (*Stmt) ResetParams

func (s *Stmt) ResetParams()

func (*Stmt) Rest

func (s *Stmt) Rest(params int, columns int, context interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL