TFDTable编辑失败,Firebird 2.5.7而非2.5.3

时间:2018-07-04 08:50:38

标签: delphi firebird firedac delphi-10.2-tokyo

此代码:

FDConnection.Open;      // Design time TFDConnection; default settings
TabelGrid.Close;        // TDFTable connected to TFDConnection; default settings
TabelGrid.TableName := 'TT_ACT';
TabelGrid.Open;
TabelGrid.Edit;
TabelGrid.FieldByName('TT_NAME').AsString := TabelGrid.FieldByName('TT_NAME').AsString + '*';
TabelGrid.Post;

失败

[FireDAC][Phys][IB]-312 Exact update affected [0] rows, while [1] was requested    

在安装Firebird 2.5.7时,不是,在安装Firebird 2.5.3时。

调用堆栈:

enter image description here

条件:

  • TFDConnection指向本地.GDB文件,驱动程序ID IB或FB,默认sysdba密码以及所有默认设置。出现TFDPhysIBDriverLinkTFDPhysFBDriverLink
  • Delphi Tokyo 10.2.3 Win32代码,Windows 7
  • 安装了Firebird,并带有将gds32.dll放入System32的选项; 周围有虚假的Firebird DLL
  • 系统上不存在Interbase

该表具有3个索引:

TT_I0_ACT                TT_ACT_ID                Primary
TT_I1_ACT                TT_PARENT_ID             
TT_I2_ACT                TT_FROMDATE 

我对设置感到困惑,特别是将默认的UpdateOptions.UpdateModeUpWhereKeyOnly更改为UpWhereChangedUpWhereAll,但到目前为止没有结果。

怎么回事?我还能调查什么?

我们通过应用程序分发了Firebird 2.5.3,但恐怕如果客户端已有更高版本(如我们的开发人员升级FB时发现的那样),它将失败。

其他研究:

在两个版本的TFDPhysCommandAsyncExecute.ExecuteFireDAC.Phys.pas)中看到的查询是(使用默认的UpWhereKey更新模式):

UPDATE TT_ACT SET TT_NAME = :NEW_TT_NAME WHERE RDB$DB_KEY = :OLD_DB_KEY

(实际上,所有FCommand属性在检查器中都显示相同)。

我浏览了Firebird 2.5.x. release notes,发现2.5.6中只有一个与之相关:

The number of affected rows was reported incorrectly for an update against a view created WITH CHECK OPTION

我不确定这是否适用,因为它与视图有关。将UpdateOptions.CountUpdatedOptions设置为false没什么区别。

2.5.8修复程序列表中没有任何内容指示2.5.4-2.5.7版本中引入了相关的错误。


我已将FireDAC代码跟踪到2.5.3和2.5.7中执行有所不同的地方,但以无法跟踪的接口方法结束:

TFDTable.InternalPost
TFDDataSet.InternalPost
TFDAdaptedDataSet.DoProcessUpdateRequest(arUpdate
TFDCustomTableAdapter.Update
TFDCustomTableAdapter.UpdateAdapterCmds(const ACmds: array of TFDActionRequest);
  ACmds contains (arUpdate, arFetchRow)
back to TFDCustomTableAdapter.Update  
TFDDAptTableAdapter.Update
TFDDAptTableAdapter.ProcessUpdate
  In the 'build command if required' part
  oCmd.SQLText := 'UPDATE TT_ACT'#$A'SET TT_NAME = ?'#$A'WHERE RDB$DB_KEY = ?'  
  ProcessRequest 
in TFDDAptTableAdapter.ProcessRequest
  SetParamsFromRow(ACommand.Params, ARow);
    AParams.Count=2: NEW_TT_NAME and OLD_DB_KEY. OLD_DB_KEY value is 0 in both cases
  then
  ACommand.Execute;
TFDPhysCommand.Execute    
  ExecuteTask
TFDPhysCommand.ExecuteTask
  FExecutor.Run
TFDStanAsyncExecutor.Run;
TFDStanAsyncExecutor.ExecuteOperation
FOperationIntf.Execute;
TFDPhysCommandAsyncExecute.Execute
TFDPhysCommand.ExecuteBase
FExecutor.Launched; -> Interface, cannot trace
Process_SingleRow  
Process_HandleSystemFailure
InternalExecute   -> Interface, cannot trace

最后一次调用返回var参数ACount(对于2.5.3)为1,对于2.5.7为0

GetRowCounts函数返回

FRowsUpdated,FRowsDeleted,FRowsSelected,FRowsInserted: 1 0 1 0 in 2.5.3
FRowsUpdated,FRowsDeleted,FRowsSelected,FRowsInserted: 0 0 0 0 in 2.5.7

0 个答案:

没有答案