From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#67142: 29.1; with-sqlite-transaction commits on exception rather than rolling back Date: Fri, 17 Nov 2023 14:08:05 +0530 Message-ID: <87a5rc4vwy.fsf@gmail.com> References: <83pm09pz2n.fsf@gnu.org> <831qcoq0py.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4587"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67142@debbugs.gnu.org, Vasilij Schneidermann To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 17 09:39:25 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 1r3uNp-000159-6g for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Nov 2023 09:39:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3uNX-0007JV-KK; Fri, 17 Nov 2023 03:39:07 -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 1r3uNT-0007HE-O6 for bug-gnu-emacs@gnu.org; Fri, 17 Nov 2023 03:39:03 -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 1r3uNS-0000nn-6w for bug-gnu-emacs@gnu.org; Fri, 17 Nov 2023 03:39:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r3uNR-0004Ah-S8 for bug-gnu-emacs@gnu.org; Fri, 17 Nov 2023 03:39:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Nov 2023 08:39:01 +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.170021029715967 (code B ref 67142); Fri, 17 Nov 2023 08:39:01 +0000 Original-Received: (at 67142) by debbugs.gnu.org; 17 Nov 2023 08:38:17 +0000 Original-Received: from localhost ([127.0.0.1]:45091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3uMj-00049R-DO for submit@debbugs.gnu.org; Fri, 17 Nov 2023 03:38:17 -0500 Original-Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:61752) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3uMg-000497-9o for 67142@debbugs.gnu.org; Fri, 17 Nov 2023 03:38:16 -0500 Original-Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-6c34e87b571so1604982b3a.3 for <67142@debbugs.gnu.org>; Fri, 17 Nov 2023 00:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700210288; x=1700815088; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K7c7Ryo9c9W/wvl5U9zlP1HDinyfKZxWaufHxBGcLcU=; b=grY2fdqLh8Uc/ulJnvOk73wFilDEApx1HaXUqyvEkw5gLS83TEkYeylX1WuR7d/k8Z cseStD5kU0/gjG+qx/6iQL6141fDjpaAfSjZirQQun6JZKWe6iX59KqsBzJq5cvTZjat rGeLyQZ1btlqaFGm0zvGwmH+wQ9qOEazcYWOtclPe6e8b6zKeYt82GNMWdluFNxXRRJ+ Duz5TCkckxhU6uHAzbN+5GbRqk8IWajGi/hTqrYljez5vlfpWqdzRa6NY+v+Y7WrE+k9 u65MLRgT/3jUdLyVucbBBaPQzw0uQa1PwOdiZ2iVECkBP0EnmSgokBXp84HNw1XwYe6D FV4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700210288; x=1700815088; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=K7c7Ryo9c9W/wvl5U9zlP1HDinyfKZxWaufHxBGcLcU=; b=ksfM59M3zyqgh1HgqqpGZDBd/dfcC6OOEIWNZrqbvm+AWdcvPVrOfe/0EPRi7P8x8I VtXBENO7e+kqmUdcmFfZeTaoSkv/NN2vcYeleAkRsVil9MwPTIlO0E9NMU9RWrTHly6C 3Vl9bkRB65Uva//CoBWjKSKfUTHFF7qhTMBAGeooamN1cnENVsbTAUOKMYM3MZmcnSqt cstyy5f1YsRj3DYMH/2cvOYKlRWZ7e2dbbRrJLK7XEdINcA17Or7Y5BcvE2Y6GbEDEXS W5P2+3cKPdCyLaf76x27USGzuLtjjIZwldOutefLhqqBSlLzirSbvAme8Zwy0CwiiScL dIWA== X-Gm-Message-State: AOJu0YxdG/Wdz5XutNtDtXdI9ROWg4xnsS2dvvW6hGiY2PpVmxpro/wm 2ZvD56ZXYSMgn9RGxxLz2M75VQyjB2FP2g== X-Google-Smtp-Source: AGHT+IHEJDtqog7n58wsvUhtaXybjM6k40VM597EIWTd9EdLX6qCH9oVjzJggUNM9ePlzx3ULEv7vw== X-Received: by 2002:a05:6a20:7d90:b0:187:a2ca:40a4 with SMTP id v16-20020a056a207d9000b00187a2ca40a4mr5769774pzj.50.1700210287947; Fri, 17 Nov 2023 00:38:07 -0800 (PST) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id b7-20020a17090a800700b00274de7c8aacsm2726501pjn.45.2023.11.17.00.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 00:38:07 -0800 (PST) In-Reply-To: <831qcoq0py.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 17 Nov 2023 09:48:41 +0200") 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:274493 Archived-At: [=E0=AE=B5=E0=AF=86=E0=AE=B3=E0=AF=8D=E0=AE=B3=E0=AE=BF =E0=AE=A8=E0=AE=B5= =E0=AE=AE=E0=AF=8D=E0=AE=AA=E0=AE=B0=E0=AF=8D 17, 2023] Eli Zaretskii wrote: >> A minor mistake is the result variable not using an uninterned symbol >> (or alternatively, `prog1` could replace the use of the result variable). > > I don't understand this part, sorry. Why do we need a symbol to > return the result of the body? db-var and func-var are uninterned symbols in the macro expansion but the variables 'result' and 'commit' marked below aren't. If the intent is not to expose these variables to the macro's BODY, the inner let should also uninterned symbols right? > diff --git a/lisp/sqlite.el b/lisp/sqlite.el > index aad0aa4..4488896 100644 > --- a/lisp/sqlite.el > +++ b/lisp/sqlite.el > @@ -24,18 +24,25 @@ > ;;; Code: >=20=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))) > `(let ((,db-var ,db) > (,func-var (lambda () ,@body))) -------- > (if (sqlite-available-p) > - (unwind-protect > - (progn > - (sqlite-transaction ,db-var) > - (funcall ,func-var)) > - (sqlite-commit ,db-var)) > + (let (result commit) ^^^^^^^^^^^^^ Use uninterned symbols here like above (marked with -). > + (unwind-protect > + (progn > + (sqlite-transaction ,db-var) > + (setq result (funcall ,func-var)) > + (setq commit (sqlite-commit ,db-var)) > + result) > + (or commit (sqlite-rollback ,db-var)))) > (funcall ,func-var))))) >=20=20 > (provide 'sqlite)