Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: enable gosimple linter #24617

Merged
merged 13 commits into from
May 14, 2021
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ check-static: tools/bin/golangci-lint
--enable=unused \
--enable=structcheck \
--enable=deadcode \
--enable=gosimple \
$$($(PACKAGE_DIRECTORIES))

check-slow:tools/bin/gometalinter tools/bin/gosec
Expand Down
8 changes: 3 additions & 5 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2280,10 +2280,8 @@ func (s *testDBSuite6) TestDropColumn(c *C) {
testddlutil.ExecMultiSQLInGoroutine(c, s.store, "drop_col_db", []string{"insert into t2 set c1 = 1, c2 = 1, c3 = 1, c4 = 1"}, dmlDone)
}
for i := 0; i < num; i++ {
select {
case err := <-ddlDone:
c.Assert(err, IsNil, Commentf("err:%v", errors.ErrorStack(err)))
}
err := <-ddlDone
c.Assert(err, IsNil, Commentf("err:%v", errors.ErrorStack(err)))
}

// Test for drop partition table column.
Expand Down Expand Up @@ -6575,7 +6573,7 @@ func (s *testSerialDBSuite) TestModifyColumnTypeWhenInterception(c *C) {

count := defaultBatchSize * 4
// Add some rows.
dml := fmt.Sprintf("insert into t values")
dml := "insert into t values"
for i := 1; i <= count; i++ {
dml += fmt.Sprintf("(%d, %f)", i, 11.22)
if i != count {
Expand Down
2 changes: 1 addition & 1 deletion ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4040,7 +4040,7 @@ func checkAutoRandom(tableInfo *model.TableInfo, originCol *table.Column, specNe
autoid.MaxAutoRandomBits, newRandBits, specNewColumn.Name.Name.O)
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(errMsg)
}
break // Increasing auto_random shard bits is allowed.
// increasing auto_random shard bits is allowed.
case oldRandBits > newRandBits:
if newRandBits == 0 {
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomAlterErrMsg)
Expand Down
10 changes: 5 additions & 5 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,15 @@ func (s *testSerialSuite) TestCreateTableWithLike(c *C) {

// for failure table cases
tk.MustExec("use ctwl_db")
failSQL := fmt.Sprintf("create table t1 like test_not_exist.t")
failSQL := "create table t1 like test_not_exist.t"
tk.MustGetErrCode(failSQL, mysql.ErrNoSuchTable)
failSQL = fmt.Sprintf("create table t1 like test.t_not_exist")
failSQL = "create table t1 like test.t_not_exist"
tk.MustGetErrCode(failSQL, mysql.ErrNoSuchTable)
failSQL = fmt.Sprintf("create table t1 (like test_not_exist.t)")
failSQL = "create table t1 (like test_not_exist.t)"
tk.MustGetErrCode(failSQL, mysql.ErrNoSuchTable)
failSQL = fmt.Sprintf("create table test_not_exis.t1 like ctwl_db.t")
failSQL = "create table test_not_exis.t1 like ctwl_db.t"
tk.MustGetErrCode(failSQL, mysql.ErrBadDB)
failSQL = fmt.Sprintf("create table t1 like ctwl_db.t")
failSQL = "create table t1 like ctwl_db.t"
tk.MustGetErrCode(failSQL, mysql.ErrTableExists)

// test failure for wrong object cases
Expand Down
4 changes: 1 addition & 3 deletions executor/aggfuncs/func_percentile.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ func (e *basePercentile) AllocPartialResult() (pr PartialResult, memDelta int64)
return
}

func (e *basePercentile) ResetPartialResult(pr PartialResult) {
return
}
func (e *basePercentile) ResetPartialResult(pr PartialResult) {}

func (e *basePercentile) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) (memDelta int64, err error) {
return
Expand Down
1 change: 0 additions & 1 deletion executor/concurrent_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func (m concurrentMap) Insert(key uint64, value *entry) {
shard.items[key] = value
}
shard.Unlock()
return
}

// UpsertCb : Callback to return new element to be inserted into the map
Expand Down
5 changes: 1 addition & 4 deletions executor/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ func (e *DeleteExec) removeRowsInTblRowMap(tblRowMap tableRowMapType) error {
var err error
rowMap.Range(func(h kv.Handle, val interface{}) bool {
err = e.removeRow(e.ctx, e.tblID2Table[id], h, val.([]types.Datum))
if err != nil {
return false
}
return true
return err == nil
})
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5809,7 +5809,7 @@ func (s *testRecoverTable) TestRecoverTable(c *C) {
// Test for recover one table multiple time.
tk.MustExec("drop table t_recover")
tk.MustExec("flashback table t_recover to t_recover_tmp")
_, err = tk.Exec(fmt.Sprintf("recover table t_recover"))
_, err = tk.Exec("recover table t_recover")
c.Assert(infoschema.ErrTableExists.Equal(err), IsTrue)

gcEnable, err := gcutil.CheckGCEnable(tk.Se)
Expand Down Expand Up @@ -5876,7 +5876,7 @@ func (s *testRecoverTable) TestFlashbackTable(c *C) {
tk.MustQuery("select a,_tidb_rowid from t_flashback2;").Check(testkit.Rows("1 1", "2 2", "3 3", "4 5001", "5 5002", "6 5003", "7 10001", "8 10002", "9 10003"))

// Test for flashback one table multiple time.
_, err = tk.Exec(fmt.Sprintf("flashback table t_flashback to t_flashback4"))
_, err = tk.Exec("flashback table t_flashback to t_flashback4")
c.Assert(infoschema.ErrTableExists.Equal(err), IsTrue)

// Test for flashback truncated table to new table.
Expand Down
24 changes: 12 additions & 12 deletions executor/explainfor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ func (s *testSuite) TestExplainMemTablePredicate(c *C) {

func (s *testSuite) TestExplainClusterTable(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.cluster_config where type in ('tikv', 'tidb')")).Check(testkit.Rows(
tk.MustQuery("desc select * from information_schema.cluster_config where type in ('tikv', 'tidb')").Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:CLUSTER_CONFIG node_types:["tidb","tikv"]`))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.cluster_config where instance='192.168.1.7:2379'")).Check(testkit.Rows(
tk.MustQuery("desc select * from information_schema.cluster_config where instance='192.168.1.7:2379'").Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:CLUSTER_CONFIG instances:["192.168.1.7:2379"]`))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.cluster_config where type='tidb' and instance='192.168.1.7:2379'")).Check(testkit.Rows(
tk.MustQuery("desc select * from information_schema.cluster_config where type='tidb' and instance='192.168.1.7:2379'").Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:CLUSTER_CONFIG node_types:["tidb"], instances:["192.168.1.7:2379"]`))
}

Expand All @@ -203,11 +203,11 @@ func (s *testSuite) TestInspectionResultTable(c *C) {

func (s *testSuite) TestInspectionRuleTable(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.inspection_rules where type='inspection'")).Check(testkit.Rows(
tk.MustQuery("desc select * from information_schema.inspection_rules where type='inspection'").Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:INSPECTION_RULES node_types:["inspection"]`))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.inspection_rules where type='inspection' or type='summary'")).Check(testkit.Rows(
tk.MustQuery("desc select * from information_schema.inspection_rules where type='inspection' or type='summary'").Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:INSPECTION_RULES node_types:["inspection","summary"]`))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.inspection_rules where type='inspection' and type='summary'")).Check(testkit.Rows(
tk.MustQuery("desc select * from information_schema.inspection_rules where type='inspection' and type='summary'").Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:INSPECTION_RULES skip_request: true`))
}

Expand Down Expand Up @@ -355,12 +355,12 @@ func (s *testPrepareSerialSuite) TestExplainDotForQuery(c *C) {

func (s *testSuite) TestExplainTableStorage(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'information_schema'")).Check(testkit.Rows(
fmt.Sprintf("MemTableScan_5 10000.00 root table:TABLE_STORAGE_STATS schema:[\"information_schema\"]")))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.TABLE_STORAGE_STATS where TABLE_NAME = 'schemata'")).Check(testkit.Rows(
fmt.Sprintf("MemTableScan_5 10000.00 root table:TABLE_STORAGE_STATS table:[\"schemata\"]")))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'information_schema' and TABLE_NAME = 'schemata'")).Check(testkit.Rows(
fmt.Sprintf("MemTableScan_5 10000.00 root table:TABLE_STORAGE_STATS schema:[\"information_schema\"], table:[\"schemata\"]")))
tk.MustQuery("desc select * from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'information_schema'").Check(testkit.Rows(
"MemTableScan_5 10000.00 root table:TABLE_STORAGE_STATS schema:[\"information_schema\"]"))
tk.MustQuery("desc select * from information_schema.TABLE_STORAGE_STATS where TABLE_NAME = 'schemata'").Check(testkit.Rows(
"MemTableScan_5 10000.00 root table:TABLE_STORAGE_STATS table:[\"schemata\"]"))
tk.MustQuery("desc select * from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'information_schema' and TABLE_NAME = 'schemata'").Check(testkit.Rows(
"MemTableScan_5 10000.00 root table:TABLE_STORAGE_STATS schema:[\"information_schema\"], table:[\"schemata\"]"))
}

func (s *testSuite) TestInspectionSummaryTable(c *C) {
Expand Down
4 changes: 2 additions & 2 deletions executor/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *testSuite3) TestGrantDBScope(c *C) {
createUserSQL := `CREATE USER 'testDB'@'localhost' IDENTIFIED BY '123';`
tk.MustExec(createUserSQL)
// Make sure all the db privs for new user is empty.
sql := fmt.Sprintf("SELECT * FROM mysql.db WHERE User=\"testDB\" and host=\"localhost\"")
sql := `SELECT * FROM mysql.db WHERE User="testDB" and host="localhost"`
tk.MustQuery(sql).Check(testkit.Rows())

// Grant each priv to the user.
Expand Down Expand Up @@ -101,7 +101,7 @@ func (s *testSuite3) TestWithGrantOption(c *C) {
createUserSQL := `CREATE USER 'testWithGrant'@'localhost' IDENTIFIED BY '123';`
tk.MustExec(createUserSQL)
// Make sure all the db privs for new user is empty.
sql := fmt.Sprintf("SELECT * FROM mysql.db WHERE User=\"testWithGrant\" and host=\"localhost\"")
sql := `SELECT * FROM mysql.db WHERE User="testWithGrant" and host="localhost"`
tk.MustQuery(sql).Check(testkit.Rows())

// Grant select priv to the user, with grant option.
Expand Down
1 change: 0 additions & 1 deletion executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,6 @@ func (e *memtableRetriever) dataForTableTiFlashReplica(ctx sessionctx.Context, s
}
}
e.rows = rows
return
}

func (e *memtableRetriever) setDataForStatementsSummary(ctx sessionctx.Context, tableName string) error {
Expand Down
2 changes: 1 addition & 1 deletion executor/insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (s *testSuite3) TestInsertDateTimeWithTimeZone(c *C) {
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (ts timestamp)")
tk.MustExec("insert into t values ('2020-10-22T12:00:00Z'), ('2020-10-22T13:00:00Z'), ('2020-10-22T14:00:00Z')")
tk.MustQuery(fmt.Sprintf("select count(*) from t where ts > '2020-10-22T12:00:00Z'")).Check(testkit.Rows("2"))
tk.MustQuery("select count(*) from t where ts > '2020-10-22T12:00:00Z'").Check(testkit.Rows("2"))

// test for datetime with fsp
fspCases := []struct {
Expand Down
2 changes: 1 addition & 1 deletion executor/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ func (e *joinRuntimeStats) String() string {
if e.cache.useCache {
buf.WriteString(fmt.Sprintf(", cache:ON, cacheHitRatio:%.3f%%", e.cache.hitRatio*100))
} else {
buf.WriteString(fmt.Sprintf(", cache:OFF"))
buf.WriteString(", cache:OFF")
}
}
if e.hasHashStat {
Expand Down
4 changes: 2 additions & 2 deletions executor/memtable_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ func fetchClusterConfig(sctx sessionctx.Context, nodeTypes, nodeAddrs set.String
continue
}
var str string
switch val.(type) {
switch val := val.(type) {
case string: // remove quotes
str = val.(string)
str = val
default:
tmp, err := json.Marshal(val)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions executor/merge_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ func (s *testSerialSuite1) TestShuffleMergeJoinInDisk(c *C) {
c.Assert(tk.Se.GetSessionVars().StmtCtx.MemTracker.MaxConsumed(), Greater, int64(0))
c.Assert(tk.Se.GetSessionVars().StmtCtx.DiskTracker.BytesConsumed(), Equals, int64(0))
c.Assert(tk.Se.GetSessionVars().StmtCtx.DiskTracker.MaxConsumed(), Greater, int64(0))
return
}
func (s *testSerialSuite1) TestMergeJoinInDisk(c *C) {
defer config.RestoreFunc()()
Expand Down Expand Up @@ -313,7 +312,6 @@ func (s *testSerialSuite1) TestMergeJoinInDisk(c *C) {
c.Assert(tk.Se.GetSessionVars().StmtCtx.MemTracker.MaxConsumed(), Greater, int64(0))
c.Assert(tk.Se.GetSessionVars().StmtCtx.DiskTracker.BytesConsumed(), Equals, int64(0))
c.Assert(tk.Se.GetSessionVars().StmtCtx.DiskTracker.MaxConsumed(), Greater, int64(0))
return
}

func (s *testSuite2) TestMergeJoin(c *C) {
Expand Down Expand Up @@ -726,6 +724,7 @@ func (s *testSuite2) TestMergeJoinDifferentTypes(c *C) {
}

// TestVectorizedMergeJoin is used to test vectorized merge join with some corner cases.
//nolint:gosimple // generates false positive fmt.Sprintf warnings which keep aligned
func (s *testSuiteJoin3) TestVectorizedMergeJoin(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down Expand Up @@ -841,6 +840,7 @@ func (s *testSuiteJoin3) TestVectorizedMergeJoin(c *C) {
}

// TestVectorizedShuffleMergeJoin is used to test vectorized shuffle merge join with some corner cases.
//nolint:gosimple // generates false positive fmt.Sprintf warnings which keep aligned
func (s *testSuiteJoin3) TestVectorizedShuffleMergeJoin(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("set @@session.tidb_merge_join_concurrency = 4;")
Expand Down
1 change: 0 additions & 1 deletion executor/parallel_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func checkApplyPlan(c *C, tk *testkit.TestKit, sql string, parallel int) {
}
}
c.Assert(containApply, IsTrue)
return
}

func (s *testSuite) TestParallelApply(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion executor/partition_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (s *partitionTableSuite) TestBatchGetandPointGetwithHashPartition(c *C) {
}

// test empty PointGet
queryHash := fmt.Sprintf("select a from thash where a=200")
queryHash := "select a from thash where a=200"
c.Assert(tk.HasPlan(queryHash, "Point_Get"), IsTrue) // check if PointGet is used
tk.MustQuery(queryHash).Check(testkit.Rows())

Expand Down
8 changes: 4 additions & 4 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,10 @@ func ConstructResultOfShowCreateTable(ctx sessionctx.Context, tableInfo *model.T
}

if pkCol != nil {
// If PKIsHanle, pk info is not in tb.Indices(). We should handle it here.
// If PKIsHandle, pk info is not in tb.Indices(). We should handle it here.
buf.WriteString(",\n")
fmt.Fprintf(buf, " PRIMARY KEY (%s)", stringutil.Escape(pkCol.Name.O, sqlMode))
buf.WriteString(fmt.Sprintf(" /*T![clustered_index] CLUSTERED */"))
buf.WriteString(" /*T![clustered_index] CLUSTERED */")
}

publicIndices := make([]*model.IndexInfo, 0, len(tableInfo.Indices))
Expand Down Expand Up @@ -906,9 +906,9 @@ func ConstructResultOfShowCreateTable(ctx sessionctx.Context, tableInfo *model.T
}
if idxInfo.Primary {
if tableInfo.PKIsHandle || tableInfo.IsCommonHandle {
buf.WriteString(fmt.Sprintf(" /*T![clustered_index] CLUSTERED */"))
buf.WriteString(" /*T![clustered_index] CLUSTERED */")
} else {
buf.WriteString(fmt.Sprintf(" /*T![clustered_index] NONCLUSTERED */"))
buf.WriteString(" /*T![clustered_index] NONCLUSTERED */")
}
}
if i != len(publicIndices)-1 {
Expand Down
2 changes: 1 addition & 1 deletion expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5833,7 +5833,7 @@ func (s *testIntegrationSuite) TestDecodetoChunkReuse(c *C) {
tk.MustExec("create table chk (a int,b varchar(20))")
for i := 0; i < 200; i++ {
if i%5 == 0 {
tk.MustExec(fmt.Sprintf("insert chk values (NULL,NULL)"))
tk.MustExec("insert chk values (NULL,NULL)")
continue
}
tk.MustExec(fmt.Sprintf("insert chk values (%d,'%s')", i, strconv.Itoa(i)))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
honnef.co/go/tools v0.1.3 // indirect
honnef.co/go/tools v0.1.4 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the patch need a upgrade of deps?

Copy link
Contributor Author

@tisonkun tisonkun May 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run make check locally and it upgrade this dep. I think we don't use honnef.co/go/tools in codebase actually but it includes golangci-lint

modernc.org/mathutil v1.2.2 // indirect
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil v2.19.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.21.2+incompatible h1:U+YvJfjCh6MslYlIAXvPtzhW3YZEtc9uncueUNpD/0A=
Expand Down Expand Up @@ -933,8 +932,8 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.1.3 h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
honnef.co/go/tools v0.1.4 h1:SadWOkti5uVN1FAMgxn165+Mw00fuQKyk4Gyn/inxNQ=
honnef.co/go/tools v0.1.4/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
Expand Down
14 changes: 3 additions & 11 deletions infoschema/metrics_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,9 @@ func (def *MetricTableDef) genColumnInfos() []columnInfo {
// GenPromQL generates the promQL.
func (def *MetricTableDef) GenPromQL(sctx sessionctx.Context, labels map[string]set.StringSet, quantile float64) string {
promQL := def.PromQL
if strings.Contains(promQL, promQLQuantileKey) {
promQL = strings.Replace(promQL, promQLQuantileKey, strconv.FormatFloat(quantile, 'f', -1, 64), -1)
}

if strings.Contains(promQL, promQLLabelConditionKey) {
promQL = strings.Replace(promQL, promQLLabelConditionKey, def.genLabelCondition(labels), -1)
}

if strings.Contains(promQL, promQRangeDurationKey) {
promQL = strings.Replace(promQL, promQRangeDurationKey, strconv.FormatInt(sctx.GetSessionVars().MetricSchemaRangeDuration, 10)+"s", -1)
}
promQL = strings.Replace(promQL, promQLQuantileKey, strconv.FormatFloat(quantile, 'f', -1, 64), -1)
promQL = strings.Replace(promQL, promQLLabelConditionKey, def.genLabelCondition(labels), -1)
promQL = strings.Replace(promQL, promQRangeDurationKey, strconv.FormatInt(sctx.GetSessionVars().MetricSchemaRangeDuration, 10)+"s", -1)
return promQL
}

Expand Down
10 changes: 2 additions & 8 deletions planner/cascades/implementation_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ type ImplTableDual struct {

// Match implements ImplementationRule Match interface.
func (r *ImplTableDual) Match(expr *memo.GroupExpr, prop *property.PhysicalProperty) (matched bool) {
if !prop.IsEmpty() {
return false
}
return true
return prop.IsEmpty()
}

// OnImplement implements ImplementationRule OnImplement interface.
Expand All @@ -116,10 +113,7 @@ type ImplMemTableScan struct {

// Match implements ImplementationRule Match interface.
func (r *ImplMemTableScan) Match(expr *memo.GroupExpr, prop *property.PhysicalProperty) (matched bool) {
if !prop.IsEmpty() {
return false
}
return true
return prop.IsEmpty()
}

// OnImplement implements ImplementationRule OnImplement interface.
Expand Down
5 changes: 1 addition & 4 deletions planner/cascades/transformation_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1503,10 +1503,7 @@ func NewRuleMergeAggregationProjection() Transformation {
// Match implements Transformation interface.
func (r *MergeAggregationProjection) Match(old *memo.ExprIter) bool {
proj := old.Children[0].GetExpr().ExprNode.(*plannercore.LogicalProjection)
if plannercore.ExprsHasSideEffects(proj.Exprs) {
return false
}
return true
return !plannercore.ExprsHasSideEffects(proj.Exprs)
}

// OnTransform implements Transformation interface.
Expand Down
1 change: 1 addition & 0 deletions planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ func (ijHelper *indexJoinBuildHelper) updateBestChoice(ranges []*ranger.Range, p

func (ijHelper *indexJoinBuildHelper) buildTemplateRange(matchedKeyCnt int, eqAndInFuncs []expression.Expression, nextColRange []*ranger.Range, haveExtraCol bool) (ranges []*ranger.Range, emptyRange bool, err error) {
pointLength := matchedKeyCnt + len(eqAndInFuncs)
//nolint:gosimple // false positive unnecessary nil check
if nextColRange != nil {
for _, colRan := range nextColRange {
// The range's exclude status is the same with last col's.
Expand Down
Loading