go-sql-driver/mysql

Return useful error when attempting to reuse a blocked connection

Open

#526 建立於 2016年12月8日

在 GitHub 查看
 (10 留言) (5 反應) (0 負責人)Go (9,946 star) (1,789 fork)batch import
help wanted

描述

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

貢獻者指南

Return useful error when attempting to reuse a blocked connection · go-sql-driver/mysql#526 | Good First Issue