Skip to content

Commit

Permalink
*: remove duplicate prefix for last query info (pingcap#50075)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch authored and AilinKid committed Jan 17, 2024
1 parent 9d98ba0 commit a70e16f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions pkg/executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions pkg/session/test/variable/variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
10 changes: 5 additions & 5 deletions pkg/sessionctx/sessionstates/session_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a70e16f

Please sign in to comment.