#4 Add SQLITE_CONSTRAINT_UNIQUE; Add sqlite-busy-timeout.

Closed
dannym wants to merge 2 commits from dannym/20180324 into guile-sqlite3/master
2 changed files with 14 additions and 0 deletions
  1. 12 0
      sqlite3.scm
  2. 2 0
      tests/basic.test

+ 12 - 0
sqlite3.scm

@@ -48,6 +48,7 @@
             sqlite-reset
             sqlite-finalize
             sqlite-bind-parameter-index
+            sqlite-busy-timeout
 
             SQLITE_OPEN_READONLY
             SQLITE_OPEN_READWRITE
@@ -511,6 +512,17 @@ Also bind named parameters to the respective ones."
             (lp (1+ i)))
           v))))
 
+(define sqlite-busy-timeout
+  (let ((f (pointer->procedure
+            int
+            (dynamic-func "sqlite3_busy_timeout" libsqlite3)
+            (list '* int))))
+    (lambda (db value)
+      (assert-live-db! db)
+      (let ((ret (f (db-pointer db) value)))
+        (when (not (zero? ret))
+          (check-error db 'sqlite-busy-timeout))))))
+
 (define sqlite-step
   (let ((step (pointer->procedure
                int

+ 2 - 0
tests/basic.test

@@ -41,6 +41,8 @@
                                         SQLITE_OPEN_READWRITE)))
 (format #t "~40tOk~%")
 
+(sqlite-busy-timeout db 20)
+
 (format #t "Creating table 'project':")
 (sqlite-exec
  db