diff --git a/pgxpool/errors.go b/pgxpool/errors.go new file mode 100644 index 000000000..a4c7797a7 --- /dev/null +++ b/pgxpool/errors.go @@ -0,0 +1,5 @@ +package pgxpool + +import "errors" + +var ErrInfiniteAcquireLoop = errors.New("pgxpool: detected infinite loop acquiring connection; likely bug in PrepareConn or BeforeAcquire hook") diff --git a/pgxpool/pool.go b/pgxpool/pool.go index df97bdbd7..b766a1435 100644 --- a/pgxpool/pool.go +++ b/pgxpool/pool.go @@ -2,7 +2,6 @@ package pgxpool import ( "context" - "errors" "math/rand/v2" "runtime" "strconv" @@ -652,7 +651,7 @@ func (p *Pool) Acquire(ctx context.Context) (c *Conn, err error) { return cr.getConn(p, res), nil } - return nil, errors.New("pgxpool: detected infinite loop acquiring connection; likely bug in PrepareConn or BeforeAcquire hook") + return nil, ErrInfiniteAcquireLoop } // AcquireFunc acquires a *Conn and calls f with that *Conn. ctx will only affect the Acquire. It has no effect on the