Documentation
¶
Index ¶
- Constants
- Variables
- func BindGlobalVarAccessor(ctx context.Context, accessor GlobalVarAccessor)
- func BindSessionVars(ctx context.Context)
- func GetCharsetInfo(ctx context.Context) (charset, collation string)
- func GetStatusVars() (map[string]*StatusVal, error)
- func RegisterStatistics(s Statistics)
- type GlobalVarAccessor
- type RetryInfo
- type ScopeFlag
- type SessionVars
- func (s *SessionVars) AddAffectedRows(rows uint64)
- func (s *SessionVars) AddFoundRows(rows uint64)
- func (s *SessionVars) GetNextPreparedStmtID() uint32
- func (s *SessionVars) SetAffectedRows(affectedRows uint64)
- func (s *SessionVars) SetCurrentUser(user string)
- func (s *SessionVars) SetLastInsertID(insertID uint64)
- func (s *SessionVars) SetStatusFlag(flag uint16, on bool)
- type Statistics
- type StatusVal
- type SysVar
Constants ¶
const ( CodeUnknownStatusVar terror.ErrCode = 1 CodeUnknownSystemVar terror.ErrCode = 1193 )
Variable error codes.
const ( // CollationConnection is the name for collation_connection system variable. CollationConnection = "collation_connection" // CharsetDatabase is the name for charactor_set_database system variable. CharsetDatabase = "character_set_database" // CollationDatabase is the name for collation_database system variable. CollationDatabase = "collation_database" )
Variables ¶
var ( UnknownStatusVar = terror.ClassVariable.New(CodeUnknownStatusVar, "unknown status variable") UnknownSystemVar = terror.ClassVariable.New(CodeUnknownSystemVar, "unknown system variable") )
Variable errors
var DefaultScopeFlag = ScopeGlobal | ScopeSession
DefaultScopeFlag is the status default scope.
var SetNamesVariables = []string{
"character_set_client",
"character_set_connection",
"character_set_results",
}
SetNamesVariables is the system variable names related to set names statements.
var SysVars map[string]*SysVar
SysVars is global sys vars map.
Functions ¶
func BindGlobalVarAccessor ¶
func BindGlobalVarAccessor(ctx context.Context, accessor GlobalVarAccessor)
BindGlobalVarAccessor binds global var accessor to context.
func BindSessionVars ¶
BindSessionVars creates a session vars object and binds it to context.
func GetCharsetInfo ¶
GetCharsetInfo gets charset and collation for current context. What character set should the server translate a statement to after receiving it? For this, the server uses the character_set_connection and collation_connection system variables. It converts statements sent by the client from character_set_client to character_set_connection (except for string literals that have an introducer such as _latin1 or _utf8). collation_connection is important for comparisons of literal strings. For comparisons of strings with column values, collation_connection does not matter because columns have their own collation, which has a higher collation precedence. See: https://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
func GetStatusVars ¶
GetStatusVars gets registered statistics status variables.
func RegisterStatistics ¶
func RegisterStatistics(s Statistics)
RegisterStatistics registers statistics.
Types ¶
type GlobalVarAccessor ¶
type GlobalVarAccessor interface { // GetGlobalSysVar gets the global system variable value for name. GetGlobalSysVar(ctx context.Context, name string) (string, error) // SetGlobalSysVar sets the global system variable name to value. SetGlobalSysVar(ctx context.Context, name string, value string) error }
GlobalVarAccessor is the interface for accessing global scope system and status variables.
func GetGlobalVarAccessor ¶
func GetGlobalVarAccessor(ctx context.Context) GlobalVarAccessor
GetGlobalVarAccessor gets accessor from ctx.
type RetryInfo ¶
type RetryInfo struct { Retrying bool // contains filtered or unexported fields }
RetryInfo saves retry information.
func (*RetryInfo) AddAutoIncrementID ¶
AddAutoIncrementID adds id to AutoIncrementIDs.
func (*RetryInfo) GetCurrAutoIncrementID ¶
GetCurrAutoIncrementID gets current AutoIncrementID.
func (*RetryInfo) ResetOffset ¶
func (r *RetryInfo) ResetOffset()
ResetOffset resets the current retry offset.
type ScopeFlag ¶
type ScopeFlag uint8
ScopeFlag is for system variable whether can be changed in global/session dynamically or not.
type SessionVars ¶
type SessionVars struct { // user-defined variables Users map[string]string // system variables Systems map[string]string // prepared statement PreparedStmts map[uint32]interface{} PreparedStmtNameToID map[string]uint32 // retry information RetryInfo *RetryInfo // following variables are special for current session Status uint16 LastInsertID uint64 AffectedRows uint64 // Client capability ClientCapability uint32 // Connection ID ConnectionID uint64 // Found rows FoundRows uint64 // Current user User string // contains filtered or unexported fields }
SessionVars is to handle user-defined or global variables in current session.
func GetSessionVars ¶
func GetSessionVars(ctx context.Context) *SessionVars
GetSessionVars gets the session vars from context.
func (*SessionVars) AddAffectedRows ¶
func (s *SessionVars) AddAffectedRows(rows uint64)
AddAffectedRows adds affected rows with the argument rows.
func (*SessionVars) AddFoundRows ¶
func (s *SessionVars) AddFoundRows(rows uint64)
AddFoundRows adds found rows with the argument rows.
func (*SessionVars) GetNextPreparedStmtID ¶
func (s *SessionVars) GetNextPreparedStmtID() uint32
GetNextPreparedStmtID generates and returns the next session scope prepared statement id.
func (*SessionVars) SetAffectedRows ¶
func (s *SessionVars) SetAffectedRows(affectedRows uint64)
SetAffectedRows saves the affected rows to the session context.
func (*SessionVars) SetCurrentUser ¶
func (s *SessionVars) SetCurrentUser(user string)
SetCurrentUser saves the current user to the session context.
func (*SessionVars) SetLastInsertID ¶
func (s *SessionVars) SetLastInsertID(insertID uint64)
SetLastInsertID saves the last insert id to the session context. TODO: we may store the result for last_insert_id sys var later.
func (*SessionVars) SetStatusFlag ¶
func (s *SessionVars) SetStatusFlag(flag uint16, on bool)
SetStatusFlag sets the session server status variable. If on is ture sets the flag in session status, otherwise removes the flag.
type Statistics ¶
type Statistics interface { // GetScope gets the status variables scope. GetScope(status string) ScopeFlag // Stats returns the statistics status variables. Stats() (map[string]interface{}, error) }
Statistics is the interface of statistics.