diff options
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index 9eaaa4a..828f9db 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -3323,13 +3323,14 @@ SELECT system FROM systems WHERE id = :id" (begin (unless (equal? (assq-ref derivation-details 'fixed-output?) fixed-output?) - (sqlite-exec - db - (simple-format #f - " -UPDATE derivations SET fixed_output = ~A WHERE name = '~A'" - (if fixed-output? 1 0) - derivation-name))) + (let ((statement (sqlite-prepare + db + " +UPDATE derivations SET fixed_output = :fixed_output WHERE name = :name" + #:cache? #t))) + (sqlite-bind-arguments statement + #:name derivation-name + #:fixed_output (if fixed-output? 1 0)))) 0) (let ((statement (sqlite-prepare @@ -3382,21 +3383,21 @@ INSERT OR IGNORE INTO derivations (name, system_id, fixed_output) (assoc-ref output-ids-by-name output-name)) (derivation-input-sub-derivations derivation-input)))) derivation-inputs))) - (sqlite-exec - db - (string-append - " -INSERT INTO derivation_inputs (derivation_id, derivation_output_id) VALUES " - (string-join - (map (lambda (derivation-output-id) - (simple-format - #f - "('~A', ~A)" - (db-find-derivation-id db derivation-name) - derivation-output-id)) - derivation-output-ids) - ", ") - ";"))))) + (let ((statement + (sqlite-prepare + db + " +INSERT INTO derivation_inputs (derivation_id, derivation_output_id) +VALUES (:derivation_id, :derivation_output_id)" + #:cache? #t))) + (for-each (lambda (derivation-output-id) + (sqlite-bind-arguments + statement + #:derivation_id (db-find-derivation-id db derivation-name) + #:derivation_output_id derivation-output-id) + (sqlite-step statement) + (sqlite-reset statement)) + derivation-output-ids))))) (define (db-insert-output db output) (let ((statement @@ -3485,24 +3486,25 @@ INSERT OR IGNORE INTO unbuilt_outputs (output_id) VALUES (:output_id)" (or (db-output->output-id db output) (db-insert-output db output)))))) - derivation-outputs))) - (sqlite-exec - db - (string-append - " -INSERT INTO derivation_outputs (derivation_id, name, output_id) VALUES " - (string-join - (map (match-lambda - ((name . output-id) - (simple-format - #f - "('~A', '~A', ~A)" - (db-find-derivation-id db derivation-name) - name - output-id))) - derivation-outputs-with-ids) - ", ") - ";")) + derivation-outputs)) + (statement + (sqlite-prepare + db + " +INSERT INTO derivation_outputs (derivation_id, name, output_id) + VALUES (:derivation_id, :name, :output_id)" + #:cache? #t))) + + (for-each (match-lambda + ((name . output-id) + (sqlite-bind-arguments + statement + #:derivation_id (db-find-derivation-id db derivation-name) + #:name name + #:output_id output-id) + (sqlite-step statement) + (sqlite-reset statement))) + derivation-outputs-with-ids) (for-each (lambda (output-id) (unless (output-has-successful-build? output-id) |