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

parser: move 'model' to 'ast' pkg #58704

Merged
merged 4 commits into from
Jan 7, 2025
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions br/pkg/checkpoint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ go_library(
"//pkg/domain",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/ast",
"//pkg/util",
"//pkg/util/sqlexec",
"@com_github_google_uuid//:uuid",
Expand Down Expand Up @@ -53,7 +53,7 @@ go_test(
"//br/pkg/storage",
"//br/pkg/utiltest",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/ast",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_kvproto//pkg/brpb",
"@com_github_pingcap_kvproto//pkg/encryptionpb",
Expand Down
16 changes: 8 additions & 8 deletions br/pkg/checkpoint/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/br/pkg/utiltest"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/oracle"
)
Expand Down Expand Up @@ -128,8 +128,8 @@ func TestCheckpointMetaForRestore(t *testing.T) {
SQLs: []checkpoint.CheckpointIngestIndexRepairSQL{
{
IndexID: 1,
SchemaName: pmodel.NewCIStr("2"),
TableName: pmodel.NewCIStr("3"),
SchemaName: ast.NewCIStr("2"),
TableName: ast.NewCIStr("3"),
IndexName: "4",
AddSQL: "5",
AddArgs: []any{"6", "7", "8"},
Expand All @@ -140,8 +140,8 @@ func TestCheckpointMetaForRestore(t *testing.T) {
repairSQLs, err := checkpoint.LoadCheckpointIngestIndexRepairSQLs(ctx, se.GetSessionCtx().GetRestrictedSQLExecutor())
require.NoError(t, err)
require.Equal(t, repairSQLs.SQLs[0].IndexID, int64(1))
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].SchemaName, ast.NewCIStr("2"))
require.Equal(t, repairSQLs.SQLs[0].TableName, ast.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 Expand Up @@ -360,7 +360,7 @@ func TestCheckpointRestoreRunner(t *testing.T) {

exists := checkpoint.ExistsSstRestoreCheckpoint(ctx, s.Mock.Domain, checkpoint.SnapshotRestoreCheckpointDatabaseName)
require.False(t, exists)
exists = s.Mock.Domain.InfoSchema().SchemaExists(pmodel.NewCIStr(checkpoint.SnapshotRestoreCheckpointDatabaseName))
exists = s.Mock.Domain.InfoSchema().SchemaExists(ast.NewCIStr(checkpoint.SnapshotRestoreCheckpointDatabaseName))
require.False(t, exists)
}

Expand Down Expand Up @@ -545,7 +545,7 @@ func TestCheckpointLogRestoreRunner(t *testing.T) {

exists := checkpoint.ExistsLogRestoreCheckpointMetadata(ctx, s.Mock.Domain)
require.False(t, exists)
exists = s.Mock.Domain.InfoSchema().SchemaExists(pmodel.NewCIStr(checkpoint.LogRestoreCheckpointDatabaseName))
exists = s.Mock.Domain.InfoSchema().SchemaExists(ast.NewCIStr(checkpoint.LogRestoreCheckpointDatabaseName))
require.False(t, exists)
}

Expand Down Expand Up @@ -640,6 +640,6 @@ func TestCheckpointCompactedRestoreRunner(t *testing.T) {

exists = checkpoint.ExistsSstRestoreCheckpoint(ctx, s.Mock.Domain, checkpoint.CustomSSTRestoreCheckpointDatabaseName)
require.False(t, exists)
exists = s.Mock.Domain.InfoSchema().SchemaExists(pmodel.NewCIStr(checkpoint.CustomSSTRestoreCheckpointDatabaseName))
exists = s.Mock.Domain.InfoSchema().SchemaExists(ast.NewCIStr(checkpoint.CustomSSTRestoreCheckpointDatabaseName))
require.False(t, exists)
}
20 changes: 10 additions & 10 deletions br/pkg/checkpoint/log_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/pingcap/tidb/br/pkg/glue"
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/util/sqlexec"
)

Expand Down Expand Up @@ -191,7 +191,7 @@ func ExistsLogRestoreCheckpointMetadata(
dom *domain.Domain,
) bool {
return dom.InfoSchema().
TableExists(pmodel.NewCIStr(LogRestoreCheckpointDatabaseName), pmodel.NewCIStr(checkpointMetaTableName))
TableExists(ast.NewCIStr(LogRestoreCheckpointDatabaseName), ast.NewCIStr(checkpointMetaTableName))
}

// A progress type for snapshot + log restore.
Expand Down Expand Up @@ -251,7 +251,7 @@ func ExistsCheckpointProgress(
dom *domain.Domain,
) bool {
return dom.InfoSchema().
TableExists(pmodel.NewCIStr(LogRestoreCheckpointDatabaseName), pmodel.NewCIStr(checkpointProgressTableName))
TableExists(ast.NewCIStr(LogRestoreCheckpointDatabaseName), ast.NewCIStr(checkpointProgressTableName))
}

// CheckpointTaskInfo is unique information within the same cluster id. It represents the last
Expand Down Expand Up @@ -298,12 +298,12 @@ func TryToGetCheckpointTaskInfo(
}

type CheckpointIngestIndexRepairSQL struct {
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"`
IndexID int64 `json:"index-id"`
SchemaName ast.CIStr `json:"schema-name"`
TableName ast.CIStr `json:"table-name"`
IndexName string `json:"index-name"`
AddSQL string `json:"add-sql"`
AddArgs []any `json:"add-args"`
}

type CheckpointIngestIndexRepairSQLs struct {
Expand All @@ -321,7 +321,7 @@ func LoadCheckpointIngestIndexRepairSQLs(

func ExistsCheckpointIngestIndexRepairSQLs(ctx context.Context, dom *domain.Domain) bool {
return dom.InfoSchema().
TableExists(pmodel.NewCIStr(LogRestoreCheckpointDatabaseName), pmodel.NewCIStr(checkpointIngestTableName))
TableExists(ast.NewCIStr(LogRestoreCheckpointDatabaseName), ast.NewCIStr(checkpointIngestTableName))
}

func SaveCheckpointIngestIndexRepairSQLs(
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/checkpoint/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/pingcap/tidb/br/pkg/glue"
"github.com/pingcap/tidb/br/pkg/pdutil"
"github.com/pingcap/tidb/pkg/domain"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/util/sqlexec"
)

Expand Down Expand Up @@ -173,7 +173,7 @@ func ExistsSstRestoreCheckpoint(
// we only check the existence of the checkpoint data table
// because the checkpoint metadata is not used for restore
return dom.InfoSchema().
TableExists(pmodel.NewCIStr(dbName), pmodel.NewCIStr(checkpointDataTableName))
TableExists(ast.NewCIStr(dbName), ast.NewCIStr(checkpointDataTableName))
}

func RemoveCheckpointDataForSstRestore(ctx context.Context, dom *domain.Domain, se glue.Session, dbName string) error {
Expand Down
6 changes: 3 additions & 3 deletions br/pkg/checkpoint/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pingcap/tidb/br/pkg/glue"
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/kv"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -89,7 +89,7 @@ const (
)

// IsCheckpointDB checks whether the dbname is checkpoint database.
func IsCheckpointDB(dbname pmodel.CIStr) bool {
func IsCheckpointDB(dbname ast.CIStr) bool {
return dbname.O == LogRestoreCheckpointDatabaseName ||
dbname.O == SnapshotRestoreCheckpointDatabaseName ||
dbname.O == CustomSSTRestoreCheckpointDatabaseName
Expand Down Expand Up @@ -333,7 +333,7 @@ func dropCheckpointTables(
}
}
// check if any user table is created in the checkpoint database
tables, err := dom.InfoSchema().SchemaTableInfos(ctx, pmodel.NewCIStr(dbName))
tables, err := dom.InfoSchema().SchemaTableInfos(ctx, ast.NewCIStr(dbName))
if err != nil {
return errors.Trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/checksum/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ go_test(
"//pkg/distsql",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/ast",
"//pkg/sessionctx/variable",
"//pkg/testkit",
"//pkg/testkit/testsetup",
Expand Down
6 changes: 3 additions & 3 deletions br/pkg/checksum/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/pingcap/tidb/pkg/distsql"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/stretchr/testify/require"
Expand All @@ -23,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 := pmodel.NewCIStr(db)
cTableName := pmodel.NewCIStr(table)
cDBName := ast.NewCIStr(db)
cTableName := ast.NewCIStr(table)
tableInfo, err := info.TableByName(context.Background(), cDBName, cTableName)
require.NoError(t, err)
return tableInfo.Meta()
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/glue/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ go_library(
"//pkg/domain",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/ast",
"//pkg/sessionctx",
"@com_github_fatih_color//:color",
"@com_github_pingcap_log//:log",
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/glue/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/sessionctx"
pd "github.com/tikv/pd/client"
)
Expand Down Expand Up @@ -54,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 pmodel.CIStr, table *model.TableInfo,
CreateTable(ctx context.Context, dbName ast.CIStr, table *model.TableInfo,
cs ...ddl.CreateTableOption) error
CreatePlacementPolicy(ctx context.Context, policy *model.PolicyInfo) error
Close()
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/gluetidb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ go_library(
"//pkg/executor",
"//pkg/kv",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/ast",
"//pkg/session",
"//pkg/session/types",
"//pkg/sessionctx",
Expand All @@ -35,7 +35,7 @@ go_test(
deps = [
"//br/pkg/glue",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/ast",
"//pkg/session",
"//pkg/testkit",
"//pkg/types",
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/gluetidb/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pingcap/tidb/pkg/executor"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/session"
sessiontypes "github.com/pingcap/tidb/pkg/session/types"
"github.com/pingcap/tidb/pkg/sessionctx"
Expand Down Expand Up @@ -250,7 +250,7 @@ func (gs *tidbSession) CreateTables(_ context.Context,
}

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

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

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

// CreateTable implements glue.Session.
func (*mockSession) CreateTable(_ context.Context, _ pmodel.CIStr,
func (*mockSession) CreateTable(_ context.Context, _ ast.CIStr,
_ *model.TableInfo, _ ...ddl.CreateTableOption) error {
log.Fatal("unimplemented CreateDatabase for mock session")
return nil
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/metautil/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ go_test(
"//br/pkg/storage",
"//br/pkg/utils",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/ast",
"//pkg/statistics/handle/types",
"//pkg/statistics/util",
"//pkg/tablecodec",
Expand Down
Loading
Loading