mirror of https://github.com/jackc/pgx.git
Update stdlib for latest pgconn
parent
ddd9cf451e
commit
28d5375b74
|
@ -75,7 +75,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -227,8 +226,7 @@ func (c *Conn) ExecContext(ctx context.Context, query string, argsV []driver.Nam
|
||||||
commandTag, err := c.conn.Exec(ctx, query, args...)
|
commandTag, err := c.conn.Exec(ctx, query, args...)
|
||||||
// if we got a network error before we had a chance to send the query, retry
|
// if we got a network error before we had a chance to send the query, retry
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var netErr net.Error
|
if pgconn.SafeToRetry(err) {
|
||||||
if is := errors.As(err, &netErr); is && errors.Is(err, pgconn.ErrNoBytesSent) {
|
|
||||||
return nil, driver.ErrBadConn
|
return nil, driver.ErrBadConn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +243,7 @@ func (c *Conn) QueryContext(ctx context.Context, query string, argsV []driver.Na
|
||||||
|
|
||||||
rows, err := c.conn.Query(ctx, query, args...)
|
rows, err := c.conn.Query(ctx, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, pgconn.ErrNoBytesSent) {
|
if pgconn.SafeToRetry(err) {
|
||||||
return nil, driver.ErrBadConn
|
return nil, driver.ErrBadConn
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -895,8 +895,8 @@ func TestStmtExecContextCancel(t *testing.T) {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
_, err = stmt.ExecContext(ctx, 42)
|
_, err = stmt.ExecContext(ctx, 42)
|
||||||
if err != context.DeadlineExceeded {
|
if !pgconn.Timeout(err) {
|
||||||
t.Errorf("err => %v, want %v", err, context.DeadlineExceeded)
|
t.Errorf("expected timeout error, got %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureConnValid(t, db)
|
ensureConnValid(t, db)
|
||||||
|
|
Loading…
Reference in New Issue