X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=base%2Ftransaction.lisp;h=fa4f7523fd72af0c4cea3c72a2ae33ef99703fa4;hb=86440ca219f801a087ad917d1c1f46c77c920aa4;hp=9a914551d74c0db051499fadcd1594708e5655c3;hpb=ce0e343835a040406678dff74a62d1b0cb56f317;p=clsql.git diff --git a/base/transaction.lisp b/base/transaction.lisp index 9a91455..fa4f752 100644 --- a/base/transaction.lisp +++ b/base/transaction.lisp @@ -1,7 +1,16 @@ ;;;; -*- 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) @@ -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