From 4857a8b0d72c821d581fdff6d6a0260c4a945fba Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 29 Aug 2026 13:51:12 +0200 Subject: [PATCH 1/3] Blobs go through read-array and write-array babashka.ffi replaced read-bytes and write-bytes with read-array and write-array, which take the element type; :byte is the case blobs need. The ffi dependency points at the bulk-arrays branch for now and moves to the merge commit once babashka/ffi has it. --- deps.edn | 2 +- src/babashka/sqlite.clj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deps.edn b/deps.edn index 910fb54..f0ba48c 100644 --- a/deps.edn +++ b/deps.edn @@ -3,7 +3,7 @@ ;; babashka/ffi repository. :deps {io.github.babashka/ffi {:git/url "https://github.com/babashka/ffi" - :git/sha "40fcd2784b94a062e98b4de29431450e852c57ca"}} + :git/sha "01f20a5bc6ca9c40bb60aa4c2401f39dd69a602d"}} :aliases {:test {:extra-paths ["test"] :extra-deps {io.github.cognitect-labs/test-runner diff --git a/src/babashka/sqlite.clj b/src/babashka/sqlite.clj index bc833c1..c9dcba1 100644 --- a/src/babashka/sqlite.clj +++ b/src/babashka/sqlite.clj @@ -140,7 +140,7 @@ ^bytes [n p] (if (pos? n) ;; a pointer from C has size 0; give it the blob's size first - (ffi/read-bytes (ffi/reinterpret p n) n) + (ffi/read-array (ffi/reinterpret p n) :byte n) (byte-array 0))) ;; sqlite types values per cell, not per column @@ -166,7 +166,7 @@ (bytes? v) (with-open [arena (ffi/confined-arena)] (let [n (alength ^bytes v) p (ffi/alloc arena (max n 1))] - (ffi/write-bytes p v) + (ffi/write-array p :byte v) (c-bind-blob stmt i p n sqlite-transient))) :else (throw (ex-info (str "sqlite3: cannot bind " (type v)) {:value v})))] @@ -227,7 +227,7 @@ (bytes? v) (with-open [arena (ffi/confined-arena)] (let [n (alength ^bytes v) p (ffi/alloc arena (max n 1))] - (ffi/write-bytes p v) + (ffi/write-array p :byte v) (c-result-blob ctx p n sqlite-transient))) :else (c-result-error ctx (str "cannot return " (type v) " from a function") -1))) From b849209f334d7a75bb8094704d2478cdea3bd8cd Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 29 Aug 2026 13:53:33 +0200 Subject: [PATCH 2/3] Pin babashka/ffi to the bulk arrays merge --- deps.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.edn b/deps.edn index f0ba48c..9f65b0c 100644 --- a/deps.edn +++ b/deps.edn @@ -3,7 +3,7 @@ ;; babashka/ffi repository. :deps {io.github.babashka/ffi {:git/url "https://github.com/babashka/ffi" - :git/sha "01f20a5bc6ca9c40bb60aa4c2401f39dd69a602d"}} + :git/sha "e4700ac776a61f7f3a7755fafa5784a2f86f6d137"}} :aliases {:test {:extra-paths ["test"] :extra-deps {io.github.cognitect-labs/test-runner From 93d4d2db28d4549ee48761e41223db5f144dffc6 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 29 Aug 2026 13:53:47 +0200 Subject: [PATCH 3/3] Fix the ffi sha: the previous commit had 41 characters --- deps.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.edn b/deps.edn index 9f65b0c..9f96b7b 100644 --- a/deps.edn +++ b/deps.edn @@ -3,7 +3,7 @@ ;; babashka/ffi repository. :deps {io.github.babashka/ffi {:git/url "https://github.com/babashka/ffi" - :git/sha "e4700ac776a61f7f3a7755fafa5784a2f86f6d137"}} + :git/sha "e4700ac76a61f7f3a7755fafa5784a2f86f6d137"}} :aliases {:test {:extra-paths ["test"] :extra-deps {io.github.cognitect-labs/test-runner