dbhelper

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BenchCleanup

func BenchCleanup(db *sqlx.DB) error

func ChangeMaster

func ChangeMaster(db *sqlx.DB, opt ChangeMasterOpt) error

func CheckBinlogFilters

func CheckBinlogFilters(m *sqlx.DB, s *sqlx.DB) (bool, error)

func CheckHostAddr

func CheckHostAddr(h string) (string, error)

Check if string is an IP address or a hostname, return a IP address

func CheckLongRunningWrites

func CheckLongRunningWrites(db *sqlx.DB, thresh int) int

func CheckReplicationAccount

func CheckReplicationAccount(db *sqlx.DB, pass string, user string, host string, ip string) (bool, error)

func CheckReplicationFilters

func CheckReplicationFilters(m *sqlx.DB, s *sqlx.DB) bool

func CheckSlavePrerequisites

func CheckSlavePrerequisites(db *sqlx.DB, s string) bool
Check for a list of slave prerequisites.

- Slave is connected - Binary log on - Connected to master - No replication filters

func CheckSlaveSemiSync

func CheckSlaveSemiSync(dbS *sqlx.DB) bool

func CheckSlaveSync

func CheckSlaveSync(dbS *sqlx.DB, dbM *sqlx.DB) bool

Check if a slave is in sync with his master

func ChecksumTable

func ChecksumTable(db *sqlx.DB, table string) (string, error)

func FlushLogs

func FlushLogs(db *sqlx.DB) error

func FlushTables

func FlushTables(db *sqlx.DB) error

func FlushTablesNoLog

func FlushTablesNoLog(db *sqlx.DB) error

func FlushTablesWithReadLock

func FlushTablesWithReadLock(db *sqlx.DB) error

func ForgetArbitration

func ForgetArbitration(db *sqlx.DB, secret string) error

func GetAddress

func GetAddress(host string, port string, socket string) string

func GetArbitrationMaster

func GetArbitrationMaster(db *sqlx.DB, secret string, cluster string) string

func GetBinlogEventPseudoGTID

func GetBinlogEventPseudoGTID(db *sqlx.DB, uuid string, lastfile string) (string, string, error)

func GetBinlogPosAfterSkipNumberOfEvents

func GetBinlogPosAfterSkipNumberOfEvents(db *sqlx.DB, file string, pos string, skip int) (string, string, error)

func GetEngineInnoDB

func GetEngineInnoDB(db *sqlx.DB) (map[string]string, error)

func GetEventScheduler

func GetEventScheduler(dbM *sqlx.DB) bool

func GetHostFromConnection

func GetHostFromConnection(db *sqlx.DB, user string) (string, error)

func GetHostFromProcessList

func GetHostFromProcessList(db *sqlx.DB, user string) string

func GetLastPseudoGTID

func GetLastPseudoGTID(db *sqlx.DB) (string, error)

func GetMaxscaleVersion

func GetMaxscaleVersion(db *sqlx.DB) (string, error)

func GetNumberOfEventsAfterPos

func GetNumberOfEventsAfterPos(db *sqlx.DB, lastfile string, lastpos string) (int, error)

func GetProxySQLUsers

func GetProxySQLUsers(db *sqlx.DB) (map[string]Grant, error)

func GetQueries

func GetQueries(db *sqlx.DB) (map[string]string, error)

func GetSchemas

func GetSchemas(db *sqlx.DB) ([]string, error)

func GetSlaveHosts

func GetSlaveHosts(db *sqlx.DB) (map[string]interface{}, error)

func GetSlaveHostsDiscovery

func GetSlaveHostsDiscovery(db *sqlx.DB) ([]string, error)

func GetSpiderMonitor

func GetSpiderMonitor(db *sqlx.DB) (string, error)

func GetSpiderShardUrl

func GetSpiderShardUrl(db *sqlx.DB) (string, error)

func GetSpiderTableToSync

func GetSpiderTableToSync(db *sqlx.DB) (map[string]SpiderTableNoSync, error)

func GetStatus

func GetStatus(db *sqlx.DB) (map[string]string, error)

func GetStatusAsInt

func GetStatusAsInt(db *sqlx.DB) (map[string]int64, error)

func GetTables

func GetTables(db *sqlx.DB) (map[string]Table, error)

func GetUsers

func GetUsers(db *sqlx.DB) (map[string]Grant, error)

func GetVariableByName

func GetVariableByName(db *sqlx.DB, name string) (string, error)

func GetVariableSource

func GetVariableSource(db *sqlx.DB) string

func GetVariables

func GetVariables(db *sqlx.DB) (map[string]string, error)

func HasMySQLGTID

func HasMySQLGTID(db *sqlx.DB) (bool, error)

func HaveExtraEvents

func HaveExtraEvents(db *sqlx.DB, file string, pos string) (bool, error)

func InjectLongTrx

func InjectLongTrx(db *sqlx.DB, time int) error

func InjectTrx

func InjectTrx(db *sqlx.DB) error

func InjectTrxWithoutCommit

func InjectTrxWithoutCommit(db *sqlx.DB) error

func InstallSemiSync

func InstallSemiSync(db *sqlx.DB) error

func IsSlaveof

func IsSlaveof(db *sqlx.DB, s string, m string, p string) (bool, error)

Check if server is connected to declared master

func KillThreads

func KillThreads(db *sqlx.DB)

func MariaDBFlushTablesNoLogTimeout

func MariaDBFlushTablesNoLogTimeout(db *sqlx.DB, timeout string) error

func MariaDBVersion

func MariaDBVersion(server string) int

func MasterPosWait

func MasterPosWait(db *sqlx.DB, log string, pos string, timeout int) error

func MasterWaitGTID

func MasterWaitGTID(db *sqlx.DB, gtid string, timeout int) error

func MySQLConnect

func MySQLConnect(user string, password string, address string, parameters ...string) (*sqlx.DB, error)

func RequestArbitration

func RequestArbitration(db *sqlx.DB, uuid string, secret string, cluster string, master string, uid int, hosts int, failed int) bool

func ResetAllSlaves

func ResetAllSlaves(db *sqlx.DB) error

func ResetMaster

func ResetMaster(db *sqlx.DB) error

func ResetSlave

func ResetSlave(db *sqlx.DB, all bool) error

func SQLiteConnect

func SQLiteConnect(path string) (*sqlx.DB, error)

SQLiteConnect returns a SQLite connection

func SetBinlogAnnotate

func SetBinlogAnnotate(db *sqlx.DB) error

func SetBinlogChecksum

func SetBinlogChecksum(db *sqlx.DB) error

SetBinlogChecksum Enable binlog checksum and check on master

func SetBinlogCompress

func SetBinlogCompress(db *sqlx.DB) error

SetBinlogCompress Enable MaraiDB 10.2 binlog compression

func SetBinlogFormat

func SetBinlogFormat(db *sqlx.DB, format string) error

func SetBinlogSlowqueries

func SetBinlogSlowqueries(db *sqlx.DB) error

SetBinlogSlowqueries Enable queries in replication to be reported in slow queries

func SetDefaultMasterConn

func SetDefaultMasterConn(db *sqlx.DB, dmc string) error

func SetEventScheduler

func SetEventScheduler(db *sqlx.DB, state bool) error

func SetEventStatus

func SetEventStatus(db *sqlx.DB, ev Event, status int64) error

func SetHeartbeatTable

func SetHeartbeatTable(db *sqlx.DB) error

func SetMultiSourceRepl

func SetMultiSourceRepl(db *sqlx.DB, master_host string, master_port string, master_user string, master_password string, master_filter string) error

func SetReadOnly

func SetReadOnly(db *sqlx.DB, flag bool) error

func SetRelayLogSpaceLimit

func SetRelayLogSpaceLimit(db *sqlx.DB, size string) error

func SetSlaveGTIDMode

func SetSlaveGTIDMode(db *sqlx.DB, mode string) error

func SetSlaveHeartbeat

func SetSlaveHeartbeat(db *sqlx.DB, interval string) error

func SetStatusActiveHeartbeat

func SetStatusActiveHeartbeat(db *sqlx.DB, uuid string, status string, master string, secret string, uid int) error

SetStatusActiveHeartbeat arbitrator can set or remove election flag "E"

func SetSuperReadOnly

func SetSuperReadOnly(db *sqlx.DB, flag bool) error

func SetSyncBinlog

func SetSyncBinlog(db *sqlx.DB) error

SetSyncBinlog Enable Binlog Durability

func SetSyncInnodb

func SetSyncInnodb(db *sqlx.DB) error

SetSyncInnodb Enable InnoDB Durability

func StartSlave

func StartSlave(db *sqlx.DB) error

func StopAllSlaves

func StopAllSlaves(db *sqlx.DB) error

func StopSlave

func StopSlave(db *sqlx.DB) error

func StopSlaveIOThread

func StopSlaveIOThread(db *sqlx.DB) error

func StopSlaveSQLThread

func StopSlaveSQLThread(db *sqlx.DB) error

func UnlockTables

func UnlockTables(db *sqlx.DB) error

func WriteConcurrent2

func WriteConcurrent2(dsn string, qt int) (string, error)

func WriteHeartbeat

func WriteHeartbeat(db *sqlx.DB, uuid string, secret string, cluster string, master string, uid int, hosts int, failed int) error

Types

type BenchmarkSuite

type BenchmarkSuite struct {
	WarmUp      func(*sqlx.DB) error
	Repetitions int
	PrintStats  bool
	// contains filtered or unexported fields
}

func (*BenchmarkSuite) AddBenchmark

func (bs *BenchmarkSuite) AddBenchmark(name string, n int, bm func(*sqlx.DB, int) error)

func (*BenchmarkSuite) AddDriver

func (bs *BenchmarkSuite) AddDriver(name, drv, dsn string) error

func (*BenchmarkSuite) Run

func (bs *BenchmarkSuite) Run() string

type BinlogEvents

type BinlogEvents struct {
	Log_name    string `db:"Log_name"`
	Pos         uint   `db:"Pos"`
	Event_type  string `db:"Event_type"`
	Server_id   uint   `db:"Server_id"`
	End_log_pos uint   `db:"End_log_pos"`
	Info        string `db:"Info"`
}

type ChangeMasterOpt

type ChangeMasterOpt struct {
	Host      string
	Port      string
	User      string
	Password  string
	Retry     string
	Heartbeat string
	SSL       bool
	Logfile   string
	Logpos    string
	Mode      string
}

type Event

type Event struct {
	Db      string
	Name    string
	Definer string
	Status  int64
}

func GetEventStatus

func GetEventStatus(db *sqlx.DB) ([]Event, error)

type Grant

type Grant struct {
	User     string
	Host     string
	Password string `json:"-"`
	Hash     uint64
}

type MasterStatus

type MasterStatus struct {
	File             string
	Position         uint
	Binlog_Do_DB     string
	Binlog_Ignore_DB string
}

func GetMasterStatus

func GetMasterStatus(db *sqlx.DB) (MasterStatus, error)

type MySQLVersion

type MySQLVersion struct {
	Flavor string
	Major  int
	Minor  int
}

func GetDBVersion

func GetDBVersion(db *sqlx.DB) (*MySQLVersion, error)

func NewMySQLVersion

func NewMySQLVersion(version string, versionComment string) *MySQLVersion

func (*MySQLVersion) IsMariaDB

func (mv *MySQLVersion) IsMariaDB() bool

func (*MySQLVersion) IsMySQL

func (mv *MySQLVersion) IsMySQL() bool

func (*MySQLVersion) IsMySQL57

func (mv *MySQLVersion) IsMySQL57() bool

func (*MySQLVersion) IsMySQLOrPercona

func (mv *MySQLVersion) IsMySQLOrPercona() bool

func (*MySQLVersion) IsMySQLOrPercona57

func (mv *MySQLVersion) IsMySQLOrPercona57() bool

func (*MySQLVersion) IsPercona

func (mv *MySQLVersion) IsPercona() bool

type Privileges

type Privileges struct {
	Select_priv      string
	Process_priv     string
	Super_priv       string
	Repl_slave_priv  string
	Repl_client_priv string
	Reload_priv      string
}

func GetPrivileges

func GetPrivileges(db *sqlx.DB, user string, host string, ip string) (Privileges, error)

type Processlist

type Processlist struct {
	Id       uint64
	User     string
	Host     string
	Database sql.NullString
	Command  string
	Time     float64
	State    string
}

func GetProcesslist

func GetProcesslist(db *sqlx.DB) ([]Processlist, error)

type Result

type Result struct {
	Err      error
	Queries  int
	Duration time.Duration
	Allocs   uint64
	Bytes    uint64
}

func (*Result) AllocsPerQuery

func (res *Result) AllocsPerQuery() int

func (*Result) BytesPerQuery

func (res *Result) BytesPerQuery() int

func (*Result) QueriesPerSecond

func (res *Result) QueriesPerSecond() float64

type SlaveHosts

type SlaveHosts struct {
	Server_id uint64
	Host      string
	Port      uint
	Master_id uint64
}

func GetSlaveHostsArray

func GetSlaveHostsArray(db *sqlx.DB) ([]SlaveHosts, error)

type SlaveStatus

type SlaveStatus struct {
	ConnectionName       sql.NullString `db:"Connection_Name"`
	MasterHost           sql.NullString `db:"Master_Host"`
	MasterUser           sql.NullString `db:"Master_User"`
	MasterPort           sql.NullString `db:"Master_Port"`
	MasterLogFile        sql.NullString `db:"Master_Log_File"`
	ReadMasterLogPos     sql.NullString `db:"Read_Master_Log_Pos"`
	RelayMasterLogFile   sql.NullString `db:"Relay_Master_Log_File"`
	SlaveIORunning       sql.NullString `db:"Slave_IO_Running"`
	SlaveSQLRunning      sql.NullString `db:"Slave_SQL_Running"`
	ExecMasterLogPos     sql.NullString `db:"Exec_Master_Log_Pos"`
	SecondsBehindMaster  sql.NullInt64  `db:"Seconds_Behind_Master"`
	LastIOErrno          sql.NullString `db:"Last_IO_Errno"`
	LastIOError          sql.NullString `db:"Last_IO_Error"`
	LastSQLErrno         sql.NullString `db:"Last_SQL_Errno"`
	LastSQLError         sql.NullString `db:"Last_SQL_Error"`
	MasterServerID       uint           `db:"Master_Server_Id"`
	UsingGtid            sql.NullString `db:"Using_Gtid"`
	GtidIOPos            sql.NullString `db:"Gtid_IO_Pos"`
	GtidSlavePos         sql.NullString `db:"Gtid_Slave_Pos"`
	SlaveHeartbeatPeriod float64        `db:"Slave_Heartbeat_Period"`
	ExecutedGtidSet      sql.NullString `db:"Executed_Gtid_Set"`
	RetrievedGtidSet     sql.NullString `db:"Retrieved_Gtid_Set"`
	SlaveSQLRunningState sql.NullString `db:"Slave_SQL_Running_State"`
}

func GetAllSlavesStatus

func GetAllSlavesStatus(db *sqlx.DB) ([]SlaveStatus, error)

func GetChannelSlaveStatus

func GetChannelSlaveStatus(db *sqlx.DB) ([]SlaveStatus, error)

func GetMSlaveStatus

func GetMSlaveStatus(db *sqlx.DB, conn string) (SlaveStatus, error)

func GetSlaveStatus

func GetSlaveStatus(db *sqlx.DB) (SlaveStatus, error)

type SpiderTableNoSync

type SpiderTableNoSync struct {
	Tbl_src      string
	Tbl_src_link string
	Tbl_dest     string
	Srv_dsync    string
	Srv_sync     string
}

type Table

type Table struct {
	Table_schema string
	Table_name   string
	Engine       string
	Table_rows   int64
	Data_length  int64
	Index_length int64
	Table_crc    uint64
}

Jump to

Keyboard shortcuts

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