Skip to content

Commit

Permalink
undo CL 10726044 / c9bea548fb6f
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bradfitz committed Aug 30, 2013
1 parent 4572e48 commit 9456adb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 813 deletions.
28 changes: 5 additions & 23 deletions src/pkg/database/sql/fakedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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
}

Expand Down
Loading

0 comments on commit 9456adb

Please sign in to comment.