From: Alexander Gavrilov Date: Sat, 23 Oct 2010 08:45:42 +0000 (+0400) Subject: Support returning multiple values from with-transaction body. X-Git-Tag: 0.2~9 X-Git-Url: https://repo.or.cz/w/cl-sqlite.git/commitdiff_plain/f81b198eb5d2e4d7dbea2cb78647d8cae0978f6b Support returning multiple values from with-transaction body. Multiple-value-prog1 is a special operator designed specially for cases like this one. --- diff --git a/sqlite.lisp b/sqlite.lisp index fcdfbcd..94113e3 100644 --- a/sqlite.lisp +++ b/sqlite.lisp @@ -298,17 +298,14 @@ See BIND-PARAMETER for the list of supported parameter types." (defmacro with-transaction (db &body body) "Wraps the BODY inside the transaction." (let ((ok (gensym "TRANSACTION-COMMIT-")) - (db-var (gensym "DB-")) - (result (gensym "RESULT-"))) + (db-var (gensym "DB-"))) `(let (,ok (,db-var ,db)) (execute-non-query ,db-var "begin transaction") (unwind-protect - (progn - (let ((,result (progn - ,@body))) - (setf ,ok t) - ,result)) + (multiple-value-prog1 + (progn ,@body) + (setf ,ok t)) (if ,ok (execute-non-query ,db-var "commit transaction") (execute-non-query ,db-var "rollback transaction"))))))