2013-02-19 84 views
4

根據documents在Firebird中有四個事務隔離級別。不過,據我所知,在庫(TUIBTransaction)中沒有明確的隔離級別選擇,但是有很多事務選項可供選擇。我應該如何使用這些?有沒有文件?如何在UIB中使用Firebird事務隔離級別?

+2

您鏈接到的文檔實際上並沒有說Firebird具有四個隔離級別,它表示SQL標準定義了四個,但沒有Firebird處理此方法的直接映射。 – 2013-02-19 11:10:06

+0

你是對的。所以重新說一句:我正在尋找UIB中所有這些選項的文檔,以及它們與隔離級別的關係。 – Harriv 2013-02-19 11:20:18

+4

引用UIB:'const TR默認:TTransParams = [tpConcurrency,tpWait,tpWrite]; TRSnapShot:TTransParams = [tpConcurrency,tpNowait]; TRReadCommitted:TTransParams = [tpReadCommitted,tpRecVersion,tpNowait]; TRReadOnlyTableStability:TTransParams = [tpRead,tpConsistency]; TRReadWriteTableStability:TTransParams = [tpWrite,tpConsistency];' – 2013-02-19 12:53:43

回答

1

這些選項將會改變隔離級別。正如@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代碼「opensourced」,API文檔沒有多大變化。所以,如果你想解釋其中的任何一個,你正在尋找的文檔在Interbase手冊中。

你可以讓他們在這裏http://www.firebirdsql.org/en/reference-manuals/

下面我引用安哈里森在此link到平時的選項的簡單說明使用:

isc_tpb_consistency可能會由於一個事實,即它的性能問題鎖定表並可能排除併發訪問。 isc_tpb_concurrency是Firebird的設計中心。讀者不需要 塊編寫者,編寫者不會阻止讀者,並且兩者都獲得數據庫的一致性 視圖。

isc_tpb_read_committed + isc_tpb_rec_version + isc_tbp_read_only給 不一致的結果,有時會產生上一滴 讀*一個錯誤,但不同於其它的模式,它不會阻止垃圾收集所以 它讀長時間運行的一個很好的方式交易,唐」不得不 得到「正確」的答案。

isc_tpb_read_committeed + isc_tpb_rec_version具有相同的性能 爲isc_tpb_concurrency,但得到不一致的結果 - 在同一個事務同一查詢 運行兩次可能會返回不同的行。

isc_tpb_read_committed + isc_tpb_no_rec_version + isc_tpb_wait比其它模式慢 ,因爲它會等待一個變化是 COMMITED而不是閱讀最新提交的版本。與isc_tpb_read_committed的所有變體 一樣,它不會產生一致的 結果。

isc_tpb_read_committed + isc_tpb_no_rec_version + isc_tpb_no_wait 給許許多多死鎖錯誤的,因爲每一次 遇到真實被更改的記錄的讀者,它返回一個錯誤。

注意:我希望你能看到,除了參數沒有同樣命名外,如果刪除「isc_tpb_」部分並不難理解。