Skip to content

Commit

Permalink
added QC_hit field parsing for MariaDB
Browse files Browse the repository at this point in the history
  • Loading branch information
eze-kiel committed Apr 19, 2021
1 parent 8da34d6 commit 10c606f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions database/mariadb/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func (db *Database) parseMariaDBHeader(line string, q *query.Query) {
} else if strings.Contains(part, "schema:") {
q.Schema = parts[idx+1]

} else if strings.Contains(part, "QC_hit") {
q.QC_hit = true
if parts[idx+1] == "No" {
q.QC_hit = false
}
} else if strings.Contains(part, "last_errno:") {
q.LastErrNo, err = strconv.Atoi(parts[idx+1])
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion database/mariadb/mariadb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ func TestDatabase_parseMariaDBHeader(t *testing.T) {
},
},
{
name: "id, schema", // QC_Hit is not parsed yet
name: "id, schema, QC hit",
args: args{
line: "# Thread_id: 12794 Schema: QC_hit: No",
},
refQuery: query.Query{
ID: 12794,
Schema: "",
QC_hit: false,
},
},
{
Expand Down Expand Up @@ -167,6 +168,7 @@ func TestDatabase_ParseBlocs(t *testing.T) {
RowsAffected: 0,
BytesSent: 11,
Query: "SET timestamp=1616499117;SET NAMES utf8mb4;",
QC_hit: false,
},
},
}
Expand Down
1 change: 1 addition & 0 deletions query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ type Query struct {
Host string
Schema string
Query string
QC_hit bool
}

0 comments on commit 10c606f

Please sign in to comment.