mysql

package
Version: v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeMasterToError

func ChangeMasterToError(db *sql.DB, gtid *model.Repl) error

ChangeMasterToError mock.

func ChangeToMasterError

func ChangeToMasterError(db *sql.DB) error

ChangeToMasterError mock.

func CheckGTIDLC added in v1.0.7

func CheckGTIDLC(*model.GTID, *model.GTID) bool

func DefaultChangeMasterTo

func DefaultChangeMasterTo(db *sql.DB, gtid *model.Repl) error

DefaultChangeMasterTo mock.

func DefaultChangeToMaster

func DefaultChangeToMaster(db *sql.DB) error

DefaultChangeToMaster mock.

func DefaultChangeUserPasswd added in v1.0.5

func DefaultChangeUserPasswd(db *sql.DB, user string, host string, passwd string) error

ChangeUserPasswd mock.

func DefaultCheckGTID added in v1.0.7

func DefaultCheckGTID(followerGTID *model.GTID, leaderGTID *model.GTID) bool

func DefaultCheckUserExists added in v1.0.5

func DefaultCheckUserExists(db *sql.DB, user string, host string) (bool, error)

CheckUserExists mock.

func DefaultCreateReplUserWithoutBinlog added in v1.0.5

func DefaultCreateReplUserWithoutBinlog(db *sql.DB, user string, passwd string) error

CreateReplUserWithoutBinlog mock.

func DefaultCreateUser added in v1.0.5

func DefaultCreateUser(db *sql.DB, user string, host string, passwd string, ssltype string) error

CreateUser mock.

func DefaultCreateUserWithPrivileges added in v1.0.5

func DefaultCreateUserWithPrivileges(db *sql.DB, user, passwd, database, table, host, privs string, ssl string) error

CreateUserWithPrivileges mock.

func DefaultDisableSemiSyncMaster

func DefaultDisableSemiSyncMaster(db *sql.DB) error

DefaultDisableSemiSyncMaster mock.

func DefaultDropUser added in v1.0.5

func DefaultDropUser(db *sql.DB, user string, host string) error

DropUser mock.

func DefaultEnableSemiSyncMaster

func DefaultEnableSemiSyncMaster(db *sql.DB) error

DefaultEnableSemiSyncMaster mock.

func DefaultGetGTIDSubtract added in v1.1.4

func DefaultGetGTIDSubtract(db *sql.DB, slaveGTID string, masterGTID string) (string, error)

DefaultGetGTIDSubtract mock.

func DefaultGetMasterGTID

func DefaultGetMasterGTID(db *sql.DB) (*model.GTID, error)

DefaultGetMasterGTID mock.

func DefaultGetSlaveGTID

func DefaultGetSlaveGTID(db *sql.DB) (*model.GTID, error)

DefaultGetSlaveGTID returns the default slave gtid.

func DefaultGetUUID added in v1.0.7

func DefaultGetUUID(db *sql.DB) (string, error)

DefaultGetUUID mock.

func DefaultGetUser added in v1.0.5

func DefaultGetUser(db *sql.DB) ([]model.MysqlUser, error)

GetUser mock.

func DefaultGrantAllPrivileges added in v1.0.5

func DefaultGrantAllPrivileges(db *sql.DB, user string, host string, passwd string, ssl string) error

GrantAllPrivileges mock.

func DefaultGrantNormalPrivileges added in v1.0.5

func DefaultGrantNormalPrivileges(db *sql.DB, user string, host string) error

GrantNormalPrivileges mock.

func DefaultGrantReplicationPrivileges added in v1.0.5

func DefaultGrantReplicationPrivileges(db *sql.DB, user string) error

GrantReplicationPrivileges mock.

func DefaultPurgeBinlogsTo

func DefaultPurgeBinlogsTo(db *sql.DB, binlog string) error

DefaultPurgeBinlogsTo mock.

func DefaultResetMaster

func DefaultResetMaster(db *sql.DB) error

DefaultResetMaster mock.

func DefaultResetSlaveAll

func DefaultResetSlaveAll(db *sql.DB) error

DefaultResetSlaveAll mock.

func DefaultSelectSysVar

func DefaultSelectSysVar(db *sql.DB, query string) (string, error)

DefaultSelectSysVar mock.

func DefaultSetGlobalSysVar

func DefaultSetGlobalSysVar(db *sql.DB, varsql string) error

DefaultSetGlobalSysVar mock.

func DefaultSetQueryTimeout added in v1.1.4

func DefaultSetQueryTimeout(timeout int)

DefaultSetQueryTimeout mock.

func DefaultSetReadOnly

func DefaultSetReadOnly(db *sql.DB, readonly bool) error

DefaultSetReadOnly mock.

func DefaultSetSemiWaitSlaveCount

func DefaultSetSemiWaitSlaveCount(db *sql.DB, count int) error

DefaultSetSemiWaitSlaveCount mock.

func DefaultStartSlave

func DefaultStartSlave(db *sql.DB) error

DefaultStartSlave mock.

func DefaultStartSlaveIOThread

func DefaultStartSlaveIOThread(db *sql.DB) error

DefaultStartSlaveIOThread mock.

func DefaultStopSlave

func DefaultStopSlave(db *sql.DB) error

DefaultStopSlave mock.

func DefaultStopSlaveIOThread

func DefaultStopSlaveIOThread(db *sql.DB) error

DefaultStopSlaveIOThread mock.

func DefaultWaitUntilAfterGTID

func DefaultWaitUntilAfterGTID(db *sql.DB, targetGTID string) error

DefaultWaitUntilAfterGTID mock.

func Execute

func Execute(db *sql.DB, query string, args ...interface{}) error

Execute executes a query without returning any rows

func ExecuteSuperQueryList

func ExecuteSuperQueryList(db *sql.DB, queryList []string) error

ExecuteSuperQueryList alows the user to execute queries as a super user.

func ExecuteSuperQueryListWithTimeout

func ExecuteSuperQueryListWithTimeout(db *sql.DB, maxTime int, queryList []string) error

ExecuteSuperQueryListWithTimeout alows the user to execute queries as a super user.

func ExecuteWithTimeout

func ExecuteWithTimeout(db *sql.DB, maxTime int, query string, args ...interface{}) error

ExecuteWithTimeout executes a query without returning any rows.

func GetGTIDSubtractE added in v1.1.4

func GetGTIDSubtractE(db *sql.DB, subsetGTID string, setGTID string) (string, error)

GetGTIDSubtractE mock

func GetGTIDSubtractError added in v1.1.4

func GetGTIDSubtractError(db *sql.DB, subsetGTID string, setGTID string) (string, error)

func GetGTIDSubtractInvalid added in v1.1.4

func GetGTIDSubtractInvalid(db *sql.DB, slaveGTID string, masterGTID string) (string, error)

GetGTIDSubtractInvalid mock.

func GetMasterGTIDA

func GetMasterGTIDA(db *sql.DB) (*model.GTID, error)

GetMasterGTIDA mock.

func GetMasterGTIDAA added in v1.0.7

func GetMasterGTIDAA(db *sql.DB) (*model.GTID, error)

GetMasterGTIDB mock.

func GetMasterGTIDB

func GetMasterGTIDB(db *sql.DB) (*model.GTID, error)

GetMasterGTIDB mock.

func GetMasterGTIDBB added in v1.0.7

func GetMasterGTIDBB(db *sql.DB) (*model.GTID, error)

GetMasterGTIDBB mock.

func GetMasterGTIDC

func GetMasterGTIDC(db *sql.DB) (*model.GTID, error)

GetMasterGTIDC mock.

func GetMasterGTIDCC added in v1.0.7

func GetMasterGTIDCC(db *sql.DB) (*model.GTID, error)

GetMasterGTIDC mock.

func GetMasterGTIDD

func GetMasterGTIDD(db *sql.DB) (*model.GTID, error)

GetMasterGTIDD mock.

func GetMasterGTIDE1 added in v1.1.4

func GetMasterGTIDE1(db *sql.DB) (*model.GTID, error)

GetMasterGTIDE1 mock.

func GetMasterGTIDE2 added in v1.1.4

func GetMasterGTIDE2(db *sql.DB) (*model.GTID, error)

GetMasterGTIDE2 mock.

func GetMasterGTIDE3 added in v1.1.4

func GetMasterGTIDE3(db *sql.DB) (*model.GTID, error)

GetMasterGTIDE3 mock.

func GetMasterGTIDError

func GetMasterGTIDError(db *sql.DB) (*model.GTID, error)

GetMasterGTIDError mock.

func GetMasterGTIDF added in v1.1.4

func GetMasterGTIDF(db *sql.DB) (*model.GTID, error)

GetMasterGTIDF mock.

func GetMasterGTIDInvalid added in v1.0.7

func GetMasterGTIDInvalid(db *sql.DB) (*model.GTID, error)

func GetMasterGTIDLC added in v1.0.7

func GetMasterGTIDLC(db *sql.DB) (*model.GTID, error)

GetMasterGTIDLC mock.

func GetMasterGTIDNull added in v1.1.4

func GetMasterGTIDNull(db *sql.DB) (*model.GTID, error)

GetMasterGTIDNull mock.

func GetMasterGTIDPingError

func GetMasterGTIDPingError(db *sql.DB) (*model.GTID, error)

GetMasterGTIDPingError mock.

func GetSlaveGTIDA

func GetSlaveGTIDA(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDA mock. with GTID{Master_Log_File = "", Read_Master_Log_Pos = 0} all functions return is OK

func GetSlaveGTIDAA added in v1.0.7

func GetSlaveGTIDAA(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDB mock.

func GetSlaveGTIDB

func GetSlaveGTIDB(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDB mock.

func GetSlaveGTIDBB added in v1.0.7

func GetSlaveGTIDBB(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDBB mock.

func GetSlaveGTIDC

func GetSlaveGTIDC(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDC mock.

func GetSlaveGTIDCC added in v1.0.7

func GetSlaveGTIDCC(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDC mock.

func GetSlaveGTIDError

func GetSlaveGTIDError(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDError mock.

func GetSlaveGTIDX1

func GetSlaveGTIDX1(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDX1 mock.

func GetSlaveGTIDX3

func GetSlaveGTIDX3(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDX3 mock.

func GetSlaveGTIDX5

func GetSlaveGTIDX5(db *sql.DB) (*model.GTID, error)

GetSlaveGTIDX5 mock.

func GetUUIDA added in v1.0.7

func GetUUIDA(db *sql.DB) (string, error)

func GetUUIDLC added in v1.0.7

func GetUUIDLC(db *sql.DB) (string, error)

func MockGetClient

func MockGetClient(t *testing.T, svrConn string) (*xrpc.Client, func())

MockGetClient mock.

func Query

func Query(db *sql.DB, query string, args ...interface{}) ([]map[string]string, error)

Query executes a query that returns rows

func QueryWithTimeout

func QueryWithTimeout(db *sql.DB, maxTime int, query string, args ...interface{}) ([]map[string]string, error)

QueryWithTimeout used to execute the query with maxTime.

func SetReadOnlyError

func SetReadOnlyError(db *sql.DB, readonly bool) error

SetReadOnlyError mock.

func SetSemiSyncMasterTimeout added in v1.0.9

func SetSemiSyncMasterTimeout(db *sql.DB, timeout uint64) error

SetSemiSyncMasterTimeout mock

func StartSlaveError

func StartSlaveError(db *sql.DB) error

StartSlaveError mock.

func StartSlaveIOThreadError

func StartSlaveIOThreadError(db *sql.DB) error

StartSlaveIOThreadError mock.

func StopSlaveError

func StopSlaveError(db *sql.DB) error

StopSlaveError mock.

func StopSlaveIOThreadError

func StopSlaveIOThreadError(db *sql.DB) error

StopSlaveIOThreadError mock.

func WaitUntilAfterGTIDError

func WaitUntilAfterGTIDError(db *sql.DB, targetGTID string) error

WaitUntilAfterGTIDError mock.

Types

type MockGTID

type MockGTID struct {
	SetQueryTimeoutFn          func(int)
	PingFn                     func(*sql.DB) (*PingEntry, error)
	SetReadOnlyFn              func(*sql.DB, bool) error
	GetMasterGTIDFn            func(*sql.DB) (*model.GTID, error)
	GetSlaveGTIDFn             func(*sql.DB) (*model.GTID, error)
	StartSlaveIOThreadFn       func(*sql.DB) error
	StopSlaveIOThreadFn        func(*sql.DB) error
	StartSlaveFn               func(*sql.DB) error
	StopSlaveFn                func(*sql.DB) error
	ChangeMasterToFn           func(*sql.DB, *model.Repl) error
	ChangeToMasterFn           func(*sql.DB) error
	WaitUntilAfterGTIDFn       func(*sql.DB, string) error
	GetGTIDSubtractFn          func(*sql.DB, string, string) (string, error)
	GetUUIDFn                  func(*sql.DB) (string, error)
	CheckGTIDFn                func(*model.GTID, *model.GTID) bool
	SetGlobalSysVarFn          func(*sql.DB, string) error
	ResetMasterFn              func(*sql.DB) error
	ResetSlaveAllFn            func(*sql.DB) error
	PurgeBinlogsToFn           func(*sql.DB, string) error
	EnableSemiSyncMasterFn     func(*sql.DB) error
	DisableSemiSyncMasterFn    func(*sql.DB) error
	SelectSysVarFn             func(*sql.DB, string) (string, error)
	SetSemiWaitSlaveCountFn    func(*sql.DB, int) error
	SetSemiSyncMasterTimeoutFn func(*sql.DB, uint64) error

	// Users
	GetUserFn                     func(*sql.DB) ([]model.MysqlUser, error)
	CheckUserExistsFn             func(*sql.DB, string, string) (bool, error)
	CreateUserFn                  func(*sql.DB, string, string, string, string) error
	DropUserFn                    func(*sql.DB, string, string) error
	ChangeUserPasswdFn            func(*sql.DB, string, string, string) error
	CreateReplUserWithoutBinlogFn func(*sql.DB, string, string) error
	GrantAllPrivilegesFn          func(*sql.DB, string, string, string, string) error
	GrantNormalPrivilegesFn       func(*sql.DB, string, string) error
	CreateUserWithPrivilegesFn    func(*sql.DB, string, string, string, string, string, string, string) error
	GrantReplicationPrivilegesFn  func(*sql.DB, string) error
}

MockGTID tuple.

func NewMockGTIDA

func NewMockGTIDA() *MockGTID

NewMockGTIDA mock.

func NewMockGTIDAA added in v1.0.7

func NewMockGTIDAA() *MockGTID

NewMockGTIDAA mock. with GTID{Master_Log_File = "mysql-bin.000001", Read_Master_Log_Pos = 123} all functions return is OK

func NewMockGTIDB

func NewMockGTIDB() *MockGTID

NewMockGTIDB mock. with GTID{Master_Log_File = "mysql-bin.000001", Read_Master_Log_Pos = 123} all functions return is OK

func NewMockGTIDBB added in v1.0.7

func NewMockGTIDBB() *MockGTID

NewMockGTIDBB mock. with GTID{Master_Log_File = "mysql-bin.000001", Read_Master_Log_Pos = 123} all functions return is OK

func NewMockGTIDC

func NewMockGTIDC() *MockGTID

NewMockGTIDC mock. with GTID{Master_Log_File = "mysql-bin.000001", Read_Master_Log_Pos = 124} all functions return is OK

func NewMockGTIDCC added in v1.0.7

func NewMockGTIDCC() *MockGTID

NewMockGTIDCC mock. with GTID{Master_Log_File = "mysql-bin.000001", Read_Master_Log_Pos = 124} all functions return is OK

func NewMockGTIDD

func NewMockGTIDD() *MockGTID

NewMockGTIDD mock.

func NewMockGTIDE1 added in v1.1.4

func NewMockGTIDE1() *MockGTID

NewMockGTIDE1 mock.

func NewMockGTIDE2 added in v1.1.4

func NewMockGTIDE2() *MockGTID

NewMockGTIDE2 mock.

func NewMockGTIDE3 added in v1.1.4

func NewMockGTIDE3() *MockGTID

NewMockGTIDE3 mock.

func NewMockGTIDError

func NewMockGTIDError() *MockGTID

NewMockGTIDError mock. mock GetSlaveGTID returns error mock GetMasterGTID returns error

func NewMockGTIDF added in v1.1.4

func NewMockGTIDF() *MockGTID

NewMockGTIDF mock.

func NewMockGTIDGetGTIDSubtractError added in v1.1.4

func NewMockGTIDGetGTIDSubtractError() *MockGTID

NewMockGTIDGetSubtractError mock.

func NewMockGTIDInvalid added in v1.0.7

func NewMockGTIDInvalid() *MockGTID

NewMockGTIDInvalid mock. mock GetSlaveGTIDInvalid returns Invalid mock GetMasterGTIDInvalid returns Invalid

func NewMockGTIDLC added in v1.0.7

func NewMockGTIDLC() *MockGTID

NewMockGTIDLC mock

func NewMockGTIDNull added in v1.1.4

func NewMockGTIDNull() *MockGTID

NewMockGTIDNull mock.

func NewMockGTIDPingError

func NewMockGTIDPingError() *MockGTID

NewMockGTIDPingError mock. mock Ping returns error

func NewMockGTIDX1

func NewMockGTIDX1() *MockGTID

NewMockGTIDX1 mock. with GTID{Master_Log_File = "mysql-bin.000001", Read_Master_Log_Pos = 123,

gtid.Executed_GTID_Set = "6127a668-gtid-x555-a28d-5254335479b2:1"}

all functions return is OK

func NewMockGTIDX3

func NewMockGTIDX3() *MockGTID

NewMockGTIDX3 mock. with GTID{Master_Log_File = "mysql-bin.000003", Read_Master_Log_Pos = 123 ,

gtid.Executed_GTID_Set = "6127a668-gtid-x555-a28d-5254335479b2:1"}

all functions return is OK

func NewMockGTIDX5

func NewMockGTIDX5() *MockGTID

NewMockGTIDX5 mock. with GTID{Master_Log_File = "mysql-bin.000005", Read_Master_Log_Pos = 123,

gtid.Executed_GTID_Set = "6127a668-gtid-x555-a28d-5254335479b2:1"}

all functions return is OK

func NewMockGTIDX5ChangeToMasterError added in v1.0.4

func NewMockGTIDX5ChangeToMasterError() *MockGTID

NewMockGTIDX5ChangeToMasterError mock. with GTID{Master_Log_File = "mysql-bin.000005", Read_Master_Log_Pos = 123} all functions return is OK except ChangeToMaster error.

func NewMockGTIDX5WaitUntilAfterGTIDError added in v1.0.4

func NewMockGTIDX5WaitUntilAfterGTIDError() *MockGTID

NewMockGTIDX5WaitUntilAfterGTIDError mock. with GTID{Master_Log_File = "mysql-bin.000005", Read_Master_Log_Pos = 123} all functions return is OK except WaitUntilAfterGTID

func (*MockGTID) ChangeMasterTo

func (mogtid *MockGTID) ChangeMasterTo(db *sql.DB, gtid *model.Repl) error

ChangeMasterTo mock.

func (*MockGTID) ChangeToMaster

func (mogtid *MockGTID) ChangeToMaster(db *sql.DB) error

ChangeToMaster mock.

func (*MockGTID) ChangeUserPasswd added in v1.0.5

func (mogtid *MockGTID) ChangeUserPasswd(db *sql.DB, user string, host string, passwd string) error

func (*MockGTID) CheckUserExists added in v1.0.5

func (mogtid *MockGTID) CheckUserExists(db *sql.DB, user string, host string) (bool, error)

func (*MockGTID) CreateReplUserWithoutBinlog added in v1.0.5

func (mogtid *MockGTID) CreateReplUserWithoutBinlog(db *sql.DB, user string, passwd string) error

func (*MockGTID) CreateUser added in v1.0.5

func (mogtid *MockGTID) CreateUser(db *sql.DB, user string, host string, passwd string, ssltype string) error

func (*MockGTID) CreateUserWithPrivileges added in v1.0.5

func (mogtid *MockGTID) CreateUserWithPrivileges(db *sql.DB, user, passwd, database, table, host, privs string, ssl string) error

func (*MockGTID) DisableSemiSyncMaster

func (mogtid *MockGTID) DisableSemiSyncMaster(db *sql.DB) error

DisableSemiSyncMaster mock.

func (*MockGTID) DropUser added in v1.0.5

func (mogtid *MockGTID) DropUser(db *sql.DB, user string, host string) error

func (*MockGTID) EnableSemiSyncMaster

func (mogtid *MockGTID) EnableSemiSyncMaster(db *sql.DB) error

EnableSemiSyncMaster mock.

func (*MockGTID) GetGTIDSubtract added in v1.1.4

func (mogtid *MockGTID) GetGTIDSubtract(db *sql.DB, slaveGTID string, masterGTID string) (string, error)

GetGTIDSubtract mock.

func (*MockGTID) GetMasterGTID

func (mogtid *MockGTID) GetMasterGTID(db *sql.DB) (*model.GTID, error)

GetMasterGTID mock.

func (*MockGTID) GetSlaveGTID

func (mogtid *MockGTID) GetSlaveGTID(db *sql.DB) (*model.GTID, error)

GetSlaveGTID mock.

func (*MockGTID) GetUUID added in v1.0.7

func (mogtid *MockGTID) GetUUID(db *sql.DB) (string, error)

GetUUID mock.

func (*MockGTID) GetUser added in v1.0.5

func (mogtid *MockGTID) GetUser(db *sql.DB) ([]model.MysqlUser, error)

func (*MockGTID) GrantAllPrivileges added in v1.0.5

func (mogtid *MockGTID) GrantAllPrivileges(db *sql.DB, user string, host, passwd, ssl string) error

func (*MockGTID) GrantNormalPrivileges added in v1.0.5

func (mogtid *MockGTID) GrantNormalPrivileges(db *sql.DB, user string, host string) error

func (*MockGTID) GrantReplicationPrivileges added in v1.0.5

func (mogtid *MockGTID) GrantReplicationPrivileges(db *sql.DB, user string) error

func (*MockGTID) Ping

func (mogtid *MockGTID) Ping(db *sql.DB) (*PingEntry, error)

Ping mock.

func (*MockGTID) PurgeBinlogsTo

func (mogtid *MockGTID) PurgeBinlogsTo(db *sql.DB, binlog string) error

PurgeBinlogsTo mock.

func (*MockGTID) ResetMaster

func (mogtid *MockGTID) ResetMaster(db *sql.DB) error

ResetMaster mock.

func (*MockGTID) ResetSlaveAll

func (mogtid *MockGTID) ResetSlaveAll(db *sql.DB) error

ResetSlaveAll mock.

func (*MockGTID) SelectSysVar

func (mogtid *MockGTID) SelectSysVar(db *sql.DB, query string) (string, error)

SelectSysVar mock.

func (*MockGTID) SetGlobalSysVar

func (mogtid *MockGTID) SetGlobalSysVar(db *sql.DB, varsql string) error

SetGlobalSysVar mock.

func (*MockGTID) SetQueryTimeout added in v1.1.4

func (mogtid *MockGTID) SetQueryTimeout(timeout int)

SetQueryTimeout mock.

func (*MockGTID) SetReadOnly

func (mogtid *MockGTID) SetReadOnly(db *sql.DB, readonly bool) error

SetReadOnly mock.

func (*MockGTID) SetSemiSyncMasterTimeout added in v1.0.9

func (mogtid *MockGTID) SetSemiSyncMasterTimeout(db *sql.DB, timeout uint64) error

SetSemiSyncMasterTimeout mock.

func (*MockGTID) SetSemiWaitSlaveCount

func (mogtid *MockGTID) SetSemiWaitSlaveCount(db *sql.DB, count int) error

SetSemiWaitSlaveCount mock

func (*MockGTID) StartSlave

func (mogtid *MockGTID) StartSlave(db *sql.DB) error

StartSlave mock.

func (*MockGTID) StartSlaveIOThread

func (mogtid *MockGTID) StartSlaveIOThread(db *sql.DB) error

StartSlaveIOThread mock.

func (*MockGTID) StopSlave

func (mogtid *MockGTID) StopSlave(db *sql.DB) error

StopSlave mock.

func (*MockGTID) StopSlaveIOThread

func (mogtid *MockGTID) StopSlaveIOThread(db *sql.DB) error

StopSlaveIOThread mock.

func (*MockGTID) WaitUntilAfterGTID

func (mogtid *MockGTID) WaitUntilAfterGTID(db *sql.DB, targetGTID string) error

WaitUntilAfterGTID mock.

type Mysql

type Mysql struct {
	// contains filtered or unexported fields
}

Mysql tuple.

func MockMysql

func MockMysql(log *xlog.Log, port int, h MysqlHandler) (string, *Mysql, func())

MockMysql mock.

func MockMysqlReplUser added in v1.0.2

func MockMysqlReplUser(log *xlog.Log, port int, h MysqlHandler) (string, *Mysql, func())

MockMysqlReplUser mock.

func NewMysql

func NewMysql(conf *config.MysqlConfig, queryTimeout int, log *xlog.Log) *Mysql

NewMysql creates the new Mysql.

func (*Mysql) ChangeMasterTo

func (m *Mysql) ChangeMasterTo(repl *model.Repl) error

ChangeMasterTo used to do the 'change master to' command.

func (*Mysql) ChangeToMaster

func (m *Mysql) ChangeToMaster() error

ChangeToMaster used to do the 'reset slave all' command.

func (*Mysql) ChangeUserPasswd

func (m *Mysql) ChangeUserPasswd(user string, host string, passwd string) error

ChangeUserPasswd used to change the user's password.

func (*Mysql) CheckGTID added in v1.0.7

func (m *Mysql) CheckGTID(followerGTID *model.GTID, candidateGTID *model.GTID) bool

CheckGTID use to compare the followerGTID and candidateGTID

func (*Mysql) CheckUserExists

func (m *Mysql) CheckUserExists(user string, host string) (bool, error)

CheckUserExists used to check the user exists or not.

func (*Mysql) CreateReplUserWithoutBinlog

func (m *Mysql) CreateReplUserWithoutBinlog(user string, passwd string) error

CreateReplUserWithoutBinlog used to create a repl user without binlog.

func (*Mysql) CreateUser

func (m *Mysql) CreateUser(user string, host string, passwd string, ssltype string) error

CreateUser used to create the new user.

func (*Mysql) CreateUserWithPrivileges

func (m *Mysql) CreateUserWithPrivileges(user, passwd, database, table, host, privs string, ssl string) error

CreateUserWithPrivileges used to create a new user with grants.

func (*Mysql) DisableSemiSyncMaster

func (m *Mysql) DisableSemiSyncMaster() error

DisableSemiSyncMaster used to disable the semi-sync from master.

func (*Mysql) DropUser

func (m *Mysql) DropUser(user string, host string) error

DropUser used to drop a user.

func (*Mysql) EnableSemiSyncMaster

func (m *Mysql) EnableSemiSyncMaster() error

EnableSemiSyncMaster used to enable the semi-sync on master.

func (*Mysql) GTIDGreaterThan

func (m *Mysql) GTIDGreaterThan(gtid *model.GTID) (bool, model.GTID, error)

GTIDGreaterThan used to compare the master_log_file and read_master_log_pos between from and this.

func (*Mysql) GetGTID

func (m *Mysql) GetGTID() (model.GTID, error)

GetGTID returns the mysql master_binlog and read_master_log_pos. 1. first try GetSlaveGTID 2. if STEP1) fails, try GetMasterGTID

func (*Mysql) GetGTIDSubtract added in v1.1.4

func (m *Mysql) GetGTIDSubtract(subsetGTID string, setGTID string) (string, error)

func (*Mysql) GetLocalGTID added in v1.0.7

func (m *Mysql) GetLocalGTID(gtid string) (string, error)

func (*Mysql) GetMasterGTID

func (m *Mysql) GetMasterGTID() (*model.GTID, error)

GetMasterGTID used to get master binlog info.

func (*Mysql) GetMysqlRPC

func (m *Mysql) GetMysqlRPC() *MysqlRPC

GetMysqlRPC returns the MysqlRPC.

func (*Mysql) GetOption

func (m *Mysql) GetOption() Option

GetOption returns the mysql option.

func (*Mysql) GetRepl

func (m *Mysql) GetRepl() model.Repl

GetRepl returns the repl info.

func (*Mysql) GetSlaveGTID

func (m *Mysql) GetSlaveGTID() (*model.GTID, error)

GetSlaveGTID used to get Relay_Master_Log_File and read_master_binlog_pos.

func (*Mysql) GetState

func (m *Mysql) GetState() model.MysqlState

GetState returns the mysql state.

func (*Mysql) GetUUID added in v1.0.7

func (m *Mysql) GetUUID() (string, error)

GetUUID used to get local uuid.

func (*Mysql) GetUser

func (m *Mysql) GetUser() ([]model.MysqlUser, error)

GetUser used to get the mysql user list.

func (*Mysql) GrantAllPrivileges

func (m *Mysql) GrantAllPrivileges(user string, host string, passwd string, ssl string) error

GrantAllPrivileges used to grants all privs for the user.

func (*Mysql) GrantNormalPrivileges

func (m *Mysql) GrantNormalPrivileges(user string, host string) error

GrantNormalPrivileges used grant normal privs.

func (*Mysql) GrantReplicationPrivileges

func (m *Mysql) GrantReplicationPrivileges(user string) error

GrantReplicationPrivileges used to grant replication privs.

func (*Mysql) IncMysqlDowns

func (s *Mysql) IncMysqlDowns()

IncMysqlDowns used to increase the mysql down counter.

func (*Mysql) Ping

func (m *Mysql) Ping()

Ping used to get the master binlog every ping.

func (*Mysql) PingStart

func (m *Mysql) PingStart()

PingStart used to start the ping.

func (*Mysql) PingStop

func (m *Mysql) PingStop()

PingStop used to stop the ping.

func (*Mysql) Promotable

func (m *Mysql) Promotable() bool

Promotable used to check whether we can promote to candidate. Promotable: 1. MySQL is MysqlAlive 2. Slave_SQL_Running

NOTES: we do not consider Slave_IO_Running to Promotable, because the MySQL of leader maybe down the slaves Slave_IO_Running is false, because it's in connecting state

func (*Mysql) PurgeBinlogsTo

func (m *Mysql) PurgeBinlogsTo(binlog string) error

PurgeBinlogsTo used to purge binlog.

func (*Mysql) RelayMasterLogFile

func (m *Mysql) RelayMasterLogFile() string

RelayMasterLogFile returns RelayMasterLogFile.

func (*Mysql) ResetMaster

func (m *Mysql) ResetMaster() error

ResetMaster used to reset master.

func (*Mysql) ResetSlaveAll

func (m *Mysql) ResetSlaveAll() error

ResetSlaveAll used to reset slave.

func (*Mysql) SetGlobalSysVar

func (m *Mysql) SetGlobalSysVar(varsql string) error

SetGlobalSysVar used to set global variables.

func (*Mysql) SetMasterGlobalSysVar

func (m *Mysql) SetMasterGlobalSysVar() error

SetMasterGlobalSysVar used to set master global variables.

func (*Mysql) SetMysqlHandler added in v1.0.5

func (m *Mysql) SetMysqlHandler(h MysqlHandler)

SetMysqlHandler used to set the repl handler.

func (*Mysql) SetReadOnly

func (m *Mysql) SetReadOnly() (err error)

SetReadOnly used to set the mysql to readonly.

func (*Mysql) SetReadWrite

func (m *Mysql) SetReadWrite() (err error)

SetReadWrite used to set the mysql to write.

func (*Mysql) SetSemiSyncMasterTimeout added in v1.0.9

func (m *Mysql) SetSemiSyncMasterTimeout(timeout uint64) error

SetSemiSyncMasterTimeout used to set semi-sync master timeout.

func (*Mysql) SetSemiWaitSlaveCount

func (m *Mysql) SetSemiWaitSlaveCount(count int) error

SetSemiWaitSlaveCount used to set rpl_semi_sync_master_wait_for_slave_count

func (*Mysql) SetSlaveGlobalSysVar

func (m *Mysql) SetSlaveGlobalSysVar() error

SetSlaveGlobalSysVar used to set slave global variables.

func (*Mysql) StartSlave

func (m *Mysql) StartSlave() error

StartSlave used to start the slave.

func (*Mysql) StartSlaveIOThread

func (m *Mysql) StartSlaveIOThread() error

StartSlaveIOThread used to start the slave io thread.

func (*Mysql) StopSlave

func (m *Mysql) StopSlave() error

StopSlave used to stop the slave.

func (*Mysql) StopSlaveIOThread

func (m *Mysql) StopSlaveIOThread() error

StopSlaveIOThread used to stop the slave io thread.

func (*Mysql) WaitMysqlWorks

func (m *Mysql) WaitMysqlWorks(timeout int) error

WaitMysqlWorks used to wait for the mysqld to work.

func (*Mysql) WaitUntilAfterGTID

func (m *Mysql) WaitUntilAfterGTID(targetGTID string) error

WaitUntilAfterGTID used to do 'SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS' command.

type Mysql56 added in v1.0.5

type Mysql56 struct {
	MysqlBase
}

Mysql56 tuple.

func (*Mysql56) ChangeUserPasswd added in v1.0.5

func (my *Mysql56) ChangeUserPasswd(db *sql.DB, user string, host string, passwd string) error

ChangeUserPasswd used to change the user password.

func (*Mysql56) CreateUser added in v1.1.3

func (my *Mysql56) CreateUser(db *sql.DB, user string, host string, passwd string, ssltype string) error

CreateUser use to create new user.

func (*Mysql56) CreateUserWithPrivileges added in v1.1.3

func (my *Mysql56) CreateUserWithPrivileges(db *sql.DB, user, passwd, database, table, host, privs string, ssl string) error

CreateUserWithPrivileges for create normal user.

func (*Mysql56) GrantAllPrivileges added in v1.1.3

func (my *Mysql56) GrantAllPrivileges(db *sql.DB, user string, host string, passwd string, ssl string) error

GrantAllPrivileges used to grant all privis.

func (*Mysql56) SetSemiWaitSlaveCount added in v1.0.5

func (my *Mysql56) SetSemiWaitSlaveCount(db *sql.DB, count int) error

SetSemiWaitSlaveCount used set rpl_semi_sync_master_wait_for_slave_count

type Mysql57

type Mysql57 struct {
	MysqlBase
}

Mysql57 tuple.

type Mysql80 added in v1.1.3

type Mysql80 struct {
	MysqlBase
}

Mysql80 tuple.

type MysqlBase added in v1.0.5

type MysqlBase struct {
	MysqlHandler
	// contains filtered or unexported fields
}

MysqlBase tuple.

func (*MysqlBase) ChangeMasterTo added in v1.0.5

func (my *MysqlBase) ChangeMasterTo(db *sql.DB, master *model.Repl) error

ChangeMasterTo stop for all channels and reset all replication filter to null. In Xenon, we never set replication filter.

func (*MysqlBase) ChangeToMaster added in v1.0.5

func (my *MysqlBase) ChangeToMaster(db *sql.DB) error

ChangeToMaster changes a slave to be master.

func (*MysqlBase) ChangeUserPasswd added in v1.0.5

func (my *MysqlBase) ChangeUserPasswd(db *sql.DB, user string, host string, passwd string) error

ChangeUserPasswd used to change the user password.

func (*MysqlBase) CheckUserExists added in v1.0.5

func (my *MysqlBase) CheckUserExists(db *sql.DB, user string, host string) (bool, error)

CheckUserExists used to check the user exists or not.

func (*MysqlBase) CreateReplUserWithoutBinlog added in v1.0.5

func (my *MysqlBase) CreateReplUserWithoutBinlog(db *sql.DB, user string, passwd string) error

CreateReplUserWithoutBinlog create replication accounts without writing binlog.

func (*MysqlBase) CreateUser added in v1.0.5

func (my *MysqlBase) CreateUser(db *sql.DB, user string, host string, passwd string, ssltype string) error

CreateUser use to create new user. see http://dev.mysql.com/doc/refman/5.7/en/string-literals.html

func (*MysqlBase) CreateUserWithPrivileges added in v1.0.5

func (my *MysqlBase) CreateUserWithPrivileges(db *sql.DB, user, passwd, database, table, host, privs string, ssl string) error

CreateUserWithPrivileges for create normal user.

func (*MysqlBase) DisableSemiSyncMaster added in v1.0.5

func (my *MysqlBase) DisableSemiSyncMaster(db *sql.DB) error

DisableSemiSyncMaster used to disable the semi-sync from master.

func (*MysqlBase) DropUser added in v1.0.5

func (my *MysqlBase) DropUser(db *sql.DB, user string, host string) error

DropUser used to drop the user.

func (*MysqlBase) EnableSemiSyncMaster added in v1.0.5

func (my *MysqlBase) EnableSemiSyncMaster(db *sql.DB) error

EnableSemiSyncMaster used to enable the semi-sync on master.

func (*MysqlBase) GetGTIDSubtract added in v1.1.4

func (my *MysqlBase) GetGTIDSubtract(db *sql.DB, subsetGTID string, setGTID string) (string, error)

GetGTIDSubtract used to do "SELECT GTID_SUBTRACT('subsetGTID','setGTID') as gtid_sub" command

func (*MysqlBase) GetMasterGTID added in v1.0.5

func (my *MysqlBase) GetMasterGTID(db *sql.DB) (*model.GTID, error)

GetMasterGTID used to get binlog info from master.

func (*MysqlBase) GetSlaveGTID added in v1.0.5

func (my *MysqlBase) GetSlaveGTID(db *sql.DB) (*model.GTID, error)

GetSlaveGTID gets the gtid from the default channel. Here, We just show the default slave channel.

func (*MysqlBase) GetUUID added in v1.0.7

func (my *MysqlBase) GetUUID(db *sql.DB) (string, error)

GetUUID used to get local uuid.

func (*MysqlBase) GetUser added in v1.0.5

func (my *MysqlBase) GetUser(db *sql.DB) ([]model.MysqlUser, error)

GetUser used to get the mysql user list

func (*MysqlBase) GrantAllPrivileges added in v1.0.5

func (my *MysqlBase) GrantAllPrivileges(db *sql.DB, user string, host string, passwd string, ssl string) error

GrantAllPrivileges used to grant all privis.

func (*MysqlBase) GrantNormalPrivileges added in v1.0.5

func (my *MysqlBase) GrantNormalPrivileges(db *sql.DB, user string, host string) error

GrantNormalPrivileges used to grants normal privileges.

func (*MysqlBase) GrantReplicationPrivileges added in v1.0.5

func (my *MysqlBase) GrantReplicationPrivileges(db *sql.DB, user string) error

GrantReplicationPrivileges used to grant repli privis.

func (*MysqlBase) Ping added in v1.0.5

func (my *MysqlBase) Ping(db *sql.DB) (*PingEntry, error)

Ping has 2 affects: one for heath check other for get master_binglog the slave is syncing

func (*MysqlBase) PurgeBinlogsTo added in v1.0.5

func (my *MysqlBase) PurgeBinlogsTo(db *sql.DB, binlog string) error

PurgeBinlogsTo used to purge binlog.

func (*MysqlBase) ResetMaster added in v1.0.5

func (my *MysqlBase) ResetMaster(db *sql.DB) error

ResetMaster used to reset master.

func (*MysqlBase) ResetSlaveAll added in v1.0.5

func (my *MysqlBase) ResetSlaveAll(db *sql.DB) error

ResetSlaveAll used to reset slave.

func (*MysqlBase) SetGlobalSysVar added in v1.0.5

func (my *MysqlBase) SetGlobalSysVar(db *sql.DB, varsql string) error

SetGlobalSysVar used to set global variables.

func (*MysqlBase) SetQueryTimeout added in v1.1.4

func (my *MysqlBase) SetQueryTimeout(timeout int)

SetQueryTimeout used to set parameter queryTimeout

func (*MysqlBase) SetReadOnly added in v1.0.5

func (my *MysqlBase) SetReadOnly(db *sql.DB, readonly bool) error

SetReadOnly used to set mysql to readonly.

func (*MysqlBase) SetSemiSyncMasterTimeout added in v1.0.9

func (my *MysqlBase) SetSemiSyncMasterTimeout(db *sql.DB, timeout uint64) error

SetSemiSyncMasterTimeout used to set semi-sync master timeout

func (*MysqlBase) SetSemiWaitSlaveCount added in v1.0.5

func (my *MysqlBase) SetSemiWaitSlaveCount(db *sql.DB, count int) error

SetSemiWaitSlaveCount used set rpl_semi_sync_master_wait_for_slave_count

func (*MysqlBase) StartSlave added in v1.0.5

func (my *MysqlBase) StartSlave(db *sql.DB) error

StartSlave used to start slave.

func (*MysqlBase) StartSlaveIOThread added in v1.0.5

func (my *MysqlBase) StartSlaveIOThread(db *sql.DB) error

StartSlaveIOThread used to start the io thread.

func (*MysqlBase) StopSlave added in v1.0.5

func (my *MysqlBase) StopSlave(db *sql.DB) error

StopSlave used to stop the slave.

func (*MysqlBase) StopSlaveIOThread added in v1.0.5

func (my *MysqlBase) StopSlaveIOThread(db *sql.DB) error

StopSlaveIOThread used to stop the op thread.

func (*MysqlBase) WaitUntilAfterGTID added in v1.0.5

func (my *MysqlBase) WaitUntilAfterGTID(db *sql.DB, targetGTID string) error

WaitUntilAfterGTID used to do 'SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS' command. https://dev.mysql.com/doc/refman/5.7/en/gtid-functions.html

type MysqlHandler added in v1.0.5

type MysqlHandler interface {
	SetQueryTimeout(int)

	// check health and return log_bin_basename
	Ping(*sql.DB) (*PingEntry, error)

	// set mysql readonly variable
	SetReadOnly(*sql.DB, bool) error

	// get GTID from traversal binlog folder and find the newest one
	GetMasterGTID(*sql.DB) (*model.GTID, error)

	// get GTID from SHOW SLAVE STATUS
	GetSlaveGTID(*sql.DB) (*model.GTID, error)

	// start slave io_thread
	StartSlaveIOThread(*sql.DB) error

	// stop slave io_thread
	StopSlaveIOThread(*sql.DB) error

	// start slave
	StartSlave(*sql.DB) error

	// stop slave
	StopSlave(*sql.DB) error

	// use the provided master as the new master
	ChangeMasterTo(*sql.DB, *model.Repl) error

	// change a slave to master
	ChangeToMaster(*sql.DB) error

	// waits until slave replication reaches at least targetGTID
	WaitUntilAfterGTID(*sql.DB, string) error

	// get local uuid
	GetUUID(db *sql.DB) (string, error)

	// get gtid subtract with slavegtid and master gtid
	GetGTIDSubtract(*sql.DB, string, string) (string, error)

	// set global variables
	SetGlobalSysVar(db *sql.DB, varsql string) error

	// reset master
	ResetMaster(db *sql.DB) error

	// reset slave all
	ResetSlaveAll(db *sql.DB) error

	// purge binglog to
	PurgeBinlogsTo(*sql.DB, string) error

	// enable master semi sync: wait slave ack
	EnableSemiSyncMaster(db *sql.DB) error

	// disable master semi sync: don't wait slave ack
	DisableSemiSyncMaster(db *sql.DB) error

	// set semi-sync master-timeout
	SetSemiSyncMasterTimeout(db *sql.DB, timeout uint64) error

	//set rpl_semi_master_wait_for_slave_count
	SetSemiWaitSlaveCount(db *sql.DB, count int) error

	// User handlers.
	GetUser(*sql.DB) ([]model.MysqlUser, error)
	CheckUserExists(*sql.DB, string, string) (bool, error)
	CreateUser(*sql.DB, string, string, string, string) error
	DropUser(*sql.DB, string, string) error
	ChangeUserPasswd(*sql.DB, string, string, string) error
	CreateReplUserWithoutBinlog(*sql.DB, string, string) error
	GrantAllPrivileges(*sql.DB, string, string, string, string) error
	GrantNormalPrivileges(*sql.DB, string, string) error
	CreateUserWithPrivileges(db *sql.DB, user, passwd, database, table, host, privs string, ssl string) error
	GrantReplicationPrivileges(*sql.DB, string) error
}

MysqlHandler interface.

type MysqlRPC

type MysqlRPC struct {
	// contains filtered or unexported fields
}

MysqlRPC tuple.

func (*MysqlRPC) ChangeToMaster

func (m *MysqlRPC) ChangeToMaster(req *model.MysqlRPCRequest, rsp *model.MysqlRPCResponse) error

ChangeToMaster used to do 'reset slave all' command.

func (*MysqlRPC) GTIDSubtract added in v1.1.4

GTIDSubstract returns the mysql GTID subtract info.

func (*MysqlRPC) IsWorking

func (m *MysqlRPC) IsWorking(req *model.MysqlRPCRequest, rsp *model.MysqlRPCResponse) error

IsWorking used to check the mysql works or not.

func (*MysqlRPC) ResetMaster

func (m *MysqlRPC) ResetMaster(req *model.MysqlRPCRequest, rsp *model.MysqlRPCResponse) error

ResetMaster used to reset master.

func (*MysqlRPC) ResetSlaveAll

func (m *MysqlRPC) ResetSlaveAll(req *model.MysqlRPCRequest, rsp *model.MysqlRPCResponse) error

ResetSlaveAll used to reset slave.

func (*MysqlRPC) SetGlobalSysVar

func (m *MysqlRPC) SetGlobalSysVar(req *model.MysqlVarRPCRequest, rsp *model.MysqlVarRPCResponse) error

SetGlobalSysVar used to set global vars.

func (*MysqlRPC) SetState added in v1.1.4

SetState used to set the mysql state.

func (*MysqlRPC) StartSlave

func (m *MysqlRPC) StartSlave(req *model.MysqlRPCRequest, rsp *model.MysqlRPCResponse) error

StartSlave used to start the slave.

func (*MysqlRPC) Status

Status returns the mysql GTID info.

func (*MysqlRPC) StopSlave

func (m *MysqlRPC) StopSlave(req *model.MysqlRPCRequest, rsp *model.MysqlRPCResponse) error

StopSlave used to stop the slave.

type Option

type Option string

Option enum.

const (
	// MysqlReadonly enum.
	MysqlReadonly Option = "READONLY"
	// MysqlReadwrite enum.
	MysqlReadwrite Option = "READWRITE"
)

type PingEntry

type PingEntry struct {
	Relay_Master_Log_File string
}

PingEntry tuple.

func DefaultPing

func DefaultPing(db *sql.DB) (*PingEntry, error)

DefaultPing mock.

func PingError1

func PingError1(db *sql.DB) (*PingEntry, error)

PingError1 mock.

func PingError2

func PingError2(db *sql.DB) (*PingEntry, error)

PingError2 mock.

func PingX1

func PingX1(db *sql.DB) (*PingEntry, error)

PingX1 mock.

func PingX3

func PingX3(db *sql.DB) (*PingEntry, error)

PingX3 mock.

func PingX5

func PingX5(db *sql.DB) (*PingEntry, error)

PingX5 mock.

Jump to

Keyboard shortcuts

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