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

*: move XXInfo/Job, etc, out from model pkg in parser to meta #55754

Merged
merged 16 commits into from
Sep 4, 2024
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion br/cmd/br/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ go_library(
"//br/pkg/utils",
"//br/pkg/version/build",
"//pkg/config",
"//pkg/parser/model",
"//pkg/meta/model",
"//pkg/session",
"//pkg/util",
"//pkg/util/gctuner",
Expand Down
2 changes: 1 addition & 1 deletion br/cmd/br/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pingcap/tidb/br/pkg/task"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/br/pkg/version/build"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
tidblogutil "github.com/pingcap/tidb/pkg/util/logutil"
"github.com/spf13/cobra"
"go.uber.org/zap"
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/backup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ go_library(
"//pkg/distsql",
"//pkg/kv",
"//pkg/meta",
"//pkg/parser/model",
"//pkg/meta/model",
"//pkg/statistics/handle",
"//pkg/statistics/handle/util",
"//pkg/util",
Expand Down Expand Up @@ -78,7 +78,7 @@ go_test(
"//br/pkg/rtree",
"//br/pkg/storage",
"//br/pkg/utils",
"//pkg/parser/model",
"//pkg/meta/model",
"//pkg/sessionctx/variable",
"//pkg/testkit",
"//pkg/testkit/testsetup",
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/pingcap/tidb/pkg/distsql"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/util"
filter "github.com/pingcap/tidb/pkg/util/table-filter"
"github.com/tikv/client-go/v2/oracle"
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/backup/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pingcap/tidb/br/pkg/rtree"
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/oracle"
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/backup/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/pingcap/tidb/br/pkg/summary"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/statistics/handle"
"github.com/pingcap/tidb/pkg/statistics/handle/util"
tidbutil "github.com/pingcap/tidb/pkg/util"
Expand Down
2 changes: 2 additions & 0 deletions br/pkg/checkpoint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//br/pkg/storage",
"//br/pkg/summary",
"//br/pkg/utils",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/util",
"@com_github_pingcap_errors//:errors",
Expand All @@ -42,6 +43,7 @@ go_test(
":checkpoint",
"//br/pkg/pdutil",
"//br/pkg/storage",
"//pkg/meta/model",
"//pkg/parser/model",
"@com_github_pingcap_kvproto//pkg/brpb",
"@com_github_pingcap_kvproto//pkg/encryptionpb",
Expand Down
11 changes: 6 additions & 5 deletions br/pkg/checkpoint/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (
"github.com/pingcap/tidb/br/pkg/checkpoint"
"github.com/pingcap/tidb/br/pkg/pdutil"
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/oracle"
)
Expand Down Expand Up @@ -95,8 +96,8 @@ func TestCheckpointMeta(t *testing.T) {
SQLs: []checkpoint.CheckpointIngestIndexRepairSQL{
{
IndexID: 1,
SchemaName: model.NewCIStr("2"),
TableName: model.NewCIStr("3"),
SchemaName: pmodel.NewCIStr("2"),
TableName: pmodel.NewCIStr("3"),
IndexName: "4",
AddSQL: "5",
AddArgs: []any{"6", "7", "8"},
Expand All @@ -107,8 +108,8 @@ func TestCheckpointMeta(t *testing.T) {
repairSQLs, err := checkpoint.LoadCheckpointIngestIndexRepairSQLs(ctx, s, "123")
require.NoError(t, err)
require.Equal(t, repairSQLs.SQLs[0].IndexID, int64(1))
require.Equal(t, repairSQLs.SQLs[0].SchemaName, model.NewCIStr("2"))
require.Equal(t, repairSQLs.SQLs[0].TableName, model.NewCIStr("3"))
require.Equal(t, repairSQLs.SQLs[0].SchemaName, pmodel.NewCIStr("2"))
require.Equal(t, repairSQLs.SQLs[0].TableName, pmodel.NewCIStr("3"))
require.Equal(t, repairSQLs.SQLs[0].IndexName, "4")
require.Equal(t, repairSQLs.SQLs[0].AddSQL, "5")
require.Equal(t, repairSQLs.SQLs[0].AddArgs, []any{"6", "7", "8"})
Expand Down
15 changes: 8 additions & 7 deletions br/pkg/checkpoint/log_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/log"
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -247,12 +248,12 @@ func removeCheckpointTaskInfoForLogRestore(ctx context.Context, s storage.Extern
}

type CheckpointIngestIndexRepairSQL struct {
IndexID int64 `json:"index-id"`
SchemaName model.CIStr `json:"schema-name"`
TableName model.CIStr `json:"table-name"`
IndexName string `json:"index-name"`
AddSQL string `json:"add-sql"`
AddArgs []any `json:"add-args"`
IndexID int64 `json:"index-id"`
SchemaName pmodel.CIStr `json:"schema-name"`
TableName pmodel.CIStr `json:"table-name"`
IndexName string `json:"index-name"`
AddSQL string `json:"add-sql"`
AddArgs []any `json:"add-args"`
}

type CheckpointIngestIndexRepairSQLs struct {
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/checksum/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ go_library(
"//br/pkg/utils",
"//pkg/distsql",
"//pkg/kv",
"//pkg/parser/model",
"//pkg/meta/model",
"//pkg/sessionctx/variable",
"//pkg/tablecodec",
"//pkg/util/ranger",
Expand Down Expand Up @@ -44,6 +44,7 @@ go_test(
"//br/pkg/mock",
"//pkg/distsql",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/sessionctx/variable",
"//pkg/testkit",
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/checksum/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/pkg/distsql"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/tablecodec"
"github.com/pingcap/tidb/pkg/util/ranger"
Expand Down
7 changes: 4 additions & 3 deletions br/pkg/checksum/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
"github.com/pingcap/tidb/br/pkg/mock"
"github.com/pingcap/tidb/pkg/distsql"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/stretchr/testify/require"
Expand All @@ -22,8 +23,8 @@ import (
func getTableInfo(t *testing.T, mock *mock.Cluster, db, table string) *model.TableInfo {
info, err := mock.Domain.GetSnapshotInfoSchema(math.MaxUint64)
require.NoError(t, err)
cDBName := model.NewCIStr(db)
cTableName := model.NewCIStr(table)
cDBName := pmodel.NewCIStr(db)
cTableName := pmodel.NewCIStr(table)
tableInfo, err := info.TableByName(context.Background(), cDBName, cTableName)
require.NoError(t, err)
return tableInfo.Meta()
Expand Down
1 change: 1 addition & 0 deletions br/pkg/glue/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_library(
"//pkg/ddl",
"//pkg/domain",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/sessionctx",
"@com_github_fatih_color//:color",
Expand Down
5 changes: 3 additions & 2 deletions br/pkg/glue/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
"github.com/pingcap/tidb/pkg/ddl"
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/sessionctx"
pd "github.com/tikv/pd/client"
)
Expand Down Expand Up @@ -53,7 +54,7 @@ type Session interface {
Execute(ctx context.Context, sql string) error
ExecuteInternal(ctx context.Context, sql string, args ...any) error
CreateDatabase(ctx context.Context, schema *model.DBInfo) error
CreateTable(ctx context.Context, dbName model.CIStr, table *model.TableInfo,
CreateTable(ctx context.Context, dbName pmodel.CIStr, table *model.TableInfo,
cs ...ddl.CreateTableOption) error
CreatePlacementPolicy(ctx context.Context, policy *model.PolicyInfo) error
Close()
Expand Down
2 changes: 2 additions & 0 deletions br/pkg/gluetidb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_library(
"//pkg/domain",
"//pkg/executor",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/session",
"//pkg/session/types",
Expand All @@ -33,6 +34,7 @@ go_test(
flaky = True,
deps = [
"//br/pkg/glue",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/session",
"//pkg/testkit",
Expand Down
5 changes: 3 additions & 2 deletions br/pkg/gluetidb/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/executor"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/session"
sessiontypes "github.com/pingcap/tidb/pkg/session/types"
"github.com/pingcap/tidb/pkg/sessionctx"
Expand Down Expand Up @@ -246,7 +247,7 @@ func (gs *tidbSession) CreateTables(_ context.Context,
}

// CreateTable implements glue.Session.
func (gs *tidbSession) CreateTable(_ context.Context, dbName model.CIStr,
func (gs *tidbSession) CreateTable(_ context.Context, dbName pmodel.CIStr,
table *model.TableInfo, cs ...ddl.CreateTableOption) error {
return errors.Trace(executor.BRIECreateTable(gs.se, dbName, table, brComment, cs...))
}
Expand Down
25 changes: 13 additions & 12 deletions br/pkg/gluetidb/glue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"testing"

"github.com/pingcap/tidb/br/pkg/glue"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/session"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/types"
Expand All @@ -44,7 +45,7 @@ func TestTheSessionIsoation(t *testing.T) {
})

require.NoError(t, glueSe.CreateDatabase(ctx, &model.DBInfo{
Name: model.NewCIStr("test_db"),
Name: pmodel.NewCIStr("test_db"),
}))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test_db")
Expand All @@ -53,41 +54,41 @@ func TestTheSessionIsoation(t *testing.T) {
req.NoError(glueSe.ExecuteInternal(ctx, "use test;"))
infos := []*model.TableInfo{}
infos = append(infos, &model.TableInfo{
Name: model.NewCIStr("tables_1"),
Name: pmodel.NewCIStr("tables_1"),
Columns: []*model.ColumnInfo{
{Name: model.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
{Name: pmodel.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
},
})
infos = append(infos, &model.TableInfo{
Name: model.NewCIStr("tables_2"),
Name: pmodel.NewCIStr("tables_2"),
PlacementPolicyRef: &model.PolicyRefInfo{
Name: model.NewCIStr("threereplication"),
Name: pmodel.NewCIStr("threereplication"),
},
Columns: []*model.ColumnInfo{
{Name: model.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
{Name: pmodel.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
},
})
infos = append(infos, &model.TableInfo{
Name: model.NewCIStr("tables_3"),
Name: pmodel.NewCIStr("tables_3"),
PlacementPolicyRef: &model.PolicyRefInfo{
Name: model.NewCIStr("fivereplication"),
Name: pmodel.NewCIStr("fivereplication"),
},
Columns: []*model.ColumnInfo{
{Name: model.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
{Name: pmodel.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
},
})
polices := []*model.PolicyInfo{
{
PlacementSettings: &model.PlacementSettings{
Followers: 4,
},
Name: model.NewCIStr("fivereplication"),
Name: pmodel.NewCIStr("fivereplication"),
},
{
PlacementSettings: &model.PlacementSettings{
Followers: 2,
},
Name: model.NewCIStr("threereplication"),
Name: pmodel.NewCIStr("threereplication"),
},
}
for _, pinfo := range polices {
Expand Down
1 change: 1 addition & 0 deletions br/pkg/gluetidb/mock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go_library(
"//pkg/ddl",
"//pkg/domain",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/session/types",
"//pkg/sessionctx",
Expand Down
5 changes: 3 additions & 2 deletions br/pkg/gluetidb/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
"github.com/pingcap/tidb/pkg/ddl"
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
sessiontypes "github.com/pingcap/tidb/pkg/session/types"
"github.com/pingcap/tidb/pkg/sessionctx"
pd "github.com/tikv/pd/client"
Expand Down Expand Up @@ -85,7 +86,7 @@ func (*mockSession) CreateTables(_ context.Context, _ map[string][]*model.TableI
}

// CreateTable implements glue.Session.
func (*mockSession) CreateTable(_ context.Context, _ model.CIStr,
func (*mockSession) CreateTable(_ context.Context, _ pmodel.CIStr,
_ *model.TableInfo, _ ...ddl.CreateTableOption) error {
log.Fatal("unimplemented CreateDatabase for mock session")
return nil
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/metautil/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_library(
"//br/pkg/logutil",
"//br/pkg/storage",
"//br/pkg/summary",
"//pkg/parser/model",
"//pkg/meta/model",
"//pkg/statistics/handle",
"//pkg/statistics/handle/types",
"//pkg/statistics/handle/util",
Expand Down Expand Up @@ -47,6 +47,7 @@ go_test(
shard_count = 9,
deps = [
"//br/pkg/storage",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/statistics/handle/types",
"//pkg/statistics/handle/util",
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/metautil/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/meta/model"
)

// Database wraps the schema and tables of a database.
Expand Down
Loading
Loading