dbhelper

package
v0.0.0-...-1dcae54 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2017 License: GPL-3.0 Imports: 16 Imported by: 0

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 GetEventScheduler

func GetEventScheduler(dbM *sqlx.DB) bool

func GetHostFromConnection

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

func GetHostFromProcessList

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

func GetMaxscaleVersion

func GetMaxscaleVersion(db *sqlx.DB) (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 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 InjectLongTrx

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

func InjectTrx

func InjectTrx(db *sqlx.DB) error

func InjectTrxWithoutCommit

func InjectTrxWithoutCommit(db *sqlx.DB, time int) 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 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 MemDBConnect

func MemDBConnect() (*sqlx.DB, error)

MemDBConnect returns a SQLite memory connection

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 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 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 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 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 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) 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 {
	Connection_name               string
	Slave_SQL_State               string
	Slave_IO_State                string
	Master_Host                   string
	Master_User                   string
	Master_Port                   uint
	Connect_Retry                 uint
	Master_Log_File               string
	Read_Master_Log_Pos           uint
	Relay_Log_File                string
	Relay_Log_Pos                 uint
	Relay_Master_Log_File         string
	Slave_IO_Running              string
	Slave_SQL_Running             string
	Replicate_Do_DB               string
	Replicate_Ignore_DB           string
	Replicate_Do_Table            string
	Replicate_Ignore_Table        string
	Replicate_Wild_Do_Table       string
	Replicate_Wild_Ignore_Table   string
	Last_Errno                    uint
	Last_Error                    string
	Skip_Counter                  uint
	Exec_Master_Log_Pos           uint
	Relay_Log_Space               uint
	Until_Condition               string
	Until_Log_File                string
	Until_Log_Pos                 uint
	Master_SSL_Allowed            string
	Master_SSL_CA_File            string
	Master_SSL_CA_Path            string
	Master_SSL_Cert               string
	Master_SSL_Cipher             string
	Master_SSL_Key                string
	Seconds_Behind_Master         sql.NullInt64
	Master_SSL_Verify_Server_Cert string
	Last_IO_Errno                 uint
	Last_IO_Error                 string
	Last_SQL_Errno                uint
	Last_SQL_Error                string
	Replicate_Ignore_Server_Ids   string
	Master_Server_Id              uint
	Master_SSL_Crl                string
	Master_SSL_Crlpath            string
	Using_Gtid                    string
	Gtid_IO_Pos                   string
	Retried_transactions          uint
	Max_relay_log_size            uint
	Executed_log_entries          uint
	Slave_received_heartbeats     uint
	Slave_heartbeat_period        float64
	Gtid_Slave_Pos                string
}

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
}

func GetTables

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

Jump to

Keyboard shortcuts

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