FAQ
Hi,

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.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupgolang-dev @
categoriesgo
postedJan 28, '14 at 1:38p
activeJan 28, '14 at 3:02p
posts2
users1
websitegolang.org

1 user in discussion

Graham King: 2 posts

People

Translate

site design / logo © 2022 Grokbase