Skip to content

Commit

Permalink
sqlite: return error before checking duration of preparing statement
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl authored and n8maninger committed May 22, 2024
1 parent b56710b commit 58db87c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions persist/sqlite/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ func (lt *loggedTxn) Exec(query string, args ...any) (sql.Result, error) {
func (lt *loggedTxn) Prepare(query string) (*loggedStmt, error) {
start := time.Now()
stmt, err := lt.Tx.Prepare(query)
if dur := time.Since(start); dur > longQueryDuration {
lt.log.Debug("slow prepare", zap.String("query", query), zap.Duration("elapsed", dur), zap.Stack("stack"))
} else if err != nil {
if err != nil {
return nil, err
} else if dur := time.Since(start); dur > longQueryDuration {
lt.log.Debug("slow prepare", zap.String("query", query), zap.Duration("elapsed", dur), zap.Stack("stack"))
}
return &loggedStmt{
Stmt: stmt,
Expand Down

0 comments on commit 58db87c

Please sign in to comment.