@@ -419,7 +419,7 @@ func (a *ExecStmt) PointGet(ctx context.Context) (*recordSet, error) {
419419 }
420420
421421 if executor == nil {
422- b := newExecutorBuilder (a .Ctx , a .InfoSchema , a .Ti )
422+ b := newExecutorBuilder (ctx , a .Ctx , a .InfoSchema , a .Ti )
423423 executor = b .build (a .Plan )
424424 if b .err != nil {
425425 return nil , b .err
@@ -678,7 +678,7 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
678678 execStartTime = time .Now ()
679679 }
680680
681- e , err := a .buildExecutor ()
681+ e , err := a .buildExecutor (ctx )
682682 if err != nil {
683683 return nil , err
684684 }
@@ -1371,7 +1371,7 @@ func (a *ExecStmt) handlePessimisticLockError(ctx context.Context, lockErr error
13711371 a .resetPhaseDurations ()
13721372
13731373 a .inheritContextFromExecuteStmt ()
1374- e , err := a .buildExecutor ()
1374+ e , err := a .buildExecutor (ctx )
13751375 if err != nil {
13761376 return nil , err
13771377 }
@@ -1397,20 +1397,20 @@ type pessimisticTxn interface {
13971397}
13981398
13991399// buildExecutor build an executor from plan, prepared statement may need additional procedure.
1400- func (a * ExecStmt ) buildExecutor () (exec.Executor , error ) {
1400+ func (a * ExecStmt ) buildExecutor (ctx context. Context ) (exec.Executor , error ) {
14011401 defer func (start time.Time ) { a .phaseBuildDurations [0 ] += time .Since (start ) }(time .Now ())
1402- ctx := a .Ctx
1403- stmtCtx := ctx .GetSessionVars ().StmtCtx
1402+ sctx := a .Ctx
1403+ stmtCtx := sctx .GetSessionVars ().StmtCtx
14041404 if _ , ok := a .Plan .(* plannercore.Execute ); ! ok {
14051405 if stmtCtx .Priority == mysql .NoPriority && a .LowerPriority {
14061406 stmtCtx .Priority = kv .PriorityLow
14071407 }
14081408 }
1409- if _ , ok := a .Plan .(* plannercore.Analyze ); ok && ctx .GetSessionVars ().InRestrictedSQL {
1410- ctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
1409+ if _ , ok := a .Plan .(* plannercore.Analyze ); ok && sctx .GetSessionVars ().InRestrictedSQL {
1410+ sctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
14111411 }
14121412
1413- b := newExecutorBuilder (ctx , a .InfoSchema , a .Ti )
1413+ b := newExecutorBuilder (ctx , sctx , a .InfoSchema , a .Ti )
14141414 e := b .build (a .Plan )
14151415 if b .err != nil {
14161416 return nil , errors .Trace (b .err )
@@ -1428,7 +1428,7 @@ func (a *ExecStmt) buildExecutor() (exec.Executor, error) {
14281428 return nil , err
14291429 }
14301430 if executorExec .lowerPriority {
1431- ctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
1431+ sctx .GetSessionVars ().StmtCtx .Priority = kv .PriorityLow
14321432 }
14331433 e = executorExec .stmtExec
14341434 }
0 commit comments