Skip to content

Commit

Permalink
*: gocritic fixes for commentFormatting (pingcap#21578)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgo authored Dec 9, 2020
1 parent cd2600f commit 28c9e92
Show file tree
Hide file tree
Showing 65 changed files with 675 additions and 675 deletions.
2 changes: 1 addition & 1 deletion cmd/importer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (c *DBConfig) String() string {
return fmt.Sprintf("DBConfig(%+v)", *c)
}

//DDLConfig is the configuration for ddl statements.
// DDLConfig is the configuration for ddl statements.
type DDLConfig struct {
TableSQL string `toml:"table-sql" json:"table-sql"`

Expand Down
6 changes: 3 additions & 3 deletions distsql/distsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *testSuite) createSelectNormal(batch, totalRows int, c *C, planIDs []int
Build()
c.Assert(err, IsNil)

/// 4 int64 types.
// 4 int64 types.
colTypes := []*types.FieldType{
{
Tp: mysql.TypeLonglong,
Expand Down Expand Up @@ -203,7 +203,7 @@ func (s *testSuite) createSelectStreaming(batch, totalRows int, c *C) (*streamRe
Build()
c.Assert(err, IsNil)

/// 4 int64 types.
// 4 int64 types.
colTypes := []*types.FieldType{
{
Tp: mysql.TypeLonglong,
Expand Down Expand Up @@ -473,7 +473,7 @@ func createSelectNormal(batch, totalRows int, ctx sessionctx.Context) (*selectRe
SetMemTracker(memory.NewTracker(-1, -1)).
Build()

/// 4 int64 types.
// 4 int64 types.
colTypes := []*types.FieldType{
{
Tp: mysql.TypeLonglong,
Expand Down
6 changes: 3 additions & 3 deletions executor/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,9 @@ func (s *testSuite3) TestAdminCheckPartitionTableFailed(c *C) {
c.Assert(err.Error(), Equals, fmt.Sprintf("[executor:8003]admin_test_p err:[admin:8223]index:<nil> != record:&admin.RecordData{Handle:%d, Values:[]types.Datum{types.Datum{k:0x1, decimal:0x0, length:0x0, i:%d, collation:\"\", b:[]uint8(nil), x:interface {}(nil)}}}", i, i))
c.Assert(executor.ErrAdminCheckTable.Equal(err), IsTrue)
// TODO: fix admin recover for partition table.
//r := tk.MustQuery("admin recover index admin_test_p idx")
//r.Check(testkit.Rows("0 0"))
//tk.MustExec("admin check table admin_test_p")
// r := tk.MustQuery("admin recover index admin_test_p idx")
// r.Check(testkit.Rows("0 0"))
// tk.MustExec("admin check table admin_test_p")
// Manual recover index.
txn, err = s.store.Begin()
c.Assert(err, IsNil)
Expand Down
8 changes: 4 additions & 4 deletions executor/aggfuncs/func_count_distinct.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ type approxCountDistinctHashValue uint32
// This algorithm is also very accurate for data sets with small cardinality and very efficient on CPU. If number of
// distinct element is more than 2^32, relative error may be high.
type partialResult4ApproxCountDistinct struct {
size uint32 /// Number of elements.
sizeDegree uint8 /// The size of the table as a power of 2.
skipDegree uint8 /// Skip elements not divisible by 2 ^ skipDegree.
hasZero bool /// The hash table contains an element with a hash value of 0.
size uint32 // Number of elements.
sizeDegree uint8 // The size of the table as a power of 2.
skipDegree uint8 // Skip elements not divisible by 2 ^ skipDegree.
hasZero bool // The hash table contains an element with a hash value of 0.
buf []approxCountDistinctHashValue
}

Expand Down
2 changes: 1 addition & 1 deletion executor/aggfuncs/func_rank.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

const (
//DefPartialResult4RankSize is the size of partialResult4Rank
// DefPartialResult4RankSize is the size of partialResult4Rank
DefPartialResult4RankSize = int64(unsafe.Sizeof(partialResult4Rank{}))
)

Expand Down
10 changes: 5 additions & 5 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func (s *testSuiteAgg) TestAggregation(c *C) {
tk.MustQuery("select std(b) from t1 group by a order by a;").Check(testkit.Rows("<nil>", "0", "0"))
tk.MustQuery("select stddev(b) from t1 group by a order by a;").Check(testkit.Rows("<nil>", "0", "0"))

//For var_samp()/stddev_samp()
// For var_samp()/stddev_samp()
tk.MustExec("drop table if exists t1;")
tk.MustExec("CREATE TABLE t1 (id int(11),value1 float(10,2));")
tk.MustExec("INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00), (2,13.00);")
Expand Down Expand Up @@ -777,10 +777,10 @@ func (s *testSuiteAgg) TestOnlyFullGroupBy(c *C) {
c.Assert(terror.ErrorEqual(err, plannercore.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err))

// FixMe: test functional dependency of derived table
//tk.MustQuery("select * from (select * from t) as e group by a")
//tk.MustQuery("select * from (select * from t) as e group by b,d")
//err = tk.ExecToErr("select * from (select * from t) as e group by b,c")
//c.Assert(terror.ErrorEqual(err, plannercore.ErrFieldNotInGroupBy), IsTrue)
// tk.MustQuery("select * from (select * from t) as e group by a")
// tk.MustQuery("select * from (select * from t) as e group by b,d")
// err = tk.ExecToErr("select * from (select * from t) as e group by b,c")
// c.Assert(terror.ErrorEqual(err, plannercore.ErrFieldNotInGroupBy), IsTrue)

// test order by
tk.MustQuery("select c from t group by c,d order by d")
Expand Down
2 changes: 1 addition & 1 deletion executor/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func getStmtDbLabel(stmtNode ast.StmtNode) map[string]struct{} {
return dbLabelSet
}

func getDbFromResultNode(resultNode ast.ResultSetNode) []string { //may have duplicate db name
func getDbFromResultNode(resultNode ast.ResultSetNode) []string { // may have duplicate db name
var dbLabels []string

if resultNode == nil {
Expand Down
26 changes: 13 additions & 13 deletions executor/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,45 +186,45 @@ func (s *testSuite6) TestCreateTable(c *C) {
func (s *testSuite6) TestCreateView(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
//create an source table
// create an source table
tk.MustExec("CREATE TABLE source_table (id INT NOT NULL DEFAULT 1, name varchar(255), PRIMARY KEY(id));")
//test create a exist view
// test create a exist view
tk.MustExec("CREATE VIEW view_t AS select id , name from source_table")
defer tk.MustExec("DROP VIEW IF EXISTS view_t")
_, err := tk.Exec("CREATE VIEW view_t AS select id , name from source_table")
c.Assert(err.Error(), Equals, "[schema:1050]Table 'test.view_t' already exists")
//create view on nonexistent table
// create view on nonexistent table
_, err = tk.Exec("create view v1 (c,d) as select a,b from t1")
c.Assert(err.Error(), Equals, "[schema:1146]Table 'test.t1' doesn't exist")
//simple view
// simple view
tk.MustExec("create table t1 (a int ,b int)")
tk.MustExec("insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10)")
//view with colList and SelectFieldExpr
// view with colList and SelectFieldExpr
tk.MustExec("create view v1 (c) as select b+1 from t1")
//view with SelectFieldExpr
// view with SelectFieldExpr
tk.MustExec("create view v2 as select b+1 from t1")
//view with SelectFieldExpr and AsName
// view with SelectFieldExpr and AsName
tk.MustExec("create view v3 as select b+1 as c from t1")
//view with colList , SelectField and AsName
// view with colList , SelectField and AsName
tk.MustExec("create view v4 (c) as select b+1 as d from t1")
//view with select wild card
// view with select wild card
tk.MustExec("create view v5 as select * from t1")
tk.MustExec("create view v6 (c,d) as select * from t1")
_, err = tk.Exec("create view v7 (c,d,e) as select * from t1")
c.Assert(err.Error(), Equals, ddl.ErrViewWrongList.Error())
//drop multiple views in a statement
// drop multiple views in a statement
tk.MustExec("drop view v1,v2,v3,v4,v5,v6")
//view with variable
// view with variable
tk.MustExec("create view v1 (c,d) as select a,b+@@global.max_user_connections from t1")
_, err = tk.Exec("create view v1 (c,d) as select a,b from t1 where a = @@global.max_user_connections")
c.Assert(err.Error(), Equals, "[schema:1050]Table 'test.v1' already exists")
tk.MustExec("drop view v1")
//view with different col counts
// view with different col counts
_, err = tk.Exec("create view v1 (c,d,e) as select a,b from t1 ")
c.Assert(err.Error(), Equals, ddl.ErrViewWrongList.Error())
_, err = tk.Exec("create view v1 (c) as select a,b from t1 ")
c.Assert(err.Error(), Equals, ddl.ErrViewWrongList.Error())
//view with or_replace flag
// view with or_replace flag
tk.MustExec("drop view if exists v1")
tk.MustExec("create view v1 (c,d) as select a,b from t1")
tk.MustExec("create or replace view v1 (c,d) as select a,b from t1 ")
Expand Down
8 changes: 4 additions & 4 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1785,17 +1785,17 @@ func (s *testSuiteP1) TestJSON(c *C) {
// Check cast json to decimal.
// NOTE: this test case contains a bug, it should be uncommented after the bug is fixed.
// TODO: Fix bug https://github.com/pingcap/tidb/issues/12178
//tk.MustExec("drop table if exists test_json")
//tk.MustExec("create table test_json ( a decimal(60,2) as (JSON_EXTRACT(b,'$.c')), b json );")
//tk.MustExec(`insert into test_json (b) values
// tk.MustExec("drop table if exists test_json")
// tk.MustExec("create table test_json ( a decimal(60,2) as (JSON_EXTRACT(b,'$.c')), b json );")
// tk.MustExec(`insert into test_json (b) values
// ('{"c": "1267.1"}'),
// ('{"c": "1267.01"}'),
// ('{"c": "1267.1234"}'),
// ('{"c": "1267.3456"}'),
// ('{"c": "1234567890123456789012345678901234567890123456789012345"}'),
// ('{"c": "1234567890123456789012345678901234567890123456789012345.12345"}');`)
//
//tk.MustQuery("select a from test_json;").Check(testkit.Rows("1267.10", "1267.01", "1267.12",
// tk.MustQuery("select a from test_json;").Check(testkit.Rows("1267.10", "1267.01", "1267.12",
// "1267.35", "1234567890123456789012345678901234567890123456789012345.00",
// "1234567890123456789012345678901234567890123456789012345.12"))
}
Expand Down
2 changes: 1 addition & 1 deletion executor/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *testSuiteP1) TestGrantGlobal(c *C) {
sql := fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal1\" and host=\"localhost\"", mysql.Priv2UserCol[v])
tk.MustQuery(sql).Check(testkit.Rows("Y"))
}
//with grant option
// with grant option
tk.MustExec("GRANT ALL ON *.* TO 'testGlobal1'@'localhost' WITH GRANT OPTION;")
for _, v := range mysql.AllGlobalPrivs {
sql := fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal1\" and host=\"localhost\"", mysql.Priv2UserCol[v])
Expand Down
4 changes: 2 additions & 2 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex
return nil, nil
}

//Cache the ret full rows in schemataRetriever
// Cache the ret full rows in schemataRetriever
if !e.initialized {
is := infoschema.GetInfoSchema(sctx)
dbs := is.AllSchemas()
Expand Down Expand Up @@ -149,7 +149,7 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex
e.initialized = true
}

//Adjust the amount of each return
// Adjust the amount of each return
maxCount := 1024
retCount := maxCount
if e.rowIdx+maxCount > len(e.rows) {
Expand Down
18 changes: 9 additions & 9 deletions executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (s *testInfoschemaTableSuite) TestKeyColumnUsage(c *C) {
tk.MustQuery("select * from information_schema.KEY_COLUMN_USAGE where TABLE_NAME='stats_meta' and COLUMN_NAME='table_id';").Check(
testkit.Rows("def mysql tbl def mysql stats_meta table_id 1 <nil> <nil> <nil> <nil>"))

//test the privilege of new user for information_schema.table_constraints
// test the privilege of new user for information_schema.table_constraints
tk.MustExec("create user key_column_tester")
keyColumnTester := testkit.NewTestKit(c, s.store)
keyColumnTester.MustExec("use information_schema")
Expand All @@ -285,7 +285,7 @@ func (s *testInfoschemaTableSuite) TestKeyColumnUsage(c *C) {
}, nil, nil), IsTrue)
keyColumnTester.MustQuery("select * from information_schema.KEY_COLUMN_USAGE;").Check([][]interface{}{})

//test the privilege of user with privilege of mysql.gc_delete_range for information_schema.table_constraints
// test the privilege of user with privilege of mysql.gc_delete_range for information_schema.table_constraints
tk.MustExec("CREATE ROLE r_stats_meta ;")
tk.MustExec("GRANT ALL PRIVILEGES ON mysql.stats_meta TO r_stats_meta;")
tk.MustExec("GRANT r_stats_meta TO key_column_tester;")
Expand All @@ -295,7 +295,7 @@ func (s *testInfoschemaTableSuite) TestKeyColumnUsage(c *C) {

func (s *testInfoschemaTableSuite) TestUserPrivileges(c *C) {
tk := testkit.NewTestKit(c, s.store)
//test the privilege of new user for information_schema.table_constraints
// test the privilege of new user for information_schema.table_constraints
tk.MustExec("create user constraints_tester")
constraintsTester := testkit.NewTestKit(c, s.store)
constraintsTester.MustExec("use information_schema")
Expand All @@ -305,15 +305,15 @@ func (s *testInfoschemaTableSuite) TestUserPrivileges(c *C) {
}, nil, nil), IsTrue)
constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS;").Check([][]interface{}{})

//test the privilege of user with privilege of mysql.gc_delete_range for information_schema.table_constraints
// test the privilege of user with privilege of mysql.gc_delete_range for information_schema.table_constraints
tk.MustExec("CREATE ROLE r_gc_delete_range ;")
tk.MustExec("GRANT ALL PRIVILEGES ON mysql.gc_delete_range TO r_gc_delete_range;")
tk.MustExec("GRANT r_gc_delete_range TO constraints_tester;")
constraintsTester.MustExec("set role r_gc_delete_range")
c.Assert(len(constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME='gc_delete_range';").Rows()), Greater, 0)
constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME='tables_priv';").Check([][]interface{}{})

//test the privilege of new user for information_schema
// test the privilege of new user for information_schema
tk.MustExec("create user tester1")
tk1 := testkit.NewTestKit(c, s.store)
tk1.MustExec("use information_schema")
Expand All @@ -323,7 +323,7 @@ func (s *testInfoschemaTableSuite) TestUserPrivileges(c *C) {
}, nil, nil), IsTrue)
tk1.MustQuery("select * from information_schema.STATISTICS;").Check([][]interface{}{})

//test the privilege of user with some privilege for information_schema
// test the privilege of user with some privilege for information_schema
tk.MustExec("create user tester2")
tk.MustExec("CREATE ROLE r_columns_priv;")
tk.MustExec("GRANT ALL PRIVILEGES ON mysql.columns_priv TO r_columns_priv;")
Expand All @@ -340,7 +340,7 @@ func (s *testInfoschemaTableSuite) TestUserPrivileges(c *C) {
tk2.MustQuery("select * from information_schema.STATISTICS where TABLE_NAME='tables_priv' and COLUMN_NAME='Host';").Check(
[][]interface{}{})

//test the privilege of user with all privilege for information_schema
// test the privilege of user with all privilege for information_schema
tk.MustExec("create user tester3")
tk.MustExec("CREATE ROLE r_all_priv;")
tk.MustExec("GRANT ALL PRIVILEGES ON mysql.* TO r_all_priv;")
Expand Down Expand Up @@ -507,7 +507,7 @@ func (s *testInfoschemaTableSuite) TestForAnalyzeStatus(c *C) {
tk.MustExec("analyze table analyze_test")
tk.MustQuery("select distinct TABLE_NAME from information_schema.analyze_status where TABLE_NAME='analyze_test'").Check(testkit.Rows("analyze_test"))

//test the privilege of new user for information_schema.analyze_status
// test the privilege of new user for information_schema.analyze_status
tk.MustExec("create user analyze_tester")
analyzeTester := testkit.NewTestKit(c, s.store)
analyzeTester.MustExec("use information_schema")
Expand All @@ -518,7 +518,7 @@ func (s *testInfoschemaTableSuite) TestForAnalyzeStatus(c *C) {
analyzeTester.MustQuery("show analyze status").Check([][]interface{}{})
analyzeTester.MustQuery("select * from information_schema.ANALYZE_STATUS;").Check([][]interface{}{})

//test the privilege of user with privilege of test.t1 for information_schema.analyze_status
// test the privilege of user with privilege of test.t1 for information_schema.analyze_status
tk.MustExec("create table t1 (a int, b int, index idx(a))")
tk.MustExec("insert into t1 values (1,2),(3,4)")
tk.MustExec("analyze table t1")
Expand Down
2 changes: 1 addition & 1 deletion executor/point_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ func (s *testPointGetSuite) TestPointGetLockExistKey(c *C) {
errCh <- tk2.ExecToErr(fmt.Sprintf("insert into %s values(2, 2, 2)", tableName))
go func() {
errCh <- tk2.ExecToErr(fmt.Sprintf("insert into %s values(1, 1, 10)", tableName))
//tk2.MustExec(fmt.Sprintf("insert into %s values(1, 1, 10)", tableName))
// tk2.MustExec(fmt.Sprintf("insert into %s values(1, 1, 10)", tableName))
doneCh <- struct{}{}
}()
time.Sleep(150 * time.Millisecond)
Expand Down
2 changes: 1 addition & 1 deletion executor/shuffle.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import (
// +----------> | fetch data from DataSource |
// +---------------------------------+
//
////////////////////////////////////////////////////////////////////////////////////////
//
type ShuffleExec struct {
baseExecutor
concurrency int
Expand Down
2 changes: 1 addition & 1 deletion executor/slow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
// ParseSlowLogBatchSize is the batch size of slow-log lines for a worker to parse, exported for testing.
var ParseSlowLogBatchSize = 64

//slowQueryRetriever is used to read slow log data.
// slowQueryRetriever is used to read slow log data.
type slowQueryRetriever struct {
table *model.TableInfo
outputCols []*model.ColumnInfo
Expand Down
2 changes: 1 addition & 1 deletion executor/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2824,7 +2824,7 @@ func (s *testSuite7) TestSetWithCurrentTimestampAndNow(c *C) {
tk.MustExec("use test")
tk.MustExec(`drop table if exists tbl;`)
tk.MustExec(`create table t1(c1 timestamp default current_timestamp, c2 int, c3 timestamp default current_timestamp);`)
//c1 insert using now() function result, c3 using default value calculation, should be same
// c1 insert using now() function result, c3 using default value calculation, should be same
tk.MustExec(`insert into t1 set c1 = current_timestamp, c2 = sleep(2);`)
tk.MustQuery("select c1 = c3 from t1").Check(testkit.Rows("1"))
tk.MustExec(`insert into t1 set c1 = current_timestamp, c2 = sleep(1);`)
Expand Down
2 changes: 1 addition & 1 deletion expression/aggregation/base_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (a *baseFuncDesc) typeInfer4LeadLag(ctx sessionctx.Context) {
}

func (a *baseFuncDesc) typeInfer4PopOrSamp(ctx sessionctx.Context) {
//var_pop/std/var_samp/stddev_samp's return value type is double
// var_pop/std/var_samp/stddev_samp's return value type is double
a.RetTp = types.NewFieldType(mysql.TypeDouble)
a.RetTp.Flen, a.RetTp.Decimal = mysql.MaxRealWidth, types.UnspecifiedLength
}
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin_compare_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func vecResOfGE(res []int64) {
}
}

//vecCompareInt is vectorized CompareInt()
// vecCompareInt is vectorized CompareInt()
func vecCompareInt(isUnsigned0, isUnsigned1 bool, largs, rargs, result *chunk.Column) {
switch {
case isUnsigned0 && isUnsigned1:
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type aesModeAttr struct {
}

var aesModes = map[string]*aesModeAttr{
//TODO support more modes, permitted mode values are: ECB, CBC, CFB1, CFB8, CFB128, OFB
// TODO support more modes, permitted mode values are: ECB, CBC, CFB1, CFB8, CFB128, OFB
"aes-128-ecb": {"ecb", 16, false},
"aes-192-ecb": {"ecb", 24, false},
"aes-256-ecb": {"ecb", 32, false},
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin_math_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ func (s *testEvaluatorSuite) TestTan(c *C) {
{int64(0), float64(0), false, false},
{math.Pi / 4, float64(1), false, false},
{-math.Pi / 4, float64(-1), false, false},
{math.Pi * 3 / 4, math.Tan(math.Pi * 3 / 4), false, false}, //in mysql and golang, it equals -1.0000000000000002, not -1
{math.Pi * 3 / 4, math.Tan(math.Pi * 3 / 4), false, false}, // in mysql and golang, it equals -1.0000000000000002, not -1
{"0.000", float64(0), false, false},
{"sdfgsdfg", 0, false, true},
}
Expand Down
Loading

0 comments on commit 28c9e92

Please sign in to comment.