Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ddl/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func mergeContinuousKeyRanges(schemaKeyRanges []keyRangeMayExclude) []kv.KeyRang
// It contains all non system table key ranges and meta data key ranges.
// The time complexity is O(nlogn).
func getFlashbackKeyRanges(ctx context.Context, sess sessionctx.Context, flashbackTS uint64) ([]kv.KeyRange, error) {
is := sess.GetDomainInfoSchema().(infoschema.InfoSchema)
is := sess.GetLatestInfoSchema().(infoschema.InfoSchema)
schemas := is.AllSchemas()

// get snapshot schema IDs.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/metabuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewMetaBuildContextWithSctx(sctx sessionctx.Context, otherOpts ...metabuild
metabuild.WithClusteredIndexDefMode(sessVars.EnableClusteredIndex),
metabuild.WithShardRowIDBits(sessVars.ShardRowIDBits),
metabuild.WithPreSplitRegions(sessVars.PreSplitRegions),
metabuild.WithInfoSchema(sctx.GetDomainInfoSchema()),
metabuild.WithInfoSchema(sctx.GetLatestInfoSchema()),
}

if len(otherOpts) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/metabuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestNewMetaBuildContextWithSctx(t *testing.T) {
{
field: "is",
check: func(ctx *metabuild.Context) {
sctxInfoSchema := sctx.GetDomainInfoSchema()
sctxInfoSchema := sctx.GetLatestInfoSchema()
require.NotNil(t, sctxInfoSchema)
is, ok := ctx.GetInfoSchema()
require.True(t, ok)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/tests/multivaluedindex/multi_valued_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestCreateMultiValuedIndexHasBinaryCollation(t *testing.T) {
tk := testkit.NewTestKit(t, store)

tk.MustExec("create table test.t (pk varchar(4) primary key clustered, j json, str varchar(255), value int, key idx((cast(j as char(100) array)), str));")
is := tk.Session().GetDomainInfoSchema().(infoschema.InfoSchema)
is := tk.Session().GetLatestInfoSchema().(infoschema.InfoSchema)
require.NotNil(t, is)

tbl, err := is.TableByName(context.Background(), ast.NewCIStr("test"), ast.NewCIStr("t"))
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ func (b *executorBuilder) buildInsert(v *plannercore.Insert) exec.Executor {

func (b *executorBuilder) buildImportInto(v *plannercore.ImportInto) exec.Executor {
// see planBuilder.buildImportInto for detail why we use the latest schema here.
latestIS := b.ctx.GetDomainInfoSchema().(infoschema.InfoSchema)
latestIS := b.ctx.GetLatestInfoSchema().(infoschema.InfoSchema)
tbl, ok := latestIS.TableByID(context.Background(), v.Table.TableInfo.ID)
if !ok {
b.err = errors.Errorf("Can not get table %d", v.Table.TableInfo.ID)
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/distribute_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestDistributeTable(t *testing.T) {
recoverCli := infosync.SetPDHttpCliForTest(cli)
defer recoverCli()
mockCreateSchedulerWithInput := func(tblName string, config map[string]any, partitions []string) *mock.Call {
is := tk.Session().GetDomainInfoSchema()
is := tk.Session().GetLatestInfoSchema()
tbl, err := is.TableInfoByName(ast.NewCIStr(database), ast.NewCIStr(tblName))
require.NoError(t, err)
tblID := tbl.ID
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestShowTableDistributions(t *testing.T) {
recoverCli := infosync.SetPDHttpCliForTest(cli)
defer recoverCli()
mockGetDistributions := func(tblName, partition string, distributions *pdhttp.RegionDistributions) *mock.Call {
is := tk.Session().GetDomainInfoSchema()
is := tk.Session().GetLatestInfoSchema()
tbl, err := is.TableInfoByName(ast.NewCIStr("test"), ast.NewCIStr(tblName))
require.NoError(t, err)
tblID := tbl.ID
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/executor_failpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func TestGetMvccByEncodedKeyRegionError(t *testing.T) {
txn, err := store.Begin()
require.NoError(t, err)
m := meta.NewMutator(txn)
schemaVersion := tk.Session().GetDomainInfoSchema().SchemaMetaVersion()
schemaVersion := tk.Session().GetLatestInfoSchema().SchemaMetaVersion()
key := m.EncodeSchemaDiffKey(schemaVersion)

resp, err := h.GetMvccByEncodedKey(key)
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/importer/precheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestCheckRequirements(t *testing.T) {

_, err := conn.Execute(ctx, "create table test.t(id int primary key)")
require.NoError(t, err)
is := tk.Session().GetDomainInfoSchema().(infoschema.InfoSchema)
is := tk.Session().GetLatestInfoSchema().(infoschema.InfoSchema)
tableObj, err := is.TableByName(context.Background(), ast.NewCIStr("test"), ast.NewCIStr("t"))
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2062,7 +2062,7 @@ func (e *memtableRetriever) setDataForTiKVRegionStatus(ctx context.Context, sctx
}
requestByTableRange := false
var allRegionsInfo *pd.RegionsInfo
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
is := sctx.GetLatestInfoSchema().(infoschema.InfoSchema)
if e.extractor != nil {
extractor, ok := e.extractor.(*plannercore.TiKVRegionStatusExtractor)
if ok && len(extractor.GetTablesID()) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/show_placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ func TestShowPlacementHandleRegionStatus(t *testing.T) {
defer recoverCli()

mockGetState := func(tblName, partition string, state string) *mock.Call {
is := tk.Session().GetDomainInfoSchema()
is := tk.Session().GetLatestInfoSchema()
tbl, err := is.TableInfoByName(ast.NewCIStr("test"), ast.NewCIStr(tblName))
require.NoError(t, err)
tblID := tbl.ID
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func resetErrDataTooLong(colName string, rowIdx int, _ error) error {
// checkRowForExchangePartition is only used for ExchangePartition by non-partitionTable during write only state.
// It check if rowData inserted or updated violate partition definition or checkConstraints of partitionTable.
func checkRowForExchangePartition(sctx sessionctx.Context, row []types.Datum, tbl *model.TableInfo) error {
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
is := sctx.GetLatestInfoSchema().(infoschema.InfoSchema)
pt, tableFound := is.TableByID(context.Background(), tbl.ExchangePartitionInfo.ExchangePartitionTableID)
if !tableFound {
return errors.Errorf("exchange partition process table by id failed")
Expand Down
6 changes: 3 additions & 3 deletions pkg/expression/builtin_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ func (b *builtinTiDBEncodeRecordKeySig) Clone() builtinFunc {

// evalString evals a builtinTiDBEncodeRecordKeySig.
func (b *builtinTiDBEncodeRecordKeySig) evalString(ctx EvalContext, row chunk.Row) (string, bool, error) {
is, err := b.GetDomainInfoSchema(ctx)
is, err := b.GetLatestInfoSchema(ctx)
if err != nil {
return "", true, err
}
Expand Down Expand Up @@ -1123,7 +1123,7 @@ func (b *builtinTiDBEncodeIndexKeySig) Clone() builtinFunc {

// evalString evals a builtinTiDBEncodeIndexKeySig.
func (b *builtinTiDBEncodeIndexKeySig) evalString(ctx EvalContext, row chunk.Row) (string, bool, error) {
is, err := b.GetDomainInfoSchema(ctx)
is, err := b.GetLatestInfoSchema(ctx)
if err != nil {
return "", true, err
}
Expand Down Expand Up @@ -1199,7 +1199,7 @@ func (b *builtinTiDBDecodeKeySig) evalString(ctx EvalContext, row chunk.Row) (st
if isNull || err != nil {
return "", isNull, err
}
is, err := b.GetDomainInfoSchema(ctx)
is, err := b.GetLatestInfoSchema(ctx)
if err != nil {
return "", true, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/builtin_info_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func (b *builtinTiDBDecodeKeySig) vecEvalString(ctx EvalContext, input *chunk.Ch
}
result.ReserveString(n)

is, err := b.GetDomainInfoSchema(ctx)
is, err := b.GetLatestInfoSchema(ctx)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/expression/expropt/infoschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func (InfoSchemaPropReader) GetSessionInfoSchema(ctx exprctx.EvalContext) (infos
return p(false), nil
}

// GetDomainInfoSchema return domain information schema.
func (InfoSchemaPropReader) GetDomainInfoSchema(ctx exprctx.EvalContext) (infoschema.MetaOnlyInfoSchema, error) {
// GetLatestInfoSchema return domain information schema.
func (InfoSchemaPropReader) GetLatestInfoSchema(ctx exprctx.EvalContext) (infoschema.MetaOnlyInfoSchema, error) {
p, err := getPropProvider[InfoSchemaPropProvider](ctx, exprctx.OptPropInfoSchema)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/expression/expropt/optional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestOptionalEvalPropProviders(t *testing.T) {
reader = r
verifyNoProvider = func(ctx exprctx.EvalContext) {
assertReaderFuncReturnErr(t, ctx, r.GetSessionInfoSchema)
assertReaderFuncReturnErr(t, ctx, r.GetDomainInfoSchema)
assertReaderFuncReturnErr(t, ctx, r.GetLatestInfoSchema)
}
verifyProvider = func(ctx exprctx.EvalContext, val exprctx.OptionalEvalPropProvider) {
is, ok := val.(InfoSchemaPropProvider)(true).(*mockIsType)
Expand All @@ -134,7 +134,7 @@ func TestOptionalEvalPropProviders(t *testing.T) {
require.True(t, ok)
require.Same(t, &is2, is)

require.Same(t, &is1, assertReaderFuncValue(t, ctx, r.GetDomainInfoSchema))
require.Same(t, &is1, assertReaderFuncValue(t, ctx, r.GetLatestInfoSchema))
require.Same(t, &is2, assertReaderFuncValue(t, ctx, r.GetSessionInfoSchema))
}
case exprctx.OptPropKVStore:
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/sessionexpr/sessionctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func currentUserProp(sctx sessionctx.Context) exprctx.OptionalEvalPropProvider {
func infoSchemaProp(sctx sessionctx.Context) expropt.InfoSchemaPropProvider {
return func(isDomain bool) infoschema.MetaOnlyInfoSchema {
if isDomain {
return sctx.GetDomainInfoSchema()
return sctx.GetLatestInfoSchema()
}
return sctx.GetInfoSchema()
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func refineCETrace(sctx base.PlanContext) {
return cmp.Compare(i.RowCount, j.RowCount)
})
traceRecords := stmtCtx.OptimizerCETrace
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
is := sctx.GetLatestInfoSchema().(infoschema.InfoSchema)
for _, rec := range traceRecords {
tbl, _ := infoschema.FindTableByTblOrPartID(is, rec.TableID)
if tbl != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4718,7 +4718,7 @@ func (b *PlanBuilder) buildImportInto(ctx context.Context, ld *ast.ImportIntoStm
//
// tidb_read_staleness can be used to do stale read too, it's allowed as long as
// TableInfo.ID matches with the latest schema.
latestIS := b.ctx.GetDomainInfoSchema().(infoschema.InfoSchema)
latestIS := b.ctx.GetLatestInfoSchema().(infoschema.InfoSchema)
tableInPlan, ok := latestIS.TableByID(ctx, tableInfo.ID)
if !ok {
// adaptor.handleNoDelayExecutor has a similar check, but we want to give
Expand Down
4 changes: 2 additions & 2 deletions pkg/planner/core/rule_collect_plan_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (c *CollectPredicateColumnsPoint) Optimize(_ context.Context, plan base.Log

// Prepare the table metadata to avoid repeatedly fetching from the infoSchema below, and trigger extra sync/async
// stats loading for the determinate mode.
is := plan.SCtx().GetDomainInfoSchema()
is := plan.SCtx().GetLatestInfoSchema()
tblID2TblInfo := make(map[int64]*model.TableInfo)
visitedPhysTblIDs.ForEach(func(physicalTblID int) {
tblInfo, _ := is.TableInfoByID(int64(physicalTblID))
Expand Down Expand Up @@ -440,7 +440,7 @@ func recordTableRuntimeStats(sctx base.PlanContext, tbls map[int64]struct{}) {
func recordSingleTableRuntimeStats(sctx base.PlanContext, tblID int64) (stats *statistics.Table, skip bool, err error) {
dom := domain.GetDomain(sctx)
statsHandle := dom.StatsHandle()
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
is := sctx.GetLatestInfoSchema().(infoschema.InfoSchema)
tbl, ok := is.TableByID(context.Background(), tblID)
if !ok {
return nil, false, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/indexadvisor/optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewOptimizer(sctx sessionctx.Context) Optimizer {
}

func (opt *optimizerImpl) is() infoschema.InfoSchema {
return opt.sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
return opt.sctx.GetLatestInfoSchema().(infoschema.InfoSchema)
}

// IndexNameExist returns whether the specified index name exists in the specified table.
Expand Down
8 changes: 4 additions & 4 deletions pkg/planner/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func hypoIndexChecker(ctx context.Context, is infoschema.InfoSchema) func(db, tb
// queryPlanCost returns the plan cost of this node, which is mainly for the Index Advisor.
func queryPlanCost(sctx sessionctx.Context, stmt ast.StmtNode) (float64, error) {
nodeW := resolve.NewNodeW(stmt)
plan, _, err := Optimize(context.Background(), sctx, nodeW, sctx.GetDomainInfoSchema().(infoschema.InfoSchema))
plan, _, err := Optimize(context.Background(), sctx, nodeW, sctx.GetLatestInfoSchema().(infoschema.InfoSchema))
if err != nil {
return 0, err
}
Expand All @@ -647,7 +647,7 @@ func calculatePlanDigestFunc(sctx sessionctx.Context, stmt ast.StmtNode) (planDi
return "", err
}

p, _, err := Optimize(context.Background(), sctx, nodeW, sctx.GetDomainInfoSchema().(infoschema.InfoSchema))
p, _, err := Optimize(context.Background(), sctx, nodeW, sctx.GetLatestInfoSchema().(infoschema.InfoSchema))
if err != nil {
return "", err
}
Expand All @@ -672,7 +672,7 @@ func recordRelevantOptVarsAndFixes(sctx sessionctx.Context, stmt ast.StmtNode) (
return nil, nil, err
}

_, _, err = Optimize(context.Background(), sctx, nodeW, sctx.GetDomainInfoSchema().(infoschema.InfoSchema))
_, _, err = Optimize(context.Background(), sctx, nodeW, sctx.GetLatestInfoSchema().(infoschema.InfoSchema))
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -700,7 +700,7 @@ func genBriefPlanWithSCtx(sctx sessionctx.Context, stmt ast.StmtNode) (planDiges
return "", "", nil, err
}

p, _, err := Optimize(context.Background(), sctx, nodeW, sctx.GetDomainInfoSchema().(infoschema.InfoSchema))
p, _, err := Optimize(context.Background(), sctx, nodeW, sctx.GetLatestInfoSchema().(infoschema.InfoSchema))
if err != nil {
return "", "", nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/planner/planctx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ type PlanContext interface {
GetStore() kv.Storage
// GetSessionVars gets the session variables.
GetSessionVars() *variable.SessionVars
// GetDomainInfoSchema returns the latest information schema in domain
// Different with `domain.InfoSchema()`, the information schema returned by this method
// includes the temporary table definitions stored in session
GetDomainInfoSchema() infoschema.MetaOnlyInfoSchema
// GetLatestInfoSchema returns the latest information schema.
// except schema of physical schema objects, the information schema returned
// also includes the temporary table definitions stored in session.
GetLatestInfoSchema() infoschema.MetaOnlyInfoSchema
// GetInfoSchema returns the current infoschema
GetInfoSchema() infoschema.MetaOnlyInfoSchema
// UpdateColStatsUsage updates the column stats usage.
Expand Down
4 changes: 2 additions & 2 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4346,7 +4346,7 @@ func (s *session) GetInfoSchema() infoschemactx.MetaOnlyInfoSchema {
return temptable.AttachLocalTemporaryTableInfoSchema(s, is)
}

func (s *session) GetDomainInfoSchema() infoschemactx.MetaOnlyInfoSchema {
func (s *session) GetLatestInfoSchema() infoschemactx.MetaOnlyInfoSchema {
is := domain.GetDomain(s).InfoSchema()
extIs := &infoschema.SessionExtendedInfoSchema{InfoSchema: is}
return temptable.AttachLocalTemporaryTableInfoSchema(s, extIs)
Expand Down Expand Up @@ -4619,7 +4619,7 @@ func (s *session) usePipelinedDmlOrWarn(ctx context.Context) bool {
)
return false
}
is, ok := s.GetDomainInfoSchema().(infoschema.InfoSchema)
is, ok := s.GetLatestInfoSchema().(infoschema.InfoSchema)
if !ok {
stmtCtx.AppendWarning(errors.New("Pipelined DML failed to get latest InfoSchema. Fallback to standard mode"))
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/session/txnmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (m *txnManager) GetTxnInfoSchema() infoschema.InfoSchema {
return m.ctxProvider.GetTxnInfoSchema()
}

if is := m.sctx.GetDomainInfoSchema(); is != nil {
if is := m.sctx.GetLatestInfoSchema(); is != nil {
return is.(infoschema.InfoSchema)
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/sessionctx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ type Context interface {

// Deprecated: the semantics of session.GetInfoSchema() is ambiguous
// If you want to get the infoschema of the current transaction in SQL layer, use sessiontxn.GetTxnManager(ctx).GetTxnInfoSchema()
// If you want to get the latest infoschema use `GetDomainInfoSchema`
// If you want to get the latest infoschema use `GetLatestInfoSchema`
GetInfoSchema() infoschema.MetaOnlyInfoSchema

// GetDomainInfoSchema returns the latest information schema in domain
// Different with `domain.InfoSchema()`, the information schema returned by this method
// includes the temporary table definitions stored in session
GetDomainInfoSchema() infoschema.MetaOnlyInfoSchema
// GetLatestInfoSchema returns the latest information schema.
// except schema of physical schema objects, the information schema returned
// also includes the temporary table definitions stored in session.
GetLatestInfoSchema() infoschema.MetaOnlyInfoSchema

GetSessionVars() *variable.SessionVars

Expand Down
2 changes: 1 addition & 1 deletion pkg/sessiontxn/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ type TxnManager interface {
TxnAdvisable
// GetTxnInfoSchema returns the information schema used by txn
// If the session is not in any transaction, for example: between two autocommit statements,
// this method will return the latest information schema in session that is same with `sessionctx.GetDomainInfoSchema()`
// this method will return the latest information schema in session that is same with `sessionctx.GetLatestInfoSchema()`
GetTxnInfoSchema() infoschema.InfoSchema
// GetTxnScope returns the current txn scope
GetTxnScope() string
Expand Down
2 changes: 1 addition & 1 deletion pkg/sessiontxn/isolation/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (p *baseTxnContextProvider) OnInitialize(ctx context.Context, tp sessiontxn
}

p.enterNewTxnType = tp
p.infoSchema = p.sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
p.infoSchema = p.sctx.GetLatestInfoSchema().(infoschema.InfoSchema)
txnCtx := &variable.TransactionContext{
TxnCtxNoNeedToRestore: variable.TxnCtxNoNeedToRestore{
CreateTime: time.Now(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/sessiontxn/txn_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ func TestTxnContextForStaleReadInPrepare(t *testing.T) {
tk.MustExec("use test")
se := tk.Session()

is1 := se.GetDomainInfoSchema()
is1 := se.GetLatestInfoSchema()
tk.MustExec("do sleep(0.1)")
tk.MustExec("set @a=now(6)")
tk.MustExec("prepare s1 from 'select * from t1 where id=1'")
Expand Down Expand Up @@ -660,7 +660,7 @@ func TestTxnContextForStaleReadInPrepare(t *testing.T) {
se.SetValue(sessiontxn.AssertTxnInfoSchemaKey, nil)

// stale read should not use plan cache
is2 := se.GetDomainInfoSchema()
is2 := se.GetLatestInfoSchema()
se.SetValue(sessiontxn.AssertTxnInfoSchemaKey, nil)
tk.MustExec("set @@tx_read_ts=''")
tk.MustExec("do sleep(0.1)")
Expand Down
2 changes: 1 addition & 1 deletion pkg/sessiontxn/txn_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func TestSnapshotInterceptor(t *testing.T) {

tk := testkit.NewTestKit(t, store)
tk.MustExec("create temporary table test.tmp1 (id int primary key)")
tbl, err := tk.Session().GetDomainInfoSchema().(infoschema.InfoSchema).TableByName(context.Background(), ast.NewCIStr("test"), ast.NewCIStr("tmp1"))
tbl, err := tk.Session().GetLatestInfoSchema().(infoschema.InfoSchema).TableByName(context.Background(), ast.NewCIStr("test"), ast.NewCIStr("tmp1"))
require.NoError(t, err)
require.Equal(t, model.TempTableLocal, tbl.Meta().TempTableType)
tblID := tbl.Meta().ID
Expand Down
2 changes: 1 addition & 1 deletion pkg/statistics/handle/autoanalyze/autoanalyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func RandomPickOneTableAndTryAutoAnalyze(
pruneMode variable.PartitionPruneMode,
start, end time.Time,
) bool {
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
is := sctx.GetLatestInfoSchema().(infoschema.InfoSchema)
dbs := infoschema.AllSchemaNames(is)
// Shuffle the database and table slice to randomize the order of analyzing tables.
rd := rand.New(rand.NewSource(time.Now().UnixNano())) // #nosec G404
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (j *DynamicPartitionedTableAnalysisJob) ValidateAndPrepare(
j.failureHook(j, needRetry)
}
}
is := sctx.GetDomainInfoSchema()
is := sctx.GetLatestInfoSchema()
tableInfo, ok := is.TableInfoByID(j.GlobalTableID)
if !ok {
callFailureHook(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (j *NonPartitionedTableAnalysisJob) ValidateAndPrepare(
j.failureHook(j, needRetry)
}
}
is := sctx.GetDomainInfoSchema()
is := sctx.GetLatestInfoSchema()
tableInfo, ok := is.TableInfoByID(j.TableID)
if !ok {
callFailureHook(false)
Expand Down
Loading