summaryrefslogtreecommitdiff
path: root/libgo/go/database/sql/sql.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/database/sql/sql.go')
-rw-r--r--libgo/go/database/sql/sql.go33
1 files changed, 17 insertions, 16 deletions
diff --git a/libgo/go/database/sql/sql.go b/libgo/go/database/sql/sql.go
index d8e7cb77af3..09de1c34e82 100644
--- a/libgo/go/database/sql/sql.go
+++ b/libgo/go/database/sql/sql.go
@@ -199,7 +199,7 @@ type Scanner interface {
// time.Time
// nil - for NULL values
//
- // An error should be returned if the value can not be stored
+ // An error should be returned if the value cannot be stored
// without loss of information.
Scan(src interface{}) error
}
@@ -718,6 +718,9 @@ func (db *DB) maybeOpenNewConnections() {
for numRequests > 0 {
db.numOpen++ // optimistically
numRequests--
+ if db.closed {
+ return
+ }
db.openerCh <- struct{}{}
}
}
@@ -797,7 +800,7 @@ func (db *DB) conn(strategy connReuseStrategy) (*driverConn, error) {
return conn, nil
}
- // Out of free connections or we were asked not to use one. If we're not
+ // Out of free connections or we were asked not to use one. If we're not
// allowed to open any more connections, make a request and wait.
if db.maxOpen > 0 && db.numOpen >= db.maxOpen {
// Make the connRequest channel. It's buffered so that the
@@ -838,11 +841,6 @@ func (db *DB) conn(strategy connReuseStrategy) (*driverConn, error) {
return dc, nil
}
-var (
- errConnClosed = errors.New("database/sql: internal sentinel error: conn is closed")
- errConnBusy = errors.New("database/sql: internal sentinel error: conn is busy")
-)
-
// putConnHook is a hook for testing.
var putConnHook func(*DB, *driverConn)
@@ -920,6 +918,9 @@ func (db *DB) putConn(dc *driverConn, err error) {
// If a connRequest was fulfilled or the *driverConn was placed in the
// freeConn list, then true is returned, otherwise false is returned.
func (db *DB) putConnDBLocked(dc *driverConn, err error) bool {
+ if db.closed {
+ return false
+ }
if db.maxOpen > 0 && db.numOpen > db.maxOpen {
return false
}
@@ -1207,7 +1208,7 @@ type Tx struct {
// ErrTxDone.
done bool
- // All Stmts prepared for this transaction. These will be closed after the
+ // All Stmts prepared for this transaction. These will be closed after the
// transaction has been committed or rolled back.
stmts struct {
sync.Mutex
@@ -1286,7 +1287,7 @@ func (tx *Tx) Prepare(query string) (*Stmt, error) {
// necessary. Or, better: keep a map in DB of query string to
// Stmts, and have Stmt.Execute do the right thing and
// re-prepare if the Conn in use doesn't have that prepared
- // statement. But we'll want to avoid caching the statement
+ // statement. But we'll want to avoid caching the statement
// in the case where we only call conn.Prepare implicitly
// (such as in db.Exec or tx.Exec), but the caller package
// can't be holding a reference to the returned statement.
@@ -1334,7 +1335,7 @@ func (tx *Tx) Prepare(query string) (*Stmt, error) {
// be used once the transaction has been committed or rolled back.
func (tx *Tx) Stmt(stmt *Stmt) *Stmt {
// TODO(bradfitz): optimize this. Currently this re-prepares
- // each time. This is fine for now to illustrate the API but
+ // each time. This is fine for now to illustrate the API but
// we should really cache already-prepared statements
// per-Conn. See also the big comment in Tx.Prepare.
@@ -1441,9 +1442,9 @@ type Stmt struct {
closed bool
// css is a list of underlying driver statement interfaces
- // that are valid on particular connections. This is only
+ // that are valid on particular connections. This is only
// used if tx == nil and one is found that has idle
- // connections. If tx != nil, txsi is always used.
+ // connections. If tx != nil, txsi is always used.
css []connStmt
// lastNumClosed is copied from db.numClosed when Stmt is created
@@ -1741,9 +1742,9 @@ type Rows struct {
closeStmt driver.Stmt // if non-nil, statement to Close on close
}
-// Next prepares the next result row for reading with the Scan method. It
+// Next prepares the next result row for reading with the Scan method. It
// returns true on success, or false if there is no next result row or an error
-// happened while preparing it. Err should be consulted to distinguish between
+// happened while preparing it. Err should be consulted to distinguish between
// the two cases.
//
// Every call to Scan, even the first one, must be preceded by a call to Next.
@@ -1898,8 +1899,8 @@ func (r *Row) Scan(dest ...interface{}) error {
// the Rows in our defer, when we return from this function.
// the contract with the driver.Next(...) interface is that it
// can return slices into read-only temporary memory that's
- // only valid until the next Scan/Close. But the TODO is that
- // for a lot of drivers, this copy will be unnecessary. We
+ // only valid until the next Scan/Close. But the TODO is that
+ // for a lot of drivers, this copy will be unnecessary. We
// should provide an optional interface for drivers to
// implement to say, "don't worry, the []bytes that I return
// from Next will not be modified again." (for instance, if