1
0
Fork 0
forked from forgejo/forgejo

Update to latest mssqldriver (#7613)

* New driver does not tolerate USE - handle this by closing db and reopening db in the new dbname
This commit is contained in:
zeripath 2019-07-26 05:10:20 +01:00 committed by GitHub
parent bebc6a3c77
commit 78e5317242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 2376 additions and 598 deletions

View file

@ -213,7 +213,7 @@ func processEnvChg(sess *tdsSession) {
// SQL Collation data should contain 5 bytes in length
if collationSize != 5 {
badStreamPanicf("Invalid SQL Collation size value returned from server: %s", collationSize)
badStreamPanicf("Invalid SQL Collation size value returned from server: %d", collationSize)
}
// 4 bytes, contains: LCID ColFlags Version
@ -385,11 +385,9 @@ func processEnvChg(sess *tdsSession) {
}
}
type returnStatus int32
// http://msdn.microsoft.com/en-us/library/dd358180.aspx
func parseReturnStatus(r *tdsBuffer) returnStatus {
return returnStatus(r.int32())
func parseReturnStatus(r *tdsBuffer) ReturnStatus {
return ReturnStatus(r.int32())
}
func parseOrder(r *tdsBuffer) (res orderStruct) {
@ -640,7 +638,7 @@ func processSingleResponse(sess *tdsSession, ch chan tokenStruct, outs map[strin
if len(nv.Name) > 0 {
name := nv.Name[1:] // Remove the leading "@".
if ov, has := outs[name]; has {
err = scanIntoOut(nv.Value, ov)
err = scanIntoOut(name, nv.Value, ov)
if err != nil {
fmt.Println("scan error", err)
ch <- err
@ -653,28 +651,6 @@ func processSingleResponse(sess *tdsSession, ch chan tokenStruct, outs map[strin
}
}
func scanIntoOut(fromServer, scanInto interface{}) error {
switch fs := fromServer.(type) {
case int64:
switch si := scanInto.(type) {
case *int64:
*si = fs
default:
return fmt.Errorf("unsupported scan into type %[1]T for server type %[2]T", scanInto, fromServer)
}
return nil
case string:
switch si := scanInto.(type) {
case *string:
*si = fs
default:
return fmt.Errorf("unsupported scan into type %[1]T for server type %[2]T", scanInto, fromServer)
}
return nil
}
return fmt.Errorf("unsupported type from server %[1]T=%[1]v", fromServer)
}
type parseRespIter byte
const (