DRY ConnPool Begin and BeginIso

pull/95/head
Jack Christensen 2015-09-12 19:12:55 -05:00
parent 6ac98ef613
commit bc4742b80a
1 changed files with 1 additions and 19 deletions

View File

@ -214,25 +214,7 @@ func (p *ConnPool) QueryRow(sql string, args ...interface{}) *Row {
// Begin acquires a connection and begins a transaction on it. When the
// transaction is closed the connection will be automatically released.
func (p *ConnPool) Begin() (*Tx, error) {
for {
c, err := p.Acquire()
if err != nil {
return nil, err
}
tx, err := c.Begin()
if err == ErrDeadConn {
p.Release(c)
continue
}
if err != nil {
p.Release(c)
return nil, err
}
tx.pool = p
return tx, nil
}
return p.BeginIso("")
}
// BeginIso acquires a connection and begins a transaction in isolation mode iso