func (mi *Indexer) SchemaVersion() (version int, err os.Error) { var client *mysql.Client client, err = mi.getConnection() if err != nil { return } defer mi.releaseConnection(client) err = client.Query("SELECT value FROM meta WHERE metakey='version'") if err != nil { return } res, err := client.UseResult() if err != nil { return } row := res.FetchRow() if row == nil { return 0, nil } version, err = strconv.Atoi(row[0].(string)) client.FreeResult() return }
func do(db *mysql.Client, sql string) { err := db.Query(sql) if err == nil { return } exitf("Error %v running SQL: %s", err, sql) }
func dbExists(db *mysql.Client, dbname string) bool { check(db.Query("SHOW DATABASES")) result, err := db.UseResult() check(err) defer result.Free() for { row := result.FetchRow() if row == nil { break } if row[0].(string) == dbname { return true } } return false }
func (mi *Indexer) IsAlive() (ok bool, err os.Error) { var client *mysql.Client client, err = mi.getConnection() if err != nil { return } defer mi.releaseConnection(client) err = client.Query("SELECT 1 + 1") if err != nil { return } _, err = client.UseResult() if err != nil { return } client.FreeResult() return true, nil }