Possible bug with in-memory database and shared cache
(1) By anonymous on 2020-05-25 21:42:11 [source]
Hi,
I have encountered a strange behavior when using in-memory databases with shared cache. If I open the database like this from multiple threads, everything works:
sqlite3_open_v2("file:foobar", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI | SQLITE_OPEN_MEMORY | SQLITE_OPEN_SHAREDCACHE, NULL);
If I remove either the SQLITE_OPEN_URI
flag OR the file:
prefix, the shared cache does not work anymore. The reason for this seems to be that:
- The flag is removed in
sqlite3ParseUri
for both cases (see https://github.com/sqlite/sqlite/blob/d63c76fb31a0e262fb12a93b171e95a4e30c1a2e/src/main.c#L3020). - The shared cache is only enabled if
SQLITE_OPEN_URI
is set insqlite3BtreeOpen
(see https://github.com/sqlite/sqlite/blob/d63c76fb31a0e262fb12a93b171e95a4e30c1a2e/src/btree.c#L2393).
Best regards, Michael Kuhn