Esempio n. 1
0
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
}
Esempio n. 2
0
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
}
Esempio n. 3
0
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
}