使用时,TFDConnection似乎没有设置LOCK TIMEOUT
TFDConnection.UpdateOptions.LockMode := lmPessimistic;
TFDConnection.UpdateOptions.LockWait := true;
TFDTransaction
似乎也没有属性。The Firebird SET TRANSACTION documentation建议您可以设置LOCK TIMEOUT。
在设置超时属性方面我是否可以忽略,还是在打开连接后不得不执行
SET TRANSACTION LOCK TIMEOUT
?如果我在FireDAC.Phys.IB * .pas文件中四处浏览,我会看到对
isc_tpb_lock_timeout
的引用,但无法使用它们? 最佳答案
可以通过IBAdvanced参数定义(请参见Connect to Interbase (FireDAC)):
';'分隔的附加参数列表。您可以在FireDAC.Phys.IBWrapper单元中找到支持的参数的完整列表(请参阅DPBInfos常量数组)。您可以在Interbase手册中找到列出的每个代码的描述。
这是FireDAC.Phys.IBWrapper
中定义它们的部分*:
const
TRPBInfo_Items = 24;
TRPBInfos: array[1 .. TRPBInfo_Items] of TIBPBInfo = (
(Name: 'consistency'; ParamType: prNoneNoZ; Code: isc_tpb_consistency),
(Name: 'concurrency'; ParamType: prNoneNoZ; Code: isc_tpb_concurrency),
(Name: 'shared'; ParamType: prNoneNoZ; Code: isc_tpb_shared),
(Name: 'protected'; ParamType: prNoneNoZ; Code: isc_tpb_protected),
(Name: 'exclusive'; ParamType: prNoneNoZ; Code: isc_tpb_exclusive),
(Name: 'wait'; ParamType: prNoneNoZ; Code: isc_tpb_wait),
(Name: 'nowait'; ParamType: prNoneNoZ; Code: isc_tpb_nowait),
(Name: 'read'; ParamType: prNoneNoZ; Code: isc_tpb_read),
(Name: 'write'; ParamType: prNoneNoZ; Code: isc_tpb_write),
(Name: 'lock_read'; ParamType: prStrg; Code: isc_tpb_lock_read),
(Name: 'lock_write'; ParamType: prStrg; Code: isc_tpb_lock_write),
(Name: 'verb_time'; ParamType: prNoneNoZ; Code: isc_tpb_verb_time),
(Name: 'commit_time'; ParamType: prNoneNoZ; Code: isc_tpb_commit_time),
(Name: 'ignore_limbo'; ParamType: prNoneNoZ; Code: isc_tpb_ignore_limbo),
(Name: 'read_committed'; ParamType: prNoneNoZ; Code: isc_tpb_read_committed),
(Name: 'autocommit'; ParamType: prNoneNoZ; Code: isc_tpb_autocommit),
(Name: 'rec_version'; ParamType: prNoneNoZ; Code: isc_tpb_rec_version),
(Name: 'no_rec_version'; ParamType: prNoneNoZ; Code: isc_tpb_no_rec_version),
(Name: 'restart_requests'; ParamType: prNoneNoZ; Code: isc_tpb_restart_requests),
(Name: 'no_auto_undo'; ParamType: prNoneNoZ; Code: isc_tpb_no_auto_undo),
// IB75
(Name: 'no_savepoint'; ParamType: prNoneNoZ; Code: isc_tpb_no_savepoint),
// FB20
(Name: 'lock_timeout'; ParamType: prCard; Code: isc_tpb_lock_timeout),
// IB2017
(Name: 'exclusivity'; ParamType: prNoneNoZ; Code: isc_tpb_exclusive),
(Name: 'wait_time'; ParamType: prCard; Code: isc_tpb_wait_time)
);
因此,例如5秒超时:
TFDConnection.Params.Add('IBAdvanced=lock_timeout=5');
*请注意,文档指出它们在DPBInfos中,但在TRPBInfos中。
关于delphi - 如何使用FireDAC为Firebird(InterBase)设置事务锁定超时?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47755210/