X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=base%2Ftransaction.lisp;h=61438edf2a48be4f8edda77e5480a132cd92f7d5;hb=9bbed78051e80e6ab76ae47834136035602bbbf1;hp=9a914551d74c0db051499fadcd1594708e5655c3;hpb=ce0e343835a040406678dff74a62d1b0cb56f317;p=clsql.git diff --git a/base/transaction.lisp b/base/transaction.lisp index 9a91455..61438ed 100644 --- a/base/transaction.lisp +++ b/base/transaction.lisp @@ -1,9 +1,18 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; -;;;; $Id: transactions.lisp 7061 2003-09-07 06:34:45Z kevin $ +;;;; $Id$ +;;;; +;;;; Transaction support +;;;; +;;;; This file is part of CLSQL. +;;;; +;;;; CLSQL users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ************************************************************************* -(in-package #:clsql-base-sys) +(in-package #:clsql-base) (defclass transaction () ((commit-hooks :initform () :accessor commit-hooks) @@ -23,11 +32,8 @@ (when (transaction database) (push rollback-hook (rollback-hooks (transaction database))))) -(defmethod database-start-transaction ((database closed-database)) - (signal-closed-database-error database)) - (defmethod database-start-transaction (database) - (unless database (error 'clsql-nodb-error)) + (unless database (error 'clsql-no-database-error)) (unless (transaction database) (setf (transaction database) (make-instance 'transaction))) (when (= (incf (transaction-level database) 1)) @@ -37,9 +43,6 @@ (transaction-status transaction) nil) (execute-command "BEGIN" :database database)))) -(defmethod database-commit-transaction ((database closed-database)) - (signal-closed-database-error database)) - (defmethod database-commit-transaction (database) (if (> (transaction-level database) 0) (when (zerop (decf (transaction-level database))) @@ -49,9 +52,6 @@ :format-control "Cannot commit transaction against ~A because there is no transaction in progress." :format-arguments (list database)))) -(defmethod database-abort-transaction ((database closed-database)) - (signal-closed-database-error database)) - (defmethod database-abort-transaction (database) (if (> (transaction-level database) 0) (when (zerop (decf (transaction-level database))) @@ -63,7 +63,7 @@ :format-arguments (list database)))) -(defmacro with-transaction ((&key (database *default-database*)) &rest body) +(defmacro with-transaction ((&key (database '*default-database*)) &rest body) "Executes BODY within a transaction for DATABASE (which defaults to *DEFAULT-DATABASE*). The transaction is committed if the body finishes successfully (without aborting or throwing), otherwise the database is