@@ -378,7 +378,7 @@ func (a *ExecStmt) PointGet(ctx context.Context) (*recordSet, error) {
378378 }
379379
380380 if executor == nil {
381- b := newExecutorBuilder (a .Ctx , a .InfoSchema , a .Ti )
381+ b := newExecutorBuilder (ctx , a .Ctx , a .InfoSchema , a .Ti )
382382 executor = b .build (a .Plan )
383383 if b .err != nil {
384384 return nil , b .err
@@ -608,7 +608,7 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
608608 }
609609 ctx = a .observeStmtBeginForTopSQL (ctx )
610610
611- e , err := a .buildExecutor ()
611+ e , err := a .buildExecutor (ctx )
612612 if err != nil {
613613 return nil , err
614614 }
@@ -1295,7 +1295,7 @@ func (a *ExecStmt) handlePessimisticLockError(ctx context.Context, lockErr error
12951295 a .resetPhaseDurations ()
12961296
12971297 a .inheritContextFromExecuteStmt ()
1298- e , err := a .buildExecutor ()
1298+ e , err := a .buildExecutor (ctx )
12991299 if err != nil {
13001300 return nil , err
13011301 }
@@ -1321,28 +1321,28 @@ type pessimisticTxn interface {
13211321}
13221322
13231323// buildExecutor build an executor from plan, prepared statement may need additional procedure.
1324- func (a * ExecStmt ) buildExecutor () (exec.Executor , error ) {
1324+ func (a * ExecStmt ) buildExecutor (ctx context. Context ) (exec.Executor , error ) {
13251325 defer func (start time.Time ) { a .phaseBuildDurations [0 ] += time .Since (start ) }(time .Now ())
1326- ctx := a .Ctx
1327- stmtCtx := ctx .GetSessionVars ().StmtCtx
1326+ sctx := a .Ctx
1327+ stmtCtx := sctx .GetSessionVars ().StmtCtx
13281328 if _ , ok := a .Plan .(* plannercore.Execute ); ! ok {
13291329 if stmtCtx .Priority == mysql .NoPriority && a .LowerPriority {
13301330 stmtCtx .Priority = kv .PriorityLow
13311331 }
13321332 }
1333- if _ , ok := a .Plan .(* plannercore.Analyze ); ok && ctx .GetSessionVars ().InRestrictedSQL {
1334- ctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
1333+ if _ , ok := a .Plan .(* plannercore.Analyze ); ok && sctx .GetSessionVars ().InRestrictedSQL {
1334+ sctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
13351335 }
13361336
1337- b := newExecutorBuilder (ctx , a .InfoSchema , a .Ti )
1337+ b := newExecutorBuilder (ctx , sctx , a .InfoSchema , a .Ti )
13381338 e := b .build (a .Plan )
13391339 if b .err != nil {
13401340 return nil , errors .Trace (b .err )
13411341 }
13421342
13431343 failpoint .Inject ("assertTxnManagerAfterBuildExecutor" , func () {
13441344 sessiontxn .RecordAssert (a .Ctx , "assertTxnManagerAfterBuildExecutor" , true )
1345- sessiontxn .AssertTxnManagerInfoSchema (b .ctx , b .is )
1345+ sessiontxn .AssertTxnManagerInfoSchema (b .sctx , b .is )
13461346 })
13471347
13481348 // ExecuteExec is not a real Executor, we only use it to build another Executor from a prepared statement.
@@ -1352,7 +1352,7 @@ func (a *ExecStmt) buildExecutor() (exec.Executor, error) {
13521352 return nil , err
13531353 }
13541354 if executorExec .lowerPriority {
1355- ctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
1355+ sctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
13561356 }
13571357 e = executorExec .stmtExec
13581358 }
0 commit comments