mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
database/sql: refcounting and lifetime fixes
Simplifies the contract for Driver.Stmt.Close in the process of fixing issue 3865. Fixes #3865 Update #4459 (maybe fixes it; uninvestigated) R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7363043
This commit is contained in:
parent
6c976393ae
commit
f7a7716317
3 changed files with 174 additions and 55 deletions
|
|
@ -8,7 +8,6 @@ import (
|
|||
"database/sql/driver"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -63,6 +62,10 @@ func exec(t *testing.T, db *DB, query string, args ...interface{}) {
|
|||
}
|
||||
|
||||
func closeDB(t *testing.T, db *DB) {
|
||||
if e := recover(); e != nil {
|
||||
fmt.Printf("Panic: %v\n", e)
|
||||
panic(e)
|
||||
}
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("error closing DB: %v", err)
|
||||
|
|
@ -448,10 +451,8 @@ func TestIssue2542Deadlock(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// From golang.org/issue/3865
|
||||
func TestCloseStmtBeforeRows(t *testing.T) {
|
||||
t.Skip("known broken test; golang.org/issue/3865")
|
||||
return
|
||||
|
||||
db := newTestDB(t, "people")
|
||||
defer closeDB(t, db)
|
||||
|
||||
|
|
@ -666,8 +667,3 @@ func nullTestRun(t *testing.T, spec nullTestSpec) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func stack() string {
|
||||
buf := make([]byte, 1024)
|
||||
return string(buf[:runtime.Stack(buf, false)])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue