pharo-rdbms / Pharo-SQLite3

Community-owned official SQLite3 binding for Pharo
MIT License
22 stars 20 forks source link

Reengineer text and blob bindings to avoid segfaults in Pharo 10 #54

Closed gcorriga closed 2 years ago

gcorriga commented 2 years ago

Reengineer the way we bind text and blob parameters to avoid segfaults in Pharo 10.

Instead of asking SQLite to take a copy of the parameters we fully manage the lifetime of those bound parameters.

We do so by using SQLITE_STATIC instead of SQLITE_TRANSIENT as the fifth argument to sqlite3_bind_text() and sqlite3_bind_blob(). To avoid lifetime issues (i.e. the Smalltalk objects being garbage collected while the statement object on the C side is still referring to them) we keep a cache of the bound parameters and clear that whenever we clear the bindings.

codecov[bot] commented 2 years ago

Codecov Report

Merging #54 (598c4f5) into master (d527cd6) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   78.68%   78.71%   +0.02%     
==========================================
  Files         107      107              
  Lines        4415     4444      +29     
==========================================
+ Hits         3474     3498      +24     
- Misses        941      946       +5     
Impacted Files Coverage Δ
src/SQLite3-Core/SQLite3Library.class.st 65.59% <100.00%> (-0.54%) :arrow_down:
src/SQLite3-Core/SQLite3PreparedStatement.class.st 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d527cd6...598c4f5. Read the comment docs.