guix-commits
[Top][All Lists]
Advanced

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

branch master updated: Guard against divide by 0 in update-derivation-ou


From: Christopher Baines
Subject: branch master updated: Guard against divide by 0 in update-derivation-outputs-statistics
Date: Mon, 28 Nov 2022 08:19:02 -0500

This is an automated email from the git hooks/post-receive script.

cbaines pushed a commit to branch master
in repository data-service.

The following commit(s) were added to refs/heads/master by this push:
     new 6ada1cb  Guard against divide by 0 in 
update-derivation-outputs-statistics
6ada1cb is described below

commit 6ada1cb8456950460d483e04f90f64f787cfd53b
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Mon Nov 28 13:17:20 2022 +0000

    Guard against divide by 0 in update-derivation-outputs-statistics
---
 guix-data-service/model/derivation.scm | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/guix-data-service/model/derivation.scm 
b/guix-data-service/model/derivation.scm
index 05cb9ea..05a94e3 100644
--- a/guix-data-service/model/derivation.scm
+++ b/guix-data-service/model/derivation.scm
@@ -1965,16 +1965,17 @@ SELECT COUNT(DISTINCT derivation_id), COUNT(*) FROM 
derivation_outputs"))
     (match (exec-query conn query)
       (((derivation_id_count all_count))
 
-       (exec-query
-        conn
-        (format
-         #f
-         "
+       (unless (< (string->number all_count) 1)
+         (exec-query
+          conn
+          (format
+           #f
+           "
 ALTER TABLE derivation_outputs
   ALTER COLUMN derivation_id
   SET (n_distinct = ~7f)"
-         (* -1 (/ (string->number derivation_id_count)
-                  (string->number all_count)))))))))
+           (* -1 (/ (string->number derivation_id_count)
+                    (string->number all_count))))))))))
 
 (define (vacuum-derivation-outputs-table conn)
   (exec-query



reply via email to

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