-
Notifications
You must be signed in to change notification settings - Fork 41
/
master.go
57 lines (45 loc) · 1.38 KB
/
master.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package bsdb
// GetSwitchDBSignal get signal to switch db
func (b *BsDBImpl) GetSwitchDBSignal() (*MasterDB, error) {
var (
signal *MasterDB
err error
)
err = b.db.Table((&MasterDB{}).TableName()).
Select("*").
Take(&signal).Error
return signal, err
}
// GetMysqlVersion get the current mysql version
func (b *BsDBImpl) GetMysqlVersion() (string, error) {
var (
query string
version string
err error
)
query = "SELECT VERSION();"
err = b.db.Raw(query).Find(&version).Error
return version, err
}
// GetDefaultCharacterSet get the current mysql default character set
func (b *BsDBImpl) GetDefaultCharacterSet() (string, error) {
var (
query string
defaultCharacterSet string
err error
)
query = "SELECT DEFAULT_CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.SCHEMATA where SCHEMA_NAME in ('block_syncer');"
err = b.db.Raw(query).Find(&defaultCharacterSet).Error
return defaultCharacterSet, err
}
// GetDefaultCollationName get the current mysql default collation name
func (b *BsDBImpl) GetDefaultCollationName() (string, error) {
var (
query string
defaultCollationName string
err error
)
query = "SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA where SCHEMA_NAME in ('block_syncer');"
err = b.db.Raw(query).Find(&defaultCollationName).Error
return defaultCollationName, err
}