aboutsummaryrefslogtreecommitdiff
path: root/guix/store/database.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/store/database.scm')
-rw-r--r--guix/store/database.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/guix/store/database.scm b/guix/store/database.scm
index ef52036ede..ae7e96df2f 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -130,6 +130,17 @@ transaction after it finishes."
If FILE doesn't exist, create it and initialize it as a new database."
(call-with-database file (lambda (db) exp ...)))
+(define (sqlite-finalize stmt)
+ ;; As of guile-sqlite3 0.1.0, cached statements aren't reset when
+ ;; sqlite-finalize is invoked on them (see
+ ;; https://notabug.org/guile-sqlite3/guile-sqlite3/issues/12). This can
+ ;; cause problems with automatically-started transactions, so we work around
+ ;; it by wrapping sqlite-finalize so that sqlite-reset is always called.
+ ;; This always works, because resetting a statement twice has no adverse
+ ;; effects. We can remove this once the fixed guile-sqlite3 is widespread.
+ (sqlite-reset stmt)
+ ((@ (sqlite3) sqlite-finalize) stmt))
+
(define (last-insert-row-id db)
;; XXX: (sqlite3) currently lacks bindings for 'sqlite3_last_insert_rowid'.
;; Work around that.