Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix warning case
Browse files Browse the repository at this point in the history
Signed-off-by: guo-shaoge <[email protected]>
guo-shaoge committed Dec 23, 2021
1 parent ff0fb07 commit 8b50eec
Showing 5 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
@@ -5118,13 +5118,13 @@ func (s *testIntegrationSuite) TestIndexMergeWarning(c *C) {
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1(c1 int, c2 int)")
tk.MustExec("select /*+ use_index_merge(t1) */ * from t1 where c1 < 1 or c2 < 1")
warningMsg := "Warning 1105 IndexMerge is inapplicable or disabled. No available filter or access path."
warningMsg := "Warning 1105 IndexMerge is inapplicable or disabled. No available filter or available index."
tk.MustQuery("show warnings").Check(testkit.Rows(warningMsg))

tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1(c1 int, c2 int, key(c1), key(c2))")
tk.MustExec("select /*+ use_index_merge(t1), no_index_merge() */ * from t1 where c1 < 1 or c2 < 1")
warningMsg = "Warning 1105 IndexMerge is inapplicable or disabled. Got no_index_merge hint or switcher is off."
warningMsg = "Warning 1105 IndexMerge is inapplicable or disabled. Got no_index_merge hint or tidb_enable_index_merge is off."
tk.MustQuery("show warnings").Check(testkit.Rows(warningMsg))

tk.MustExec("drop table if exists t1")
10 changes: 4 additions & 6 deletions planner/core/stats.go
Original file line number Diff line number Diff line change
@@ -453,19 +453,17 @@ func (ds *DataSource) DeriveStats(childStats []*property.StatsInfo, selfSchema *
ds.indexMergeHints = nil
var msg string
if !isPossibleIdxMerge {
msg = "No available filter or access path."
msg = "No available filter or available index."
} else if !sessionAndStmtPermission {
msg = "Got no_index_merge hint or switcher is off."
} else if !needConsiderIndexMerge {
msg = "Got index path or exprs that cannot be pushed."
msg = "Got no_index_merge hint or tidb_enable_index_merge is off."
} else if ds.tableInfo.TempTableType == model.TempTableLocal {
msg = "Cannot use IndexMerge on temporary table."
} else if readFromTableCache {
msg = "Cannot use IndexMerge on TableCache."
}
msg = fmt.Sprintf("IndexMerge is inapplicable or disabled. %s", msg)
stmtCtx.AppendWarning(errors.Errorf(msg))
logutil.BgLogger().Info(msg)
logutil.BgLogger().Debug(msg)
}
return ds.stats, nil
}
@@ -483,7 +481,7 @@ func (ds *DataSource) generateAndPruneIndexMergePath(indexMergeConds []expressio
// With hints and without generated IndexMerge paths
if regularPathCount == len(ds.possibleAccessPaths) {
ds.indexMergeHints = nil
ds.ctx.GetSessionVars().StmtCtx.AppendWarning(errors.Errorf("IndexMerge is inapplicable or disabled"))
ds.ctx.GetSessionVars().StmtCtx.AppendWarning(errors.Errorf("IndexMerge is inapplicable."))
return nil
}
// Do not need to consider the regular paths in find_best_task().
4 changes: 2 additions & 2 deletions planner/core/testdata/integration_suite_out.json
Original file line number Diff line number Diff line change
@@ -1332,7 +1332,7 @@
"└─IndexRangeScan 20.00 cop[tikv] table:tt, index:a(a) range:[10,10], [20,20], keep order:false, stats:pseudo"
],
"Warnings": [
"Warning 1105 IndexMerge is inapplicable or disabled"
"Warning 1105 IndexMerge is inapplicable."
]
},
{
@@ -1342,7 +1342,7 @@
"└─IndexRangeScan 6666.67 cop[tikv] table:tt, index:a(a) range:[-inf,10), [15,15], (20,+inf], keep order:false, stats:pseudo"
],
"Warnings": [
"Warning 1105 IndexMerge is inapplicable or disabled"
"Warning 1105 IndexMerge is inapplicable."
]
}
]
4 changes: 2 additions & 2 deletions session/session_test.go
Original file line number Diff line number Diff line change
@@ -5419,7 +5419,7 @@ func (s *testSessionSuite) TestLocalTemporaryTableScan(c *C) {
"12 112 1012", "3 113 1003", "14 114 1014", "16 116 1016", "7 117 1007", "18 118 1018",
))

tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 IndexMerge is inapplicable or disabled"))
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 IndexMerge is inapplicable or disabled. Cannot use IndexMerge on temporary table."))
}

doModify := func() {
@@ -5458,7 +5458,7 @@ func (s *testSessionSuite) TestLocalTemporaryTableScan(c *C) {
"3 113 1003", "14 114 1014", "7 117 9999", "18 118 1018", "12 132 1012",
))

tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 IndexMerge is inapplicable or disabled"))
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 IndexMerge is inapplicable or disabled. Cannot use IndexMerge on temporary table."))
}

assertSelectAsUnModified()
2 changes: 1 addition & 1 deletion table/tables/cache_test.go
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ func TestCacheTableBasicScan(t *testing.T) {
"12 112 1012", "3 113 1003", "14 114 1014", "16 116 1016", "7 117 1007", "18 118 1018",
))

tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 IndexMerge is inapplicable or disabled"))
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 IndexMerge is inapplicable or disabled. Cannot use IndexMerge on TableCache."))
}
assertSelect()

0 comments on commit 8b50eec

Please sign in to comment.