GNU bug report logs - #69292
[PATCH 0/6] Prepare the database code for use in the daemon

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Christopher Baines <mail@HIDDEN>; Keywords: patch; Done: Christopher Baines <mail@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 69292-done <at> debbugs.gnu.org:


Received: (at 69292-done) by debbugs.gnu.org; 3 Apr 2024 17:36:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 03 13:36:12 2024
Received: from localhost ([127.0.0.1]:59463 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rs4Wy-00085W-Ez
	for submit <at> debbugs.gnu.org; Wed, 03 Apr 2024 13:36:12 -0400
Received: from mira.cbaines.net
 ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]:39353)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rs4Wv-00085E-SX
 for 69292-done <at> debbugs.gnu.org; Wed, 03 Apr 2024 13:36:10 -0400
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id F1F7027BBE2
 for <69292-done <at> debbugs.gnu.org>; Wed,  3 Apr 2024 18:36:04 +0100 (BST)
Received: from felis (localhost.lan [127.0.0.1])
 by localhost (OpenSMTPD) with ESMTP id 9c018383
 for <69292-done <at> debbugs.gnu.org>;
 Wed, 3 Apr 2024 17:36:04 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: 69292-done <at> debbugs.gnu.org
Subject: Re: [bug#69292] [PATCH 0/6] Prepare the database code for use in
 the daemon
In-Reply-To: <87h6i3lyph.fsf@HIDDEN> (Christopher Baines's message of
 "Tue, 20 Feb 2024 19:20:45 +0000")
References: <87h6i3lyph.fsf@HIDDEN>
User-Agent: mu4e 1.12.2; emacs 29.3
Date: Wed, 03 Apr 2024 18:36:04 +0100
Message-ID: <87y19uic1n.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69292-done
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

Christopher Baines <mail@HIDDEN> writes:

> These changes prepare the database module for use in a Guile
> implementation of the guix-daemon.
>
> There's quite a few procedures that need adding, but these changes just
> adapt the existing functionality in to something that can be built on.
>
>
> Christopher Baines (6):
>   store: database: Remove call-with-savepoint and associated code.
>   store: database: Remove with-statement and associated code.
>   store: database: Inline SQL to where it's used.
>   store: database: Stop finalizing prepared statements.
>   store: database: Refactor sqlite-register.
>   store: database: Rename a couple of procedures.
>
>  .dir-locals.el          |   3 -
>  guix/store/database.scm | 273 +++++++++++++++++-----------------------
>  2 files changed, 112 insertions(+), 164 deletions(-)

I've pushed these to master as c9cd16c630ccba655b93ff32fd9a99570b4f5373.

Chris

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmYNk4RfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XdY8g//VKUlDMUdMmRLfOl0gtQLKnKhooNXS+dG
sYS4G9WNIUapvQ0Umgp60zvrGJaAZGIR60Uk4dv1I1rGRCkUUhpNIq2bwIJC3qlN
OwqNcyrV/7RnWx65ZP/FHgMjk83aKURdA2CQxo/dQVWz1wQoPm/EOwr3uBuklcrd
UxoSQh7v9a1eyAZmeu/46OszpbfCDADlrbwM+ZZElM92pQ6Oqe3N4Z0PkhrhonL3
wn6/hBb+bi0sPps0M+GfFYelTvGFZnEjcJHt6SNGKe235sbUPg6a1UPMZa60M2x8
cJtSmggGtbWzfP7DM0xIrEizoGD1jp/yoxW43zS2LPy+6iap5WFErc+N1XJLk2Sm
WUW+HJbPDYTvrKYqotcEjujs66/2IRc9THivQoTKaiUshuLox/LFAsySzpHTmTEL
lde6IgEnmNW+zLX5j8c9JTcrD39sW0pXCs6fsY1DwgF6AggZLFxEU+130x5fYaGc
1AdrykTeJsVY6W/404stkVwIkqo3qVdaKxiaKOkbMOyoiUj23ing2NqkT9Mh3LE2
25t5gvmZQ2/7vzu7rIoez0PDF6RPS0c4veXk2MguBZFuD1gpIhk8wlZFRwU/qSVc
udvM/uCozv6Ve7va07iTsBAsSeo9Zs1afWvXmtQpkSAK3Db2r6jkklzJeHW59JEf
ieKYlPAHQHo=
=rYh8
-----END PGP SIGNATURE-----
--=-=-=--




Notification sent to Christopher Baines <mail@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Christopher Baines <mail@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 3 Apr 2024 17:35:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 03 13:35:27 2024
Received: from localhost ([127.0.0.1]:59456 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rs4WF-00080j-29
	for submit <at> debbugs.gnu.org; Wed, 03 Apr 2024 13:35:27 -0400
Received: from mira.cbaines.net ([212.71.252.8]:43300)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rs4WC-00080W-O8
 for 69292 <at> debbugs.gnu.org; Wed, 03 Apr 2024 13:35:25 -0400
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id 8CCD927BBE2;
 Wed,  3 Apr 2024 18:35:19 +0100 (BST)
Received: from felis (localhost.lan [127.0.0.1])
 by localhost (OpenSMTPD) with ESMTP id 7899911e;
 Wed, 3 Apr 2024 17:35:19 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: [bug#69292] [PATCH 6/6] store: database: Rename a couple of
 procedures.
In-Reply-To: <871q8yl0om.fsf@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?=
 =?utf-8?Q?s?= message of "Tue, 27 Feb 2024 10:24:25 +0100")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <12f872394c84039fa553e50381d040de24f24d3e.1708457946.git.mail@HIDDEN>
 <87zfvrdtcw.fsf@HIDDEN> <871q8z8p0n.fsf@HIDDEN>
 <871q8yl0om.fsf@HIDDEN>
User-Agent: mu4e 1.12.2; emacs 29.3
Date: Wed, 03 Apr 2024 18:35:19 +0100
Message-ID: <877chejqnc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69292
Cc: 69292 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> Christopher Baines <mail@HIDDEN> skribis:
>
>> Ludovic Court=C3=A8s <ludo@HIDDEN> writes:
>>
>>> Christopher Baines <mail@HIDDEN> skribis:
>>>
>>>> These names should be more descriptive.
>>>>
>>>> * guix/store/database.scm (path-id): Rename to select-valid-path-id.
>>>> (sqlite-register): Rename to register-valid-path.
>>>> (register-items): Update accordingly.
>>>>
>>>> Change-Id: I6d4a14d4cde9d71ab34d6ffdbfbfde51b2c0e1db
>>>
>>> OK for =E2=80=98register-valid-path=E2=80=99.
>>>
>>> For =E2=80=98path-id=E2=80=99 my preference would be =E2=80=98valid-pat=
h-id=E2=80=99 or keeping
>>> =E2=80=98path-id=E2=80=99; =E2=80=98select=E2=80=99 looks odd as nothin=
g=E2=80=99s being =E2=80=9Cselected=E2=80=9D here in the
>>> non-SQL sense of the word.
>>
>> The main thing I'm trying to do here is make the procedures that
>> directly interact with the database stand out (similar to the ! suffix
>> convention). Maybe the procedure taking the db as an argument is enough,
>> but to me path-id/valid-path-id look too much like record accessors.
>
> I=E2=80=99d say that having an explicit =E2=80=98db=E2=80=99 argument is =
enough (similar to
> procedures that take a =E2=80=98store=E2=80=99 argument).

I've changed it to valid-path-id now.

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmYNk1dfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XesYA/9Gh9ZjhoTsFV3RktzVH2+VpeuxXu9cv/7
5WtGRkJFttYs8OQMSAQN/4s/06HbT3Rs3YIhFYRADcRUc5q8Sq9/+p+dIFrqFOeZ
4hCa91zmP36AuYR2TmhyEG5ATi34ptNgo7sieDnEAAeDwa42MAZw1NKIH2gXKmmI
DjuTXTTDJirr98m36X3mvaZzbKNL8+/j6LjYJ17+umXqq+LvVsDE4NmT26H6aGKD
4GYtB52oRiaOYswclZjVjzk6Qg4dedc8GGBTuRp0Nq30v5JageG71iLma0TlpAcN
v/ZISEikh1UNM5cpRbhQnU9gUF+ZgCvGoZYKltCx8GJJ24uRKhjFcup95Ppgv26+
ukM3Gcf0a0q+GIwxJld8gENFr1o94epRJKglV3EuzM1Yu+yzD1OEeEc8zDvctF5j
SmMjgJO+Dpgmy41OFFpaSkcgSZr+s4mGLAcAWjyDHeWypKXQU0LcX6nvfl32mhNu
7BoQPn1HshkOCEpctjF3ZrO3lM/f/8qLjbhnQmRLjliZmjhQkvZza4dluPwV795W
ukCMQh1tfaSopidEB6N0y/WtX/R/bJ6XUSh/46MG6eGAYxIHcvfaK4DMvX7liD6L
mfjY1N6eTFAXDwhmL+Rbx1IZ7mwDhUFyxwj7hczwnsD7FL4n0RXVlhmzd/PeTN5U
8V6LgltayjI=
=c+j+
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 5 Mar 2024 11:06:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 05 06:06:23 2024
Received: from localhost ([127.0.0.1]:46360 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rhSco-0008TZ-OI
	for submit <at> debbugs.gnu.org; Tue, 05 Mar 2024 06:06:23 -0500
Received: from eggs.gnu.org ([209.51.188.92]:36444)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rhScn-0008TE-JP
 for 69292 <at> debbugs.gnu.org; Tue, 05 Mar 2024 06:06:22 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rhScB-0002cA-Fa; Tue, 05 Mar 2024 06:05:43 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=lcd9cerCz4Ozs5UTm7UwPBpbKY7pM/bTWeIe11px2PI=; b=QFigBCWI9bkftXRMuJrl
 TU48kDvlhws5/U8ZFaAHk1eQMYs/pyEkULQZcWBlkdQ9ajcpkRuNokWTBbGBrBngWM/EAevnY/LFR
 9tCyjkNd6NuGcElrb/0dOKXEbUmV8s0rHvKZRGkF4Z+5i5/HrwAYtmuPhMmWBpxmSafMcMMSwCcqr
 HCJiFxYP8Ky4VKByY5jPvDI8qHhlkEP5alqL/vZYSVibvjzeDgOkwtnNGpydjX+9nFLQf9gl2Ztrk
 0utfjdNMYf9Bqq51OjpTejeKCNQkLQOauCV4+8QWcUnAxAB4qwjuXVylblKt3lKsCGI4OAMvnwJ45
 d02qIktoFMZuEg==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Reepca Russelstein <reepca@HIDDEN>
Subject: Re: [bug#69292] [PATCH 2/6] store: database: Remove with-statement
 and associated code.
In-Reply-To: <87ttlzqbfg.fsf@HIDDEN> (Reepca Russelstein's message of
 "Fri, 23 Feb 2024 12:32:03 -0600")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <b7360abb08559073653effea98a99332fc1f8071.1708457946.git.mail@HIDDEN>
 <878r3bf8aw.fsf@HIDDEN> <87ttlzqbfg.fsf@HIDDEN>
Date: Tue, 05 Mar 2024 12:05:38 +0100
Message-ID: <87h6hlc519.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>, Christopher Baines <mail@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Reepca Russelstein <reepca@HIDDEN> skribis:

>> I=E2=80=99m all for removing =E2=80=98dynamic-wind=E2=80=99, we=E2=80=99=
ll have to do it to make it
>> usable in a fiberized context anyway.
>>
>> I=E2=80=99ll let reepca comment.
>
> What is the proper fibers-friendly replacement for dynamic-wind, anyway,
> that is "like dynamic-wind, except when suspending a fiber"?  It feels
> like the current interaction between dynamic-wind and fibers is more of
> an accident of how the implementation works; I don't suppose fibers could
> export a transparent replacement, like how it already exports a
> replacement for 'sleep'?  Or perhaps the underlying issue is that we
> keep using 'dynamic-wind' in situations where it only makes sense to
> enter or exit the dynamic extent once?  Is it time to bring
> 'unwind-protect' back into style?  I see that fibers now has a
> dynamic-wind*, should that be preferred?

I=E2=80=99ve come to think that =E2=80=98dynamic-wind=E2=80=99 is a problem=
atic abstraction.
What we really want is to perform an effect after a normal exit or when
an exception is thrown.  The latter case is actually best handled with
=E2=80=98with-exception-handler=E2=80=99 (this is what I did for =E2=80=98w=
ith-store=E2=80=99; see
commit 8ed597f4a261fe188de82cd1f5daed83dba948eb).

(In Cuirass I added =E2=80=98unwind-protect=E2=80=99 at one point but in th=
e end it was
not so nice and I eventually removed it.)

> I don't have a strong opinion on these changes, I just want to make sure
> we're all aware of how guile-sqlite3's sqlite-finalize acts with cached
> statements.

Agreed.

Thank you for chiming in!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 27 Feb 2024 09:25:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 04:25:07 2024
Received: from localhost ([127.0.0.1]:37405 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rethz-0005Uf-2Y
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2024 04:25:07 -0500
Received: from eggs.gnu.org ([209.51.188.92]:38770)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rethw-0005Ty-F4
 for 69292 <at> debbugs.gnu.org; Tue, 27 Feb 2024 04:25:05 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rethP-0004ZF-3V; Tue, 27 Feb 2024 04:24:31 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=a8yE+TSEAW7XgLoWTRRcy8Vp02u1QIhIza8IjgcEVQo=; b=rRP0e4icgm1ImjtQobEJ
 9p/fhlncqtCZe6Nn83gCNaFVECXPj0W1eq/xBclpYKfbSvn3cG5L5BqWkruc9tRxO7WvtApyDN5dQ
 vyh7zV9AOSiCSrdQJAWG5WK1ZxmhWRHH/SKgPXZJ1AcIkUOOeIjK/bOlELVKn5xyD+TIAsfP9Uerg
 2EEq7XmPXev2zB7UpqENgFDIjFsNZW5/BoBdLeIoxOYfHZ97+m0/ScIIPTLF0jT+B5Q+hsqZjvTCe
 m9MsTlsjoh81ytn/u1gbuTWF3kn7EbUejm00d3rHl0cB0GgINsQVY+C4sXlOGxfdVqUhSzSF8+/2+
 PK9y3GhsWOX25g==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Christopher Baines <mail@HIDDEN>
Subject: Re: [bug#69292] [PATCH 6/6] store: database: Rename a couple of
 procedures.
In-Reply-To: <871q8z8p0n.fsf@HIDDEN> (Christopher Baines's message of
 "Mon, 26 Feb 2024 11:03:04 +0000")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <12f872394c84039fa553e50381d040de24f24d3e.1708457946.git.mail@HIDDEN>
 <87zfvrdtcw.fsf@HIDDEN> <871q8z8p0n.fsf@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: Nonidi 9 =?utf-8?Q?Vent=C3=B4se?= an 232 de la
 =?utf-8?Q?R=C3=A9volution=2C?= jour du Marsault
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Tue, 27 Feb 2024 10:24:25 +0100
Message-ID: <871q8yl0om.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Christopher Baines <mail@HIDDEN> skribis:

> Ludovic Court=C3=A8s <ludo@HIDDEN> writes:
>
>> Christopher Baines <mail@HIDDEN> skribis:
>>
>>> These names should be more descriptive.
>>>
>>> * guix/store/database.scm (path-id): Rename to select-valid-path-id.
>>> (sqlite-register): Rename to register-valid-path.
>>> (register-items): Update accordingly.
>>>
>>> Change-Id: I6d4a14d4cde9d71ab34d6ffdbfbfde51b2c0e1db
>>
>> OK for =E2=80=98register-valid-path=E2=80=99.
>>
>> For =E2=80=98path-id=E2=80=99 my preference would be =E2=80=98valid-path=
-id=E2=80=99 or keeping
>> =E2=80=98path-id=E2=80=99; =E2=80=98select=E2=80=99 looks odd as nothing=
=E2=80=99s being =E2=80=9Cselected=E2=80=9D here in the
>> non-SQL sense of the word.
>
> The main thing I'm trying to do here is make the procedures that
> directly interact with the database stand out (similar to the ! suffix
> convention). Maybe the procedure taking the db as an argument is enough,
> but to me path-id/valid-path-id look too much like record accessors.

I=E2=80=99d say that having an explicit =E2=80=98db=E2=80=99 argument is en=
ough (similar to
procedures that take a =E2=80=98store=E2=80=99 argument).

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 26 Feb 2024 11:05:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 26 06:05:58 2024
Received: from localhost ([127.0.0.1]:55141 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1reYo2-00033b-FF
	for submit <at> debbugs.gnu.org; Mon, 26 Feb 2024 06:05:58 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43166)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1reYnz-00033L-5R
 for 69292 <at> debbugs.gnu.org; Mon, 26 Feb 2024 06:05:56 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id E580D27BBE2;
 Mon, 26 Feb 2024 11:04:58 +0000 (GMT)
Received: from felis (localhost.lan [127.0.0.1])
 by localhost (OpenSMTPD) with ESMTP id a7bdadfd;
 Mon, 26 Feb 2024 11:04:58 +0000 (UTC)
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <12f872394c84039fa553e50381d040de24f24d3e.1708457946.git.mail@HIDDEN>
 <87zfvrdtcw.fsf@HIDDEN>
User-agent: mu4e 1.10.8; emacs 29.1
From: Christopher Baines <mail@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: [bug#69292] [PATCH 6/6] store: database: Rename a couple of
 procedures.
Date: Mon, 26 Feb 2024 11:03:04 +0000
In-reply-to: <87zfvrdtcw.fsf@HIDDEN>
Message-ID: <871q8z8p0n.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> Christopher Baines <mail@HIDDEN> skribis:
>
>> These names should be more descriptive.
>>
>> * guix/store/database.scm (path-id): Rename to select-valid-path-id.
>> (sqlite-register): Rename to register-valid-path.
>> (register-items): Update accordingly.
>>
>> Change-Id: I6d4a14d4cde9d71ab34d6ffdbfbfde51b2c0e1db
>
> OK for =E2=80=98register-valid-path=E2=80=99.
>
> For =E2=80=98path-id=E2=80=99 my preference would be =E2=80=98valid-path-=
id=E2=80=99 or keeping
> =E2=80=98path-id=E2=80=99; =E2=80=98select=E2=80=99 looks odd as nothing=
=E2=80=99s being =E2=80=9Cselected=E2=80=9D here in the
> non-SQL sense of the word.

The main thing I'm trying to do here is make the procedures that
directly interact with the database stand out (similar to the ! suffix
convention). Maybe the procedure taking the db as an argument is enough,
but to me path-id/valid-path-id look too much like record accessors.

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmXccFhfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XeODA/+P0cbrvuITjA3nD1phTqlKCrJQqQX+i+9
mJ7viwHgbsn0+xoxNRBVkqNW9v5QOGc8PdLoSwbCO6n9i0f/sPD44NVwDQGNyZjO
S0vWBPx3GSoqGkpoSN2GlHqCVK5/tQ2XeP2qoFIszkPYHo53BMPUDTfg1+jj465J
goLQxSiPIi9ZOtXHlToAfRQPH2Cw/bGqOOocJlhN99M943uwYOpwkB4G2utZjmui
rXjneDW0uVKpawo1RisFV9QD6wHSXzJbUImJ+WSsdyUIGTBVp0goafyYyhRkbbsU
j7RsyCow8ONPmVsQG+nax8YnCjDIrNhimEdCSjKc73bvUyC66HYIUZsy9AzLaXtm
5eIxht2nbaRkjxCioId6gH8TTcEAbvy9Nnd0YAWRlTpUgou4Sg1bpr3wGgJH+FlS
YvlCl4zJ5JTapt6kxPqmePZ8BfmIW8HFvqzKFfsrH40Dk2/9SM66icDktFNUMLV4
xtGlAri/42KNrxb8DtljrICYHsYFzDp/En49it5Rl+pCoiihOWO2TjOHBEuFZcRb
1zqsA0OX/0Wh0EzkNo9sg6IfE/mtN8dfuHxDlbOSUjOqHaioIe1RIQZWjAhLLkiV
DhdTCAnSyfQnkU8TSLauVFEZ0byqr0jWASQutYJTjtKFlRcycM+sChegEVgGEVJO
H0hw4IVP0rI=
=7zfH
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 26 Feb 2024 10:53:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 26 05:53:41 2024
Received: from localhost ([127.0.0.1]:54264 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1reYc8-0002Td-Ma
	for submit <at> debbugs.gnu.org; Mon, 26 Feb 2024 05:53:41 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43164)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1reYc2-0002TK-K0
 for 69292 <at> debbugs.gnu.org; Mon, 26 Feb 2024 05:53:39 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id 424EE27BBE2;
 Mon, 26 Feb 2024 10:52:38 +0000 (GMT)
Received: from felis (localhost.lan [127.0.0.1])
 by localhost (OpenSMTPD) with ESMTP id 2e121626;
 Mon, 26 Feb 2024 10:52:36 +0000 (UTC)
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <c4bf41b5c91623ee93285f35516265cfdb0ab401.1708457946.git.mail@HIDDEN>
 <87y1bcr7ue.fsf@HIDDEN>
User-agent: mu4e 1.10.8; emacs 29.1
From: Christopher Baines <mail@HIDDEN>
To: reepca@HIDDEN
Subject: Re: [PATCH 4/6] store: database: Stop finalizing prepared statements.
Date: Mon, 26 Feb 2024 10:50:08 +0000
In-reply-to: <87y1bcr7ue.fsf@HIDDEN>
Message-ID: <875xyb8pl9.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69292
Cc: 69292 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain


reepca@HIDDEN writes:

> Christopher Baines <mail@HIDDEN> writes:
>
>> Especially since we're asking for these to be cached.
>>
>> Management of prepared statements isn't trivial, since you don't want to keep
>> them forever as this can lead to poor query performance, but I don't think
>> that finalizing them immediately is the right solution.
>
> guile-sqlite3 arranges for cached statements to only be reset, not
> finalized, when sqlite-finalize is called on them (see
> https://notabug.org/guile-sqlite3/guile-sqlite3/src/master/sqlite3.scm.in#L283).
> The idea behind this admittedly-unintuitive behavior is that it allows
> for the caching behavior of a statement to be decided independently of
> the code that actually uses it: if it's been decided elsewhere that a
> prepared statement is worth keeping around, it will reuse it, but if it
> hasn't, it will still properly clean up what it created.
>
> Perhaps reusing the name 'sqlite-finalize' to make that behavior
> transparent wasn't the best choice in the long run.
>
> I hope that makes the way it was written a bit less baffling.

Right, this is something I hadn't realised. I don't think this causes
any problems for how I'm using sqlite-finalize though. Thanks for
pointing this out.

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmXcbXJfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XeQNg//SopGtll99qYYhHg3iBVFT49HcJ9CATDz
lVa93cxK8gIBnRMVSHo35EFGW2fzpIpCnB100KZMScyoRtfhSwFTUTCHh8EGYYng
YA1W7du4b85IbNw4zipMeHd9WZBsyNedyTwtftj3++Ib1egWRHutDBWgUA1AED6M
1IYwWmTKzlbMBnmUn++xmKiinKYg7xDgNW2UWeuWIU6hoIli8CmfsXizQQcohFq7
RMz2LgverA50NMe26IJadFCmsLelxF1wLCz7xbfxFgU5TXB3VOcR9NKuFixhvFV0
zgcYNn6NG+4OQNXewqx3scYxWOEzdDkPzYQr+QATCgKokQ7/LyUG5QPGwPt0ymhF
0uj3oEYTTHLGghxgI8di5EvDT7WBEx4KteBUhgchjj1ir1JPszTahmEk+oiSwCMi
SZ6nvac3WcP/2rBDAQ3BkvgRS/SBF11O65lgUs80DA2e8lU5EgS5Xx5UFb5gy0uv
pXe1Acseu0fcjZ4xHPuLxzgsMDhEK5DAMrKpW9rgYFjsJBVlZjhE8rhh45DiYlnX
E5eVxEQfQ16rIeJHlXFrrMJkC2YZrXrLKMy0c3GeVAPYNqsoi/my9vawCl637N8s
Kl0Eiv70pOnL7XrKfgw3ipOQ4skzy5r4kYZjwZjeZ8BBrT4dWs3u0H1LKeiOdvwX
IUn8H6Uu5u8=
=S9g+
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 24 Feb 2024 07:55:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 24 02:55:03 2024
Received: from localhost ([127.0.0.1]:35628 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rdms9-0004zX-GL
	for submit <at> debbugs.gnu.org; Sat, 24 Feb 2024 02:55:03 -0500
Received: from mailout.russelstein.xyz ([209.141.47.21]:60706)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <reepca@HIDDEN>) id 1rdaRt-0004om-P1
 for 69292 <at> debbugs.gnu.org; Fri, 23 Feb 2024 13:39:10 -0500
DKIM-Signature: v=1; a=ed25519-sha256; q=dns/txt; c=relaxed/relaxed;
 d=russelstein.xyz; s=ed25519; h=Content-Type:MIME-Version:Message-ID:Date:
 References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=CmytX9wqOyo2TWgoT+8SJ9s2vpQlHSJnqSNuwNL8Y/0=; b=HU1nfFPXiw1jobWaOnwBFg9ITZ
 aydvMclMeyaJm3fWTfQCZp9PH88saqaXvyYb8BBsoZZ0qxwBtBXaC5cgUfCQ==;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=russelstein.xyz; s=rsa; h=Content-Type:MIME-Version:Message-ID:Date:
 References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=CmytX9wqOyo2TWgoT+8SJ9s2vpQlHSJnqSNuwNL8Y/0=; b=ArwPEP3rBF0ONcGJVtyaTrvcrS
 XNzQXMyOp3TZWIvEAB58aq3qBcwL1APSSDbxEWJhF9SJmxvBdvvM5HitKBiyr2v7xzElUww4AzqVb
 dBfiZmY6MMRq+o23rvWQKWjyeRUpK3C/lccMNcK7xYrkvNPB93sLm7qHTBB2YHRmiaRPPTs5WEfZ2
 StcgCSp/DCaImMhH2fvZKJvWYB2wSbqA7MTwAnHSPz6efM5HyHgWzwY0TBHsoGJSowpHMHr6om46p
 PqqzrkkafrRE4efHrh6Z/ZGxBOkP+mKPYgOTGQJaO7ueIjl3qxIQ4xDaATqQtMa10kcv8sNLEgEN6
 jEgMXnq+Mg4KpklLIxWEQ3SFggoe+J7hHn5BLxM25xLQp2lw2UQ1WRTYLBzEZWFAHZUeiH85Quz+l
 akfnMdYxgRaRLFq82+8ItMVWuYnVM/LopH+T0ILwne4cMiLmp0eoNxj4O/lwtDrPNrsUnRegli4qL
 CGxLz5SlFYQ12bq22CiyQOjW2G016lNb14JGXOLHtVkQLsQDeWtagfPZom2NTYX701COdflPN+NAQ
 42vx2jzHAR7YQUefzhk+So++QKFmfJAMGfSDXRVEDnhIWaRNQhlALLLQEGNyYDG8Tcy6MbouaACYy
 fVmr+3b+++niZ4/V3FVci00RDofrFt3nnZZdWwBLY=;
Received: by russelstein.xyz with esmtpsa
 (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
 (Exim 4.96.1) (envelope-from <reepca@HIDDEN>)
 id 1rdaPD-000000005bA-2zDk; Fri, 23 Feb 2024 12:36:24 -0600
From: Reepca Russelstein <reepca@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: [bug#69292] [PATCH 2/6] store: database: Remove with-statement
 and associated code.
In-Reply-To: <878r3bf8aw.fsf@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?=
 =?utf-8?Q?s?= message of "Fri, 23 Feb 2024 17:35:03 +0100")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <b7360abb08559073653effea98a99332fc1f8071.1708457946.git.mail@HIDDEN>
 <878r3bf8aw.fsf@HIDDEN>
Date: Fri, 23 Feb 2024 12:32:03 -0600
Message-ID: <87ttlzqbfg.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69292
X-Mailman-Approved-At: Sat, 24 Feb 2024 02:55:00 -0500
Cc: Josselin Poiret <dev@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Christopher Baines <mail@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

>> I think using dynamic-wind to finalize all statements is the wrong
>> approach. Firstly it would be good to allow reseting statements rather t=
han
>> finalizing them.

Let me once again mention https://issues.guix.gnu.org/69292#7 with this
much more magnificent Cc list.

>> Then for the problem of handling errors, the approach I've
>> settled on in the build coordinator is to close the database connection,=
 since
>> that'll trigger guile-sqlite3 to finalize all the cached statements.

And in the event that a statement is *not* cached, it will hang around
until the gc next pumps the statement guardian, at which point it will
do... whatever happens when a statement is finalized after the database
connection it was created with has already been closed, I guess.  I
don't know if that's a problem or not.  On further investigation, it
appears that sqlite_close would return SQLITE_BUSY, but guile-sqlite3's
sqlite-close doesn't throw any exceptions, and according to
https://www.sqlite.org/c3ref/close.html it would just hold off on
actually closing the database until all statements have been finalized.
So I guess that works.

>>
>> This reverts commit 5d6e2255286e591def122ec2f4a3cbda497fea21.
>>
>> * .dir-locals.el (scheme-mode): Remove with-statement.
>> * guix/store/database.scm (call-with-statement): Remove procedure.
>> (with-statement): Remove syntax rule.
>> (call-with-transaction, last-insert-row-id, path-id, update-or-insert,
>> add-references): Don't use with-statement.
>>
>> Change-Id: I2fd976b3f12ec8105cc56350933a953cf53647e8
>
> I=E2=80=99m all for removing =E2=80=98dynamic-wind=E2=80=99, we=E2=80=99l=
l have to do it to make it
> usable in a fiberized context anyway.
>
> I=E2=80=99ll let reepca comment.

What is the proper fibers-friendly replacement for dynamic-wind, anyway,
that is "like dynamic-wind, except when suspending a fiber"?  It feels
like the current interaction between dynamic-wind and fibers is more of
an accident of how the implementation works; I don't suppose fibers could
export a transparent replacement, like how it already exports a
replacement for 'sleep'?  Or perhaps the underlying issue is that we
keep using 'dynamic-wind' in situations where it only makes sense to
enter or exit the dynamic extent once?  Is it time to bring
'unwind-protect' back into style?  I see that fibers now has a
dynamic-wind*, should that be preferred?

I don't have a strong opinion on these changes, I just want to make sure
we're all aware of how guile-sqlite3's sqlite-finalize acts with cached
statements.

=2D reepca

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQFLBAEBCAA1FiEEdNapMPRLm4SepVYGwWaqSV9/GJwFAmXY5KMXHHJlZXBjYUBy
dXNzZWxzdGVpbi54eXoACgkQwWaqSV9/GJwZ5gf9G5/VPsqO4Y/RkSuL6Qz2RdNy
kLNh3TiARpSTcEh5I3KB9pPyztQu5w0QYwp91VrdQbLOtzUXwzgQQlRgmhrtruwH
cOwOgYqHZOjyJwMRz0QQLs0rzNr5rsfNFVDBjLViBg3nZ5InRXJ7xWZo6s9thsoz
exmMvTVuDRlDaA9PNTU1N/GKaLkq/LTgpw4mQ/PCrGLd/noNHGfyLoIbhyi9w1ok
Iew6wYUbioBwGlj6/rLz6hPqt7irSKtZ/WpuWH+CaA7bhH+t0GQ18FTEWvErf9zW
xkCjNYuodAXlEzbqoExWkAvRPayQ0c3+xy+YAbs3vqC0SHFMPWMa/x+/PG1e4A==
=LhLQ
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 23 Feb 2024 16:55:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 23 11:55:19 2024
Received: from localhost ([127.0.0.1]:53687 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rdYpR-0005Pd-QH
	for submit <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:55:18 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34142)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rdYbk-0004c2-6s
 for 69292 <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:41:09 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rdYbF-0000tx-8y; Fri, 23 Feb 2024 11:40:37 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=iANDY7egFyBAPh+lxHjQjHxC04dRZEtNAaR9xGg1JP4=; b=b29fuO+dR31phLqdwZ1d
 VGqP0EDHhcVtlvjVttXgQTkjY2RAWmyYX+2TCbnzQBM7dlF4Th2aXpU4Hbzl+25kV4jMkJoqYLmuX
 NlZscWwefOPXlsa6u54lT6riCn3BggM/pOb4laM8kqGstKtDIKhiXaPLbghUKKMJlf9NjKSRt7ThI
 nEz8mcy14EnMvExQiVhHBBKudtl2wc992GzxTpZgdTFTqfrcoNe7EjCi5jLk8Viz+S8qnPd2eWJG9
 +zQajdeYO6fRw6tCsLW4DgNpzD5/+Ie6YJA59ZAcmFb6/Uwa+KxVq72ANVp6Z8KNLNOFY8UhmJzBW
 I5wMFcq/k9nqDQ==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Christopher Baines <mail@HIDDEN>
Subject: Re: [bug#69292] [PATCH 3/6] store: database: Inline SQL to where
 it's used.
In-Reply-To: <5abcabc4cb65ea63db7c4f046700116e4882b287.1708457946.git.mail@HIDDEN>
 (Christopher Baines's message of "Tue, 20 Feb 2024 19:39:03 +0000")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <5abcabc4cb65ea63db7c4f046700116e4882b287.1708457946.git.mail@HIDDEN>
Date: Fri, 23 Feb 2024 17:40:29 +0100
Message-ID: <874jdzf81u.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Christopher Baines <mail@HIDDEN> skribis:

> This makes the code easier to read, as you don't have to keep jumping bet=
ween
> the two places.
>
> * guix/store/database.scm (path-id-sql, update-sql, insert-sql,
> add-reference-sql): Remove variables.
> (path-id, update-or-insert, add-references): Include SQL.
>
> Change-Id: I53b4ab973be8d0cd10a0f35ba25972f1c9680353

LGTM.

>    (let ((id (path-id db path)))
>      (if id
> -        (let ((stmt (sqlite-prepare db update-sql #:cache? #t)))
> +        (let ((stmt (sqlite-prepare
> +                     db
> +                     "
> +UPDATE ValidPaths
> +SET hash =3D :hash,
> +    registrationTime =3D :time,
> +    deriver =3D :deriver,
> +    narSize =3D :size
> +WHERE id =3D :id"
> +                     #:cache? #t)))

I think we can make it a bit more dense (3 or 4 lines in total for the
statement).  :-)

In the future, we should probably add a macro to sqlite3 like that one
from Cuirass:

--8<---------------cut here---------------start------------->8---
(define-syntax-rule (exec-query/bind db query args ...)
  "Execute the specific QUERY with the given ARGS.  Uses of 'exec-query/bin=
d'
typically look like this:

  (exec-query/bind db \"SELECT * FROM Foo WHERE x =3D \" x \"AND Y=3D\" y \=
";\")

References to variables 'x' and 'y' here are replaced by $1 and $2 in the
SQL query.

This ensures that (1) SQL injection is impossible, and (2) the number of
parameters matches the number of arguments to bind."
  (%exec-query/bind db () "" query args ...))
--8<---------------cut here---------------end--------------->8---

That makes things slightly more readable IMO since you don=E2=80=99t end up=
 with
two separate calls, one to prepare the statement and the other one to
bind its arguments.

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 23 Feb 2024 16:43:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 23 11:43:47 2024
Received: from localhost ([127.0.0.1]:52770 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rdYeJ-0004kU-6s
	for submit <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:43:47 -0500
Received: from eggs.gnu.org ([209.51.188.92]:49624)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rdYeG-0004jz-I9
 for 69292 <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:43:45 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rdYdm-0001IC-E7; Fri, 23 Feb 2024 11:43:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=mkDAxAgsRoUtZP/HjjCc2bPYrwgPnvqsnyi9iFWGD5E=; b=lkuToiJizOmECiepKqeQ
 QgBDfeEN7HIUv/o9qQEkRjQQfvR/uH0Oq+/1IM+F/1ovWzvxHvOOu9ZQnnrOZsHJSNUpANl0GoJ/+
 qviUpL07CMv8qlgXJXOP5pKa3JFt4wE/nPi7JdNozlppNC9M2E1g5LeYnB6w8054vMDQNFbPNjjbG
 02ryGyjRMa0t67fSXPOvF7E3gMlwDhYVTwEu0CPbbFSPyJkwb6l3vGcPGDMBO7tjj1HHrJCVCwty/
 XY0U3bRJS16zbj1MwzhmgFFn1z2lGudAB+S0pVs3ZRFpaNACT+uMiqhKr/jOmF2jXwb9++vkKS58I
 +ct0TknklsaG1w==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Christopher Baines <mail@HIDDEN>
Subject: Re: [bug#69292] [PATCH 6/6] store: database: Rename a couple of
 procedures.
In-Reply-To: <12f872394c84039fa553e50381d040de24f24d3e.1708457946.git.mail@HIDDEN>
 (Christopher Baines's message of "Tue, 20 Feb 2024 19:39:06 +0000")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <12f872394c84039fa553e50381d040de24f24d3e.1708457946.git.mail@HIDDEN>
Date: Fri, 23 Feb 2024 17:43:11 +0100
Message-ID: <87zfvrdtcw.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Christopher Baines <mail@HIDDEN> skribis:

> These names should be more descriptive.
>
> * guix/store/database.scm (path-id): Rename to select-valid-path-id.
> (sqlite-register): Rename to register-valid-path.
> (register-items): Update accordingly.
>
> Change-Id: I6d4a14d4cde9d71ab34d6ffdbfbfde51b2c0e1db

OK for =E2=80=98register-valid-path=E2=80=99.

For =E2=80=98path-id=E2=80=99 my preference would be =E2=80=98valid-path-id=
=E2=80=99 or keeping
=E2=80=98path-id=E2=80=99; =E2=80=98select=E2=80=99 looks odd as nothing=E2=
=80=99s being =E2=80=9Cselected=E2=80=9D here in the
non-SQL sense of the word.

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 23 Feb 2024 16:41:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 23 11:41:16 2024
Received: from localhost ([127.0.0.1]:52602 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rdYbr-0004d8-Hm
	for submit <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:41:16 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34142)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rdYbn-0004c2-UH
 for 69292 <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:41:12 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rdYSO-0007yN-QY; Fri, 23 Feb 2024 11:31:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=Yg4Jcgchm1eSVm/L9Uq6bvPZTgit5WH9rmuH6R2WXrs=; b=egjh1hMhyt9dik5xh+4f
 0GtolKBQMrDmFkOanMSDUNgo886b0y5KfBag6qDUYRdMCBpuXaARj4x62LEi1WLIGsQjuHJgzvtwi
 6YnTozvyagBaiAfyenhX5QiayTuV7ZpwaCBORXEdvSZqN+Tt3z5oZSi/gwCTD3GtF4nprmFIR1ohM
 sMR391uxHfY0n0kdZbNa2VzjSEsB96IRk6mROJYKX2jpPBi8Zc++x5pkfL85HhOw+nNlV5hAVvzWg
 alpLWFC2VXkvvxY8jQV3goDP5XNTdLwT8hsmEJWBp0FheqOUjPZkkOgCO9k/CHAwisP6dGLeCMt86
 XKJ8IKgsoppSDQ==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Christopher Baines <mail@HIDDEN>
Subject: Re: [bug#69292] [PATCH 1/6] store: database: Remove
 call-with-savepoint and associated code.
In-Reply-To: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 (Christopher Baines's message of "Tue, 20 Feb 2024 19:39:01 +0000")
References: <87h6i3lyph.fsf@HIDDEN>
 <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
Date: Fri, 23 Feb 2024 17:31:20 +0100
Message-ID: <87h6hzf8h3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Christopher Baines <mail@HIDDEN> skribis:

> While care does need to be taken with making updates or inserts to the
> ValidPaths table, I think that trying to ensure this within update-or-ins=
ert
> is the wrong approach. Instead, when working with the store database, onl=
y one
> connection should be used to make changes to the database and those chang=
es
> should happen in transactions that ideally begin immediately.
>
> This reverts commit 37545de4a3bf59611c184b31506fe9a16abe4c8b.
>
> * .dir-locals.el (scheme-mode): Remove entries for call-with-savepoint and
> call-with-retrying-savepoint.
> * guix/store/database.scm (call-with-savepoint, call-with-retrying-savepo=
int):
> Remove procedures.
> (update-or-insert): Remove use of call-with-savepoint.
>
> Change-Id: I2f986e8623d8235a90c40d5f219c1292c1ab157b

Okay, I trust you on this; we=E2=80=99ll have to make sure to actually start
transactions at the top level.

(BTW, make sure at least =E2=80=9Cmake check TESTS=3Dtests/store-database.s=
cm=E2=80=9D
passes for changes to this module.)




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 23 Feb 2024 16:41:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 23 11:41:15 2024
Received: from localhost ([127.0.0.1]:52597 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rdYbq-0004d4-VJ
	for submit <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:41:15 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34142)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rdYbm-0004c2-Sy
 for 69292 <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:41:11 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rdYU7-000884-UX; Fri, 23 Feb 2024 11:33:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=qhmvYIP6mcO0LSdcxbLZlwUEk/SMsxW/A8BcMkrnUuE=; b=MwBZZXJFRUFvg3ey5TUu
 0WaR4mV+aYIvVtA+oXp5eFkPNX7gDQPwHwvpVXVktkYXiBtTNV/LABmBHikDWZjc0C8mD1GBigla5
 CJJe153IAA0rsWqZCP7UVB/+8JcCQLf3f7mY3IQdetpXlp7PAsXNWIdgwwWFGgHkzeFxxD0trWl7n
 A8EyEIGMkabWpNMj48NVqZe31xLmwAOcSKCmyogfm2qridgV7s9zzrxWU3inp2Q/aOwJadptmOCuX
 XN3bWKaLYKnRTjsAH7qL36om97oHj4JZK/AYsqQDHZ3EFQlqDq44wumbJOMC5Our9kxbICM+m+tTJ
 6yCoCOgsJEJEgQ==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Christopher Baines <mail@HIDDEN>
Subject: Re: [bug#69292] [PATCH 5/6] store: database: Refactor sqlite-register.
In-Reply-To: <11b24242dd71349c09486341ed0d01b55f5f8f9a.1708457946.git.mail@HIDDEN>
 (Christopher Baines's message of "Tue, 20 Feb 2024 19:39:05 +0000")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <11b24242dd71349c09486341ed0d01b55f5f8f9a.1708457946.git.mail@HIDDEN>
Date: Fri, 23 Feb 2024 17:33:13 +0100
Message-ID: <87cysnf8dy.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 69292 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Christopher Baines <mail@HIDDEN> skribis:

> The update-or-insert procedure name was unhelpfully generic, and these changes
> should improve the code readability.
>
> * guix/store/database.scm (update-or-insert): Remove procedure and inline
> functionality in to sqlite-register.
>
> Change-Id: Ifab0cdb7972d095460cc1f79b8b2f0e9b958059c

LGTM.




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 23 Feb 2024 16:41:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 23 11:41:14 2024
Received: from localhost ([127.0.0.1]:52595 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rdYbq-0004cx-I5
	for submit <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:41:14 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34142)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rdYbl-0004c2-B6
 for 69292 <at> debbugs.gnu.org; Fri, 23 Feb 2024 11:41:09 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rdYVv-0008Rl-Or; Fri, 23 Feb 2024 11:35:07 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=oEdGDRCGnScyqAQZXb7XjpgBbEf0I4B4XtLWIRlcE4U=; b=A1a6RZVbTN644NxQEnvu
 XRWJeNXslAyaCSVGAz6NkIBBLmAomUCXT+2E4RyLFcBkkB52BuwHxNus/z55R5aQYQ9xGBD7+Ymf4
 qCwL/UrTMKh2iKKAcUaoPkbXqehX3gzDA9kS5aNuDDP1351Jr2ekjghcLx1d6Pt8XMoud/HP0mc8W
 dsigYYmjuXUV/VhWV74vCpcRpi2xakhJAHhEYdtRUEO9cGHDMtgsF8kp5rPZQlvngU2LqB1vynOMM
 qacXy5XST1ENLJ95DANyQUm0s8lvvYwaz76StwTXtdTatOdeDBDa3addTLBmfln0ds9liXmV0VfbG
 Qh6r2bVh04/Mfg==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Christopher Baines <mail@HIDDEN>
Subject: Re: [bug#69292] [PATCH 2/6] store: database: Remove with-statement
 and associated code.
In-Reply-To: <b7360abb08559073653effea98a99332fc1f8071.1708457946.git.mail@HIDDEN>
 (Christopher Baines's message of "Tue, 20 Feb 2024 19:39:02 +0000")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <b7360abb08559073653effea98a99332fc1f8071.1708457946.git.mail@HIDDEN>
Date: Fri, 23 Feb 2024 17:35:03 +0100
Message-ID: <878r3bf8aw.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69292
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>,
 Caleb Ristvedt <reepca@HIDDEN>, 69292 <at> debbugs.gnu.org,
 Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Christopher Baines <mail@HIDDEN> skribis:

> I think using dynamic-wind to finalize all statements is the wrong
> approach. Firstly it would be good to allow reseting statements rather th=
an
> finalizing them. Then for the problem of handling errors, the approach I'=
ve
> settled on in the build coordinator is to close the database connection, =
since
> that'll trigger guile-sqlite3 to finalize all the cached statements.
>
> This reverts commit 5d6e2255286e591def122ec2f4a3cbda497fea21.
>
> * .dir-locals.el (scheme-mode): Remove with-statement.
> * guix/store/database.scm (call-with-statement): Remove procedure.
> (with-statement): Remove syntax rule.
> (call-with-transaction, last-insert-row-id, path-id, update-or-insert,
> add-references): Don't use with-statement.
>
> Change-Id: I2fd976b3f12ec8105cc56350933a953cf53647e8

I=E2=80=99m all for removing =E2=80=98dynamic-wind=E2=80=99, we=E2=80=99ll =
have to do it to make it
usable in a fiberized context anyway.

I=E2=80=99ll let reepca comment.

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 22 Feb 2024 14:27:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 22 09:27:19 2024
Received: from localhost ([127.0.0.1]:58155 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rdA2g-0006FF-59
	for submit <at> debbugs.gnu.org; Thu, 22 Feb 2024 09:27:19 -0500
Received: from mailout.russelstein.xyz ([209.141.47.21]:54288)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <reepca@HIDDEN>) id 1rd8hR-0002PB-3G
 for 69292 <at> debbugs.gnu.org; Thu, 22 Feb 2024 08:01:18 -0500
DKIM-Signature: v=1; a=ed25519-sha256; q=dns/txt; c=relaxed/relaxed;
 d=russelstein.xyz; s=ed25519; h=Content-Type:MIME-Version:Message-ID:Date:
 References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=dZGYyWQi643lgjdNVH8GqbuuYDUoCB9SyRQltb3cKLM=; b=bKIln58N9JCXEW5lENTrIrWyh0
 iBcQnuJZ5/9MqcZmwRoDigdl0OYeVWgRHosKwb/OVE0ahwYGZ7JYuwzKRaBw==;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=russelstein.xyz; s=rsa; h=Content-Type:MIME-Version:Message-ID:Date:
 References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=dZGYyWQi643lgjdNVH8GqbuuYDUoCB9SyRQltb3cKLM=; b=KwivW8JA1ylQElXAOpU/IszeDG
 PQIYjlTpbHrj4pPVMZY42f1qMt1Xpk8AbXoQVsyklVrjPGcIbiXWu3I2lolx1sLD6mLBu0MHveNmh
 evlw8BGGM8yx4sYp0pacgs2KX8zzUlESG0bIK+cI3PZqjEA1PpYUP8nJhWUPwpcCPILIqFef7tLtg
 ENwixRtUymYwrRMaQ3CyYa8JtJwVc9bYG9Pr5aPal5HFsA9yASPddD+fp7UfHugjBq9mOLlPmDLR+
 YmV5s0s5y2joQjzgYjwMz25vEGqeEYX4vl1GjGwLfPOUtKAO4llZAF+aNg7BDSeAceWdjmjE2aKlr
 naLGEFhA7siCAwvzCMS5+FGfZ8J7B1qmtaZYO7MSkx9+ueWWRj1HChNt3fmOX2Ki1O/jCUUrW2C6j
 4ICane4So2irnTmpCzRl6Xx+AdN2VQ/8lBNLUuK3FG3fV2HBkraybn90S1C41ieL1aQchJplQrZnC
 TG+8cxsoa+77deRt8pRjdWz4MYbSDGoo4JcmTu+Gd/hWDIcwLcrY+Il4Uy2QI6GtQqrE6ffXuXLfj
 3fZc0zp/+DWy+Pn/YCvro1JGeqXsYSqD1swj+YuSGGIB6xJEEEfdpum5dDxKub3TnowQnNC6EwsA9
 WVBOtXb3PlP8IfIA2UucaLdpOtjo69k7LEVAEeR7Q=;
Received: by russelstein.xyz with esmtpsa
 (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
 (Exim 4.96.1) (envelope-from <reepca@HIDDEN>)
 id 1rd8Mn-000000008Om-351k; Thu, 22 Feb 2024 06:39:58 -0600
From: reepca@HIDDEN
To: Christopher Baines <mail@HIDDEN>
Subject: Re: [PATCH 4/6] store: database: Stop finalizing prepared statements.
In-Reply-To: <c4bf41b5c91623ee93285f35516265cfdb0ab401.1708457946.git.mail@HIDDEN>
 (Christopher Baines's message of "Tue, 20 Feb 2024 19:39:04 +0000")
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
 <c4bf41b5c91623ee93285f35516265cfdb0ab401.1708457946.git.mail@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
Date: Thu, 22 Feb 2024 06:39:37 -0600
Message-ID: <87y1bcr7ue.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69292
X-Mailman-Approved-At: Thu, 22 Feb 2024 09:27:16 -0500
Cc: 69292 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

--=-=-=
Content-Type: text/plain

Christopher Baines <mail@HIDDEN> writes:

> Especially since we're asking for these to be cached.
>
> Management of prepared statements isn't trivial, since you don't want to keep
> them forever as this can lead to poor query performance, but I don't think
> that finalizing them immediately is the right solution.

guile-sqlite3 arranges for cached statements to only be reset, not
finalized, when sqlite-finalize is called on them (see
https://notabug.org/guile-sqlite3/guile-sqlite3/src/master/sqlite3.scm.in#L283).
The idea behind this admittedly-unintuitive behavior is that it allows
for the caching behavior of a statement to be decided independently of
the code that actually uses it: if it's been decided elsewhere that a
prepared statement is worth keeping around, it will reuse it, but if it
hasn't, it will still properly clean up what it created.

Perhaps reusing the name 'sqlite-finalize' to make that behavior
transparent wasn't the best choice in the long run.

I hope that makes the way it was written a bit less baffling.

- reepca

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQFLBAEBCAA1FiEEdNapMPRLm4SepVYGwWaqSV9/GJwFAmXXQIkXHHJlZXBjYUBy
dXNzZWxzdGVpbi54eXoACgkQwWaqSV9/GJxKiAf/fsuX+zHXnKGCOIzBXAbWsW9H
cf6cY/5FQK/55CUQhqJ8f4+xsM8ldIgXMcNs1Nwx2gvHCAiyUOnDFrpg6zJI7Iw3
oQnQoa62L+3YtbXM60kuk3cgd/1u0Bi8euNJFdA2CdkUlHt2OkbJ0UlK6he+LCH8
BaUh7hvKxBa1gYixB8P8G4+7B8mLnlb8eFeMMGWi8cO19wPwHgr/m54qWr6KKhzl
+rTamrOa3Q9Ju1Jm38Qo0b6gpX9agQ9bPrhOKGmxURgjmU274JayHg+Fuwoxz9TJ
ydo781BYQpvuvFuiUMgonOBsEIBT5jJE5RQhubuCzTC2CvKrZ7MSHQ2vdwFbzA==
=mr/M
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 20 Feb 2024 19:40:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 20 14:40:11 2024
Received: from localhost ([127.0.0.1]:46640 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rcVyM-0002TC-IB
	for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:11 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43152)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rcVyE-0002S4-Lf
 for 69292 <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:04 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id C60D227BBED
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 9b5e01bd
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: 69292 <at> debbugs.gnu.org
Subject: [PATCH 6/6] store: database: Rename a couple of procedures.
Date: Tue, 20 Feb 2024 19:39:06 +0000
Message-ID: <12f872394c84039fa553e50381d040de24f24d3e.1708457946.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69292
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

These names should be more descriptive.

* guix/store/database.scm (path-id): Rename to select-valid-path-id.
(sqlite-register): Rename to register-valid-path.
(register-items): Update accordingly.

Change-Id: I6d4a14d4cde9d71ab34d6ffdbfbfde51b2c0e1db
---
 guix/store/database.scm | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/guix/store/database.scm b/guix/store/database.scm
index 0b570eabcd..0190696ad5 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -40,8 +40,10 @@ (define-module (guix store database)
             store-database-file
             call-with-database
             with-database
-            path-id
-            sqlite-register
+
+            select-valid-path-id
+
+            register-valid-path
             register-items
             %epoch
             reset-timestamps
@@ -181,9 +183,9 @@ (define (last-insert-row-id db)
     (vector-ref (sqlite-step-and-reset stmt)
                 0)))
 
-(define* (path-id db path)
-  "If PATH exists in the 'ValidPaths' table, return its numerical
-identifier.  Otherwise, return #f."
+(define (select-valid-path-id db path)
+  "If PATH exists in the 'ValidPaths' table, return its numerical identifier.
+Otherwise, return #f."
   (let ((stmt (sqlite-prepare
                db
                "
@@ -229,9 +231,9 @@ (define-inlinable (assert-integer proc in-range? key number)
            "Integer ~A out of range: ~S" (list key number)
            (list number))))
 
-(define* (sqlite-register db #:key path (references '())
-                          deriver hash nar-size
-                          (time (timestamp)))
+(define* (register-valid-path db #:key path (references '())
+                              deriver hash nar-size
+                              (time (timestamp)))
   "Registers this stuff in DB.  PATH is the store item to register and
 REFERENCES is the list of store items PATH refers to; DERIVER is the '.drv'
 that produced PATH, HASH is the base16-encoded Nix sha256 hash of
@@ -249,7 +251,7 @@ (define* (sqlite-register db #:key path (references '())
   (assert-integer "sqlite-register" (cut >= <> 0) #:time registration-time)
 
   (define id
-    (let ((existing-id (path-id db path)))
+    (let ((existing-id (select-valid-path-id db path)))
       (if existing-id
           (let ((stmt (sqlite-prepare
                        db
@@ -287,7 +289,8 @@ (define* (sqlite-register db #:key path (references '())
   ;; Call 'path-id' on each of REFERENCES.  This ensures we get a
   ;; "non-NULL constraint" failure if one of REFERENCES is unregistered.
   (add-references db id
-                  (map (cut path-id db <>) references)))
+                  (map (cut select-valid-path-id db <>) references)))
+
 
 
 ;;;
@@ -364,18 +367,18 @@ (define* (register-items db items
     ;; When TO-REGISTER is already registered, skip it.  This makes a
     ;; significant differences when 'register-closures' is called
     ;; consecutively for overlapping closures such as 'system' and 'bootcfg'.
-    (unless (path-id db to-register)
+    (unless (select-valid-path-id db to-register)
       (let-values (((hash nar-size) (nar-sha256 real-file-name)))
         (call-with-retrying-transaction db
           (lambda ()
-            (sqlite-register db #:path to-register
-                             #:references (store-info-references item)
-                             #:deriver (store-info-deriver item)
-                             #:hash (string-append
-                                     "sha256:"
-                                     (bytevector->base16-string hash))
-                             #:nar-size nar-size
-                             #:time registration-time))))))
+            (register-valid-path db #:path to-register
+                                 #:references (store-info-references item)
+                                 #:deriver (store-info-deriver item)
+                                 #:hash (string-append
+                                         "sha256:"
+                                         (bytevector->base16-string hash))
+                                 #:nar-size nar-size
+                                 #:time registration-time))))))
 
   (let* ((prefix   (format #f "registering ~a items" (length items)))
          (progress (progress-reporter/bar (length items)
-- 
2.41.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 20 Feb 2024 19:40:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 20 14:40:10 2024
Received: from localhost ([127.0.0.1]:46638 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rcVyM-0002TA-5C
	for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:10 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43150)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rcVyC-0002RT-6e
 for 69292 <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:01 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id B53DD27BBEA
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id c38561ed
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: 69292 <at> debbugs.gnu.org
Subject: [PATCH 3/6] store: database: Inline SQL to where it's used.
Date: Tue, 20 Feb 2024 19:39:03 +0000
Message-ID: <5abcabc4cb65ea63db7c4f046700116e4882b287.1708457946.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69292
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

This makes the code easier to read, as you don't have to keep jumping between
the two places.

* guix/store/database.scm (path-id-sql, update-sql, insert-sql,
add-reference-sql): Remove variables.
(path-id, update-or-insert, add-references): Include SQL.

Change-Id: I53b4ab973be8d0cd10a0f35ba25972f1c9680353
---
 guix/store/database.scm | 45 ++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/guix/store/database.scm b/guix/store/database.scm
index de72b79860..7e3a2873ce 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -178,13 +178,14 @@ (define (last-insert-row-id db)
       ((#(id)) id)
       (_ #f))))
 
-(define path-id-sql
-  "SELECT id FROM ValidPaths WHERE path = :path")
-
 (define* (path-id db path)
   "If PATH exists in the 'ValidPaths' table, return its numerical
 identifier.  Otherwise, return #f."
-  (let ((stmt (sqlite-prepare db path-id-sql #:cache? #t)))
+  (let ((stmt (sqlite-prepare
+               db
+               "
+SELECT id FROM ValidPaths WHERE path = :path"
+               #:cache? #t)))
     (sqlite-bind-arguments stmt #:path path)
     (let ((result (sqlite-fold cons '() stmt)))
       (sqlite-finalize stmt)
@@ -192,14 +193,6 @@ (define* (path-id db path)
         ((#(id) . _) id)
         (_ #f)))))
 
-(define update-sql
-  "UPDATE ValidPaths SET hash = :hash, registrationTime = :time, deriver =
-:deriver, narSize = :size WHERE id = :id")
-
-(define insert-sql
-  "INSERT INTO ValidPaths (path, hash, registrationTime, deriver, narSize)
-VALUES (:path, :hash, :time, :deriver, :size)")
-
 (define-inlinable (assert-integer proc in-range? key number)
   (unless (integer? number)
     (throw 'wrong-type-arg proc
@@ -222,14 +215,28 @@ (define* (update-or-insert db #:key path deriver hash nar-size time)
 
   (let ((id (path-id db path)))
     (if id
-        (let ((stmt (sqlite-prepare db update-sql #:cache? #t)))
+        (let ((stmt (sqlite-prepare
+                     db
+                     "
+UPDATE ValidPaths
+SET hash = :hash,
+    registrationTime = :time,
+    deriver = :deriver,
+    narSize = :size
+WHERE id = :id"
+                     #:cache? #t)))
           (sqlite-bind-arguments stmt #:id id
                                  #:deriver deriver
                                  #:hash hash #:size nar-size #:time time)
           (sqlite-fold cons '() stmt)
           (sqlite-finalize stmt)
           (last-insert-row-id db))
-        (let ((stmt (sqlite-prepare db insert-sql #:cache? #t)))
+        (let ((stmt (sqlite-prepare
+                     db
+                     "
+INSERT INTO ValidPaths (path, hash, registrationTime, deriver, narSize)
+VALUES (:path, :hash, :time, :deriver, :size)"
+                     #:cache? #t)))
           (sqlite-bind-arguments stmt
                                  #:path path #:deriver deriver
                                  #:hash hash #:size nar-size #:time time)
@@ -237,13 +244,15 @@ (define* (update-or-insert db #:key path deriver hash nar-size time)
           (sqlite-finalize stmt)
           (last-insert-row-id db)))))
 
-(define add-reference-sql
-  "INSERT OR REPLACE INTO Refs (referrer, reference) VALUES (:referrer, :reference);")
-
 (define (add-references db referrer references)
   "REFERRER is the id of the referring store item, REFERENCES is a list
 ids of items referred to."
-  (let ((stmt (sqlite-prepare db add-reference-sql #:cache? #t)))
+  (let ((stmt (sqlite-prepare
+               db
+               "
+INSERT OR REPLACE INTO Refs (referrer, reference)
+VALUES (:referrer, :reference)"
+               #:cache? #t)))
     (for-each (lambda (reference)
                 (sqlite-reset stmt)
                 (sqlite-bind-arguments stmt #:referrer referrer
-- 
2.41.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 20 Feb 2024 19:40:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 20 14:40:04 2024
Received: from localhost ([127.0.0.1]:46619 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rcVyE-0002S8-Np
	for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:04 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43146)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rcVyC-0002RR-5F
 for 69292 <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:01 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id A98CC27BBE2
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 1616ca35
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: 69292 <at> debbugs.gnu.org
Subject: [PATCH 1/6] store: database: Remove call-with-savepoint and
 associated code.
Date: Tue, 20 Feb 2024 19:39:01 +0000
Message-ID: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69292
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

While care does need to be taken with making updates or inserts to the
ValidPaths table, I think that trying to ensure this within update-or-insert
is the wrong approach. Instead, when working with the store database, only one
connection should be used to make changes to the database and those changes
should happen in transactions that ideally begin immediately.

This reverts commit 37545de4a3bf59611c184b31506fe9a16abe4c8b.

* .dir-locals.el (scheme-mode): Remove entries for call-with-savepoint and
call-with-retrying-savepoint.
* guix/store/database.scm (call-with-savepoint, call-with-retrying-savepoint):
Remove procedures.
(update-or-insert): Remove use of call-with-savepoint.

Change-Id: I2f986e8623d8235a90c40d5f219c1292c1ab157b
---
 .dir-locals.el          |  2 --
 guix/store/database.scm | 75 +++++++----------------------------------
 2 files changed, 13 insertions(+), 64 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index d18e6ba760..f135eb69a5 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -133,8 +133,6 @@
    (eval . (put 'call-with-transaction 'scheme-indent-function 1))
    (eval . (put 'with-statement 'scheme-indent-function 3))
    (eval . (put 'call-with-retrying-transaction 'scheme-indent-function 1))
-   (eval . (put 'call-with-savepoint 'scheme-indent-function 1))
-   (eval . (put 'call-with-retrying-savepoint 'scheme-indent-function 1))
 
    (eval . (put 'call-with-container 'scheme-indent-function 1))
    (eval . (put 'container-excursion 'scheme-indent-function 1))
diff --git a/guix/store/database.scm b/guix/store/database.scm
index 2968f13492..3093fd816a 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -151,39 +151,11 @@ (define* (call-with-transaction db proc #:key restartable?)
       (false-if-exception (exec "rollback;"))
       (apply throw args))))
 
-(define* (call-with-savepoint db proc
-                              #:optional (savepoint-name "SomeSavepoint"))
-  "Call PROC after creating a savepoint named SAVEPOINT-NAME.  If PROC exits
-abnormally, rollback to that savepoint.  In all cases, remove the savepoint
-prior to returning."
-  (define (exec sql)
-    (with-statement db sql stmt
-      (sqlite-fold cons '() stmt)))
-
-  (dynamic-wind
-    (lambda ()
-      (exec (string-append "SAVEPOINT " savepoint-name ";")))
-    (lambda ()
-      (catch #t
-        proc
-        (lambda args
-          (exec (string-append "ROLLBACK TO " savepoint-name ";"))
-          (apply throw args))))
-    (lambda ()
-      (exec (string-append "RELEASE " savepoint-name ";")))))
-
 (define* (call-with-retrying-transaction db proc #:key restartable?)
   (call-with-SQLITE_BUSY-retrying
    (lambda ()
      (call-with-transaction db proc #:restartable? restartable?))))
 
-(define* (call-with-retrying-savepoint db proc
-                                       #:optional (savepoint-name
-                                                   "SomeSavepoint"))
-  (call-with-SQLITE_BUSY-retrying
-   (lambda ()
-     (call-with-savepoint db proc savepoint-name))))
-
 (define %default-database-file
   ;; Default location of the store database.
   (string-append %store-database-directory "/db.sqlite"))
@@ -261,40 +233,19 @@ (define* (update-or-insert db #:key path deriver hash nar-size time)
   (assert-integer "update-or-insert" positive? #:nar-size nar-size)
   (assert-integer "update-or-insert" (cut >= <> 0) #:time time)
 
-  ;; It's important that querying the path-id and the insert/update operation
-  ;; take place in the same transaction, as otherwise some other
-  ;; process/thread/fiber could register the same path between when we check
-  ;; whether it's already registered and when we register it, resulting in
-  ;; duplicate paths (which, due to a 'unique' constraint, would cause an
-  ;; exception to be thrown). With the default journaling mode this will
-  ;; prevent writes from occurring during that sensitive time, but with WAL
-  ;; mode it will instead arrange to return SQLITE_BUSY when a write occurs
-  ;; between the start of a read transaction and its upgrading to a write
-  ;; transaction (see https://sqlite.org/rescode.html#busy_snapshot).
-  ;; Experimentally, it seems this SQLITE_BUSY will ignore a busy_timeout and
-  ;; immediately return (makes sense, since waiting won't change anything).
-
-  ;; Note that when that kind of SQLITE_BUSY error is returned, it will keep
-  ;; being returned every time we try to upgrade the same outermost
-  ;; transaction to a write transaction.  So when retrying, we have to restart
-  ;; the *outermost* write transaction.  We can't inherently tell whether
-  ;; we're the outermost write transaction, so we leave the retry-handling to
-  ;; the caller.
-  (call-with-savepoint db
-    (lambda ()
-      (let ((id (path-id db path)))
-        (if id
-            (with-statement db update-sql stmt
-              (sqlite-bind-arguments stmt #:id id
-                                     #:deriver deriver
-                                     #:hash hash #:size nar-size #:time time)
-              (sqlite-fold cons '() stmt))
-            (with-statement db insert-sql stmt
-              (sqlite-bind-arguments stmt
-                                     #:path path #:deriver deriver
-                                     #:hash hash #:size nar-size #:time time)
-              (sqlite-fold cons '() stmt)))
-        (last-insert-row-id db)))))
+  (let ((id (path-id db path)))
+    (if id
+        (with-statement db update-sql stmt
+          (sqlite-bind-arguments stmt #:id id
+                                 #:deriver deriver
+                                 #:hash hash #:size nar-size #:time time)
+          (sqlite-fold cons '() stmt))
+        (with-statement db insert-sql stmt
+          (sqlite-bind-arguments stmt
+                                 #:path path #:deriver deriver
+                                 #:hash hash #:size nar-size #:time time)
+          (sqlite-fold cons '() stmt)))
+    (last-insert-row-id db)))
 
 (define add-reference-sql
   "INSERT OR REPLACE INTO Refs (referrer, reference) VALUES (:referrer, :reference);")

base-commit: f4af19b037826cad90bbcfe400ad864f028cc7d8
-- 
2.41.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 20 Feb 2024 19:40:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 20 14:40:02 2024
Received: from localhost ([127.0.0.1]:46615 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rcVyD-0002Ru-Pg
	for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:02 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43148)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rcVyC-0002RS-5C
 for 69292 <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:40:00 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id AF90427BBE9
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id e23dd3da
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: 69292 <at> debbugs.gnu.org
Subject: [PATCH 2/6] store: database: Remove with-statement and associated
 code.
Date: Tue, 20 Feb 2024 19:39:02 +0000
Message-ID: <b7360abb08559073653effea98a99332fc1f8071.1708457946.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69292
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

I think using dynamic-wind to finalize all statements is the wrong
approach. Firstly it would be good to allow reseting statements rather than
finalizing them. Then for the problem of handling errors, the approach I've
settled on in the build coordinator is to close the database connection, since
that'll trigger guile-sqlite3 to finalize all the cached statements.

This reverts commit 5d6e2255286e591def122ec2f4a3cbda497fea21.

* .dir-locals.el (scheme-mode): Remove with-statement.
* guix/store/database.scm (call-with-statement): Remove procedure.
(with-statement): Remove syntax rule.
(call-with-transaction, last-insert-row-id, path-id, update-or-insert,
add-references): Don't use with-statement.

Change-Id: I2fd976b3f12ec8105cc56350933a953cf53647e8
---
 .dir-locals.el          |  1 -
 guix/store/database.scm | 62 ++++++++++++++++++-----------------------
 2 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index f135eb69a5..2d1a03c313 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -131,7 +131,6 @@
    (eval . (put 'with-database 'scheme-indent-function 2))
    (eval . (put 'call-with-database 'scheme-indent-function 1))
    (eval . (put 'call-with-transaction 'scheme-indent-function 1))
-   (eval . (put 'with-statement 'scheme-indent-function 3))
    (eval . (put 'call-with-retrying-transaction 'scheme-indent-function 1))
 
    (eval . (put 'call-with-container 'scheme-indent-function 1))
diff --git a/guix/store/database.scm b/guix/store/database.scm
index 3093fd816a..de72b79860 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -130,25 +130,22 @@ (define* (call-with-transaction db proc #:key restartable?)
 the transaction, otherwise commit the transaction after it finishes.
 RESTARTABLE? may be set to a non-#f value when it is safe to run PROC multiple
 times.  This may reduce contention for the database somewhat."
-  (define (exec sql)
-    (with-statement db sql stmt
-      (sqlite-fold cons '() stmt)))
   ;; We might use begin immediate here so that if we need to retry, we figure
   ;; that out immediately rather than because some SQLITE_BUSY exception gets
   ;; thrown partway through PROC - in which case the part already executed
   ;; (which may contain side-effects!) might have to be executed again for
   ;; every retry.
-  (exec (if restartable? "begin;" "begin immediate;"))
+  (sqlite-exec db (if restartable? "begin;" "begin immediate;"))
   (catch #t
     (lambda ()
       (let-values ((result (proc)))
-        (exec "commit;")
+        (sqlite-exec db "commit;")
         (apply values result)))
     (lambda args
       ;; The roll back may or may not have occurred automatically when the
       ;; error was generated. If it has occurred, this does nothing but signal
       ;; an error. If it hasn't occurred, this needs to be done.
-      (false-if-exception (exec "rollback;"))
+      (false-if-exception (sqlite-exec db "rollback;"))
       (apply throw args))))
 
 (define* (call-with-retrying-transaction db proc #:key restartable?)
@@ -170,26 +167,14 @@ (define-syntax with-database
     ((_ file db exp ...)
      (call-with-database file (lambda (db) exp ...)))))
 
-(define (call-with-statement db sql proc)
-  (let ((stmt (sqlite-prepare db sql #:cache? #t)))
-    (dynamic-wind
-      (const #t)
-      (lambda ()
-        (proc stmt))
-      (lambda ()
-        (sqlite-finalize stmt)))))
-
-(define-syntax-rule (with-statement db sql stmt exp ...)
-  "Run EXP... with STMT bound to a prepared statement corresponding to the sql
-string SQL for DB."
-  (call-with-statement db sql
-                       (lambda (stmt) exp ...)))
-
 (define (last-insert-row-id db)
   ;; XXX: (sqlite3) currently lacks bindings for 'sqlite3_last_insert_rowid'.
   ;; Work around that.
-  (with-statement db "SELECT last_insert_rowid();" stmt
-    (match (sqlite-fold cons '() stmt)
+  (let* ((stmt   (sqlite-prepare db "SELECT last_insert_rowid();"
+                                 #:cache? #t))
+         (result (sqlite-fold cons '() stmt)))
+    (sqlite-finalize stmt)
+    (match result
       ((#(id)) id)
       (_ #f))))
 
@@ -199,11 +184,13 @@ (define path-id-sql
 (define* (path-id db path)
   "If PATH exists in the 'ValidPaths' table, return its numerical
 identifier.  Otherwise, return #f."
-  (with-statement db path-id-sql stmt
+  (let ((stmt (sqlite-prepare db path-id-sql #:cache? #t)))
     (sqlite-bind-arguments stmt #:path path)
-    (match (sqlite-fold cons '() stmt)
-      ((#(id) . _) id)
-      (_ #f))))
+    (let ((result (sqlite-fold cons '() stmt)))
+      (sqlite-finalize stmt)
+      (match result
+        ((#(id) . _) id)
+        (_ #f)))))
 
 (define update-sql
   "UPDATE ValidPaths SET hash = :hash, registrationTime = :time, deriver =
@@ -235,17 +222,20 @@ (define* (update-or-insert db #:key path deriver hash nar-size time)
 
   (let ((id (path-id db path)))
     (if id
-        (with-statement db update-sql stmt
+        (let ((stmt (sqlite-prepare db update-sql #:cache? #t)))
           (sqlite-bind-arguments stmt #:id id
                                  #:deriver deriver
                                  #:hash hash #:size nar-size #:time time)
-          (sqlite-fold cons '() stmt))
-        (with-statement db insert-sql stmt
+          (sqlite-fold cons '() stmt)
+          (sqlite-finalize stmt)
+          (last-insert-row-id db))
+        (let ((stmt (sqlite-prepare db insert-sql #:cache? #t)))
           (sqlite-bind-arguments stmt
                                  #:path path #:deriver deriver
                                  #:hash hash #:size nar-size #:time time)
-          (sqlite-fold cons '() stmt)))
-    (last-insert-row-id db)))
+          (sqlite-fold cons '() stmt)             ;execute it
+          (sqlite-finalize stmt)
+          (last-insert-row-id db)))))
 
 (define add-reference-sql
   "INSERT OR REPLACE INTO Refs (referrer, reference) VALUES (:referrer, :reference);")
@@ -253,13 +243,15 @@ (define add-reference-sql
 (define (add-references db referrer references)
   "REFERRER is the id of the referring store item, REFERENCES is a list
 ids of items referred to."
-  (with-statement db add-reference-sql stmt
+  (let ((stmt (sqlite-prepare db add-reference-sql #:cache? #t)))
     (for-each (lambda (reference)
                 (sqlite-reset stmt)
                 (sqlite-bind-arguments stmt #:referrer referrer
                                        #:reference reference)
-                (sqlite-fold cons '() stmt))
-              references)))
+                (sqlite-fold cons '() stmt)       ;execute it
+                (last-insert-row-id db))
+              references)
+    (sqlite-finalize stmt)))
 
 (define (timestamp)
   "Return a timestamp, either the current time of SOURCE_DATE_EPOCH."
-- 
2.41.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 20 Feb 2024 19:39:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 20 14:39:37 2024
Received: from localhost ([127.0.0.1]:46610 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rcVxp-0002Qy-5P
	for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:39:37 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43144)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rcVxi-0002QX-6o
 for 69292 <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:39:33 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id C06C227BBEC
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 150cb772
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: 69292 <at> debbugs.gnu.org
Subject: [PATCH 5/6] store: database: Refactor sqlite-register.
Date: Tue, 20 Feb 2024 19:39:05 +0000
Message-ID: <11b24242dd71349c09486341ed0d01b55f5f8f9a.1708457946.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69292
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

The update-or-insert procedure name was unhelpfully generic, and these changes
should improve the code readability.

* guix/store/database.scm (update-or-insert): Remove procedure and inline
functionality in to sqlite-register.

Change-Id: Ifab0cdb7972d095460cc1f79b8b2f0e9b958059c
---
 guix/store/database.scm | 132 ++++++++++++++++++++--------------------
 1 file changed, 66 insertions(+), 66 deletions(-)

diff --git a/guix/store/database.scm b/guix/store/database.scm
index 8d8b7346e0..0b570eabcd 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -194,54 +194,15 @@ (define* (path-id db path)
       (#(id) id)
       (#f #f))))
 
-(define-inlinable (assert-integer proc in-range? key number)
-  (unless (integer? number)
-    (throw 'wrong-type-arg proc
-           "Wrong type argument ~A: ~S" (list key number)
-           (list number)))
-  (unless (in-range? number)
-    (throw 'out-of-range proc
-           "Integer ~A out of range: ~S" (list key number)
-           (list number))))
-
-(define* (update-or-insert db #:key path deriver hash nar-size time)
-  "The classic update-if-exists and insert-if-doesn't feature that sqlite
-doesn't exactly have... they've got something close, but it involves deleting
-and re-inserting instead of updating, which causes problems with foreign keys,
-of course. Returns the row id of the row that was modified or inserted."
-
-  ;; Make sure NAR-SIZE is valid.
-  (assert-integer "update-or-insert" positive? #:nar-size nar-size)
-  (assert-integer "update-or-insert" (cut >= <> 0) #:time time)
-
-  (let ((id (path-id db path)))
-    (if id
-        (let ((stmt (sqlite-prepare
-                     db
-                     "
-UPDATE ValidPaths
-SET hash = :hash,
-    registrationTime = :time,
-    deriver = :deriver,
-    narSize = :size
-WHERE id = :id"
-                     #:cache? #t)))
-          (sqlite-bind-arguments stmt #:id id
-                                 #:deriver deriver
-                                 #:hash hash #:size nar-size #:time time)
-          (sqlite-step-and-reset stmt)
-          id)
-        (let ((stmt (sqlite-prepare
-                     db
-                     "
-INSERT INTO ValidPaths (path, hash, registrationTime, deriver, narSize)
-VALUES (:path, :hash, :time, :deriver, :size)"
-                     #:cache? #t)))
-          (sqlite-bind-arguments stmt
-                                 #:path path #:deriver deriver
-                                 #:hash hash #:size nar-size #:time time)
-          (sqlite-step-and-reset stmt)
-          (last-insert-row-id db)))))
+(define (timestamp)
+  "Return a timestamp, either the current time of SOURCE_DATE_EPOCH."
+  (match (getenv "SOURCE_DATE_EPOCH")
+    (#f
+     (current-time time-utc))
+    ((= string->number seconds)
+     (if seconds
+         (make-time time-utc 0 seconds)
+         (current-time time-utc)))))
 
 (define (add-references db referrer references)
   "REFERRER is the id of the referring store item, REFERENCES is a list
@@ -258,15 +219,15 @@ (define (add-references db referrer references)
                 (sqlite-step-and-reset stmt))
               references)))
 
-(define (timestamp)
-  "Return a timestamp, either the current time of SOURCE_DATE_EPOCH."
-  (match (getenv "SOURCE_DATE_EPOCH")
-    (#f
-     (current-time time-utc))
-    ((= string->number seconds)
-     (if seconds
-         (make-time time-utc 0 seconds)
-         (current-time time-utc)))))
+(define-inlinable (assert-integer proc in-range? key number)
+  (unless (integer? number)
+    (throw 'wrong-type-arg proc
+           "Wrong type argument ~A: ~S" (list key number)
+           (list number)))
+  (unless (in-range? number)
+    (throw 'out-of-range proc
+           "Integer ~A out of range: ~S" (list key number)
+           (list number))))
 
 (define* (sqlite-register db #:key path (references '())
                           deriver hash nar-size
@@ -279,15 +240,54 @@ (define* (sqlite-register db #:key path (references '())
 the database or #f, meaning \"right now\".
 
 Every store item in REFERENCES must already be registered."
-  (let ((id (update-or-insert db #:path path
-                              #:deriver deriver
-                              #:hash hash
-                              #:nar-size nar-size
-                              #:time (time-second time))))
-    ;; Call 'path-id' on each of REFERENCES.  This ensures we get a
-    ;; "non-NULL constraint" failure if one of REFERENCES is unregistered.
-    (add-references db id
-                    (map (cut path-id db <>) references))))
+
+  (define registration-time
+    (time-second time))
+
+  ;; Make sure NAR-SIZE is valid.
+  (assert-integer "sqlite-register" positive? #:nar-size nar-size)
+  (assert-integer "sqlite-register" (cut >= <> 0) #:time registration-time)
+
+  (define id
+    (let ((existing-id (path-id db path)))
+      (if existing-id
+          (let ((stmt (sqlite-prepare
+                       db
+                       "
+UPDATE ValidPaths
+SET hash = :hash,
+    registrationTime = :time,
+    deriver = :deriver,
+    narSize = :size
+WHERE id = :id"
+                       #:cache? #t)))
+            (sqlite-bind-arguments stmt
+                                   #:id existing-id
+                                   #:deriver deriver
+                                   #:hash hash
+                                   #:size nar-size
+                                   #:time registration-time)
+            (sqlite-step-and-reset stmt)
+            existing-id)
+          (let ((stmt (sqlite-prepare
+                       db
+                       "
+INSERT INTO ValidPaths (path, hash, registrationTime, deriver, narSize)
+VALUES (:path, :hash, :time, :deriver, :size)"
+                       #:cache? #t)))
+            (sqlite-bind-arguments stmt
+                                   #:path path
+                                   #:deriver deriver
+                                   #:hash hash
+                                   #:size nar-size
+                                   #:time registration-time)
+            (sqlite-step-and-reset stmt)
+            (last-insert-row-id db)))))
+
+  ;; Call 'path-id' on each of REFERENCES.  This ensures we get a
+  ;; "non-NULL constraint" failure if one of REFERENCES is unregistered.
+  (add-references db id
+                  (map (cut path-id db <>) references)))
 
 
 ;;;
-- 
2.41.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at 69292 <at> debbugs.gnu.org:


Received: (at 69292) by debbugs.gnu.org; 20 Feb 2024 19:39:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 20 14:39:34 2024
Received: from localhost ([127.0.0.1]:46608 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rcVxl-0002Qn-OD
	for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:39:34 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43142)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rcVxi-0002QW-6i
 for 69292 <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:39:32 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id BAD1627BBEB
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 6e2d8eda
 for <69292 <at> debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
To: 69292 <at> debbugs.gnu.org
Subject: [PATCH 4/6] store: database: Stop finalizing prepared statements.
Date: Tue, 20 Feb 2024 19:39:04 +0000
Message-ID: <c4bf41b5c91623ee93285f35516265cfdb0ab401.1708457946.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69292
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

Especially since we're asking for these to be cached.

Management of prepared statements isn't trivial, since you don't want to keep
them forever as this can lead to poor query performance, but I don't think
that finalizing them immediately is the right solution.

Change-Id: I61706b4d09d771835bb8f074b8f6a6ee871f5e2d

* guix/store/database.scm (sqlite-step-and-reset): New procedure.
(last-insert-row, path-id, update-or-insert, add-references): Don't finalize
prepared statements.

Change-Id: I2a2c6deb43935d67df9e43000a5105343d72b3e6
---
 guix/store/database.scm | 40 ++++++++++++++++++----------------------
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/guix/store/database.scm b/guix/store/database.scm
index 7e3a2873ce..8d8b7346e0 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -167,16 +167,19 @@ (define-syntax with-database
     ((_ file db exp ...)
      (call-with-database file (lambda (db) exp ...)))))
 
+(define (sqlite-step-and-reset statement)
+  (let ((val (sqlite-step statement)))
+    (sqlite-reset statement)
+    val))
+
 (define (last-insert-row-id db)
   ;; XXX: (sqlite3) currently lacks bindings for 'sqlite3_last_insert_rowid'.
   ;; Work around that.
-  (let* ((stmt   (sqlite-prepare db "SELECT last_insert_rowid();"
-                                 #:cache? #t))
-         (result (sqlite-fold cons '() stmt)))
-    (sqlite-finalize stmt)
-    (match result
-      ((#(id)) id)
-      (_ #f))))
+  (let ((stmt (sqlite-prepare db
+                              "SELECT last_insert_rowid();"
+                              #:cache? #t)))
+    (vector-ref (sqlite-step-and-reset stmt)
+                0)))
 
 (define* (path-id db path)
   "If PATH exists in the 'ValidPaths' table, return its numerical
@@ -187,11 +190,9 @@ (define* (path-id db path)
 SELECT id FROM ValidPaths WHERE path = :path"
                #:cache? #t)))
     (sqlite-bind-arguments stmt #:path path)
-    (let ((result (sqlite-fold cons '() stmt)))
-      (sqlite-finalize stmt)
-      (match result
-        ((#(id) . _) id)
-        (_ #f)))))
+    (match (sqlite-step-and-reset stmt)
+      (#(id) id)
+      (#f #f))))
 
 (define-inlinable (assert-integer proc in-range? key number)
   (unless (integer? number)
@@ -228,9 +229,8 @@ (define* (update-or-insert db #:key path deriver hash nar-size time)
           (sqlite-bind-arguments stmt #:id id
                                  #:deriver deriver
                                  #:hash hash #:size nar-size #:time time)
-          (sqlite-fold cons '() stmt)
-          (sqlite-finalize stmt)
-          (last-insert-row-id db))
+          (sqlite-step-and-reset stmt)
+          id)
         (let ((stmt (sqlite-prepare
                      db
                      "
@@ -240,8 +240,7 @@ (define* (update-or-insert db #:key path deriver hash nar-size time)
           (sqlite-bind-arguments stmt
                                  #:path path #:deriver deriver
                                  #:hash hash #:size nar-size #:time time)
-          (sqlite-fold cons '() stmt)             ;execute it
-          (sqlite-finalize stmt)
+          (sqlite-step-and-reset stmt)
           (last-insert-row-id db)))))
 
 (define (add-references db referrer references)
@@ -254,13 +253,10 @@ (define (add-references db referrer references)
 VALUES (:referrer, :reference)"
                #:cache? #t)))
     (for-each (lambda (reference)
-                (sqlite-reset stmt)
                 (sqlite-bind-arguments stmt #:referrer referrer
                                        #:reference reference)
-                (sqlite-fold cons '() stmt)       ;execute it
-                (last-insert-row-id db))
-              references)
-    (sqlite-finalize stmt)))
+                (sqlite-step-and-reset stmt))
+              references)))
 
 (define (timestamp)
   "Return a timestamp, either the current time of SOURCE_DATE_EPOCH."
-- 
2.41.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Feb 2024 19:31:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 20 14:31:54 2024
Received: from localhost ([127.0.0.1]:46586 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rcVqM-0002Eu-A7
	for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:31:54 -0500
Received: from lists.gnu.org ([209.51.188.17]:36826)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rcVqK-0002Ek-CI
 for submit <at> debbugs.gnu.org; Tue, 20 Feb 2024 14:31:53 -0500
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 <mail@HIDDEN>) id 1rcVpy-0004sR-6d
 for guix-patches@HIDDEN; Tue, 20 Feb 2024 14:31:30 -0500
Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27])
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <mail@HIDDEN>) id 1rcVpw-0007Xd-Lo
 for guix-patches@HIDDEN; Tue, 20 Feb 2024 14:31:29 -0500
Received: from localhost (unknown [212.132.255.10])
 by mira.cbaines.net (Postfix) with ESMTPSA id ED49D27BBE2
 for <guix-patches@HIDDEN>; Tue, 20 Feb 2024 19:31:25 +0000 (GMT)
Received: from felis (localhost.lan [127.0.0.1])
 by localhost (OpenSMTPD) with ESMTP id b3a37161
 for <guix-patches@HIDDEN>; Tue, 20 Feb 2024 19:31:25 +0000 (UTC)
User-agent: mu4e 1.10.8; emacs 29.1
From: Christopher Baines <mail@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 0/6] Prepare the database code for use in the daemon
Date: Tue, 20 Feb 2024 19:20:45 +0000
Message-ID: <87h6i3lyph.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
Received-SPF: pass client-ip=2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27;
 envelope-from=mail@HIDDEN; helo=mira.cbaines.net
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.2 (-----)

--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

These changes prepare the database module for use in a Guile
implementation of the guix-daemon.

There's quite a few procedures that need adding, but these changes just
adapt the existing functionality in to something that can be built on.


Christopher Baines (6):
  store: database: Remove call-with-savepoint and associated code.
  store: database: Remove with-statement and associated code.
  store: database: Inline SQL to where it's used.
  store: database: Stop finalizing prepared statements.
  store: database: Refactor sqlite-register.
  store: database: Rename a couple of procedures.

 .dir-locals.el          |   3 -
 guix/store/database.scm | 273 +++++++++++++++++-----------------------
 2 files changed, 112 insertions(+), 164 deletions(-)


base-commit: f4af19b037826cad90bbcfe400ad864f028cc7d8
=2D-=20
2.41.0

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmXU/gpfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9Xewow//ZcJ4ZCY790jv/n5viw4ucJgi/FFr98JY
dHQg0ygLvbtVAaTFROFg55+s8R4iZSPf5UKEYaxS4X8L5s7vSeN5CZirR9cEwGdh
LNyIzyvjqsUNxKvc1olI/36DRzduS2PIbW5nYBniO2eJ9RKp/3T8rTI+MBccT03N
giHSSM0Q9I/MHbmXzGIFDuoQvP+9+4sUwSVvUfk2gXMp4ZEud0oL4LKP/Jq4AJkI
fUqhQbiVhCHQOLR1okMhlFM1M5rSyOT5e+hFOWOVMw/jbl5Yy0YQ6mtCCsSjZi6g
UY2HOqnfx/uSUNJdfBcQoag6FBZ9nqSm3Zl7QTa2NGLs0TCEK22GzHhY5Fz/NC9b
Hx6Q9zMCC4K1FBhM+1lbNn/gEfNABf3MzQeTdUfqQSVey0Xr7EmGJ3hT6dBcEBNO
YPtDoTIAfyerNLG/OdHy/pdefZET/Rsh96A/02MZe5ySK5eBtrLC6jL/b7iSnGbg
UhKm9n1uV2AsNglExYE/LkdSLFcHdnzkDfwcD/+T45FHp+lyMadeYvpQEyYeLQ8r
mupawMZzcwySmfgYLJzDuRFLZkQW8P2w+TFKdOxiW6q2vgg6Ot7ZLbxLuccTW4n1
K455I8AOl3SBl10zVpM4Pc3/lBeRVqW3gX0riSLGYjYhPF6uu2UPSU16Ymu9ZAMJ
H//8GBe5NM4=
=rx2e
-----END PGP SIGNATURE-----
--=-=-=--




Acknowledgement sent to Christopher Baines <mail@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#69292; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 3 Apr 2024 17:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.