;;;; -*- 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)
(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))
(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)))
: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)))
: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