undo CL 10726044 / c9bea548fb6f

Breaks build, and has a race.

««« original CL description
database/sql: add SetMaxOpenConns

Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added seperate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044

»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/13252046
This commit is contained in:
Brad Fitzpatrick 2013-08-29 17:26:00 -07:00
parent 4572e48483
commit 9456adb36b
3 changed files with 69 additions and 812 deletions

View file

@ -447,10 +447,6 @@ func (c *fakeConn) Prepare(query string) (driver.Stmt, error) {
return c.prepareCreate(stmt, parts)
case "INSERT":
return c.prepareInsert(stmt, parts)
case "NOSERT":
// Do all the prep-work like for an INSERT but don't actually insert the row.
// Used for some of the concurrent tests.
return c.prepareInsert(stmt, parts)
default:
stmt.Close()
return nil, errf("unsupported command type %q", cmd)
@ -501,20 +497,13 @@ func (s *fakeStmt) Exec(args []driver.Value) (driver.Result, error) {
}
return driver.ResultNoRows, nil
case "INSERT":
return s.execInsert(args, true)
case "NOSERT":
// Do all the prep-work like for an INSERT but don't actually insert the row.
// Used for some of the concurrent tests.
return s.execInsert(args, false)
return s.execInsert(args)
}
fmt.Printf("EXEC statement, cmd=%q: %#v\n", s.cmd, s)
return nil, fmt.Errorf("unimplemented statement Exec command type of %q", s.cmd)
}
// When doInsert is true, add the row to the table.
// When doInsert is false do prep-work and error checking, but don't
// actually add the row to the table.
func (s *fakeStmt) execInsert(args []driver.Value, doInsert bool) (driver.Result, error) {
func (s *fakeStmt) execInsert(args []driver.Value) (driver.Result, error) {
db := s.c.db
if len(args) != s.placeholders {
panic("error in pkg db; should only get here if size is correct")
@ -529,10 +518,7 @@ func (s *fakeStmt) execInsert(args []driver.Value, doInsert bool) (driver.Result
t.mu.Lock()
defer t.mu.Unlock()
var cols []interface{}
if doInsert {
cols = make([]interface{}, len(t.colname))
}
cols := make([]interface{}, len(t.colname))
argPos := 0
for n, colname := range s.colName {
colidx := t.columnIndex(colname)
@ -546,14 +532,10 @@ func (s *fakeStmt) execInsert(args []driver.Value, doInsert bool) (driver.Result
} else {
val = s.colValue[n]
}
if doInsert {
cols[colidx] = val
}
cols[colidx] = val
}
if doInsert {
t.rows = append(t.rows, &row{cols: cols})
}
t.rows = append(t.rows, &row{cols: cols})
return driver.RowsAffected(1), nil
}