fixed tds query & format date

This commit is contained in:
solar
2019-03-06 15:57:54 +08:00
parent de389e8c30
commit 4ebbd8cf59
6 changed files with 419 additions and 94 deletions

View File

@@ -192,7 +192,6 @@ func readStream(r io.Reader) (*packet, error) {
if p.length > 0 {
io.CopyN(&buffer, r, int64(p.length-8))
}
p.payload = buffer.Bytes()
return p, nil
@@ -201,9 +200,20 @@ func readStream(r io.Reader) (*packet, error) {
func (m *stream) resolveClientPacket(p *packet) {
var msg string
switch p.packetType {
case 1:
msg = fmt.Sprintf("【query】 %s", string(p.payload))
headerLength := int(binary.LittleEndian.Uint32(p.payload[0:4]))
// fmt.Printf("headers %d\n", headerLength)
if headerLength > 22 {
//not exists headers
msg = fmt.Sprintf("【query】 %s", string(p.payload))
} else {
//tds 7.2+
msg = fmt.Sprintf("【query】 %s", string(p.payload[headerLength:]))
}
case 4:
msg = fmt.Sprintf("【query】 %s", "Tabular result")
@@ -218,10 +228,10 @@ func (m *stream) resolveServerPacket(p *packet) {
switch p.packetType {
case 4:
var b = int32(p.payload[0])
msg = fmt.Sprintf("【OK】 %d", b)
msg = fmt.Sprintf("【OK】%d", b)
}
parseToken(p.payload)
// parseToken(p.payload)
fmt.Println(GetNowStr(false), msg)
}