This should fix it x.x
This commit is contained in:
parent
f84f11a1eb
commit
91c81b96e0
|
@ -85,7 +85,6 @@ func gloinit() (err error) {
|
||||||
}
|
}
|
||||||
err = InitDatabase()
|
err = InitDatabase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print("err2: ", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = afterDBInit()
|
err = afterDBInit()
|
||||||
|
|
|
@ -4,7 +4,7 @@ package qgen
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -41,13 +41,6 @@ func (adapter *MysqlAdapter) GetStmts() map[string]DBStmt {
|
||||||
|
|
||||||
// TODO: Add an option to disable unix pipes
|
// TODO: Add an option to disable unix pipes
|
||||||
func (adapter *MysqlAdapter) BuildConn(config map[string]string) (*sql.DB, error) {
|
func (adapter *MysqlAdapter) BuildConn(config map[string]string) (*sql.DB, error) {
|
||||||
// The adapter seems to be panicking when encountering a recoverable error x.x
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
fmt.Println("Recovered in f", r)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
dbCollation, ok := config["collation"]
|
dbCollation, ok := config["collation"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrNoCollation
|
return nil, ErrNoCollation
|
||||||
|
@ -64,14 +57,15 @@ func (adapter *MysqlAdapter) BuildConn(config map[string]string) (*sql.DB, error
|
||||||
dbsocket = config["socket"]
|
dbsocket = config["socket"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The MySQL adapter refuses to open any other connections, if the unix socket doesn't exist, so check for it first
|
||||||
|
_, err := os.Stat(dbsocket)
|
||||||
|
if err == nil {
|
||||||
db, err := sql.Open("mysql", config["username"]+dbpassword+"@unix("+dbsocket+")/"+config["name"]+"?collation="+dbCollation+"&parseTime=true")
|
db, err := sql.Open("mysql", config["username"]+dbpassword+"@unix("+dbsocket+")/"+config["name"]+"?collation="+dbCollation+"&parseTime=true")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Make sure that the connection is alive
|
// Make sure that the connection is alive
|
||||||
return db, db.Ping()
|
return db, db.Ping()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Am I supposed to do this? o.O
|
|
||||||
db, err = nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the database connection
|
// Open the database connection
|
||||||
|
|
Loading…
Reference in New Issue