No need to fetch statement duration more than once
This commit is contained in:
parent
2ef562de06
commit
f3ab0596f5
1 changed files with 3 additions and 3 deletions
|
@ -269,11 +269,11 @@ func (e *executor) operate(ctx context.Context, stm sql.Statement) (res []interf
|
||||||
// it runs no longer than specified.
|
// it runs no longer than specified.
|
||||||
|
|
||||||
if stm, ok := stm.(sql.KillableStatement); ok {
|
if stm, ok := stm.(sql.KillableStatement); ok {
|
||||||
if stm.Duration() > 0 {
|
if dur := stm.Duration(); dur > 0 {
|
||||||
ctx, canc = context.WithTimeout(ctx, stm.Duration())
|
ctx, canc = context.WithTimeout(ctx, dur)
|
||||||
defer func() {
|
defer func() {
|
||||||
if tim := ctx.Err(); err == nil && tim != nil {
|
if tim := ctx.Err(); err == nil && tim != nil {
|
||||||
res, err = nil, &TimerError{timer: stm.Duration()}
|
res, err = nil, &TimerError{timer: dur}
|
||||||
}
|
}
|
||||||
canc()
|
canc()
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in a new issue