Skip to content

Commit 7c50014

Browse files
authored
Make serialization of blobs threadsafe (#256)
1 parent 03b526e commit 7c50014

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/SQLite.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,14 @@ struct Serialized
307307
object
308308
end
309309

310-
const GLOBAL_BUF = IOBuffer()
311310
function sqlserialize(x)
312-
seekstart(GLOBAL_BUF)
311+
buffer = IOBuffer()
313312
# deserialize will sometimes return a random object when called on an array
314313
# which has not been previously serialized, we can use this mutable struct to check
315314
# that the array has been serialized
316315
s = Serialized(x)
317-
Serialization.serialize(GLOBAL_BUF, s)
318-
return take!(GLOBAL_BUF)
316+
Serialization.serialize(buffer, s)
317+
return take!(buffer)
319318
end
320319
# fallback method to bind arbitrary julia `val` to the parameter at index `i` (object is serialized)
321320
bind!(stmt::_Stmt, i::Integer, val::Any) = bind!(stmt, i, sqlserialize(val))

0 commit comments

Comments
 (0)