From bc4742b80aaab9584e4df145d2d1d1d1ea8201af Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 12 Sep 2015 19:12:55 -0500 Subject: [PATCH] DRY ConnPool Begin and BeginIso --- conn_pool.go | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/conn_pool.go b/conn_pool.go index 20323992..0e04268e 100644 --- a/conn_pool.go +++ b/conn_pool.go @@ -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