server: replace session in statsHistoryHandler with types.Context (#56783)

close pingcap/tidb#56782
This commit is contained in:
YangKeao
2024-10-23 19:02:14 +08:00
committed by GitHub
parent 5cbe855459
commit b759f3306c
2 changed files with 3 additions and 10 deletions

View File

@ -17,7 +17,6 @@ go_library(
"//pkg/parser/model",
"//pkg/parser/mysql",
"//pkg/server/handler",
"//pkg/session",
"//pkg/sessionctx/variable",
"//pkg/statistics/handle",
"//pkg/statistics/handle/util",

View File

@ -26,7 +26,6 @@ import (
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/server/handler"
"github.com/pingcap/tidb/pkg/session"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/table"
"github.com/pingcap/tidb/pkg/types"
@ -95,12 +94,6 @@ func (sh StatsHistoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
w.Header().Set("Content-Type", "application/json")
params := mux.Vars(req)
se, err := session.CreateSession(sh.do.Store())
if err != nil {
handler.WriteError(w, err)
return
}
defer se.Close()
enabeld, err := sh.do.StatsHandle().CheckHistoricalStatsEnable()
if err != nil {
handler.WriteError(w, err)
@ -111,8 +104,9 @@ func (sh StatsHistoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
return
}
se.GetSessionVars().StmtCtx.SetTimeZone(time.Local)
t, err := types.ParseTime(se.GetSessionVars().StmtCtx.TypeCtx(), params[handler.Snapshot], mysql.TypeTimestamp, 6)
typeCtx := types.DefaultStmtNoWarningContext
typeCtx = typeCtx.WithLocation(time.Local)
t, err := types.ParseTime(typeCtx, params[handler.Snapshot], mysql.TypeTimestamp, 6)
if err != nil {
handler.WriteError(w, err)
return