From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#67142: 29.1; with-sqlite-transaction commits on exception rather than rolling back Date: Mon, 20 Nov 2023 22:14:00 +0100 Message-ID: References: <83pm09pz2n.fsf@gnu.org> <831qcoq0py.fsf@gnu.org> <87a5rc4vwy.fsf@gmail.com> <83leavmjnu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="euL6N/Z18P9gtxFJ" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1562"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67142@debbugs.gnu.org, visuweshm@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 20 22:15:26 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r5Bc6-0000Fy-1F for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Nov 2023 22:15:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bbh-0005J2-P1; Mon, 20 Nov 2023 16:15:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bbg-0005It-KK for bug-gnu-emacs@gnu.org; Mon, 20 Nov 2023 16:15:00 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bbg-0005zC-C8 for bug-gnu-emacs@gnu.org; Mon, 20 Nov 2023 16:15:00 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r5Bbi-0007es-Au for bug-gnu-emacs@gnu.org; Mon, 20 Nov 2023 16:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Nov 2023 21:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67142 X-GNU-PR-Package: emacs Original-Received: via spool by 67142-submit@debbugs.gnu.org id=B67142.170051485829366 (code B ref 67142); Mon, 20 Nov 2023 21:15:02 +0000 Original-Received: (at 67142) by debbugs.gnu.org; 20 Nov 2023 21:14:18 +0000 Original-Received: from localhost ([127.0.0.1]:54764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5Baz-0007dZ-U5 for submit@debbugs.gnu.org; Mon, 20 Nov 2023 16:14:18 -0500 Original-Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]:38950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5Bav-0007dH-SP for 67142@debbugs.gnu.org; Mon, 20 Nov 2023 16:14:16 -0500 Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4SZ0cX36GCz9stW; Mon, 20 Nov 2023 22:14:04 +0100 (CET) Content-Disposition: inline In-Reply-To: <83leavmjnu.fsf@gnu.org> X-Rspamd-Queue-Id: 4SZ0cX36GCz9stW X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274689 Archived-At: --euL6N/Z18P9gtxFJ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > OK, how about the below? >=20 > diff --git a/lisp/sqlite.el b/lisp/sqlite.el > index aad0aa4..8a52573 100644 > --- a/lisp/sqlite.el > +++ b/lisp/sqlite.el > @@ -24,19 +24,28 @@ > ;;; Code: > =20 > (defmacro with-sqlite-transaction (db &rest body) > - "Execute BODY while holding a transaction for DB." > + "Execute BODY while holding a transaction for DB. > +If BODY completes normally, commit the changes and return > +the value of BODY. > +If BODY signals an error, or transaction commit fails, roll > +back the transaction changes." > (declare (indent 1) (debug (form body))) > (let ((db-var (gensym)) > - (func-var (gensym))) > + (func-var (gensym)) > + (res-var (gensym)) > + (commit-var (gensym))) > `(let ((,db-var ,db) > - (,func-var (lambda () ,@body))) > + (,func-var (lambda () ,@body)) > + ,res-var ,commit-var) > (if (sqlite-available-p) > (unwind-protect > (progn > (sqlite-transaction ,db-var) > - (funcall ,func-var)) > - (sqlite-commit ,db-var)) > - (funcall ,func-var))))) > + (setq ,res-var (funcall ,func-var)) > + (setq ,commit-var (sqlite-commit ,db-var)) > + ,res-var) > + (or ,commit-var (sqlite-rollback ,db-var)))) > + (funcall ,func-var)))) > =20 > (provide 'sqlite) Thank you, this looks very good. I've tested it on my own code using the SQLite support and there don't appear to be any (obvious issues). --euL6N/Z18P9gtxFJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEE0dAcySl3bqM8O17WFmfJg6zCifoFAmVbzBUACgkQFmfJg6zC ifpoMggAgXuZ1jMQWyaGV+p97ui4SwIFoVh1fV5FX1n6Ql5GXLWHUjTbdOPMsp5D ldV9MIe5+QEvYB2woaro+LjxEE7P5GjLhJhC6Seb+YzD7N7L/ydNQarNCWHFz1ln kIUfLSHRPwJC00P5/gV64wxMbPz4QzAMLNaZC3tJcaSI3uUZUaXNhh36r96Y33Q4 yrswlxMCXvoyeoDWOs9pQwVHqpDgWxDbtDJI9KnUkfE/S7ptaV43MG61REBetEHz LKVYfsEqVr/vZmfNit1OCsFxwe+k+byrq4aTq628a9kYHWDEb2DOa08OYR297UBG NV3iO16BWK0RDpxfEKFEjg4sOCluSQ== =uG0y -----END PGP SIGNATURE----- --euL6N/Z18P9gtxFJ--