delphi - 如何将 Firebird 事务隔离级别与 UIB 结合使用?

标签 delphi firebird uib

根据documents Firebird 中有四种事务隔离级别。但是,据我所知,uib 中没有明确的隔离级别选择。库(TUIBTransaction),但有一堆交易选项。我应该如何使用那些?某处有文档吗?

最佳答案

这些选项将改变隔离级别。正如 @Arioch 在他的紧凑评论中所说,您可以更改隔离级别,更改类型为 TTransParams 的属性 Options。这是一组TTransParam,如下所示。

 // Transaction parameters
TTransParam = (
{ prevents a transaction from accessing tables if they are written to by
other transactions.}
tpConsistency,
{ allows concurrent transactions to read and write shared data. }
tpConcurrency,
{ Concurrent, shared access of a specified table among all transactions. }
{$IFNDEF FB_21UP}
tpShared,
{ Concurrent, restricted access of a specified table. }
tpProtected,
tpExclusive,
{$ENDIF}
{ Specifies that the transaction is to wait until the conflicting resource
is released before retrying an operation [Default]. }
tpWait,
{ Specifies that the transaction is not to wait for the resource to be
released, but instead, should return an update conflict error immediately. }
tpNowait,
{ Read-only access mode that allows a transaction only to select data from tables. }
tpRead,
{ Read-write access mode of that allows a transaction to select, insert,
update, and delete table data [Default]. }
tpWrite,
{ Read-only access of a specified table. Use in conjunction with tpShared,
tpProtected, and tpExclusive to establish the lock option. }
tpLockRead,
{ Read-write access of a specified table. Use in conjunction with tpShared,
tpProtected, and tpExclusive to establish the lock option [Default]. }
tpLockWrite,
tpVerbTime,
tpCommitTime,
tpIgnoreLimbo,
{ Unlike a concurrency transaction, a read committed transaction sees changes
made and committed by transactions that were active after this transaction started. }
tpReadCommitted,
tpAutoCommit,
{ Enables an tpReadCommitted transaction to read only the latest committed
version of a record. }
tpRecVersion,
tpNoRecVersion,
tpRestartRequests,
tpNoAutoUndo
{$IFDEF FB20_UP}
,tpLockTimeout
{$ENDIF}
); 

自从 Interbase 6.0 代码“开源”以来,API 的文档没有太大变化。因此,如果您想了解其中任何一个的解释,您正在查找的文档可以在 Interbase 手册中找到。

您可以在这里获取它们 https://www.firebirdsql.org/en/reference-manuals/

下面我在 link 中引用了 Ann Harrison 的话对常用选项的快速解释:

isc_tpb_consistency can cause performance problems due the fact that it's locking tables and possibly excluding concurrent access. isc_tpb_concurrency is the design center for Firebird. Readers don't block writers, writers don't block readers, and both get a consistent view of the database.

isc_tpb_read_committed + isc_tpb_rec_version + isc_tbp_read_only give inconsistent results and occasionally produces an error on a blob read*, but unlike other modes, it does not block garbage collection so it's a good mode for long running read transactions that don't have to get the "right" answer.

isc_tpb_read_committeed + isc_tpb_rec_version has the same performance as isc_tpb_concurrency, but gets inconsistent results - the same query run twice in the same transaction may return different rows.

isc_tpb_read_committed + isc_tpb_no_rec_version + isc_tpb_wait is slower than other modes because it will wait for a change to be commited rather than reading the newest committed version. Like all variants of isc_tpb_read_committed, it does not produce consistent results.

isc_tpb_read_committed + isc_tpb_no_rec_version + isc_tpb_no_wait gives lots and lots of deadlock errors because every time a reader encounters a record that's being changed, it returns an error.

注意:我希望你能看到,除了参数命名不一样之外,如果去掉“isc_tpb_”部分,也不难理解。

关于delphi - 如何将 Firebird 事务隔离级别与 UIB 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14953013/

相关文章:

css - 如何更改uib轮播的高度宽度?

html - Delphi:解析此 html 表的一些提示?

delphi - vcl组合框并不总是显示它有焦点

java - 当函数没有返回值时,Delphi XE2 是否正确从 Java/Axis2 导入 WSDL?

delphi - 如果 RLink32 失败,如何链接巨大的 Res

sql - 我可以在 Where 子句中使用 Firebird DateAdd 函数吗?

sql - 如何更新日期时间字段以仅包含日期或时间部分

java - 我可以将 JBoss AS 5 或 6 与 Firebird 或 InterBase SQL 服务器一起使用吗?

swift - 模糊框架顶部和底部的 UiImageView

angularjs - 带组件的 UI 引导模式导致 "One of template or templateUrl options is required."错误