From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 6Fs2OlIA1WXNAwEAe85BDQ:P1 (envelope-from ) for ; Tue, 20 Feb 2024 20:41:07 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 6Fs2OlIA1WXNAwEAe85BDQ (envelope-from ) for ; Tue, 20 Feb 2024 20:41:07 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708458066; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=U4BdhDvDYx2fOtY6ATYl3SKN2bprpWn4pkciYY/JOCM=; b=CwPUISoYVtcXh5Z3dwrxFqrY5o2CKwRsqtW08AK8/QIG7W0I0V+BMFIJhipzt+OoJNE46i r2dOJxzzhN0R7YhXF1g/lVH4WSviqgB1cSqcxdUgdAnYCuvlHZRglCEIHHPxVanfQJuzNP 00UT6gwAMde6IMmOGxUy0fGvjZK81LUULnh9+mv60wcGv5yuWQxUKqhT8MwijYG149U70h lZNim5Mrr051z8sa6eBhtkqAoxV3ZU0G9SkJ1JvwtPx/i9PxfD9sXi/fWXstPP/Xz7X0To GO9tEG8T9H3nMK0OjDQMeSQ+oFOrG4POVqK0B7HtdE3rw6Q3monWRMx+1HMV7w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708458066; a=rsa-sha256; cv=none; b=FvMjbRNUvCUm4cnw+jZObb4z7mLJSiNreNloaNfV6odixNfanssm1u+ZEFeZruXme1CjDm b9qgFREFeO2yQ27QwGAJs0439dvfoZrrlyUx92Xr7taAAD+2DHDwah8fiN/9ExpOM98ubG Gl/soIyrzb4ie8X3R47TLQWk6wZntjD2nXUWftLpLHTcuC6HKA6uGsGHxxyRIcOSyGw+IL 0rXlEdGOipOUPPiemgIQ9WDsoSm4Aqxd5d0ZsZuTz0CEieN0uXOuc/7cwux1ckQ0UtF33U 3p2LETnT2tiomxU3OUVdbhDl4He2IZY7RwK75Gem10XlRy/EIA9QhKj2nr3f5g== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B82DF21A6E for ; Tue, 20 Feb 2024 20:41:06 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcVz0-0002ts-5G; Tue, 20 Feb 2024 14:40:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcVys-0002kY-9z for guix-patches@gnu.org; Tue, 20 Feb 2024 14:40:43 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcVyq-0000oa-NP; Tue, 20 Feb 2024 14:40:41 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcVzC-0002V9-HD; Tue, 20 Feb 2024 14:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69292] [PATCH 6/6] store: database: Rename a couple of procedures. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 20 Feb 2024 19:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69292 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69292@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 69292-submit@debbugs.gnu.org id=B69292.17084580119508 (code B ref 69292); Tue, 20 Feb 2024 19:41:02 +0000 Received: (at 69292) by debbugs.gnu.org; 20 Feb 2024 19:40:11 +0000 Received: from localhost ([127.0.0.1]:46640 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcVyM-0002TC-IB for submit@debbugs.gnu.org; Tue, 20 Feb 2024 14:40:11 -0500 Received: from mira.cbaines.net ([212.71.252.8]:43152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcVyE-0002S4-Lf for 69292@debbugs.gnu.org; Tue, 20 Feb 2024 14:40:04 -0500 Received: from localhost (unknown [212.132.255.10]) by mira.cbaines.net (Postfix) with ESMTPSA id C60D227BBED for <69292@debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 9b5e01bd for <69292@debbugs.gnu.org>; Tue, 20 Feb 2024 19:39:07 +0000 (UTC) From: Christopher Baines Date: Tue, 20 Feb 2024 19:39:06 +0000 Message-ID: <12f872394c84039fa553e50381d040de24f24d3e.1708457946.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@cbaines.net> References: <4b6a268daab5e0b307dff2229d551a47c9fe1ebc.1708457946.git.mail@cbaines.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -1.61 X-Spam-Score: -1.61 X-Migadu-Queue-Id: B82DF21A6E X-TUID: pDk1r+ulT2y/ These names should be more descriptive. * guix/store/database.scm (path-id): Rename to select-valid-path-id. (sqlite-register): Rename to register-valid-path. (register-items): Update accordingly. Change-Id: I6d4a14d4cde9d71ab34d6ffdbfbfde51b2c0e1db --- guix/store/database.scm | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/guix/store/database.scm b/guix/store/database.scm index 0b570eabcd..0190696ad5 100644 --- a/guix/store/database.scm +++ b/guix/store/database.scm @@ -40,8 +40,10 @@ (define-module (guix store database) store-database-file call-with-database with-database - path-id - sqlite-register + + select-valid-path-id + + register-valid-path register-items %epoch reset-timestamps @@ -181,9 +183,9 @@ (define (last-insert-row-id db) (vector-ref (sqlite-step-and-reset stmt) 0))) -(define* (path-id db path) - "If PATH exists in the 'ValidPaths' table, return its numerical -identifier. Otherwise, return #f." +(define (select-valid-path-id db path) + "If PATH exists in the 'ValidPaths' table, return its numerical identifier. +Otherwise, return #f." (let ((stmt (sqlite-prepare db " @@ -229,9 +231,9 @@ (define-inlinable (assert-integer proc in-range? key number) "Integer ~A out of range: ~S" (list key number) (list number)))) -(define* (sqlite-register db #:key path (references '()) - deriver hash nar-size - (time (timestamp))) +(define* (register-valid-path db #:key path (references '()) + deriver hash nar-size + (time (timestamp))) "Registers this stuff in DB. PATH is the store item to register and REFERENCES is the list of store items PATH refers to; DERIVER is the '.drv' that produced PATH, HASH is the base16-encoded Nix sha256 hash of @@ -249,7 +251,7 @@ (define* (sqlite-register db #:key path (references '()) (assert-integer "sqlite-register" (cut >= <> 0) #:time registration-time) (define id - (let ((existing-id (path-id db path))) + (let ((existing-id (select-valid-path-id db path))) (if existing-id (let ((stmt (sqlite-prepare db @@ -287,7 +289,8 @@ (define* (sqlite-register db #:key path (references '()) ;; Call 'path-id' on each of REFERENCES. This ensures we get a ;; "non-NULL constraint" failure if one of REFERENCES is unregistered. (add-references db id - (map (cut path-id db <>) references))) + (map (cut select-valid-path-id db <>) references))) + ;;; @@ -364,18 +367,18 @@ (define* (register-items db items ;; When TO-REGISTER is already registered, skip it. This makes a ;; significant differences when 'register-closures' is called ;; consecutively for overlapping closures such as 'system' and 'bootcfg'. - (unless (path-id db to-register) + (unless (select-valid-path-id db to-register) (let-values (((hash nar-size) (nar-sha256 real-file-name))) (call-with-retrying-transaction db (lambda () - (sqlite-register db #:path to-register - #:references (store-info-references item) - #:deriver (store-info-deriver item) - #:hash (string-append - "sha256:" - (bytevector->base16-string hash)) - #:nar-size nar-size - #:time registration-time)))))) + (register-valid-path db #:path to-register + #:references (store-info-references item) + #:deriver (store-info-deriver item) + #:hash (string-append + "sha256:" + (bytevector->base16-string hash)) + #:nar-size nar-size + #:time registration-time)))))) (let* ((prefix (format #f "registering ~a items" (length items))) (progress (progress-reporter/bar (length items) -- 2.41.0