如何在 SQLite 中将事务隔离级别设置为 ReadUncommited?
根据此帖子的答案,它指出:
您是否知道,除非您启用了共享缓存并且两个连接都来自同一线程,否则 ReadUncomfilled 将恢复为序列化隔离?
然后,我使用 C# 继续定义 DLL 导入,如下所示:
[DllImport("System.Data.SQLite.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int sqlite3_enable_shared_cache(int enable);
我调用此函数来启用缓存,并在调用时获得成功结果状态 0。尽管如此,在执行以下行并尝试将隔离级别设置为 ReadUncommissed 时,我仍然收到异常“isolationlevel”。
string connectionString = @"data source=d:\db\test.db3;datetimeformat=Ticks";
SQLiteConnection conn = new SQLiteConnection(connectionString);
conn.Open();
IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadUncommitted);
如何在 SQLite 中执行隔离级别为 ReadUncommissed 的查询?
According to the answer on this post it states:
Did you know that ReadUncommitted will revert to Serialized isolation unless you've enabled the shared cache and both connections are from the same thread?
Working in C#, I then went ahead and defined a DLL import as follows:
[DllImport("System.Data.SQLite.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int sqlite3_enable_shared_cache(int enable);
I called this function to enable the cache and got a successful result status of 0 when called. Nonetheless, I still get the exception "isolationlevel", when executing the below lines and attempting to set the isolation level to ReadUncommitted.
string connectionString = @"data source=d:\db\test.db3;datetimeformat=Ticks";
SQLiteConnection conn = new SQLiteConnection(connectionString);
conn.Open();
IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadUncommitted);
This question is related to another question I posted here.
How can I pull off a query with an isolation level of ReadUncommitted in SQLite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要完成未提交的读取,请参阅以下问题和答案:
如何在不锁定数据库的情况下使用数据读取器执行SQLite查询?
To accomplish uncommitted reads see the following question and answer:
How perform SQLite query with a data reader without locking database?