gpt4 book ai didi

delphi - 如何使用 FireDAC 设置 Firebird (InterBase) 的事务锁定超时?

转载 作者:行者123 更新时间:2023-12-01 16:05:30 28 4
gpt4 key购买 nike

使用时,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) ):

The ';' separated list of additional parameters. You can find the full list of the supported parameters in the FireDAC.Phys.IBWrapper unit (see the DPBInfos constant array). You can find the description of each Code listed there in the Interbase manuals.

这是 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com