diff --git a/executor/set.go b/executor/set.go index f9ac8abd38a1d..de9e603c37922 100644 --- a/executor/set.go +++ b/executor/set.go @@ -301,7 +301,15 @@ func (e *SetExecutor) loadSnapshotInfoSchemaIfNeeded(name string, snapshotTS uin if name != variable.TiDBSnapshot && name != variable.TiDBTxnReadTS { return nil } +<<<<<<< HEAD:executor/set.go vars := e.ctx.GetSessionVars() +======= + return loadSnapshotInfoSchemaIfNeeded(e.Ctx(), snapshotTS) +} + +func loadSnapshotInfoSchemaIfNeeded(sctx sessionctx.Context, snapshotTS uint64) error { + vars := sctx.GetSessionVars() +>>>>>>> c5185cbdc58 (executor: `runWithSystemSession` also copy snapshot status (#54989)):pkg/executor/set.go if snapshotTS == 0 { vars.SnapshotInfoschema = nil return nil @@ -309,12 +317,20 @@ func (e *SetExecutor) loadSnapshotInfoSchemaIfNeeded(name string, snapshotTS uin logutil.BgLogger().Info("load snapshot info schema", zap.Uint64("conn", vars.ConnectionID), zap.Uint64("SnapshotTS", snapshotTS)) +<<<<<<< HEAD:executor/set.go dom := domain.GetDomain(e.ctx) +======= + dom := domain.GetDomain(sctx) +>>>>>>> c5185cbdc58 (executor: `runWithSystemSession` also copy snapshot status (#54989)):pkg/executor/set.go snapInfo, err := dom.GetSnapshotInfoSchema(snapshotTS) if err != nil { return err } +<<<<<<< HEAD:executor/set.go vars.SnapshotInfoschema = temptable.AttachLocalTemporaryTableInfoSchema(e.ctx, snapInfo) +======= + vars.SnapshotInfoschema = temptable.AttachLocalTemporaryTableInfoSchema(sctx, snapInfo) +>>>>>>> c5185cbdc58 (executor: `runWithSystemSession` also copy snapshot status (#54989)):pkg/executor/set.go return nil } diff --git a/executor/show.go b/executor/show.go index 59c160bc2df0e..bede0faf8b566 100644 --- a/executor/show.go +++ b/executor/show.go @@ -2283,6 +2283,22 @@ func runWithSystemSession(ctx context.Context, sctx sessionctx.Context, fn func( if err != nil { return err } +<<<<<<< HEAD:executor/show.go defer b.releaseSysSession(ctx, sysCtx) +======= + defer b.ReleaseSysSession(ctx, sysCtx) + + if err = loadSnapshotInfoSchemaIfNeeded(sysCtx, sctx.GetSessionVars().SnapshotTS); err != nil { + return err + } + // `fn` may use KV transaction, so initialize the txn here + if err = sessiontxn.NewTxn(ctx, sysCtx); err != nil { + return err + } + defer sysCtx.RollbackTxn(ctx) + if err = ResetContextOfStmt(sysCtx, &ast.SelectStmt{}); err != nil { + return err + } +>>>>>>> c5185cbdc58 (executor: `runWithSystemSession` also copy snapshot status (#54989)):pkg/executor/show.go return fn(sysCtx) }