From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Cuirass news Date: Thu, 08 Feb 2018 23:21:58 +0100 Message-ID: <871shvt94p.fsf@gnu.org> References: <877es6x5xj.fsf@gnu.org> <87lggmjjgo.fsf@gmail.com> <87k1w6jjak.fsf@gmail.com> <87h8raxeym.fsf@gnu.org> <20180126153005.259a75e8@scratchpost.org> <87zi4z1eb0.fsf@gnu.org> <20180127181852.42f0bcbf@scratchpost.org> <87fu6bwqix.fsf@gnu.org> <20180208172905.19e9e789@scratchpost.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejua5-0001Ut-6H for guix-devel@gnu.org; Thu, 08 Feb 2018 17:22:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejua2-0000Uh-2V for guix-devel@gnu.org; Thu, 08 Feb 2018 17:22:13 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:39194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejua1-0000Te-Px for guix-devel@gnu.org; Thu, 08 Feb 2018 17:22:09 -0500 In-Reply-To: <20180208172905.19e9e789@scratchpost.org> (Danny Milosavljevic's message of "Thu, 8 Feb 2018 17:29:05 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Danny Milosavljevic Cc: guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Danny, Danny Milosavljevic skribis: > On Thu, 08 Feb 2018 14:37:58 +0100 > ludo@gnu.org (Ludovic Court=C3=A8s) wrote: >> We=E2=80=99re making progress! :-) > > Nice! I'm still checking a few loose ends but I think we're pretty okay = now > from a security standpoint - except for db-get-builds, which I'm amending > right now. Oh sorry, I think I did the same thing as you were sending this message: https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git/commit/?id=3D8c7c= 93922bbe0513ff4c4ff3a6e554e3a72635b6 WDYT? > Also, I'd like to get the number of distinct SQL statements down, so I'll > propose another patch on guix-patches to do that. Excellent. > Also, I think sqlite-exec shouldn't call sqlite-finalize most of the time= - > otherwise the cached statement will be lost :P Indeed! Should we change =E2=80=98sqlite-finalize=E2=80=99 to a noop when = called on a cached statement? (Otherwise users would have to keep track of whether or not a statement is cached.) Besides, on the big database on berlin, the initial: (db-get-builds db '((status pending))) call takes a lot of time and memory. I guess we=E2=80=99re doing something wrong, but I=E2=80=99m not sure what. The same query in the =E2=80=98sqlit= e3=E2=80=99 CLI is snappy and does not consume much memory. One of the things we=E2=80=99re doing wrong is that =E2=80=98Outputs=E2=80= =99 table: each =E2=80=98db-format-build=E2=80=99 call triggers a lookup in that table. We= should instead probably simply store output lists in the =E2=80=98Derivations=E2= =80=99 table. Thoughts? Which also means we should have schema versioning and a way to upgrade=E2= =80=A6 > I've also reintroduced sqlite-bind-args in a nicer version, please pull: > https://notabug.org/civodul/guile-sqlite3/pulls/3 . It is OK with you to write it like this: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/sqlite3.scm b/sqlite3.scm index 156c461..fa96bdb 100644 --- a/sqlite3.scm +++ b/sqlite3.scm @@ -38,6 +38,7 @@ sqlite-prepare* sqlite-prepare sqlite-bind + sqlite-bind-arguments sqlite-column-names sqlite-step sqlite-fold @@ -390,6 +391,21 @@ (error "unexpected value" val))) (check-error (stmt->db stmt)))))) +(define (sqlite-bind-arguments stmt . args) + "Bind STMT parameters, one after another, to ARGS. +Also bind named parameters to the respective ones." + (let loop ((i 1) + (args args)) + (match args + (() + #f) + (((? keyword? kw) value . rest) + (sqlite-bind stmt (keyword->symbol kw) value) + (loop i rest)) + ((arg . rest) + (sqlite-bind stmt i arg) + (loop (+ 1 i) rest))))) + (define sqlite-column-count (let ((column-count (pointer->procedure --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ? At some point we=E2=80=99ll also need a real test suite in guile-sqlite3=E2= =80=A6 Ludo=E2=80=99. --=-=-=--