guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cuirass news


From: Ludovic Courtès
Subject: Re: Cuirass news
Date: Thu, 08 Feb 2018 23:21:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hi Danny,

Danny Milosavljevic <address@hidden> skribis:

> On Thu, 08 Feb 2018 14:37:58 +0100
> address@hidden (Ludovic Courtès) wrote:
>> We’re 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=8c7c93922bbe0513ff4c4ff3a6e554e3a72635b6

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 ‘sqlite-finalize’ 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’re doing something
wrong, but I’m not sure what.  The same query in the ‘sqlite3’ CLI is
snappy and does not consume much memory.

One of the things we’re doing wrong is that ‘Outputs’ table: each
‘db-format-build’ call triggers a lookup in that table.  We should
instead probably simply store output lists in the ‘Derivations’ table.

Thoughts?

Which also means we should have schema versioning and a way to upgrade…

> 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:

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
?

At some point we’ll also need a real test suite in guile-sqlite3…

Ludo’.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]