Subject: Re: [bug#70494] [PATCH 10/23] store: database: Add procedures for querying valid paths.

From: Ludovic Courtès <[email-masked]>
Date: Thu, 16 May 2024 18:04:40 +0200

Hi again! :-)

Christopher Baines <[email-masked]> skribis:

> * guix/store/database.scm (valid-path, all-valid-paths,
> valid-path-from-hash-part, valid-path-references): New procedures.
>
> Change-Id: Ib08837ee20f5a5a24a8089e611b5d67b003b62cc

[...]

> +(define (valid-path db store-filename)

Please add docstrings to top-level procedures (info "(guix) Formatting
Code").

> +  (let ((statement
> +         (sqlite-prepare
> +          db
> +          "
> +SELECT id, hash, registrationTime, deriver, narSize
> +FROM ValidPaths
> +WHERE path = :path"
> +          #:cache? #t)))
> +
> +    (sqlite-bind-arguments
> +     statement
> +     #:path store-filename)
> +
> +    (let ((result (sqlite-step statement)))
> +      (sqlite-reset statement)
> +
> +      result)))

Am I right that this returns a vector of 4 elements?

If that’s the case, it should instead return a <valid-path> record (or
similar), and that should be consistent across the interface (except in
case where we explicitly want an ID as input.)  We’d rather not expose
SQLite-related implementation details.

Ludo’.