ignore reset result, reset on error

Reset result is from last step; looking at it was probably causing
spurious failures and busy-timeouts.

Transaction completion relies on statements being reset reliably.
This commit is contained in:
Ryan Culpepper 2012-11-30 03:14:18 -05:00
parent 67c6da058b
commit 46fb05e6ee

View File

@ -62,8 +62,8 @@
(when delenda
(for ([pst (in-hash-values delenda)])
(send pst finalize #f)))
(HANDLE fsym (sqlite3_reset stmt))
(HANDLE fsym (sqlite3_clear_bindings stmt))
(void (sqlite3_reset stmt))
(void (sqlite3_clear_bindings stmt))
(for ([i (in-naturals 1)]
[param (in-list params)])
(load-param fsym db stmt i param))
@ -126,16 +126,22 @@
(error/internal* fsym "bad parameter value" '("value" value) param)])))
(define/private (step* fsym db stmt end-box fetch-limit)
(if (zero? fetch-limit)
null
(let ([c (step fsym db stmt)])
(cond [c
(cons c (step* fsym db stmt end-box (sub1 fetch-limit)))]
[else
(HANDLE fsym (sqlite3_reset stmt))
(HANDLE fsym (sqlite3_clear_bindings stmt))
(when end-box (set-box! end-box #t))
null]))))
(with-handlers ([exn:fail?
(lambda (e)
(void (sqlite3_reset stmt))
(void (sqlite3_clear_bindings stmt))
(raise e))])
(let loop ([fetch-limit fetch-limit])
(if (zero? fetch-limit)
null
(let ([c (step fsym db stmt)])
(cond [c
(cons c (loop (sub1 fetch-limit)))]
[else
(void (sqlite3_reset stmt))
(void (sqlite3_clear_bindings stmt))
(when end-box (set-box! end-box #t))
null]))))))
(define/private (step fsym db stmt)
(let ([s (HANDLE fsym (sqlite3_step stmt))])