Skip to content

Commit

Permalink
Mark connection as not good when error on cancellation confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
Eygin Semen Leonidovich committed Nov 9, 2022
1 parent ed0f620 commit a0bfc23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mssql.go
Expand Up @@ -228,6 +228,8 @@ func (c *Conn) checkBadConn(ctx context.Context, err error, mayRetry bool) error
return nil
case io.EOF:
c.connectionGood = false
case ErrorCancelConfirmation:
c.connectionGood = false
case driver.ErrBadConn:
// It is an internal programming error if driver.ErrBadConn
// is ever passed to this function. driver.ErrBadConn should
Expand Down Expand Up @@ -874,9 +876,10 @@ func (r *Rows) ColumnTypeLength(index int) (int64, bool) {
// It should return
// the precision and scale for decimal types. If not applicable, ok should be false.
// The following are examples of returned values for various types:
//
// decimal(38, 4) (38, 4, true)
// int (0, 0, false)
// decimal (math.MaxInt64, math.MaxInt64, true)
// decimal (math.MaxInt64, math.MaxInt64, true)
func (r *Rows) ColumnTypePrecisionScale(index int) (int64, int64, bool) {
return makeGoLangTypePrecisionScale(r.cols[index].ti)
}
Expand Down
4 changes: 3 additions & 1 deletion token.go
Expand Up @@ -85,6 +85,8 @@ const (
// TODO implement more flags
)

var ErrorCancelConfirmation = errors.New("did not get cancellation confirmation from the server")

// interface for all tokens
type tokenStruct interface{}

Expand Down Expand Up @@ -934,7 +936,7 @@ func (t tokenProcessor) nextToken() (tokenStruct, error) {
}
// we did not get cancellation confirmation, something is not
// right, this connection is not usable anymore
return nil, errors.New("did not get cancellation confirmation from the server")
return nil, ErrorCancelConfirmation
}
}

Expand Down

0 comments on commit a0bfc23

Please sign in to comment.