[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 9f0a19280c 296/427: Enhance emacsql-with-transacti
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 9f0a19280c 296/427: Enhance emacsql-with-transaction to retry. |
Date: |
Tue, 13 Dec 2022 02:59:52 -0500 (EST) |
branch: elpa/emacsql
commit 9f0a19280cad2a74382780f59d8406b4e676764c
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Enhance emacsql-with-transaction to retry.
---
emacsql.el | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/emacsql.el b/emacsql.el
index ec8bc3d0fc..0840c3b09d 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -252,20 +252,28 @@ CONNECTION-SPEC establishes a single binding.
(defmacro emacsql-with-transaction (connection &rest body)
"Evaluate BODY inside a single transaction, issuing a rollback on error.
This macro can be nested indefinitely, wrapping everything in a
-single transaction at the lowest level."
+single transaction at the lowest level.
+
+Warning: BODY should *not* have any side effects besides making
+changes to the database behind CONNECTION. Body may be evaluated
+multiple times before the changes are committed."
(declare (indent 1))
`(let ((emacsql--connection ,connection)
(emacsql--completed nil)
(emacsql--transaction-level (1+ emacsql--transaction-level)))
(unwind-protect
- (progn
- (when (= 1 emacsql--transaction-level)
- (emacsql emacsql--connection [:begin :transaction]))
- (let ((result (progn ,@body)))
- (prog1 result
- (when (= 1 emacsql--transaction-level)
- (emacsql emacsql--connection [:commit]))
- (setf emacsql--completed t))))
+ (while (not emacsql--completed)
+ (condition-case nil
+ (progn
+ (when (= 1 emacsql--transaction-level)
+ (emacsql emacsql--connection [:begin :transaction]))
+ (let ((result (progn ,@body)))
+ (prog1 result
+ (when (= 1 emacsql--transaction-level)
+ (emacsql emacsql--connection [:commit]))
+ (setf emacsql--completed t))))
+ (emacsql-locked (emacsql emacsql--connection [:rollback])
+ (sleep-for 0.05))))
(when (and (= 1 emacsql--transaction-level)
(not emacsql--completed))
(emacsql emacsql--connection [:rollback])))))
- [nongnu] elpa/emacsql 8f3d0d4b81 344/427: Use font-lock-flush and font-lock-ensure if available, (continued)
- [nongnu] elpa/emacsql 8f3d0d4b81 344/427: Use font-lock-flush and font-lock-ensure if available, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3176aeee61 345/427: Use elisp--preceding-sexp if available, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 327b09b4b9 348/427: Add support for raw strings and raw parameters (#26, #28)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c93f52159f 347/427: Bump to version 2.0.2., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e91bac3a20 350/427: Add cl-generic require to emacsql.el (#32)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b65c5b03d5 351/427: Fix up Cask file., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e3bc9b105f 354/427: Finish removing Cask, including updating the README, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 83a278aa6b 356/427: Remove trailing &key in method definition, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 67ca8124bc 425/427: make: Suppress warning about obsolete autoload package, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e318a6c8f6 426/427: Add new SQLite back-ends, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9f0a19280c 296/427: Enhance emacsql-with-transaction to retry.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 616dde3752 361/427: An identifier named * means select all columns (#19), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5da614bc9b 359/427: Drop finalizer use and explicitely depend on Emacs 25, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3b70e8f5dd 366/427: Add support for NUL characters in strings (fixes #42), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 75ac0448a5 364/427: Add support for DISTINCT in aggregate functions (#41), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8c46fb2c1e 286/427: Drop argument count check since it's wrong., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 641338533c 331/427: Just build SQLite on first connection., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 56a2882936 333/427: Update README for Melpa changes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1b37570bf5 352/427: Fix up the Makefile., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2e9e2d6ba1 390/427: Fix SQL truncated when print-level or print-length are changed, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 50b139443b 414/427: make: Fix compiling and cleaning tests, ELPA Syncer, 2022/12/13