If you run this code (also pasted below) http://play.golang.org/p/eribZlGr3B it will block forever on the second time through the for loop. Change SetMaxIdleConns to 0 and it works.
Problem happens with either MySQL database driver, and with both db.Query()/Next/Close and db.QueryRow().Scan(). Is it a bug? Could someone help me understand?
Thanks!
Graham
---
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
//_ "github.com/ziutek/mymysql/godrv"
)
func main() {
db, err := sql.Open("mysql", "root@tcp(localhost:3306)/nitro")
//db, err := sql.Open("mymysql", "tcp:localhost:3306*nitro/root/")
if err != nil {
fmt.Println(err)
}
db.SetMaxOpenConns(1)
db.SetMaxIdleConns(1) // Change to 0 it will work
var now string
for i := 0; i < 2; i++ {
err := db.QueryRow("SELECT NOW()").Scan(&now)
fmt.Println(i, now, err)
}
}
--
---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.