aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2016-07-22 13:13:52 +0200
committerMathieu Lirzin <mthl@gnu.org>2016-07-25 02:12:40 +0200
commit8ad3ce782f9e75297bd420d651375843a0f7824e (patch)
tree6c75554ebec3e37a4416a38706bb227baaa9790c /src
parent447d9f7ba81e90b2a8a799c11eea59d47060da2c (diff)
downloadcuirass-8ad3ce782f9e75297bd420d651375843a0f7824e.tar
cuirass-8ad3ce782f9e75297bd420d651375843a0f7824e.tar.gz
database: Add 'last-insert-rowid' procedure.
Diffstat (limited to 'src')
-rw-r--r--src/cuirass/database.scm9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index d8d1ed2..da39bcc 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -98,15 +98,16 @@ database object."
(map (λ (key) (or (assq-ref alst key) default-value))
keys))
+(define (last-insert-rowid db)
+ (vector-ref (car (sqlite-exec db "SELECT last_insert_rowid();"))
+ 0))
+
(define (db-add-evaluation db job)
"Store a derivation result in database DB and return its ID."
(sqlite-exec db "insert into build (job_spec, drv) values ('~A', '~A');"
(assq-ref job #:job-name)
(assq-ref job #:derivation))
- (let* ((stmt (sqlite-prepare db "select last_insert_rowid() from build;"))
- (res (sqlite-step stmt)))
- (sqlite-finalize stmt)
- (vector-ref res 0)))
+ (last-insert-rowid db))
(define (db-get-evaluation db id)
"Retrieve a job in database DB which corresponds to ID."