diff --git a/mssql.go b/mssql.go index 1bcce021..381fe01d 100644 --- a/mssql.go +++ b/mssql.go @@ -23,9 +23,9 @@ import ( // ReturnStatus may be used to return the return value from a proc. // -// var rs mssql.ReturnStatus -// _, err := db.Exec("theproc", &rs) -// log.Printf("return status = %d", rs) +// var rs mssql.ReturnStatus +// _, err := db.Exec("theproc", &rs) +// log.Printf("return status = %d", rs) type ReturnStatus int32 var driverInstance = &Driver{processQueryText: true} @@ -243,8 +243,6 @@ 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 @@ -879,12 +877,13 @@ func (r *Rows) ColumnTypeDatabaseTypeName(index int) string { // not a variable length type ok should return false. // If length is not limited other than system limits, it should return math.MaxInt64. // The following are examples of returned values for various types: -// TEXT (math.MaxInt64, true) -// varchar(10) (10, true) -// nvarchar(10) (10, true) -// decimal (0, false) -// int (0, false) -// bytea(30) (30, true) +// +// TEXT (math.MaxInt64, true) +// varchar(10) (10, true) +// nvarchar(10) (10, true) +// decimal (0, false) +// int (0, false) +// bytea(30) (30, true) func (r *Rows) ColumnTypeLength(index int) (int64, bool) { return makeGoLangTypeLength(r.cols[index].ti) } @@ -892,9 +891,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(38, 4) (38, 4, true) +// int (0, 0, false) +// decimal (math.MaxInt64, math.MaxInt64, true) func (r *Rows) ColumnTypePrecisionScale(index int) (int64, int64, bool) { return makeGoLangTypePrecisionScale(r.cols[index].ti) } @@ -1321,12 +1321,13 @@ func (r *Rowsq) ColumnTypeDatabaseTypeName(index int) string { // not a variable length type ok should return false. // If length is not limited other than system limits, it should return math.MaxInt64. // The following are examples of returned values for various types: -// TEXT (math.MaxInt64, true) -// varchar(10) (10, true) -// nvarchar(10) (10, true) -// decimal (0, false) -// int (0, false) -// bytea(30) (30, true) +// +// TEXT (math.MaxInt64, true) +// varchar(10) (10, true) +// nvarchar(10) (10, true) +// decimal (0, false) +// int (0, false) +// bytea(30) (30, true) func (r *Rowsq) ColumnTypeLength(index int) (int64, bool) { return makeGoLangTypeLength(r.cols[index].ti) } @@ -1334,9 +1335,10 @@ func (r *Rowsq) 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(38, 4) (38, 4, true) +// int (0, 0, false) +// decimal (math.MaxInt64, math.MaxInt64, true) func (r *Rowsq) ColumnTypePrecisionScale(index int) (int64, int64, bool) { return makeGoLangTypePrecisionScale(r.cols[index].ti) } diff --git a/mssql_test.go b/mssql_test.go index 57beb9ed..9c50b831 100644 --- a/mssql_test.go +++ b/mssql_test.go @@ -127,10 +127,6 @@ func TestCheckBadConn(t *testing.T) { {io.EOF, true, false, newRetryableError(io.EOF), false}, {io.EOF, false, true, io.EOF, false}, {io.EOF, true, true, io.EOF, false}, - {ErrorCancelConfirmation, false, false, ErrorCancelConfirmation, false}, - {ErrorCancelConfirmation, true, false, newRetryableError(ErrorCancelConfirmation), false}, - {ErrorCancelConfirmation, false, true, ErrorCancelConfirmation, false}, - {ErrorCancelConfirmation, true, true, ErrorCancelConfirmation, false}, {netErr, false, false, netErr, false}, {netErr, true, false, newRetryableError(netErr), false}, {netErr, false, true, netErr, false}, diff --git a/queries_test.go b/queries_test.go index 139fc684..7acda02c 100644 --- a/queries_test.go +++ b/queries_test.go @@ -1419,8 +1419,8 @@ func TestProcessQueryCancelConfirmationError(t *testing.T) { t.Error("processQueryResponse expected to fail but it succeeded") } // should not fail with ErrBadConn because query was successfully sent to server - if err != ErrorCancelConfirmation { - t.Error("processQueryResponse expected to fail with ErrorCancelConfirmation error but failed with other error: ", err) + if !errors.As(err, &ServerError{}) { + t.Error("processQueryResponse expected to fail with ServerError error but failed with other error: ", err) } if conn.connectionGood { diff --git a/token.go b/token.go index 1c138257..7d222307 100644 --- a/token.go +++ b/token.go @@ -3,7 +3,6 @@ package mssql import ( "context" "encoding/binary" - "errors" "fmt" "io" "io/ioutil" @@ -99,8 +98,6 @@ const ( // TODO implement more flags ) -var ErrorCancelConfirmation = errors.New("did not get cancellation confirmation from the server") - // interface for all tokens type tokenStruct interface{} @@ -961,7 +958,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, ErrorCancelConfirmation + return nil, ServerError{Error{Message: "did not get cancellation confirmation from the server"}} } }