Documentation
¶
Overview ¶
Package mysqltest is a small fake MySQL server for tests, in this package and in others. It speaks the text query protocol only (handshake v10 and mysql_native_password), so a test must use the driver's default query_mode (simple). It does not parse SQL: the test gives it a Handler that answers each SQL text.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
Column is one column of a Result. Type is a server type name such as "BIGINT", "VARCHAR" or "UNSIGNED BIGINT". Use Text and Int for the usual ones.
type Handler ¶
Handler answers one query text. It returns one Result for each statement in the text. No result at all means an OK packet with nothing changed.
type Result ¶
type Result struct {
Columns []Column
Rows [][]any
Affected int64
LastInsertID int64
ErrNumber uint16
ErrState string
ErrMessage string
}
Result is the answer to one statement. A cell is printed as text, or nil for NULL. Set ErrNumber to make the statement fail. The statements after it in the same reply are not sent.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a running fake server.
func StartTLS ¶ added in v0.8.0
StartTLS is Start, and it offers TLS with cfg after the client asks.
func StartWithPassword ¶
StartWithPassword is Start, but a client must log in with this password.
func (*Server) Inits ¶
Inits are the session statements the client sent, such as the read-only setting and the sql_mode query. They are not in Queries.
func (*Server) Queries ¶
Queries are the SQL texts received, in order, without the session setup the driver sends on each new connection.
func (*Server) SetSQLMode ¶
SetSQLMode sets the text SELECT @@SESSION.sql_mode returns.