go-sql-driver / go-sql-driver/mysql

Return useful error when attempting to reuse a blocked connection

Open
#526 10 comments 5 reactions 0 assignees View on GitHub
help wanted
Dominant language
Go
Stars
15.3k
Forks
2.3k
Avg merge
2h 23m
Merged PRs (30d)
10

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
```go
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.