Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: AdQuery.Delete fails
AdQuery.Delete fails
Posted: 2007/06/10 17:40
 

 function TADDatSRow.GetDBLockIDLongWord; var   pInfoPDEDataRowExtraInfo; begin   pInfo := GetRowInfo(False);   if pInfo <> nil then     Result := pInfo^.FLockID <----- fail's here when debugging from IDE   else     Result := 0; end;



JEDI exception log:

Exception: Access violation at address 02657961 in module 'daADComID7.bpl'. Read of address 80808090
Exception class: EAccessViolation
Version : 0.4.1.19
Call Stack:
[026F52BE] daADDAptManager.TADDAptTableAdapter.ProcessUpdate (Line 1907, "daADDAptManager.pas" + 161) + $5
[026F5633] daADDAptManager.TADDAptTableAdapter.Update (Line 2005, "daADDAptManager.pas" + 13) + $11
[025F0425] daADCompClient.TADCustomTableAdapter.UnLock (Line 4537, "daADCompClient.pas" + 2) + $F
[025F1D6A] daADCompClient.TADAdaptedDataSet.DoProcessUpdateRequest (Line 5435, "daADCompClient.pas" + 11) + $10
[005BF145] Db.TDataSet.CheckOperation + $29
[005BEE53] Db.TDataSet.Delete + $93

SQL.Text=
SELECT FEQ27PNO5R5HKHCAJ9FN4OLQ5E2, F4M8DJ6I89KQK10FG4DLM6FVOD7, Id, IdHeader FROM TK22HE2OUNJUK7F6O4RRKBPF328 WHERE ((IdHeader='{C9EB4C10-178E-11DC-81D6-005056C00008}'))

Fails in our application (database is MS SQL) - not occasional error. Update with the same query (i.e. changing fields and then Post) works Ok. In a simple test application is not reproduced. Delete fails for each table - not for the given query - as a workaround we changed deletion queries to 'DELETE FROM '
Re:AdQuery.Delete fails
Posted: 2007/06/21 07:08
 
Hello

Could you send me small demo (or post here), showing this issue ?

Regards,
Dmitry
Re:AdQuery.Delete fails
Posted: 2007/06/21 13:12
 
I've could not reproduce it in a demo application

Here is the trace

I start the trace from here (*) tracing TADDatSRow object for being valid at place (1)


 procedure TADDatSRow.AcceptChanges(AUseCascadeBoolean True); ...   rsDeleted:     begin       oList := RowList;       if oList <> nil then (*)      oList.Remove(self);     end; ... (1)if DBLockID <> 0 then     DBUnlock; end;



As we trace into oList.Remove(self) we shell come to TADDatSRow.Destroy (ANotDestroy is False by default)

Here is call stack


 TADDatSRow.Destroy TADDatSRowListWithAggregates.RemoveAt(???,???) TADDatSTableRowList.RemoveAt(???,???) TADDatSList.Remove(???,True) TADDatSRow.AcceptChanges(???) TADDAptTableAdapter.ProcessUpdate($2EAE5B8,eaApplied,arUnlock,[uoImmediateUpd,uoNoSrvRecord],[],-1) TADDAptTableAdapter.Update(???,eaApplied,???,arUnlock) TADCustomTableAdapter.UnLock(???,???,[uoImmediateUpd,uoNoSrvRecord]) TADAdaptedDataSet.DoProcessUpdateRequest(???,[uoDeferedLock,uoNoSrvRecord..(out of bound7]) TADDataSet.InternalDelete



So at (1) we have invalid reference - Self is already Destroyed
If check is done - i.e.

 ...   := True;   case RowState of ...       if oList <> nil then       begin         oList.Remove(self);         := False;       end; ...   if b then     if DBLockID <> 0 then       DBUnlock;



Then neither error nor memory leak is reported
Re:AdQuery.Delete fails
Posted: 2007/06/22 06:22
 
Ok, fixed. Thank you.

Regards,
Dmitry