Use bulk-insert for inserting derivation_sources
This commit is contained in:
parent
2fc20fa37e
commit
42ac51212f
1 changed files with 13 additions and 14 deletions
|
|
@ -1456,18 +1456,6 @@ ON CONFLICT DO NOTHING")))
|
||||||
query-parts)))
|
query-parts)))
|
||||||
|
|
||||||
(define (insert-derivation-sources conn derivation-id sources)
|
(define (insert-derivation-sources conn derivation-id sources)
|
||||||
(define (insert-into-derivation-sources derivation-source-file-ids)
|
|
||||||
(string-append
|
|
||||||
"INSERT INTO derivation_sources "
|
|
||||||
"(derivation_id, derivation_source_file_id) VALUES "
|
|
||||||
(string-join
|
|
||||||
(map (lambda (derivation-source-file-id)
|
|
||||||
(simple-format
|
|
||||||
#f "(~A, ~A)" derivation-id derivation-source-file-id))
|
|
||||||
(vector->list derivation-source-file-ids))
|
|
||||||
",")
|
|
||||||
"ON CONFLICT DO NOTHING;"))
|
|
||||||
|
|
||||||
(let ((sources-ids
|
(let ((sources-ids
|
||||||
(insert-missing-data-and-return-all-ids
|
(insert-missing-data-and-return-all-ids
|
||||||
conn
|
conn
|
||||||
|
|
@ -1476,8 +1464,19 @@ ON CONFLICT DO NOTHING")))
|
||||||
(list->vector
|
(list->vector
|
||||||
(map list sources)))))
|
(map list sources)))))
|
||||||
|
|
||||||
(exec-query conn
|
(bulk-insert
|
||||||
(insert-into-derivation-sources sources-ids))
|
conn
|
||||||
|
"derivation_sources"
|
||||||
|
'(derivation_id derivation_source_file_id)
|
||||||
|
(vector-fold
|
||||||
|
(lambda (_ result derivation-source-file-id)
|
||||||
|
(cons
|
||||||
|
(list derivation-id
|
||||||
|
derivation-source-file-id)
|
||||||
|
result))
|
||||||
|
'()
|
||||||
|
sources-ids)
|
||||||
|
#:returning #f)
|
||||||
|
|
||||||
sources-ids))
|
sources-ids))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue