go-sql-driver/mysql

Return useful error when attempting to reuse a blocked connection

Open

#526 opened on Dec 8, 2016

View on GitHub
 (10 comments) (5 reactions) (0 assignees)Go (9,946 stars) (1,789 forks)batch import
help wanted

Description

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

Contributor guide