phiresky / sqlite-zstd

Transparent dictionary-based row-level compression for SQLite
GNU Lesser General Public License v3.0
1.43k stars 49 forks source link

cached dictionaries are global, need to be file-local (data loss) #1

Closed phiresky closed 2 years ago

phiresky commented 3 years ago

this means if the process has multiple different databases it will return the wrong dictionaries.

trivial solution is to make the cache local to each connection. better would be to make it local to each database, but i don't think there's an easy way to get a unique identifier for a database based on a connection (without storing some id in the db itself)

phiresky commented 3 years ago

To be precise, this cache (+ the decoder one):

https://github.com/phiresky/sqlite-zstd/blob/4b100ccb83a2249a4d3ca41f9e6205969bf41445/src/dict_management.rs#L41-L43

is currently keyed by (dictid, level), but it needs to be made specific to each database or to each connection (keyed by (connection, dictid, level)