[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
11/20: squash! Keep store prefix in database.
From: |
guix-commits |
Subject: |
11/20: squash! Keep store prefix in database. |
Date: |
Sun, 4 Jun 2023 17:34:41 -0400 (EDT) |
civodul pushed a commit to branch wip-guix-index
in repository guix.
commit 24f86dded744cd9bee46729ef9240f99a02b428c
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun May 21 18:07:48 2023 +0200
squash! Keep store prefix in database.
This shaves 1 MiB out of 149 MiB...
---
guix/scripts/index.scm | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/guix/scripts/index.scm b/guix/scripts/index.scm
index 37f1ef9c15..c4996815b5 100644
--- a/guix/scripts/index.scm
+++ b/guix/scripts/index.scm
@@ -63,7 +63,8 @@
"
create table if not exists SchemaVersion (
version integer primary key not null,
- date date,
+ date date,
+ store text not null, -- value of (%store-prefix)
unique (version)
);
@@ -131,11 +132,13 @@ add column output text;
"Insert application VERSION into the DB."
(define stmt-insert-version
(sqlite-prepare db "\
-INSERT OR IGNORE INTO SchemaVersion(version, date)
-VALUES (:version, CURRENT_TIMESTAMP);"
+INSERT OR IGNORE INTO SchemaVersion(version, date, store)
+VALUES (:version, CURRENT_TIMESTAMP, :store);"
#:cache? #t))
(sqlite-exec db "begin immediate;")
- (sqlite-bind-arguments stmt-insert-version #:version version)
+ (sqlite-bind-arguments stmt-insert-version
+ #:version version
+ #:store (%store-prefix))
(sqlite-fold (const #t) #t stmt-insert-version)
(sqlite-exec db "commit;"))
@@ -208,7 +211,7 @@ VALUES (:name, :basename, :directory);"
;; DIRECTORY is missing so insert it and traverse it.
(sqlite-reset stmt-insert-directory)
(sqlite-bind-arguments stmt-insert-directory
- #:name directory
+ #:name (store-path-base directory)
#:package package-id)
(sqlite-fold (const #t) #t stmt-insert-directory)
@@ -336,12 +339,22 @@ ON f.basename = :file
AND d.id = f.directory
AND p.id = d.package;"))
+ (define prefix
+ (match (sqlite-fold (lambda (value _) value)
+ #f
+ (sqlite-prepare db "SELECT store FROM SchemaVersion;"))
+ (#(prefix) prefix)))
+
(sqlite-bind-arguments lookup-stmt #:file file)
(sqlite-fold (lambda (result lst)
(match result
(#(package version output directory file)
- (cons (package-match package version output
- (string-append directory "/" file))
+ (cons (package-match package version
+ (match output
+ ("" "out")
+ (_ output))
+ (string-append prefix "/"
+ directory "/" file))
lst))))
'() lookup-stmt))
- 13/20: squash! Create database when it doesn't already exist., (continued)
- 13/20: squash! Create database when it doesn't already exist., guix-commits, 2023/06/04
- 16/20: squash! Simplify '--help'., guix-commits, 2023/06/04
- 18/20: squash! Optimize 'insert-package'., guix-commits, 2023/06/04
- 19/20: squash! Show output name except for "out"; remove '-d'., guix-commits, 2023/06/04
- 02/20: DRAFT Add 'guix index'., guix-commits, 2023/06/04
- 03/20: squash! Update test., guix-commits, 2023/06/04
- 05/20: squash! Improve error reporting and i18n., guix-commits, 2023/06/04
- 01/20: store: Tolerate non-existent GC root directories., guix-commits, 2023/06/04
- 06/20: squash! "with-method" -> "method", guix-commits, 2023/06/04
- 09/20: squash! Choose system-wide database if it's more recent., guix-commits, 2023/06/04
- 11/20: squash! Keep store prefix in database.,
guix-commits <=
- 15/20: squash! Rename to 'guix locate'., guix-commits, 2023/06/04
- 17/20: squash! Migrate schema when opening., guix-commits, 2023/06/04
- 20/20: squash! Document., guix-commits, 2023/06/04
- 10/20: squash! Do not insert the same directory more than once., guix-commits, 2023/06/04
- 14/20: squash! Remove actions; auto-update database when needed., guix-commits, 2023/06/04