diff --git a/pkg/executor/adapter.go b/pkg/executor/adapter.go index 45047f2adbcfb..b1677f8fc0421 100644 --- a/pkg/executor/adapter.go +++ b/pkg/executor/adapter.go @@ -1477,10 +1477,10 @@ func (a *ExecStmt) recordLastQueryInfo(err error) { }) // Keep the previous queryInfo for `show session_states` because the statement needs to encode it. sessVars.LastQueryInfo = sessionstates.QueryInfo{ - TxnScope: sessVars.CheckAndGetTxnScope(), - StartTS: sessVars.TxnCtx.StartTS, - ForUpdateTS: sessVars.TxnCtx.GetForUpdateTS(), - LastRUConsumption: lastRUConsumption, + TxnScope: sessVars.CheckAndGetTxnScope(), + StartTS: sessVars.TxnCtx.StartTS, + ForUpdateTS: sessVars.TxnCtx.GetForUpdateTS(), + RUConsumption: lastRUConsumption, } if err != nil { sessVars.LastQueryInfo.ErrMsg = err.Error() diff --git a/pkg/session/test/variable/variable_test.go b/pkg/session/test/variable/variable_test.go index 84354537e445e..94a04dc8f454a 100644 --- a/pkg/session/test/variable/variable_test.go +++ b/pkg/session/test/variable/variable_test.go @@ -379,8 +379,8 @@ func TestLastQueryInfo(t *testing.T) { checkMatch := func(actual []string, expected []interface{}) bool { return strings.Contains(actual[0], expected[0].(string)) } - tk.MustQuery("select @@tidb_last_query_info;").CheckWithFunc(testkit.Rows(`"last_ru_consumption":15`), checkMatch) + tk.MustQuery("select @@tidb_last_query_info;").CheckWithFunc(testkit.Rows(`"ru_consumption":15`), checkMatch) tk.MustExec("select a from t where a = 1") - tk.MustQuery("select @@tidb_last_query_info;").CheckWithFunc(testkit.Rows(`"last_ru_consumption":27`), checkMatch) - tk.MustQuery("select @@tidb_last_query_info;").CheckWithFunc(testkit.Rows(`"last_ru_consumption":30`), checkMatch) + tk.MustQuery("select @@tidb_last_query_info;").CheckWithFunc(testkit.Rows(`"ru_consumption":27`), checkMatch) + tk.MustQuery("select @@tidb_last_query_info;").CheckWithFunc(testkit.Rows(`"ru_consumption":30`), checkMatch) } diff --git a/pkg/sessionctx/sessionstates/session_states.go b/pkg/sessionctx/sessionstates/session_states.go index 325fd1a520b79..7afa39ffe404e 100644 --- a/pkg/sessionctx/sessionstates/session_states.go +++ b/pkg/sessionctx/sessionstates/session_states.go @@ -49,11 +49,11 @@ type PreparedStmtInfo struct { // QueryInfo represents the information of last executed query. It's used to expose information for test purpose. type QueryInfo struct { - TxnScope string `json:"txn_scope"` - StartTS uint64 `json:"start_ts"` - ForUpdateTS uint64 `json:"for_update_ts"` - LastRUConsumption float64 `json:"last_ru_consumption"` - ErrMsg string `json:"error,omitempty"` + TxnScope string `json:"txn_scope"` + StartTS uint64 `json:"start_ts"` + ForUpdateTS uint64 `json:"for_update_ts"` + RUConsumption float64 `json:"ru_consumption"` + ErrMsg string `json:"error,omitempty"` } // LastDDLInfo represents the information of last DDL. It's used to expose information for test purpose.