Skip to content

Commit

Permalink
cherry pick pingcap#20000 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
crazycs520 authored and ti-srebot committed Sep 17, 2020
1 parent 4904fed commit 2599af3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5910,7 +5910,25 @@ func (s *testSuite) TestGenerateColumnReplace(c *C) {
tk.MustQuery("select * from t1").Check(testkit.Rows("3 4"))
}

<<<<<<< HEAD
func (s *testSuite) TestSlowQuerySensitiveQuery(c *C) {
=======
func (s *testSlowQuery) TestSlowQueryWithoutSlowLog(c *C) {
tk := testkit.NewTestKit(c, s.store)
originCfg := config.GetGlobalConfig()
newCfg := *originCfg
newCfg.Log.SlowQueryFile = "tidb-slow-not-exist.log"
newCfg.Log.SlowThreshold = math.MaxUint64
config.StoreGlobalConfig(&newCfg)
defer func() {
config.StoreGlobalConfig(originCfg)
}()
tk.MustQuery("select query from information_schema.slow_query").Check(testkit.Rows())
tk.MustQuery("select query from information_schema.slow_query where time > '2020-09-15 12:16:39' and time < now()").Check(testkit.Rows())
}

func (s *testSlowQuery) TestSlowQuerySensitiveQuery(c *C) {
>>>>>>> aed24e4... executor: fix query slow_query error when slow-log file not exist (#20000)
tk := testkit.NewTestKit(c, s.store)
originCfg := config.GetGlobalConfig()
newCfg := *originCfg
Expand Down
3 changes: 3 additions & 0 deletions executor/slow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ func (e *slowQueryRetriever) getAllFiles(sctx sessionctx.Context, logFilePath st
if e.extractor == nil || !e.extractor.Enable {
file, err := os.Open(logFilePath)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, err
}
return []logFile{{file: file}}, nil
Expand Down

0 comments on commit 2599af3

Please sign in to comment.