Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/benchdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ func (ut *benchDB) query(spec string) {
})
}

func cLogf(format string, args ...interface{}) {
func cLogf(format string, args ...any) {
str := fmt.Sprintf(format, args...)
fmt.Println("\033[0;32m" + str + "\033[0m\n")
}

func cLog(args ...interface{}) {
func cLog(args ...any) {
str := fmt.Sprint(args...)
fmt.Println("\033[0;32m" + str + "\033[0m\n")
}
4 changes: 2 additions & 2 deletions cmd/benchfilesort/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,12 @@ func main() {
}
}

func cLogf(format string, args ...interface{}) {
func cLogf(format string, args ...any) {
str := fmt.Sprintf(format, args...)
fmt.Println("\033[0;32m" + str + "\033[0m")
}

func cLog(args ...interface{}) {
func cLog(args ...any) {
str := fmt.Sprint(args...)
fmt.Println("\033[0;32m" + str + "\033[0m")
}
6 changes: 3 additions & 3 deletions cmd/ddltest/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

// After add column finished, check the records in the table.
func (s *TestDDLSuite) checkAddColumn(c *C, rowID int64, defaultVal interface{}, updatedVal interface{}) {
func (s *TestDDLSuite) checkAddColumn(c *C, rowID int64, defaultVal any, updatedVal any) {
ctx := s.ctx
err := ctx.NewTxn(goctx.Background())
c.Assert(err, IsNil)
Expand Down Expand Up @@ -81,7 +81,7 @@ func (s *TestDDLSuite) checkAddColumn(c *C, rowID int64, defaultVal interface{},
c.Assert(deleteCount, Greater, int64(0))
}

func (s *TestDDLSuite) checkDropColumn(c *C, rowID int64, alterColumn *table.Column, updateDefault interface{}) {
func (s *TestDDLSuite) checkDropColumn(c *C, rowID int64, alterColumn *table.Column, updateDefault any) {
ctx := s.ctx
err := ctx.NewTxn(goctx.Background())
c.Assert(err, IsNil)
Expand Down Expand Up @@ -134,7 +134,7 @@ func (s *TestDDLSuite) TestColumn(c *C) {
Query string
ColumnName string
Add bool
Default interface{}
Default any
}{
{"alter table test_column add column c3 int default -1", "c3", true, int64(-1)},
{"alter table test_column drop column c3", "c3", false, nil},
Expand Down
24 changes: 12 additions & 12 deletions cmd/ddltest/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func isRetryError(err error) bool {
return false
}

func (s *TestDDLSuite) exec(query string, args ...interface{}) (sql.Result, error) {
func (s *TestDDLSuite) exec(query string, args ...any) (sql.Result, error) {
for {
server := s.getServer()
r, err := server.db.Exec(query, args...)
Expand All @@ -385,7 +385,7 @@ func (s *TestDDLSuite) exec(query string, args ...interface{}) (sql.Result, erro
}
}

func (s *TestDDLSuite) mustExec(c *C, query string, args ...interface{}) sql.Result {
func (s *TestDDLSuite) mustExec(c *C, query string, args ...any) sql.Result {
r, err := s.exec(query, args...)
if err != nil {
log.Fatalf("[mustExec fail]query - %v %v, error - %v", query, args, err)
Expand All @@ -394,7 +394,7 @@ func (s *TestDDLSuite) mustExec(c *C, query string, args ...interface{}) sql.Res
return r
}

func (s *TestDDLSuite) execInsert(c *C, query string, args ...interface{}) sql.Result {
func (s *TestDDLSuite) execInsert(c *C, query string, args ...any) sql.Result {
for {
r, err := s.exec(query, args...)
if err == nil {
Expand All @@ -413,7 +413,7 @@ func (s *TestDDLSuite) execInsert(c *C, query string, args ...interface{}) sql.R
}
}

func (s *TestDDLSuite) query(query string, args ...interface{}) (*sql.Rows, error) {
func (s *TestDDLSuite) query(query string, args ...any) (*sql.Rows, error) {
for {
server := s.getServer()
r, err := server.db.Query(query, args...)
Expand Down Expand Up @@ -464,20 +464,20 @@ func (s *TestDDLSuite) getTable(c *C, name string) table.Table {
return tbl
}

func dumpRows(c *C, rows *sql.Rows) [][]interface{} {
func dumpRows(c *C, rows *sql.Rows) [][]any {
cols, err := rows.Columns()
c.Assert(err, IsNil)
var ay [][]interface{}
var ay [][]any
for rows.Next() {
v := make([]interface{}, len(cols))
v := make([]any, len(cols))
for i := range v {
v[i] = new(interface{})
v[i] = new(any)
}
err = rows.Scan(v...)
c.Assert(err, IsNil)

for i := range v {
v[i] = *(v[i].(*interface{}))
v[i] = *(v[i].(*any))
}
ay = append(ay, v)
}
Expand All @@ -487,15 +487,15 @@ func dumpRows(c *C, rows *sql.Rows) [][]interface{} {
return ay
}

func matchRows(c *C, rows *sql.Rows, expected [][]interface{}) {
func matchRows(c *C, rows *sql.Rows, expected [][]any) {
ay := dumpRows(c, rows)
c.Assert(len(ay), Equals, len(expected), Commentf("%v", expected))
for i := range ay {
match(c, ay[i], expected[i]...)
}
}

func match(c *C, row []interface{}, expected ...interface{}) {
func match(c *C, row []any, expected ...any) {
c.Assert(len(row), Equals, len(expected))
for i := range row {
if row[i] == nil {
Expand Down Expand Up @@ -563,7 +563,7 @@ func (s *TestDDLSuite) TestSimple(c *C) {

rows, err := s.query("select c1 from test_simple limit 1")
c.Assert(err, IsNil)
matchRows(c, rows, [][]interface{}{{1}})
matchRows(c, rows, [][]any{{1}})

done = s.runDDL("drop table if exists test_simple")
err = <-done
Expand Down
2 changes: 1 addition & 1 deletion cmd/explaintest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (t *tester) executeStmt(query string) error {
t.buf.WriteString("\n")

values := make([][]byte, len(cols))
scanArgs := make([]interface{}, len(values))
scanArgs := make([]any, len(values))
for i := range values {
scanArgs[i] = &values[i]
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pluginpkg/pluginpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func main() {
flag.Usage()
}

var manifest map[string]interface{}
var manifest map[string]any
_, err = toml.DecodeFile(filepath.Join(pkgDir, "manifest.toml"), &manifest)
if err != nil {
log.Printf("read pkg %s's manifest failure, %+v\n", pkgDir, err)
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (b nullableBool) MarshalText() ([]byte, error) {

func (b *nullableBool) UnmarshalJSON(data []byte) error {
var err error
var v interface{}
var v any
if err = json.Unmarshal(data, &v); err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions config/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ func decodeConfig(content string) (*Config, error) {
}

// FlattenConfigItems flatten this config, see more cases in the test.
func FlattenConfigItems(nestedConfig map[string]interface{}) map[string]interface{} {
flatMap := make(map[string]interface{})
func FlattenConfigItems(nestedConfig map[string]any) map[string]any {
flatMap := make(map[string]any)
flatten(flatMap, nestedConfig, "")
return flatMap
}

func flatten(flatMap map[string]interface{}, nested interface{}, prefix string) {
func flatten(flatMap map[string]any, nested any, prefix string) {
switch nested.(type) {
case map[string]interface{}:
for k, v := range nested.(map[string]interface{}) {
case map[string]any:
for k, v := range nested.(map[string]any) {
path := k
if prefix != "" {
path = prefix + "." + k
Expand Down
6 changes: 3 additions & 3 deletions config/config_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *testConfigSuite) TestAtomicWriteConfig(c *C) {
}

func (s *testConfigSuite) TestFlattenConfig(c *C) {
toJSONStr := func(v interface{}) string {
toJSONStr := func(v any) string {
str, err := json.Marshal(v)
c.Assert(err, IsNil)
return string(str)
Expand All @@ -139,7 +139,7 @@ func (s *testConfigSuite) TestFlattenConfig(c *C) {
"k4-2": [5, 6, 7, 8],
"k4-3": [666]
}}`
nested := make(map[string]interface{})
nested := make(map[string]any)
c.Assert(json.Unmarshal([]byte(jsonConf), &nested), IsNil)
flatMap := FlattenConfigItems(nested)
c.Assert(len(flatMap), Equals, 7)
Expand All @@ -159,7 +159,7 @@ format='text'
[isolation-read]
engines = ["tikv", "tiflash", "tidb"]
`
nested = make(map[string]interface{})
nested = make(map[string]any)
c.Assert(toml.Unmarshal([]byte(tomlConf), &nested), IsNil)
flatMap = FlattenConfigItems(nested)
c.Assert(len(flatMap), Equals, 4)
Expand Down
14 changes: 7 additions & 7 deletions ddl/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
)

// adjustColumnInfoInAddColumn is used to set the correct position of column info when adding column.
// 1. The added column was append at the end of tblInfo.Columns, due to ddl state was not public then.
// It should be moved to the correct position when the ddl state to be changed to public.
// 2. The offset of column should also to be set to the right value.
// 1. The added column was append at the end of tblInfo.Columns, due to ddl state was not public then.
// It should be moved to the correct position when the ddl state to be changed to public.
// 2. The offset of column should also to be set to the right value.
func adjustColumnInfoInAddColumn(tblInfo *model.TableInfo, offset int) {
oldCols := tblInfo.Columns
newCols := make([]*model.ColumnInfo, 0, len(oldCols))
Expand Down Expand Up @@ -188,7 +188,7 @@ func onAddColumn(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, err error)
logutil.BgLogger().Info("[ddl] run add column job", zap.String("job", job.String()), zap.Reflect("columnInfo", *columnInfo), zap.Int("offset", offset))
// Set offset arg to job.
if offset != 0 {
job.Args = []interface{}{columnInfo, pos, offset}
job.Args = []any{columnInfo, pos, offset}
}
if err = checkAddColumnTooManyColumns(len(tblInfo.Columns)); err != nil {
job.State = model.JobStateCancelled
Expand Down Expand Up @@ -324,7 +324,7 @@ func onAddColumns(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, err error
columnInfos = append(columnInfos, columnInfo)
}
// Set arg to job.
job.Args = []interface{}{columnInfos, positions, offsets, ifNotExists}
job.Args = []any{columnInfos, positions, offsets, ifNotExists}
}

originalState := columnInfos[0].State
Expand Down Expand Up @@ -473,7 +473,7 @@ func checkDropColumns(t *meta.Meta, job *model.Job) (*model.TableInfo, []*model.
newIfExists = append(newIfExists, ifExists[i])
colInfos = append(colInfos, colInfo)
}
job.Args = []interface{}{newColNames, newIfExists}
job.Args = []any{newColNames, newIfExists}
return tblInfo, colInfos, len(colInfos), nil
}

Expand Down Expand Up @@ -857,7 +857,7 @@ func modifyColsFromNull2NotNull(w *worker, dbInfo *model.DBInfo, tblInfo *model.
return nil
}

func generateOriginDefaultValue(col *model.ColumnInfo) (interface{}, error) {
func generateOriginDefaultValue(col *model.ColumnInfo) (any, error) {
var err error
odValue := col.GetDefaultValue()
if odValue == nil && mysql.HasNotNullFlag(col.Flag) {
Expand Down
8 changes: 4 additions & 4 deletions ddl/column_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ func getCurrentTable(d *ddl, schemaID, tableID int64) (table.Table, error) {
return tbl, err
}

func checkResult(ctx sessionctx.Context, t table.Table, cols []*table.Column, rows [][]interface{}) error {
var gotRows [][]interface{}
func checkResult(ctx sessionctx.Context, t table.Table, cols []*table.Column, rows [][]any) error {
var gotRows [][]any
err := t.IterRecords(ctx, t.FirstKey(), cols, func(h int64, data []types.Datum, cols []*table.Column) (bool, error) {
gotRows = append(gotRows, datumsToInterfaces(data))
return true, nil
Expand All @@ -377,8 +377,8 @@ func checkResult(ctx sessionctx.Context, t table.Table, cols []*table.Column, ro
return nil
}

func datumsToInterfaces(datums []types.Datum) []interface{} {
ifs := make([]interface{}, 0, len(datums))
func datumsToInterfaces(datums []types.Datum) []any {
ifs := make([]any, 0, len(datums))
for _, d := range datums {
ifs = append(ifs, d.GetValue())
}
Expand Down
Loading