Skip to content

Commit

Permalink
Merge pull request #7 from tiket-oss/bugfix
Browse files Browse the repository at this point in the history
making query digest the same as in stats_mysql_query_digest table
  • Loading branch information
asdptkt authored Apr 16, 2019
2 parents 3c63973 + 228f383 commit 46d9f7c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
11 changes: 1 addition & 10 deletions get.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,12 @@ func GetQueryDigest(dataStream io.Reader) (digest string, err error) {
return
}

// turn the digestRaw into TWO uint32
// first we need to convert it back into []byte
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, digestRaw)

// then split it into two
b1 := buf[:4]
b2 := buf[4:]

// then convert them into uint32
d1 := binary.LittleEndian.Uint32(b1)
d2 := binary.LittleEndian.Uint32(b2)

// then turn into hex string
digest = fmt.Sprintf("0x%X%X", d1, d2)
digest = fmt.Sprintf("0x%X", buf)

return
}
Expand Down
2 changes: 1 addition & 1 deletion get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestGetQueryDigest(t *testing.T) {

digestStr, err := GetQueryDigest(buf)
require.NoError(t, err)
require.Equal(t, "0x14BA1FD6AE231F4D", digestStr)
require.Equal(t, "0xD61FBA144D1F23AE", digestStr)
}

func TestGetQueryDigestNegative(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pxld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
RawMessage: testData[8:],
Username: "didasy",
Schema: "test",
QueryDigest: "0xB3136F4238DF1D37",
QueryDigest: "0x426F13B3371DDF38",
HID: 1,
ClientAddr: "127.0.0.1:33680",
ServerAddr: "127.0.0.1:3306",
Expand All @@ -57,7 +57,7 @@ var (
"schema": "test",
"start_at": "2019-04-10T15:08:00.727354+07:00",
"end_at": "2019-04-10T15:08:00.727354+07:00",
"query_digest": "0xB3136F4238DF1D37",
"query_digest": "0x426F13B3371DDF38",
"hid": 1,
"client_addr": "127.0.0.1:33680",
"server_addr": "127.0.0.1:3306",
Expand Down

0 comments on commit 46d9f7c

Please sign in to comment.