Add with-transaction.
* src/cuirass/database.scm (with-transaction): New macro.
This commit is contained in:
parent
a5346d615e
commit
f5287dc11e
|
@ -13,6 +13,7 @@
|
|||
(eval put 'test-error 'scheme-indent-function 1)
|
||||
(eval put 'make-parameter 'scheme-indent-function 1)
|
||||
(eval put 'with-database 'scheme-indent-function 0)
|
||||
(eval put 'with-transaction 'scheme-indent-function 0)
|
||||
(texinfo-mode
|
||||
(indent-tabs-mode)
|
||||
(fill-column . 72)
|
||||
|
|
|
@ -107,7 +107,8 @@
|
|||
;; Macros.
|
||||
exec-query/bind
|
||||
with-database
|
||||
with-db-worker-thread))
|
||||
with-db-worker-thread
|
||||
with-transaction))
|
||||
|
||||
;; Maximum priority for a Build or Specification.
|
||||
(define max-priority 9)
|
||||
|
@ -273,6 +274,13 @@ DB is bound to the argument of that critical section: the database connection."
|
|||
(number->string receive-timeout)
|
||||
caller-name))))))
|
||||
|
||||
(define-syntax-rule (with-transaction exp ...)
|
||||
"Evalute EXP within an SQL transaction."
|
||||
(with-db-worker-thread db
|
||||
(exec-query db "BEGIN TRANSACTION;")
|
||||
exp ...
|
||||
(exec-query db "COMMIT;")))
|
||||
|
||||
(define (read-sql-file file-name)
|
||||
"Return a list of string containing SQL instructions from FILE-NAME."
|
||||
(call-with-input-file file-name
|
||||
|
|
Loading…
Reference in New Issue