go-sql-driver/mysql

Return useful error when attempting to reuse a blocked connection

Open

#526 aperta il 8 dic 2016

Vedi su GitHub
 (10 commenti) (5 reazioni) (0 assegnatari)Go (1789 fork)batch import
help wanted

Metriche repository

Star
 (9946 star)
Metriche merge PR
 (Merge medio 5h 59m) (4 PR mergiate in 30 g)

Descrizione

Issue description

the latest version: 1.3.

Prepare one statement and execute it on one transaction, keep rows open. Error happens when trying to prepare another statement: [mysql] 2016/12/08 15:45:57 packets.go:431: busy buffer

I see issue#314 which was similiar with the problem and closed. Looks like this problem not fixed in 1.3.

Example code

func query(db *sql.DB) {
	var (
		tx    *sql.Tx
		stmt1 *sql.Stmt
		stmt2 *sql.Stmt
		rs1   *sql.Rows
		rs2   *sql.Rows
	)

	tx, _ = db.Begin()
	stmt1, _ = tx.Prepare("select f1, f2 from test where f2 = 11")
	rs1, _ = stmt1.Query()
	rs1.Next()

	stmt2, _ = tx.Prepare("select f2 from test where f2 = 111")  // error here
	rs2, _ = stmt2.Query()
	rs2.Next()

}

Error log

[mysql] 2016/12/08 15:45:57 packets.go:431: busy buffer

Configuration

*Driver version:1.3

Go version: go version go1.7.1 windows/amd64,go version go1.7.4 linux/amd64

Guida contributor