variable

package
v0.0.0-...-7f9930a Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SysVars map[string]*SysVar

Global sys vars map

Functions

func BindSessionVars

func BindSessionVars(ctx context.Context)

BindSessionVars creates a session vars object and bind it to context

func IsAutocommit

func IsAutocommit(ctx context.Context) bool

IsAutocommit checks if it is in autocommit enviroment

Types

type ScopeFlag

type ScopeFlag uint8

ScopeFlag is for system variable whether can be changed in global/session dynamically or not.

const (
	// ScopeNone means the system variable can not be changed dynamically.
	ScopeNone ScopeFlag = iota << 0
	// ScopeGlobal means the system variable can be changed globally.
	ScopeGlobal
	// ScopeSession means the system variable can only be changed in current session.
	ScopeSession
)

type SessionVars

type SessionVars struct {
	// user-defined variables
	Users map[string]string
	// system variables
	Systems map[string]string
	// prepared statement
	PreparedStmts map[string]stmt.Statement

	// following variables are specail for current session
	Status       uint16
	LastInsertID uint64
	AffectedRows uint64

	// Client Capability
	ClientCapability uint32 // Client capability

	// Disable autocommit
	DisableAutocommit bool

	// Found rows
	FoundRows uint64
	// contains filtered or unexported fields
}

SessionVars is to handle user-defined or global varaibles 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 return 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) SetLastInsertID

func (s *SessionVars) SetLastInsertID(insertID uint64)

SetLastInsertID saves the last insert id to the session context

func (*SessionVars) SetStatus

func (s *SessionVars) SetStatus(status uint16)

SetStatus sets the session server status variable

type SysVar

type SysVar struct {
	// Scope is for whether can be changed or not
	Scope ScopeFlag

	// Variable name
	Name string

	// Variable value
	Value string
}

SysVar is for system variable

func GetSysVar

func GetSysVar(name string) *SysVar

GetSysVar returns the sysvar value for the given name TODO: later we will get global sys vars from KV storage, so this function will be removed later, maybe.

Jump to

Keyboard shortcuts

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