Skip to content

Make serialization of blobs threadsafe #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/SQLite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,14 @@ struct Serialized
object
end

const GLOBAL_BUF = IOBuffer()
function sqlserialize(x)
seekstart(GLOBAL_BUF)
buffer = IOBuffer()
# deserialize will sometimes return a random object when called on an array
# which has not been previously serialized, we can use this mutable struct to check
# that the array has been serialized
s = Serialized(x)
Serialization.serialize(GLOBAL_BUF, s)
return take!(GLOBAL_BUF)
Serialization.serialize(buffer, s)
return take!(buffer)
end
# fallback method to bind arbitrary julia `val` to the parameter at index `i` (object is serialized)
bind!(stmt::_Stmt, i::Integer, val::Any) = bind!(stmt, i, sqlserialize(val))
Expand Down