Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao committed Feb 2, 2024
1 parent bd6aa65 commit 3c452f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions pkg/ddl/schematracker/info_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ func (i *InfoStore) DeleteTable(schema, table model.CIStr) error {
return nil
}

// AllSchemaNames returns all the schemas' names.
func (i *InfoStore) AllSchemaNames() []string {
names := make([]string, 0, len(i.dbs))
for name := range i.dbs {
names = append(names, name)
}
return names
}

// AllTableNamesOfSchema return all table names of a schema.
func (i *InfoStore) AllTableNamesOfSchema(schema model.CIStr) ([]string, error) {
schemaKey := i.ciStr2Key(schema)
Expand Down
10 changes: 5 additions & 5 deletions pkg/ddl/schematracker/info_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestInfoStoreLowerCaseTableNames(t *testing.T) {
require.True(t, infoschema.ErrTableNotExists.Equal(err))
require.Nil(t, got2)

schemaNames := AllSchemaNames(is)
schemaNames := is.AllSchemaNames()
require.Equal(t, []string{dbName.O}, schemaNames)
_, err = is.AllTableNamesOfSchema(model.NewCIStr("wrong-db"))
require.Error(t, err)
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestInfoStoreLowerCaseTableNames(t *testing.T) {
require.NotNil(t, got2)
require.Equal(t, tableName, got2.Name)

schemaNames = AllSchemaNames(is)
schemaNames = is.AllSchemaNames()
require.Equal(t, []string{dbName.L}, schemaNames)
_, err = is.AllTableNamesOfSchema(model.NewCIStr("wrong-db"))
require.Error(t, err)
Expand All @@ -108,7 +108,7 @@ func TestInfoStoreDeleteTables(t *testing.T) {
err = is.PutTable(dbName1, tableInfo2)
require.NoError(t, err)

schemaNames := AllSchemaNames(is)
schemaNames := is.AllSchemaNames()
require.Equal(t, []string{dbName1.O}, schemaNames)
tableNames, err := is.AllTableNamesOfSchema(dbName1)
require.NoError(t, err)
Expand All @@ -127,7 +127,7 @@ func TestInfoStoreDeleteTables(t *testing.T) {
err = is.PutTable(dbName2, tableInfo1)
require.NoError(t, err)

schemaNames = AllSchemaNames(is)
schemaNames = is.AllSchemaNames()
sort.Strings(schemaNames)
require.Equal(t, []string{dbName1.O, dbName2.O}, schemaNames)
tableNames, err = is.AllTableNamesOfSchema(dbName2)
Expand All @@ -149,6 +149,6 @@ func TestInfoStoreDeleteTables(t *testing.T) {
_, err = is.TableByName(dbName1, tableName1)
require.True(t, infoschema.ErrDatabaseNotExists.Equal(err))

schemaNames = AllSchemaNames(is)
schemaNames = is.AllSchemaNames()
require.Equal(t, []string{dbName2.O}, schemaNames)
}

0 comments on commit 3c452f8

Please sign in to comment.