[elephant-cvs] CVS update: elephant/src/sleepycat.lisp
blee at common-lisp.net
blee at common-lisp.net
Mon Aug 30 21:36:55 UTC 2004
Update of /project/elephant/cvsroot/elephant/src
In directory common-lisp.net:/tmp/cvs-serv5168/src
Modified Files:
sleepycat.lisp
Log Message:
db-delete-* returns T on success, Nil if it couldn't find
the record
Date: Mon Aug 30 23:36:55 2004
Author: blee
Index: elephant/src/sleepycat.lisp
diff -u elephant/src/sleepycat.lisp:1.6 elephant/src/sleepycat.lisp:1.7
--- elephant/src/sleepycat.lisp:1.6 Sun Aug 29 22:41:30 2004
+++ elephant/src/sleepycat.lisp Mon Aug 30 23:36:54 2004
@@ -760,15 +760,23 @@
(flags :unsigned-int))
:returning :int)
-(wrap-errno db-delete-buffered (db transaction key key-length flags)
- :flags (auto-commit)
- :keys ((transaction *current-transaction*))
- :declarations (declare (optimize (speed 3) (safety 0) (space 0))
- (type pointer-void db transaction)
- (type array-or-pointer-char key)
- (type fixnum key-length)
- (type boolean auto-commit))
- :transaction transaction)
+(defun db-delete-buffered (db key key-length &key auto-commit
+ (transaction *current-transaction*))
+ (declare (optimize (speed 3) (safety 0) (space 0))
+ (type pointer-void db transaction) (type array-or-pointer-char key)
+ (type fixnum key-length) (type boolean auto-commit))
+ (let ((errno (%db-delete-buffered db transaction
+ key key-length
+ (flags :auto-commit auto-commit))))
+ (declare (type fixnum errno))
+ (cond ((= errno 0) t)
+ ((or (= errno DB_NOTFOUND)
+ (= errno DB_KEYEMPTY))
+ nil)
+ ((or (= errno DB_LOCK_DEADLOCK)
+ (= errno DB_LOCK_NOTGRANTED))
+ (throw transaction transaction))
+ (t (error 'db-error :errno errno)))))
(def-function ("db_del" %db-delete)
((db :pointer-void)
@@ -778,17 +786,24 @@
(flags :unsigned-int))
:returning :int)
-(wrap-errno db-delete (db transaction key key-length flags)
- :flags (auto-commit)
- :keys ((key-length (length key))
- (transaction *current-transaction*))
- :cstrings (key)
- :declarations (declare (optimize (speed 3) (safety 0) (space 0))
- (type pointer-void db transaction)
- (type string key)
- (type fixnum key-length)
- (type boolean auto-commit))
- :transaction transaction)
+(defun db-delete (db key &key auto-commit (key-length (length key))
+ (transaction *current-transaction*))
+ (declare (optimize (speed 3) (safety 0) (space 0))
+ (type pointer-void db transaction) (type string key)
+ (type fixnum key-length) (type boolean auto-commit))
+ (with-cstrings ((key key))
+ (let ((errno
+ (%db-delete db transaction key
+ key-length (flags :auto-commit auto-commit))))
+ (declare (type fixnum errno))
+ (cond ((= errno 0) nil)
+ ((or (= errno DB_NOTFOUND)
+ (= errno DB_KEYEMPTY))
+ nil)
+ ((or (= errno DB_LOCK_DEADLOCK)
+ (= errno DB_LOCK_NOTGRANTED))
+ (throw transaction transaction))
+ (t (error 'db-error :errno errno))))))
;; Transactions
More information about the Elephant-cvs
mailing list