[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
11/13: squash! Keep store prefix in database.
From: |
guix-commits |
Subject: |
11/13: squash! Keep store prefix in database. |
Date: |
Sun, 21 May 2023 17:40:24 -0400 (EDT) |
civodul pushed a commit to branch wip-guix-index
in repository guix.
commit ca1d7a51cc793554db66ec0fe7558d412ac21c56
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))
- branch wip-guix-index created (now 5fc794ac94), guix-commits, 2023/05/21
- 06/13: squash! "with-method" -> "method", guix-commits, 2023/05/21
- 03/13: squash! Update test., guix-commits, 2023/05/21
- 05/13: squash! Improve error reporting and i18n., guix-commits, 2023/05/21
- 08/13: squash! Remove debugging statements., guix-commits, 2023/05/21
- 01/13: store: Tolerate non-existent GC root directories., guix-commits, 2023/05/21
- 07/13: squash! Don't insert directory if it's already present., guix-commits, 2023/05/21
- 10/13: squash! Do not insert the same directory more than once., guix-commits, 2023/05/21
- 11/13: squash! Keep store prefix in database.,
guix-commits <=
- 13/13: squash! Create database when it doesn't already exist., guix-commits, 2023/05/21
- 09/13: squash! Choose system-wide database if it's more recent., guix-commits, 2023/05/21
- 12/13: squash! Add one variant of each package (name/version pair)., guix-commits, 2023/05/21
- 02/13: DRAFT Add 'guix index'., guix-commits, 2023/05/21
- 04/13: squash! "--db-path" -> "--database"., guix-commits, 2023/05/21