【问题标题】:How set transaction isolation level to ReadUncommitted in SQLite?如何在 SQLite 中将事务隔离级别设置为 ReadUncommitted?
【发布时间】:2011-07-19 06:40:30
【问题描述】:

根据post 上的答案,它指出:

您是否知道除非您启用了共享缓存并且两个连接都来自同一个线程,否则 ReadUncommitted 将恢复为序列化隔离?

在 C# 中工作,然后我继续定义了一个 DLL 导入,如下所示:

[DllImport("System.Data.SQLite.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int sqlite3_enable_shared_cache(int enable);

我调用了这个函数来启用缓存,调用时成功的结果状态为0。尽管如此,在执行以下几行并尝试将隔离级别设置为 ReadUncommitted 时,我仍然收到异常“isolationlevel”。

string connectionString = @"data source=d:\db\test.db3;datetimeformat=Ticks";
SQLiteConnection conn = new SQLiteConnection(connectionString);
conn.Open();
IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadUncommitted);

这个问题与我在here发布的另一个问题有关。

如何在 SQLite 中以 ReadUncommitted 隔离级别执行查询?

【问题讨论】:

  • 您能否在 BeginTransaction 之后显示更多源代码?您将 conn.BeginTransaction 分配给接口而不是具体类型有什么原因吗?
  • 实际上我使用的是提供者工厂,但为了这篇文章,我简化了代码以隔离异常。异常发生在对 conn.BeginTransaction(IsolationLevel.ReadUncommited) 的调用上。虽然我可以发布更多代码,但我不清楚为什么这之后的代码是相关的。

标签: c# sqlite isolation-level read-uncommitted


【解决方案1】:

要完成未提交的读取,请参阅以下问题和答案:

How perform SQLite query with a data reader without locking database?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-20
    • 1970-01-01
    • 2012-04-22
    • 2016-01-20
    • 2011-12-17
    • 2011-03-31
    • 1970-01-01
    相关资源
    最近更新 更多