Deleting the last record throws "record not found" or an AV

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
h.hasenack
Posts: 48
Joined: Tue 20 Jan 2009 12:35

Deleting the last record throws "record not found" or an AV

Post by h.hasenack » Fri 23 Apr 2010 10:43

I have a TCLientdataset, a TOraprovader and a TOraTable connected.

When I delete the last (I mean there's only one left) record available in t clientdataset, and call applyupdates an exception is raised from within
  • procedure TMemData.SetToBookmark(Bookmark: PRecBookmark);
I have added the following fix to avoid the error:

Code: Select all

procedure TCustomDADataSet.Resync(Mode: TResyncMode);
begin
  // this need if Resync called for closed dataset (AV BUG !!!)
  // HH Added   and (Data.RecordCount>0)
  if Active and (Data.RecordCount>0) then 
    inherited;
end;
Is this a correct fix? Or am I missing something else here?

Background info:
RAD Studio 2007
Oracle 10g

Regards - Hans

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Mon 26 Apr 2010 13:55

Hello

I cannot reproduce your issue. When I call ApplyUpdates the application doesn't call the TCustomDADataSet.Resync procedure. Try to remove all event handles from TOraTable and TClientDataset and try to delete the last record from the client dataset again. If exception is raised again then please tell us your TOraTable and TClientDataSet options the default values of which were changed.

h.hasenack
Posts: 48
Joined: Tue 20 Jan 2009 12:35

Post by h.hasenack » Tue 27 Apr 2010 08:27

Hard to reproduce, yes, it may have something to do with the actual layout of the table (BLOB's/CLOB's/indexes and that kind of stuff)

Unfortunately I do not have the time at the moment to build a minicase demonstrating the problem. I'll let you know when I have one.

Meanwhile: Can you predict if my quickfix potentially breaks other code or is it relatively safe (after running some tests at least it appears to be safe)

Kind regards
Hans

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Wed 28 Apr 2010 09:11

After applying your fix I found the following bug:

- open TOraQuery or TOraTable with 1 record
- delete this record

Record will be deleted from database but record will be kept by dataset until you execute refresh. And next operation with this dataset without refresh can raise unpredictable errors.

I advise you to determine which dataset properties or events reduce to raising this exception and we will fix it.

h.hasenack
Posts: 48
Joined: Tue 20 Jan 2009 12:35

Post by h.hasenack » Wed 28 Apr 2010 09:39

Still had no time to create a simple Delphi project to reproduce this.

But I don't see how can it keep a record when (Data.RecordCount=0)

I actually avoid the doing the resync because the somehow the bookmarks get messed up, and this again causes the Resync call to produce an AV.

Maybe this is useful information: There was DBGrid connected, which causes the TDataset to have multiple record buffers.

Regards - hans

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 29 Apr 2010 11:19

The problem is that the Data object has no record (Data.RecordCount=0) but the DataSet's buffer has one record and and ReSync synchronizes DataSet's buffers with the Data object, which is actually the records storage.

Post Reply