mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 20:26:00 +02:00
* Restore the order of two deleted records bound to the same record properly when reading a dataset from file
git-svn-id: trunk@12417 -
This commit is contained in:
parent
fc2409d812
commit
7cd20771b0
@ -2279,35 +2279,56 @@ procedure TBufDataset.GetDatasetPacket(AWriter: TDataPacketReader);
|
|||||||
|
|
||||||
procedure StoreUpdateBuffer(AUpdBuffer : TRecUpdateBuffer; var ARowState: TRowState);
|
procedure StoreUpdateBuffer(AUpdBuffer : TRecUpdateBuffer; var ARowState: TRowState);
|
||||||
var AThisRowState : TRowState;
|
var AThisRowState : TRowState;
|
||||||
|
AStoreUpdBuf : Integer;
|
||||||
begin
|
begin
|
||||||
FFilterBuffer:=AUpdBuffer.OldValuesBuffer;
|
|
||||||
if AUpdBuffer.UpdateKind = ukModify then
|
if AUpdBuffer.UpdateKind = ukModify then
|
||||||
begin
|
begin
|
||||||
AThisRowState := [rsvOriginal];
|
AThisRowState := [rsvOriginal];
|
||||||
ARowState:=[rsvUpdated];
|
ARowState:=[rsvUpdated];
|
||||||
end
|
end
|
||||||
else if AUpdBuffer.UpdateKind = ukDelete then
|
else if AUpdBuffer.UpdateKind = ukDelete then
|
||||||
AThisRowState := [rsvDeleted]
|
begin
|
||||||
|
AStoreUpdBuf:=FCurrentUpdateBuffer;
|
||||||
|
if GetRecordUpdateBuffer(AUpdBuffer.BookmarkData,True) then
|
||||||
|
begin
|
||||||
|
repeat
|
||||||
|
if FCurrentIndex.CompareBookmarks(@FUpdateBuffer[FCurrentUpdateBuffer].NextBookmarkData, @AUpdBuffer.BookmarkData) then
|
||||||
|
StoreUpdateBuffer(FUpdateBuffer[FCurrentUpdateBuffer], ARowState);
|
||||||
|
until not GetRecordUpdateBuffer(AUpdBuffer.BookmarkData,True,True)
|
||||||
|
end;
|
||||||
|
FCurrentUpdateBuffer:=AStoreUpdBuf;
|
||||||
|
AThisRowState := [rsvDeleted];
|
||||||
|
end
|
||||||
else // ie: updatekind = ukInsert
|
else // ie: updatekind = ukInsert
|
||||||
begin
|
begin
|
||||||
ARowState := [rsvInserted];
|
ARowState := [rsvInserted];
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
FFilterBuffer:=AUpdBuffer.OldValuesBuffer;
|
||||||
FDatasetReader.StoreRecord(Self,AThisRowState,FCurrentUpdateBuffer);
|
FDatasetReader.StoreRecord(Self,AThisRowState,FCurrentUpdateBuffer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure HandleUpdateBuffersFromRecord(ARecBookmark : TBufBookmark; var ARowState: TRowState);
|
procedure HandleUpdateBuffersFromRecord(AFirstCall : boolean;ARecBookmark : TBufBookmark; var ARowState: TRowState);
|
||||||
|
var StoreUpdBuf1,StoreUpdBuf2 : Integer;
|
||||||
begin
|
begin
|
||||||
if GetRecordUpdateBuffer(ARecBookmark,True) then
|
if AFirstCall then ARowState:=[];
|
||||||
|
if GetRecordUpdateBuffer(ARecBookmark,True,not AFirstCall) then
|
||||||
begin
|
begin
|
||||||
// Loop to see if there is more then one update-buffer
|
if FUpdateBuffer[FCurrentUpdateBuffer].UpdateKind=ukDelete then
|
||||||
// linked to the current record
|
begin
|
||||||
repeat
|
StoreUpdBuf1:=FCurrentUpdateBuffer;
|
||||||
StoreUpdateBuffer(FUpdateBuffer[FCurrentUpdateBuffer], ARowState);
|
HandleUpdateBuffersFromRecord(False,ARecBookmark,ARowState);
|
||||||
until not GetRecordUpdateBuffer(ARecBookmark,True,True)
|
StoreUpdBuf2:=FCurrentUpdateBuffer;
|
||||||
|
FCurrentUpdateBuffer:=StoreUpdBuf1;
|
||||||
|
StoreUpdateBuffer(FUpdateBuffer[StoreUpdBuf1], ARowState);
|
||||||
|
FCurrentUpdateBuffer:=StoreUpdBuf2;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
StoreUpdateBuffer(FUpdateBuffer[FCurrentUpdateBuffer], ARowState);
|
||||||
|
HandleUpdateBuffersFromRecord(False,ARecBookmark,ARowState);
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
|
||||||
ARowState:=[];
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var ScrollResult : TGetResult;
|
var ScrollResult : TGetResult;
|
||||||
@ -2330,7 +2351,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
RowState:=[];
|
RowState:=[];
|
||||||
FCurrentIndex.StoreCurrentRecIntoBookmark(ABookmark);
|
FCurrentIndex.StoreCurrentRecIntoBookmark(ABookmark);
|
||||||
HandleUpdateBuffersFromRecord(ABookmark^,RowState);
|
HandleUpdateBuffersFromRecord(True,ABookmark^,RowState);
|
||||||
FFilterBuffer:=FCurrentIndex.CurrentBuffer;
|
FFilterBuffer:=FCurrentIndex.CurrentBuffer;
|
||||||
if RowState=[] then
|
if RowState=[] then
|
||||||
FDatasetReader.StoreRecord(Self,[])
|
FDatasetReader.StoreRecord(Self,[])
|
||||||
@ -2346,7 +2367,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
// There could be a update-buffer linked to the last (spare) record
|
// There could be a update-buffer linked to the last (spare) record
|
||||||
FCurrentIndex.StoreSpareRecIntoBookmark(ABookmark);
|
FCurrentIndex.StoreSpareRecIntoBookmark(ABookmark);
|
||||||
HandleUpdateBuffersFromRecord(ABookmark^,RowState);
|
HandleUpdateBuffersFromRecord(True,ABookmark^,RowState);
|
||||||
|
|
||||||
RestoreState(StoreDSState);
|
RestoreState(StoreDSState);
|
||||||
|
|
||||||
@ -2438,6 +2459,7 @@ var StoreState : TDataSetState;
|
|||||||
AddRecordBuffer : boolean;
|
AddRecordBuffer : boolean;
|
||||||
ARowState : TRowState;
|
ARowState : TRowState;
|
||||||
AUpdOrder : integer;
|
AUpdOrder : integer;
|
||||||
|
x : integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FDatasetReader.InitLoadRecords;
|
FDatasetReader.InitLoadRecords;
|
||||||
@ -2496,6 +2518,10 @@ begin
|
|||||||
FIndexes[0].RemoveRecordFromIndex(FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData);
|
FIndexes[0].RemoveRecordFromIndex(FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData);
|
||||||
FIndexes[0].StoreSpareRecIntoBookmark(@FUpdateBuffer[FCurrentUpdateBuffer].NextBookmarkData);
|
FIndexes[0].StoreSpareRecIntoBookmark(@FUpdateBuffer[FCurrentUpdateBuffer].NextBookmarkData);
|
||||||
|
|
||||||
|
for x := FCurrentUpdateBuffer+1 to length(FUpdateBuffer)-1 do
|
||||||
|
if Findexes[0].CompareBookmarks(@FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData,@FUpdateBuffer[x].NextBookmarkData) then
|
||||||
|
FIndexes[0].StoreSpareRecIntoBookmark(@FUpdateBuffer[x].NextBookmarkData);
|
||||||
|
|
||||||
AddRecordBuffer:=False;
|
AddRecordBuffer:=False;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user