X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Ftransaction.lisp;h=be3e6d8fdd15c2694299b991036734d09690e189;hb=b08c25a7a9e56fb125caa9f7d7a56a473615007e;hp=d41d6eff7c0f8a33d332a430af54ea617a382607;hpb=333e8280f2f3438ffd379349bc9746c34cccc159;p=clsql.git diff --git a/sql/transaction.lisp b/sql/transaction.lisp index d41d6ef..be3e6d8 100644 --- a/sql/transaction.lisp +++ b/sql/transaction.lisp @@ -52,9 +52,9 @@ (setf autocommit (previous-autocommit transaction)) (map nil #'funcall (commit-hooks transaction))) (warn 'sql-warning - :format-control - "Cannot commit transaction against ~A because there is no transaction in progress." - :format-arguments (list database))))) + :message + (format nil "Cannot commit transaction against ~A because there is no transaction in progress." + database))))) (defmethod database-abort-transaction ((database database)) (with-slots (transaction transaction-level autocommit) database @@ -65,9 +65,9 @@ (setf autocommit (previous-autocommit transaction)) (map nil #'funcall (rollback-hooks transaction)))) (warn 'sql-warning - :format-control - "Cannot abort transaction against ~A because there is no transaction in progress." - :format-arguments (list database))))) + :message + (format nil "Cannot abort transaction against ~A because there is no transaction in progress." + database))))) (defun mark-transaction-committed (database) (when (and (transaction database) @@ -82,9 +82,10 @@ back and otherwise the transaction is committed." (let ((db (gensym "db-"))) `(let ((,db ,database)) (unwind-protect - (progn + (prog2 (database-start-transaction ,db) - ,@body + (progn + ,@body) (mark-transaction-committed ,db)) (if (eq (transaction-status (transaction ,db)) :committed) (database-commit-transaction ,db) @@ -115,8 +116,10 @@ are called." transaction." (and database (transaction database) (= (transaction-level database) 1))) -(defun autocommit (&key (database *default-database*) (set :unspecified)) - "Returns whether autocommit is currently active." - (unless (eq set :unspecified) - (setf (database-autocommit database) set)) - (database-autocommit database)) +(defun set-autocommit (value &key (database *default-database*)) + "Sets autocommit on or off. Returns old value of of autocommit flag." + (let ((old-value (database-autocommit database))) + (setf (database-autocommit database) value) + (database-autocommit database) + old-value)) +