2
0

Replace lastStmtSent with pgconn support

This commit is contained in:
Jack Christensen
2019-04-20 17:12:20 -05:00
parent 35a0f64876
commit b7e56b003a
7 changed files with 47 additions and 78 deletions
+5 -3
View File
@@ -80,8 +80,9 @@ import (
"sync"
"time"
"github.com/pkg/errors"
errors "golang.org/x/xerrors"
"github.com/jackc/pgconn"
"github.com/jackc/pgx"
"github.com/jackc/pgx/pgtype"
)
@@ -226,8 +227,9 @@ func (c *Conn) ExecContext(ctx context.Context, query string, argsV []driver.Nam
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 err != nil && !c.conn.LastStmtSent() {
if _, is := err.(net.Error); is {
if err != nil {
var netErr net.Error
if is := errors.As(err, &netErr); is && errors.Is(err, pgconn.ErrNoBytesSent) {
return nil, driver.ErrBadConn
}
}