From f3ab0596f5ac84c2fc213335a0538839de2dd029 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 7 Mar 2020 09:55:25 +0000 Subject: [PATCH] No need to fetch statement duration more than once --- db/executor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/executor.go b/db/executor.go index a8ec61c9..ab81c1c9 100644 --- a/db/executor.go +++ b/db/executor.go @@ -269,11 +269,11 @@ func (e *executor) operate(ctx context.Context, stm sql.Statement) (res []interf // it runs no longer than specified. if stm, ok := stm.(sql.KillableStatement); ok { - if stm.Duration() > 0 { - ctx, canc = context.WithTimeout(ctx, stm.Duration()) + if dur := stm.Duration(); dur > 0 { + ctx, canc = context.WithTimeout(ctx, dur) defer func() { if tim := ctx.Err(); err == nil && tim != nil { - res, err = nil, &TimerError{timer: stm.Duration()} + res, err = nil, &TimerError{timer: dur} } canc() }()