Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#54989
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
lance6716 authored and ti-chi-bot committed Oct 28, 2024
1 parent cc04dd7 commit a510771
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions executor/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,36 @@ 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
}
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
}
16 changes: 16 additions & 0 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit a510771

Please sign in to comment.