Skip to content

Commit 084a6c9

Browse files
author
Eygin Semen Leonidovich
committed
return ServerError when failed to get cancelation confirmation
1 parent 85e531a commit 084a6c9

File tree

4 files changed

+3
-12
lines changed

4 files changed

+3
-12
lines changed

mssql.go

-2
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ func (c *Conn) checkBadConn(ctx context.Context, err error, mayRetry bool) error
243243
return nil
244244
case io.EOF:
245245
c.connectionGood = false
246-
case ErrorCancelConfirmation:
247-
c.connectionGood = false
248246
case driver.ErrBadConn:
249247
// It is an internal programming error if driver.ErrBadConn
250248
// is ever passed to this function. driver.ErrBadConn should

mssql_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ func TestCheckBadConn(t *testing.T) {
127127
{io.EOF, true, false, newRetryableError(io.EOF), false},
128128
{io.EOF, false, true, io.EOF, false},
129129
{io.EOF, true, true, io.EOF, false},
130-
{ErrorCancelConfirmation, false, false, ErrorCancelConfirmation, false},
131-
{ErrorCancelConfirmation, true, false, newRetryableError(ErrorCancelConfirmation), false},
132-
{ErrorCancelConfirmation, false, true, ErrorCancelConfirmation, false},
133-
{ErrorCancelConfirmation, true, true, ErrorCancelConfirmation, false},
134130
{netErr, false, false, netErr, false},
135131
{netErr, true, false, newRetryableError(netErr), false},
136132
{netErr, false, true, netErr, false},

queries_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1419,8 +1419,8 @@ func TestProcessQueryCancelConfirmationError(t *testing.T) {
14191419
t.Error("processQueryResponse expected to fail but it succeeded")
14201420
}
14211421
// should not fail with ErrBadConn because query was successfully sent to server
1422-
if err != ErrorCancelConfirmation {
1423-
t.Error("processQueryResponse expected to fail with ErrorCancelConfirmation error but failed with other error: ", err)
1422+
if !errors.As(err, &ServerError{}) {
1423+
t.Error("processQueryResponse expected to fail with ServerError error but failed with other error: ", err)
14241424
}
14251425

14261426
if conn.connectionGood {

token.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package mssql
33
import (
44
"context"
55
"encoding/binary"
6-
"errors"
76
"fmt"
87
"io"
98
"io/ioutil"
@@ -99,8 +98,6 @@ const (
9998
// TODO implement more flags
10099
)
101100

102-
var ErrorCancelConfirmation = errors.New("did not get cancellation confirmation from the server")
103-
104101
// interface for all tokens
105102
type tokenStruct interface{}
106103

@@ -961,7 +958,7 @@ func (t tokenProcessor) nextToken() (tokenStruct, error) {
961958
}
962959
// we did not get cancellation confirmation, something is not
963960
// right, this connection is not usable anymore
964-
return nil, ErrorCancelConfirmation
961+
return nil, ServerError{Error{Message: "did not get cancellation confirmation from the server"}}
965962
}
966963
}
967964

0 commit comments

Comments
 (0)