这些选项将改变隔离级别。正如 @Arioch 在他的紧凑评论中所说,您可以更改隔离级别,更改Options类型的属性TTransParams。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}
);
Run Code Online (Sandbox Code Playgroud)
自从 Interbase 6.0 代码“开源”以来,API 的文档没有太大变化。因此,如果您想了解其中任何一个的解释,您正在查找的文档可以在 Interbase 手册中找到。
您可以在这里获取它们https://www.firebirdsql.org/en/reference-manuals/
下面我在此链接中引用 Ann Harrison 的内容来快速解释常用选项:
isc_tpb_consistency 可能会导致性能问题,因为它会锁定表并可能排除并发访问。isc_tpb_concurrency是Firebird的设计中心。读取器不会阻止写入器,写入器也不会阻止读取器,并且两者都可以获得一致的数据库视图。
isc_tpb_read_commit + isc_tpb_rec_version + isc_tbp_read_only 给出不一致的结果,并且偶尔会在 blob read* 上产生错误,但与其他模式不同,它不会阻止垃圾收集,因此对于长时间运行的读取事务来说,这是一个很好的模式,不需要获得“正确的” “ 回答。
isc_tpb_read_committeed + isc_tpb_rec_version 与 isc_tpb_concurrency 具有相同的性能,但得到不一致的结果 - 在同一事务中运行两次的同一查询可能会返回不同的行。
isc_tpb_read_commissed + isc_tpb_no_rec_version + isc_tpb_wait 比其他模式慢,因为它将等待提交更改而不是读取最新提交的版本。与 isc_tpb_read_comfilled 的所有变体一样,它不会产生一致的结果。
isc_tpb_read_comfilled + isc_tpb_no_rec_version + isc_tpb_no_wait 会产生大量死锁错误,因为每次读取器遇到正在更改的记录时,它都会返回错误。
注意:我希望你能看到,除了参数命名不一样之外,如果去掉“isc_tpb_”部分,也不难理解。
| 归档时间: |
|
| 查看次数: |
1782 次 |
| 最近记录: |