Changed the code to pass through the prep-status to the outer HANDLE so

error reporting is uniformly handled and any SQL_BUSY errors are properly identified.
This commit is contained in:
Alexander McLin 2017-06-22 13:26:12 -04:00 committed by Ryan Culpepper
parent ed481865cf
commit 113049607a

View File

@ -208,22 +208,20 @@
(let*-values ([(db) (get-db fsym)] (let*-values ([(db) (get-db fsym)]
[(prep-status stmt) [(prep-status stmt)
(HANDLE fsym (HANDLE fsym
;; Do not allow break/kill between prepare and ;; Do not allow break/kill between prepare and
;; entry of stmt in table. ;; entry of stmt in table.
(A (let-values ([(prep-status stmt tail?) (A (let-values ([(prep-status stmt tail?)
(sqlite3_prepare_v2 db sql)]) (sqlite3_prepare_v2 db sql)])
(cond (cond [(not (zero? prep-status))
[(not (= 0 prep-status)) (when stmt (sqlite3_finalize stmt))
(when stmt (sqlite3_finalize stmt)) (values prep-status #f)]
(error* fsym (get-error-message) [tail?
'("given" value) sql)] (when stmt (sqlite3_finalize stmt))
[else (error* fsym "multiple statements given"
(when tail? '("given" value) sql)]
(when stmt (sqlite3_finalize stmt)) [else
(error* fsym "multiple statements given" (when stmt (hash-set! stmt-table stmt #t))
'("given" value) sql))]) (values prep-status stmt)]))))])
(when stmt (hash-set! stmt-table stmt #t))
(values prep-status stmt))))])
(when DEBUG? (when DEBUG?
(dprintf " << prepared statement #x~x\n" (cast stmt _pointer _uintptr))) (dprintf " << prepared statement #x~x\n" (cast stmt _pointer _uintptr)))
(unless stmt (error* fsym "SQL syntax error" '("given" value) sql)) (unless stmt (error* fsym "SQL syntax error" '("given" value) sql))