From 7bade7c8d2109e96e070373250c67c1de404a98e Mon Sep 17 00:00:00 2001 From: mazrean Date: Tue, 3 Dec 2024 20:40:53 +0900 Subject: [PATCH] =?UTF-8?q?explain=E3=81=AEnull=E3=81=B8=E3=81=AE=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/server.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/db/server.go b/db/server.go index 32a017c..4f68af5 100644 --- a/db/server.go +++ b/db/server.go @@ -160,18 +160,18 @@ func queryExplainHandler(w http.ResponseWriter, r *http.Request) { defer rows.Close() type explainRow struct { - ID sql.NullInt64 `json:"id"` - SelectType string `json:"select_type"` - Table string `json:"table"` - Partitions sql.NullString `json:"partitions"` - Type string `json:"type"` - PossibleKeys sql.NullString `json:"possible_keys"` - Key sql.NullString `json:"key"` - KeyLen sql.NullInt64 `json:"key_len"` - Ref sql.NullString `json:"ref"` - Rows int `json:"rows"` - Filtered float64 `json:"filtered"` - Extra sql.NullString `json:"Extra"` + ID sql.NullInt64 `json:"id"` + SelectType sql.NullString `json:"select_type"` + Table sql.NullString `json:"table"` + Partitions sql.NullString `json:"partitions"` + Type sql.NullString `json:"type"` + PossibleKeys sql.NullString `json:"possible_keys"` + Key sql.NullString `json:"key"` + KeyLen sql.NullInt64 `json:"key_len"` + Ref sql.NullString `json:"ref"` + Rows sql.NullInt64 `json:"rows"` + Filtered sql.NullFloat64 `json:"filtered"` + Extra sql.NullString `json:"Extra"` } for rows.Next() { @@ -181,11 +181,11 @@ func queryExplainHandler(w http.ResponseWriter, r *http.Request) { return } explainResults = append(explainResults, ExplainResult{ - Table: row.Table, + Table: row.Table.String, PossibleKeys: strings.Split(row.PossibleKeys.String, ","), Key: row.Key.String, - Rows: row.Rows, - Filtered: row.Filtered, + Rows: int(row.Rows.Int64), + Filtered: row.Filtered.Float64, }) } }