5

I'm trying to create a database with journal mode set to WAL and disable shared memory by setting locking mode to EXCLUSIVE but I can't seem to make it work.

My connection string looks like this:

_connectionString = string.Format("Data Source={0};Synchronous=Off;Journal Mode=WAL; PRAGMA locking_mode=EXCLUSIVE", _databasePath);

When I start the application and the database gets created I still get a shm-file which I was under the impression wouldn't happen when using EXCLUSIVE as locking mode. I can also have the database open in multiple applications so no Exclusive lock seems to have been set.

I would appreciate if anyone could shed some light on this situation.

Edit to say I'm using System.Data.SQLite v-1.0.74.0 which is using SQLite v-3.7.7.1 so disabling shared memory in WAL mode should be implemented.

MKII
  • 892
  • 11
  • 36
Erik Karlstrand
  • 1,479
  • 9
  • 22

1 Answers1

2

Setting Locking Mode is not supported by the SQLiteConnection constructor. While it looks like it supports any generic Pragma statement they actually have a table of supported parameters you can send. They do support many Pragma statements but Locking Mode is not one of them.

for System.Data.SQLite their API is available for download at their website https://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki you will get it in a .chm file (remember to unblock if you are on windows 10 after downloading it)

Instead I would recommend executing Pragma statements as a separate query after creating and opening the connection for the SQLiteConnection object.

Per Hyyrynen
  • 81
  • 1
  • 14