/usr/share/gocode/src/github.com/denisenkom/go-mssqldb/rpc.go is in golang-github-denisenkom-go-mssqldb-dev 0.0~git20170717.0.8fccfc8-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | package mssql
import (
"encoding/binary"
)
type ProcId struct {
id uint16
name string
}
// parameter flags
const (
fByRevValue = 1
fDefaultValue = 2
)
type Param struct {
Name string
Flags uint8
ti typeInfo
buffer []byte
}
func MakeProcId(name string) (res ProcId) {
res.name = name
if len(name) == 0 {
panic("Proc name shouln't be empty")
}
if len(name) >= 0xffff {
panic("Invalid length of procedure name, should be less than 0xffff")
}
return res
}
const (
fWithRecomp = 1
fNoMetaData = 2
fReuseMetaData = 4
)
var (
Sp_Cursor = ProcId{1, ""}
Sp_CursorOpen = ProcId{2, ""}
Sp_CursorPrepare = ProcId{3, ""}
Sp_CursorExecute = ProcId{4, ""}
Sp_CursorPrepExec = ProcId{5, ""}
Sp_CursorUnprepare = ProcId{6, ""}
Sp_CursorFetch = ProcId{7, ""}
Sp_CursorOption = ProcId{8, ""}
Sp_CursorClose = ProcId{9, ""}
Sp_ExecuteSql = ProcId{10, ""}
Sp_Prepare = ProcId{11, ""}
Sp_PrepExec = ProcId{13, ""}
Sp_PrepExecRpc = ProcId{14, ""}
Sp_Unprepare = ProcId{15, ""}
)
// http://msdn.microsoft.com/en-us/library/dd357576.aspx
func sendRpc(buf *tdsBuffer, headers []headerStruct, proc ProcId, flags uint16, params []Param) (err error) {
buf.BeginPacket(packRPCRequest)
writeAllHeaders(buf, headers)
if len(proc.name) == 0 {
var idswitch uint16 = 0xffff
err = binary.Write(buf, binary.LittleEndian, &idswitch)
if err != nil {
return
}
err = binary.Write(buf, binary.LittleEndian, &proc.id)
if err != nil {
return
}
} else {
err = writeUsVarChar(buf, proc.name)
if err != nil {
return
}
}
err = binary.Write(buf, binary.LittleEndian, &flags)
if err != nil {
return
}
for _, param := range params {
if err = writeBVarChar(buf, param.Name); err != nil {
return
}
if err = binary.Write(buf, binary.LittleEndian, param.Flags); err != nil {
return
}
err = writeTypeInfo(buf, ¶m.ti)
if err != nil {
return
}
err = param.ti.Writer(buf, param.ti, param.buffer)
if err != nil {
return
}
}
return buf.FinishPacket()
}
|