mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 23:19:24 +02:00
* Cleaned up old Arraybuf defines and code
git-svn-id: trunk@11492 -
This commit is contained in:
parent
330d10851f
commit
e8fcc2b82e
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
unit BufDataset;
|
unit BufDataset;
|
||||||
|
|
||||||
{ $DEFINE ARRAYBUF}
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
{$h+}
|
{$h+}
|
||||||
|
|
||||||
@ -70,26 +69,16 @@ type
|
|||||||
|
|
||||||
TRecUpdateBuffer = record
|
TRecUpdateBuffer = record
|
||||||
UpdateKind : TUpdateKind;
|
UpdateKind : TUpdateKind;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
{ BookMarkData:
|
{ BookMarkData:
|
||||||
- Is -1 if the update has canceled out. For example: a appended record has been deleted again
|
- Is -1 if the update has canceled out. For example: a appended record has been deleted again
|
||||||
- If UpdateKind is ukInsert it contains a bookmark to the new created record
|
- If UpdateKind is ukInsert it contains a bookmark to the new created record
|
||||||
- If UpdateKind is ukModify it contains a bookmark to the record with the new data
|
- If UpdateKind is ukModify it contains a bookmark to the record with the new data
|
||||||
- If UpdateKind is ukDelete it contains a bookmark to the record just after the deleted record
|
- If UpdateKind is ukDelete it contains a bookmark to the record just after the deleted record
|
||||||
}
|
|
||||||
Bookmark : TBufBookmark;
|
|
||||||
{$ELSE}
|
|
||||||
{ BookMarkData:
|
|
||||||
- Is nil if the update has canceled out. For example: a appended record has been deleted again
|
|
||||||
- If UpdateKind is ukInsert it contains the PBufRecLinkItem of the created record
|
|
||||||
- If UpdateKind is ukModify it contains the PBufRecLinkItem of the record with the new data
|
|
||||||
- If UpdateKind is ukDelete it contains the PBufRecLinkItem of the deleted record
|
|
||||||
}
|
}
|
||||||
BookmarkData : TBufBookmark;
|
BookmarkData : TBufBookmark;
|
||||||
{$ENDIF}
|
|
||||||
{ OldValuesBuffer:
|
{ OldValuesBuffer:
|
||||||
- If UpdateKind is ukModify it contains a record-buffer which contains the old data
|
- If UpdateKind is ukModify it contains a record-buffer which contains the old data
|
||||||
- If UpdateKind is ukDelete it contains the PBufRecLinkItem of the deleted record
|
- If UpdateKind is ukDelete it contains a record-buffer with the data of the deleted record
|
||||||
}
|
}
|
||||||
OldValuesBuffer : pchar;
|
OldValuesBuffer : pchar;
|
||||||
end;
|
end;
|
||||||
@ -111,8 +100,6 @@ type
|
|||||||
end;
|
end;
|
||||||
TDBCompareStruct = array of TDBCompareRec;
|
TDBCompareStruct = array of TDBCompareRec;
|
||||||
|
|
||||||
PInternalBookmark = pointer;
|
|
||||||
|
|
||||||
{ TBufIndex }
|
{ TBufIndex }
|
||||||
|
|
||||||
TBufIndex = class(TObject)
|
TBufIndex = class(TObject)
|
||||||
@ -237,8 +224,6 @@ type
|
|||||||
|
|
||||||
TArrayBufIndex = class(TBufIndex)
|
TArrayBufIndex = class(TBufIndex)
|
||||||
private
|
private
|
||||||
FCursOnFirstRec : boolean;
|
|
||||||
|
|
||||||
FStoredRecBuf : integer;
|
FStoredRecBuf : integer;
|
||||||
|
|
||||||
FInitialBuffers,
|
FInitialBuffers,
|
||||||
@ -292,12 +277,7 @@ type
|
|||||||
TBufDataset = class(TDBDataSet)
|
TBufDataset = class(TDBDataSet)
|
||||||
private
|
private
|
||||||
FIndexes : array of TBufIndex;
|
FIndexes : array of TBufIndex;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
FInitialBuffers : integer;
|
|
||||||
FGrowBuffer : integer;
|
|
||||||
{$ELSE}
|
|
||||||
FMaxIndexesCount: integer;
|
FMaxIndexesCount: integer;
|
||||||
{$ENDIF ARRAYBUF}
|
|
||||||
|
|
||||||
FIndexesCount : integer;
|
FIndexesCount : integer;
|
||||||
FCurrentIndex : TBufIndex;
|
FCurrentIndex : TBufIndex;
|
||||||
@ -327,9 +307,6 @@ type
|
|||||||
procedure FetchAll;
|
procedure FetchAll;
|
||||||
procedure BuildIndex(var AIndex : TBufIndex);
|
procedure BuildIndex(var AIndex : TBufIndex);
|
||||||
function GetIndexDefs : TIndexDefs;
|
function GetIndexDefs : TIndexDefs;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
procedure AddRecordToIndex(var AIndex: TBufIndex; ARecBuf: pchar);
|
|
||||||
{$ENDIF}
|
|
||||||
function GetCurrentBuffer: PChar;
|
function GetCurrentBuffer: PChar;
|
||||||
procedure CalcRecordSize;
|
procedure CalcRecordSize;
|
||||||
function GetIndexFieldNames: String;
|
function GetIndexFieldNames: String;
|
||||||
@ -340,9 +317,7 @@ type
|
|||||||
procedure ProcessFieldCompareStruct(AField: TField; var ACompareRec : TDBCompareRec);
|
procedure ProcessFieldCompareStruct(AField: TField; var ACompareRec : TDBCompareRec);
|
||||||
procedure SetIndexFieldNames(const AValue: String);
|
procedure SetIndexFieldNames(const AValue: String);
|
||||||
procedure SetIndexName(AValue: String);
|
procedure SetIndexName(AValue: String);
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
procedure SetMaxIndexesCount(const AValue: Integer);
|
procedure SetMaxIndexesCount(const AValue: Integer);
|
||||||
{$ENDIF}
|
|
||||||
procedure SetPacketRecords(aValue : integer);
|
procedure SetPacketRecords(aValue : integer);
|
||||||
function IntAllocRecordBuffer: PChar;
|
function IntAllocRecordBuffer: PChar;
|
||||||
procedure DoFilterRecord(var Acceptable: Boolean);
|
procedure DoFilterRecord(var Acceptable: Boolean);
|
||||||
@ -407,9 +382,7 @@ type
|
|||||||
procedure AddIndex(const AName, AFields : string; AOptions : TIndexOptions; const ADescFields: string = '';
|
procedure AddIndex(const AName, AFields : string; AOptions : TIndexOptions; const ADescFields: string = '';
|
||||||
const ACaseInsFields: string = ''); virtual;
|
const ACaseInsFields: string = ''); virtual;
|
||||||
property ChangeCount : Integer read GetChangeCount;
|
property ChangeCount : Integer read GetChangeCount;
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
property MaxIndexesCount : Integer read FMaxIndexesCount write SetMaxIndexesCount;
|
property MaxIndexesCount : Integer read FMaxIndexesCount write SetMaxIndexesCount;
|
||||||
{$ENDIF ARRAYBUF}
|
|
||||||
published
|
published
|
||||||
property PacketRecords : Integer read FPacketRecords write SetPacketRecords default 10;
|
property PacketRecords : Integer read FPacketRecords write SetPacketRecords default 10;
|
||||||
property OnUpdateError: TResolverErrorEvent read FOnUpdateError write SetOnUpdateError;
|
property OnUpdateError: TResolverErrorEvent read FOnUpdateError write SetOnUpdateError;
|
||||||
@ -482,7 +455,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function DBCompareDouble(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
function DBCompareDouble(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
||||||
var Dbl : Double;
|
|
||||||
begin
|
begin
|
||||||
// A simple subtraction doesn't work, since it could be that the result
|
// A simple subtraction doesn't work, since it could be that the result
|
||||||
// doesn't fit into a LargeInt
|
// doesn't fit into a LargeInt
|
||||||
@ -516,12 +488,7 @@ end;
|
|||||||
constructor TBufDataset.Create(AOwner : TComponent);
|
constructor TBufDataset.Create(AOwner : TComponent);
|
||||||
begin
|
begin
|
||||||
Inherited Create(AOwner);
|
Inherited Create(AOwner);
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
FInitialBuffers:=10000;
|
|
||||||
FGrowBuffer:=1000;
|
|
||||||
{$ELSE}
|
|
||||||
FMaxIndexesCount:=2;
|
FMaxIndexesCount:=2;
|
||||||
{$ENDIF}
|
|
||||||
FIndexesCount:=0;
|
FIndexesCount:=0;
|
||||||
InternalAddIndex('DEFAULT_ORDER','',[],'','');
|
InternalAddIndex('DEFAULT_ORDER','',[],'','');
|
||||||
FCurrentIndex:=FIndexes[0];
|
FCurrentIndex:=FIndexes[0];
|
||||||
@ -623,7 +590,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// This simply copies the index...
|
// This simply copies the index...
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
PCurRecLinkItem:=(FIndexes[0] as TDoubleLinkedBufIndex).FFirstRecBuf;
|
PCurRecLinkItem:=(FIndexes[0] as TDoubleLinkedBufIndex).FFirstRecBuf;
|
||||||
PCurRecLinkItem[(AIndex as TDoubleLinkedBufIndex).IndNr].next := PCurRecLinkItem[0].next;
|
PCurRecLinkItem[(AIndex as TDoubleLinkedBufIndex).IndNr].next := PCurRecLinkItem[0].next;
|
||||||
PCurRecLinkItem[(AIndex as TDoubleLinkedBufIndex).IndNr].prior := PCurRecLinkItem[0].prior;
|
PCurRecLinkItem[(AIndex as TDoubleLinkedBufIndex).IndNr].prior := PCurRecLinkItem[0].prior;
|
||||||
@ -738,8 +704,6 @@ begin
|
|||||||
until MergeAmount = 1;
|
until MergeAmount = 1;
|
||||||
(AIndex as TDoubleLinkedBufIndex).FLastRecBuf[(AIndex as TDoubleLinkedBufIndex).IndNr].next:=(AIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
|
(AIndex as TDoubleLinkedBufIndex).FLastRecBuf[(AIndex as TDoubleLinkedBufIndex).IndNr].next:=(AIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
|
||||||
(AIndex as TDoubleLinkedBufIndex).FLastRecBuf[(AIndex as TDoubleLinkedBufIndex).IndNr].prior:=l;
|
(AIndex as TDoubleLinkedBufIndex).FLastRecBuf[(AIndex as TDoubleLinkedBufIndex).IndNr].prior:=l;
|
||||||
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBufDataset.GetIndexDefs : TIndexDefs;
|
function TBufDataset.GetIndexDefs : TIndexDefs;
|
||||||
@ -770,16 +734,11 @@ end;
|
|||||||
function TBufDataset.intAllocRecordBuffer: PChar;
|
function TBufDataset.intAllocRecordBuffer: PChar;
|
||||||
begin
|
begin
|
||||||
// Note: Only the internal buffers of TDataset provide bookmark information
|
// Note: Only the internal buffers of TDataset provide bookmark information
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
result := AllocMem(FRecordsize);
|
|
||||||
{$ELSE}
|
|
||||||
result := AllocMem(FRecordsize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
|
result := AllocMem(FRecordsize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBufDataset.AllocRecordBuffer: PChar;
|
function TBufDataset.AllocRecordBuffer: PChar;
|
||||||
begin
|
begin
|
||||||
// result := AllocMem(FRecordsize + sizeof(TBufBookmark) + CalcfieldsSize);
|
|
||||||
result := AllocMem(FRecordsize + BookmarkSize + CalcfieldsSize);
|
result := AllocMem(FRecordsize + BookmarkSize + CalcfieldsSize);
|
||||||
// The records are initialised, or else the fields of an empty, just-opened dataset
|
// The records are initialised, or else the fields of an empty, just-opened dataset
|
||||||
// are not null
|
// are not null
|
||||||
@ -806,19 +765,8 @@ begin
|
|||||||
|
|
||||||
FBRecordcount := 0;
|
FBRecordcount := 0;
|
||||||
|
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
for IndexNr:=0 to FIndexesCount-1 do with FIndexes[IndexNr] do
|
for IndexNr:=0 to FIndexesCount-1 do with FIndexes[IndexNr] do
|
||||||
begin
|
|
||||||
InitialiseSpareRecord(IntAllocRecordBuffer);
|
InitialiseSpareRecord(IntAllocRecordBuffer);
|
||||||
end;
|
|
||||||
{$ELSE}
|
|
||||||
for IndexNr:=0 to FIndexesCount-1 do with FIndexes[IndexNr] do
|
|
||||||
begin
|
|
||||||
FLastRecInd := 0;
|
|
||||||
FCurrentRecInd := 0;
|
|
||||||
FRecordArray[0] := IntAllocRecordBuffer;
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
FAllPacketsFetched := False;
|
FAllPacketsFetched := False;
|
||||||
|
|
||||||
@ -838,17 +786,12 @@ procedure TBufDataset.InternalClose;
|
|||||||
|
|
||||||
var r : integer;
|
var r : integer;
|
||||||
iGetResult : TGetResult;
|
iGetResult : TGetResult;
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
pc : pchar;
|
pc : pchar;
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FOpen:=False;
|
FOpen:=False;
|
||||||
with FIndexes[0] do if IsInitialized then
|
with FIndexes[0] do if IsInitialized then
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
for r := 0 to FLastRecInd-1 do FreeRecordBuffer(FRecordArray[r]);
|
|
||||||
{$ELSE}
|
|
||||||
iGetResult:=ScrollFirst;
|
iGetResult:=ScrollFirst;
|
||||||
while iGetResult = grOK do
|
while iGetResult = grOK do
|
||||||
begin
|
begin
|
||||||
@ -856,29 +799,20 @@ begin
|
|||||||
iGetResult:=ScrollForward;
|
iGetResult:=ScrollForward;
|
||||||
FreeRecordBuffer(pc);
|
FreeRecordBuffer(pc);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for r := 0 to FIndexesCount-1 do with FIndexes[r] do if IsInitialized then
|
for r := 0 to FIndexesCount-1 do with FIndexes[r] do if IsInitialized then
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
// FreeRecordBuffer(FRecordArray[FLastRecInd]);
|
|
||||||
{$ELSE}
|
|
||||||
pc := SpareRecord;
|
pc := SpareRecord;
|
||||||
ReleaseSpareRecord;
|
ReleaseSpareRecord;
|
||||||
FreeRecordBuffer(pc);
|
FreeRecordBuffer(pc);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Length(FUpdateBuffer) > 0 then
|
if Length(FUpdateBuffer) > 0 then
|
||||||
begin
|
begin
|
||||||
for r := 0 to length(FUpdateBuffer)-1 do with FUpdateBuffer[r] do
|
for r := 0 to length(FUpdateBuffer)-1 do with FUpdateBuffer[r] do
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
if Bookmark.BookmarkData > 0 then
|
|
||||||
{$ELSE}
|
|
||||||
if assigned(OldValuesBuffer) then
|
if assigned(OldValuesBuffer) then
|
||||||
{$ENDIF}
|
|
||||||
FreeRecordBuffer(OldValuesBuffer);
|
FreeRecordBuffer(OldValuesBuffer);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -901,12 +835,8 @@ procedure TBufDataset.InternalFirst;
|
|||||||
begin
|
begin
|
||||||
with FCurrentIndex do
|
with FCurrentIndex do
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
// if FCurrentRecBuf = FLastRecBuf then the dataset is just opened and empty
|
// if FCurrentRecBuf = FLastRecBuf then the dataset is just opened and empty
|
||||||
// in which case InternalFirst should do nothing (bug 7211)
|
// in which case InternalFirst should do nothing (bug 7211)
|
||||||
if FCurrentRecInd <> FLastRecInd then
|
|
||||||
FCurrentRecInd := -1;
|
|
||||||
{$ENDIF}
|
|
||||||
SetToFirstRecord;
|
SetToFirstRecord;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -915,11 +845,7 @@ procedure TBufDataset.InternalLast;
|
|||||||
begin
|
begin
|
||||||
FetchAll;
|
FetchAll;
|
||||||
with FCurrentIndex do
|
with FCurrentIndex do
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
if FLastRecInd <> 0 then FCurrentRecInd := FLastRecInd;
|
|
||||||
{$ELSE}
|
|
||||||
SetToLastRecord;
|
SetToLastRecord;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure unSetFieldIsNull(NullMask : pbyte;x : longint); //inline;
|
procedure unSetFieldIsNull(NullMask : pbyte;x : longint); //inline;
|
||||||
@ -1062,9 +988,7 @@ end;
|
|||||||
|
|
||||||
procedure TDoubleLinkedBufIndex.GotoBookmark(const ABookmark : PBufBookmark);
|
procedure TDoubleLinkedBufIndex.GotoBookmark(const ABookmark : PBufBookmark);
|
||||||
begin
|
begin
|
||||||
// note that ABookMarkLocation should be a PBufBookmark. But this way it can
|
FCurrentRecBuf := ABookmark^.BookmarkData;
|
||||||
// also be a pointer to a TBufRecLinkItem
|
|
||||||
FCurrentRecBuf := ABookmark^.BookmarkData; // is effectively the same as: PBufBookmark(ABookmarkLocation)^.BookmarkData;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDoubleLinkedBufIndex.InitialiseIndex;
|
procedure TDoubleLinkedBufIndex.InitialiseIndex;
|
||||||
@ -1096,7 +1020,7 @@ end;
|
|||||||
procedure TDoubleLinkedBufIndex.RemoveRecordFromIndex(const ABookmark : TBufBookmark);
|
procedure TDoubleLinkedBufIndex.RemoveRecordFromIndex(const ABookmark : TBufBookmark);
|
||||||
var ARecord : PBufRecLinkItem;
|
var ARecord : PBufRecLinkItem;
|
||||||
begin
|
begin
|
||||||
ARecord := ABookmark.BookmarkData;//pointer(ARecordBuffer)-(sizeof(TBufRecLinkItem)*FDataset.MaxIndexesCount);
|
ARecord := ABookmark.BookmarkData;
|
||||||
if ARecord <> FFirstRecBuf then
|
if ARecord <> FFirstRecBuf then
|
||||||
ARecord[IndNr].prior[IndNr].next := ARecord[IndNr].next
|
ARecord[IndNr].prior[IndNr].next := ARecord[IndNr].next
|
||||||
else
|
else
|
||||||
@ -1175,17 +1099,7 @@ begin
|
|||||||
Acceptable := True;
|
Acceptable := True;
|
||||||
case GetMode of
|
case GetMode of
|
||||||
gmPrior : Result := ScrollBackward;
|
gmPrior : Result := ScrollBackward;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
if FCurrentRecInd=0 then
|
|
||||||
Result := grBOF
|
|
||||||
else
|
|
||||||
Dec(FCurrentRecInd);
|
|
||||||
{$ENDIF}
|
|
||||||
gmCurrent : Result := GetCurrent;
|
gmCurrent : Result := GetCurrent;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
if FCurrentRecInd = FLastRecInd then
|
|
||||||
Result := grError;
|
|
||||||
{$ENDIF}
|
|
||||||
gmNext : begin
|
gmNext : begin
|
||||||
if not CanScrollForward and (getnextpacket = 0) then result := grEOF
|
if not CanScrollForward and (getnextpacket = 0) then result := grEOF
|
||||||
else
|
else
|
||||||
@ -1194,28 +1108,6 @@ begin
|
|||||||
DoScrollForward;
|
DoScrollForward;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
if FCurrentRecInd = FLastRecInd then // Dataset is empty (just opened)
|
|
||||||
begin
|
|
||||||
if getnextpacket = 0 then result := grEOF;
|
|
||||||
end
|
|
||||||
else if FCurrentRecInd = -1 then FCurrentRecInd := 0
|
|
||||||
else if FCurrentRecInd = FLastRecInd-1 then
|
|
||||||
begin
|
|
||||||
if getnextpacket > 0 then
|
|
||||||
begin
|
|
||||||
inc(FCurrentRecInd);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
result:=grEOF;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
inc(FCurrentRecInd);
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Result = grOK then
|
if Result = grOK then
|
||||||
@ -1227,20 +1119,6 @@ begin
|
|||||||
ABookmark^.BookmarkFlag:=bfCurrent;
|
ABookmark^.BookmarkFlag:=bfCurrent;
|
||||||
StoreCurrentRecIntoBookmark(ABookMark);
|
StoreCurrentRecIntoBookmark(ABookMark);
|
||||||
end;
|
end;
|
||||||
{ with PBufBookmark(Buffer + FRecordSize)^ do
|
|
||||||
begin
|
|
||||||
{ $IFDEF ARRAYBUF}
|
|
||||||
BookmarkData := FCurrentIndex^.FCurrentRecInd;
|
|
||||||
BookMarkBuf := FCurrentIndex^.FRecordArray[FCurrentIndex^.FCurrentRecInd];
|
|
||||||
{ $ELSE}
|
|
||||||
BookmarkData := FCurrentRecBuf;
|
|
||||||
{ $ENDIF}
|
|
||||||
BookmarkFlag := bfCurrent;
|
|
||||||
end;}
|
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
with FCurrentIndex^ do
|
|
||||||
move((FRecordArray[FCurrentRecInd])^,buffer^,FRecordSize);
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
GetCalcFields(Buffer);
|
GetCalcFields(Buffer);
|
||||||
|
|
||||||
@ -1269,12 +1147,7 @@ var x : integer;
|
|||||||
ABookmark : TBufBookmark;
|
ABookmark : TBufBookmark;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
GetBookmarkData(ActiveBuffer,@ABookmark);
|
GetBookmarkData(ActiveBuffer,@ABookmark);
|
||||||
CurrBuff:=GetRecordFromBookmark(ABookmark);
|
|
||||||
{$ELSE}
|
|
||||||
GetBookmarkData(ActiveBuffer,@ABookmark);
|
|
||||||
{$ENDIF}
|
|
||||||
if (FCurrentUpdateBuffer >= length(FUpdateBuffer)) or not FCurrentIndex.CompareBookmarks(@FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData,@ABookmark) then
|
if (FCurrentUpdateBuffer >= length(FUpdateBuffer)) or not FCurrentIndex.CompareBookmarks(@FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData,@ABookmark) then
|
||||||
for x := 0 to high(FUpdateBuffer) do
|
for x := 0 to high(FUpdateBuffer) do
|
||||||
if FCurrentIndex.CompareBookmarks(@FUpdateBuffer[x].BookmarkData,@ABookmark) then
|
if FCurrentIndex.CompareBookmarks(@FUpdateBuffer[x].BookmarkData,@ABookmark) then
|
||||||
@ -1338,7 +1211,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
procedure TBufDataset.SetMaxIndexesCount(const AValue: Integer);
|
procedure TBufDataset.SetMaxIndexesCount(const AValue: Integer);
|
||||||
begin
|
begin
|
||||||
CheckInactive;
|
CheckInactive;
|
||||||
@ -1347,23 +1219,15 @@ begin
|
|||||||
else
|
else
|
||||||
DatabaseError(SMinIndexes);
|
DatabaseError(SMinIndexes);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
procedure TBufDataset.InternalSetToRecord(Buffer: PChar);
|
procedure TBufDataset.InternalSetToRecord(Buffer: PChar);
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
FCurrentIndex^.FCurrentRecInd:=GetRecordFromBookmark(PBufBookmark(Buffer + FRecordSize)^);
|
|
||||||
{$ENDIF}
|
|
||||||
FCurrentIndex.GotoBookmark(PBufBookmark(Buffer+FRecordSize));
|
FCurrentIndex.GotoBookmark(PBufBookmark(Buffer+FRecordSize));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBufDataset.SetBookmarkData(Buffer: PChar; Data: Pointer);
|
procedure TBufDataset.SetBookmarkData(Buffer: PChar; Data: Pointer);
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
PBufBookmark(Buffer + FRecordSize)^.BookmarkData := integer(Data^);
|
|
||||||
{$ELSE}
|
|
||||||
PBufBookmark(Buffer + FRecordSize)^.BookmarkData := pointer(Data^);
|
PBufBookmark(Buffer + FRecordSize)^.BookmarkData := pointer(Data^);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBufDataset.SetBookmarkFlag(Buffer: PChar; Value: TBookmarkFlag);
|
procedure TBufDataset.SetBookmarkFlag(Buffer: PChar; Value: TBookmarkFlag);
|
||||||
@ -1373,11 +1237,7 @@ end;
|
|||||||
|
|
||||||
procedure TBufDataset.GetBookmarkData(Buffer: PChar; Data: Pointer);
|
procedure TBufDataset.GetBookmarkData(Buffer: PChar; Data: Pointer);
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
PBufBookmark(Data)^ := PBufBookmark(Buffer + FRecordSize)^;
|
|
||||||
{$ELSE}
|
|
||||||
pointer(Data^) := PBufBookmark(Buffer + FRecordSize)^.BookmarkData;
|
pointer(Data^) := PBufBookmark(Buffer + FRecordSize)^.BookmarkData;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBufDataset.GetBookmarkFlag(Buffer: PChar): TBookmarkFlag;
|
function TBufDataset.GetBookmarkFlag(Buffer: PChar): TBookmarkFlag;
|
||||||
@ -1389,14 +1249,10 @@ procedure TBufDataset.InternalGotoBookmark(ABookmark: Pointer);
|
|||||||
begin
|
begin
|
||||||
// note that ABookMark should be a PBufBookmark. But this way it can also be
|
// note that ABookMark should be a PBufBookmark. But this way it can also be
|
||||||
// a pointer to a TBufRecLinkItem
|
// a pointer to a TBufRecLinkItem
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
FCurrentIndex^.FCurrentRecInd:=GetRecordFromBookmark(PBufBookmark(ABookmark)^);
|
|
||||||
{$ELSE}
|
|
||||||
FCurrentIndex.GotoBookmark(ABookmark);
|
FCurrentIndex.GotoBookmark(ABookmark);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF ARRAYBUF}
|
(*
|
||||||
procedure TBufDataset.AddRecordToIndex(var AIndex: TBufIndex; ARecBuf : pchar);
|
procedure TBufDataset.AddRecordToIndex(var AIndex: TBufIndex; ARecBuf : pchar);
|
||||||
var cp : integer;
|
var cp : integer;
|
||||||
NewValueBufLen : Integer;
|
NewValueBufLen : Integer;
|
||||||
@ -1447,7 +1303,7 @@ begin
|
|||||||
AIndex.FRecordArray[RecInd]:= ARecBuf;
|
AIndex.FRecordArray[RecInd]:= ARecBuf;
|
||||||
inc(AIndex.FLastRecInd)
|
inc(AIndex.FLastRecInd)
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
*)
|
||||||
|
|
||||||
function TBufDataset.getnextpacket : integer;
|
function TBufDataset.getnextpacket : integer;
|
||||||
|
|
||||||
@ -1644,11 +1500,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
if state = dsFilter then // Set the value into the 'temporary' FLastRecBuf buffer for Locate and Lookup
|
if state = dsFilter then // Set the value into the 'temporary' FLastRecBuf buffer for Locate and Lookup
|
||||||
with FCurrentIndex do
|
with FCurrentIndex do
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
CurrBuff := FRecordArray[FLastRecInd]
|
|
||||||
{$ELSE}
|
|
||||||
CurrBuff := SpareBuffer
|
CurrBuff := SpareBuffer
|
||||||
{$ENDIF}
|
|
||||||
else
|
else
|
||||||
CurrBuff := GetCurrentBuffer;
|
CurrBuff := GetCurrentBuffer;
|
||||||
If Field.Fieldno > 0 then // If = 0, then calculated field or something
|
If Field.Fieldno > 0 then // If = 0, then calculated field or something
|
||||||
@ -1682,12 +1534,8 @@ var i : Integer;
|
|||||||
RemRecBuf : Pchar;
|
RemRecBuf : Pchar;
|
||||||
RemRec : pointer;
|
RemRec : pointer;
|
||||||
RemRecBookmrk : TBufBookmark;
|
RemRecBookmrk : TBufBookmark;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
ABookmark : TBufBookmark;
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
InternalSetToRecord(ActiveBuffer);
|
InternalSetToRecord(ActiveBuffer);
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
// Remove the record from all active indexes
|
// Remove the record from all active indexes
|
||||||
FCurrentIndex.StoreCurrentRecIntoBookmark(@RemRecBookmrk);
|
FCurrentIndex.StoreCurrentRecIntoBookmark(@RemRecBookmrk);
|
||||||
RemRecBuf:=FCurrentIndex.GetCurrentRecord;
|
RemRecBuf:=FCurrentIndex.GetCurrentRecord;
|
||||||
@ -1696,7 +1544,6 @@ begin
|
|||||||
if FCurrentIndex=FIndexes[1] then StartInd := 1 else StartInd := 2;
|
if FCurrentIndex=FIndexes[1] then StartInd := 1 else StartInd := 2;
|
||||||
for i := StartInd to FIndexesCount-1 do
|
for i := StartInd to FIndexesCount-1 do
|
||||||
findexes[i].RemoveRecordFromIndex(RemRecBookmrk);
|
findexes[i].RemoveRecordFromIndex(RemRecBookmrk);
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
// If a modified record is deleted, and GetRecordUpdateBuffer is used, problems
|
// If a modified record is deleted, and GetRecordUpdateBuffer is used, problems
|
||||||
// may arise. The 'delete' is placed in the update-buffer before the actual delete
|
// may arise. The 'delete' is placed in the update-buffer before the actual delete
|
||||||
@ -1707,19 +1554,10 @@ begin
|
|||||||
FCurrentUpdateBuffer := length(FUpdateBuffer);
|
FCurrentUpdateBuffer := length(FUpdateBuffer);
|
||||||
SetLength(FUpdateBuffer,FCurrentUpdateBuffer+1);
|
SetLength(FUpdateBuffer,FCurrentUpdateBuffer+1);
|
||||||
|
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
with (FIndexes[0] as TDoubleLinkedBufIndex) do
|
|
||||||
begin
|
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer := FRecordArray[FCurrentRecInd];
|
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].Bookmark.BookMarkBuf:=nil;
|
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].Bookmark.BookmarkData := FCurrentRecInd;
|
|
||||||
end;
|
|
||||||
{$ELSE}
|
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer := IntAllocRecordBuffer;
|
FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer := IntAllocRecordBuffer;
|
||||||
move(RemRec^, FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer^,FRecordSize);
|
move(RemRec^, FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer^,FRecordSize);
|
||||||
FreeRecordBuffer(RemRecBuf);
|
FreeRecordBuffer(RemRecBuf);
|
||||||
FCurrentIndex.StoreCurrentRecIntoBookmark(@FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData);
|
FCurrentIndex.StoreCurrentRecIntoBookmark(@FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData);
|
||||||
{$ENDIF}
|
|
||||||
end
|
end
|
||||||
else //with FIndexes[0] do
|
else //with FIndexes[0] do
|
||||||
begin
|
begin
|
||||||
@ -1729,14 +1567,6 @@ begin
|
|||||||
FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer := nil; //this 'disables' the updatebuffer
|
FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer := nil; //this 'disables' the updatebuffer
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
with FCurrentIndex^ do
|
|
||||||
begin
|
|
||||||
Move(FRecordArray[FCurrentRecInd+1],FRecordArray[FCurrentRecInd],sizeof(Pointer)*(FLastRecInd-FCurrentRecInd));
|
|
||||||
dec(FLastRecInd);
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
dec(FBRecordCount);
|
dec(FBRecordCount);
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].UpdateKind := ukDelete;
|
FUpdateBuffer[FCurrentUpdateBuffer].UpdateKind := ukDelete;
|
||||||
end;
|
end;
|
||||||
@ -1753,9 +1583,6 @@ procedure TBufDataset.CancelUpdates;
|
|||||||
var r : Integer;
|
var r : Integer;
|
||||||
StoreRecBM : TBufBookmark;
|
StoreRecBM : TBufBookmark;
|
||||||
TmpBuf : PChar;
|
TmpBuf : PChar;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
RecInd : integer;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
CheckBrowseMode;
|
CheckBrowseMode;
|
||||||
@ -1766,53 +1593,24 @@ begin
|
|||||||
r := Length(FUpdateBuffer) -1;
|
r := Length(FUpdateBuffer) -1;
|
||||||
while r > -1 do with FUpdateBuffer[r] do
|
while r > -1 do with FUpdateBuffer[r] do
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
if FUpdateBuffer[r].Bookmark.BookmarkData <> -1 then
|
|
||||||
{$ELSE}
|
|
||||||
// if assigned(FUpdateBuffer[r].BookmarkData) then
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
if UpdateKind = ukModify then
|
if UpdateKind = ukModify then
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
with FCurrentIndex^ do
|
|
||||||
begin
|
|
||||||
FreeRecordBuffer(FRecordArray[Bookmark.BookmarkData]);
|
|
||||||
FRecordArray[Bookmark.BookmarkData] := OldValuesBuffer;
|
|
||||||
end;
|
|
||||||
{$ELSE}
|
|
||||||
FCurrentIndex.GotoBookmark(@BookmarkData);
|
FCurrentIndex.GotoBookmark(@BookmarkData);
|
||||||
move(pchar(OldValuesBuffer)^,pchar(FCurrentIndex.CurrentBuffer)^,FRecordSize);
|
move(pchar(OldValuesBuffer)^,pchar(FCurrentIndex.CurrentBuffer)^,FRecordSize);
|
||||||
FreeRecordBuffer(OldValuesBuffer);
|
FreeRecordBuffer(OldValuesBuffer);
|
||||||
{$ENDIF}
|
|
||||||
end
|
end
|
||||||
else if (UpdateKind = ukDelete) and (assigned(FUpdateBuffer[r].OldValuesBuffer)) then
|
else if (UpdateKind = ukDelete) and (assigned(FUpdateBuffer[r].OldValuesBuffer)) then
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
RecInd := GetRecordFromBookmark(Bookmark);
|
|
||||||
with FCurrentIndex^ do
|
|
||||||
begin
|
|
||||||
move(FRecordArray[RecInd],FRecordArray[RecInd+1],sizeof(Pointer)*(FLastRecInd-RecInd+1));
|
|
||||||
FRecordArray[RecInd] := OldValuesBuffer;
|
|
||||||
inc(FLastRecInd);
|
|
||||||
end;
|
|
||||||
{$ELSE}
|
|
||||||
FCurrentIndex.GotoBookmark(@BookmarkData);
|
FCurrentIndex.GotoBookmark(@BookmarkData);
|
||||||
FCurrentIndex.InsertRecordBeforeCurrentRecord(IntAllocRecordBuffer);
|
FCurrentIndex.InsertRecordBeforeCurrentRecord(IntAllocRecordBuffer);
|
||||||
FCurrentIndex.ScrollBackward;
|
FCurrentIndex.ScrollBackward;
|
||||||
move(pchar(OldValuesBuffer)^,pchar(FCurrentIndex.CurrentBuffer)^,FRecordSize);
|
move(pchar(OldValuesBuffer)^,pchar(FCurrentIndex.CurrentBuffer)^,FRecordSize);
|
||||||
FreeRecordBuffer(OldValuesBuffer);
|
FreeRecordBuffer(OldValuesBuffer);
|
||||||
{$ENDIF}
|
|
||||||
inc(FBRecordCount);
|
inc(FBRecordCount);
|
||||||
end
|
end
|
||||||
else if UpdateKind = ukInsert then
|
else if UpdateKind = ukInsert then
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
RecInd := GetRecordFromBookmark(Bookmark);
|
|
||||||
FreeRecordBuffer(FCurrentIndex^.FRecordArray[RecInd]);
|
|
||||||
move(FCurrentIndex^.FRecordArray[RecInd+1],FCurrentIndex^.FRecordArray[RecInd],sizeof(Pointer)*(FCurrentIndex^.FLastRecInd-RecInd));
|
|
||||||
dec(FCurrentIndex^.FLastRecInd);
|
|
||||||
{$ELSE}
|
|
||||||
FCurrentIndex.GotoBookmark(@BookmarkData);
|
FCurrentIndex.GotoBookmark(@BookmarkData);
|
||||||
TmpBuf:=FCurrentIndex.CurrentRecord;
|
TmpBuf:=FCurrentIndex.CurrentRecord;
|
||||||
// resync won't work if the currentbuffer is freed...
|
// resync won't work if the currentbuffer is freed...
|
||||||
@ -1825,7 +1623,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
FCurrentIndex.RemoveRecordFromIndex(BookmarkData);
|
FCurrentIndex.RemoveRecordFromIndex(BookmarkData);
|
||||||
FreeRecordBuffer(TmpBuf);
|
FreeRecordBuffer(TmpBuf);
|
||||||
{$ENDIF}
|
|
||||||
dec(FBRecordCount);
|
dec(FBRecordCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1861,9 +1658,6 @@ var r : Integer;
|
|||||||
AUpdateErr : EUpdateError;
|
AUpdateErr : EUpdateError;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
DatabaseError('ApplyUpdates is not supported');
|
|
||||||
{$ELSE}
|
|
||||||
CheckBrowseMode;
|
CheckBrowseMode;
|
||||||
|
|
||||||
FCurrentIndex.StoreCurrentRecIntoBookmark(@StoreCurrRec);
|
FCurrentIndex.StoreCurrentRecIntoBookmark(@StoreCurrRec);
|
||||||
@ -1941,7 +1735,6 @@ begin
|
|||||||
Resync([]);
|
Resync([]);
|
||||||
EnableControls;
|
EnableControls;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1961,13 +1754,10 @@ end;
|
|||||||
|
|
||||||
procedure TBufDataset.InternalPost;
|
procedure TBufDataset.InternalPost;
|
||||||
|
|
||||||
Var tmpRecBuffer : PBufRecLinkItem;
|
Var CurrBuff : PChar;
|
||||||
CurrBuff : PChar;
|
|
||||||
i : integer;
|
i : integer;
|
||||||
blobbuf : tbufblobfield;
|
blobbuf : tbufblobfield;
|
||||||
NullMask : pbyte;
|
NullMask : pbyte;
|
||||||
StartInd : Integer;
|
|
||||||
IndNr : Integer;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited InternalPost;
|
inherited InternalPost;
|
||||||
@ -1988,13 +1778,6 @@ begin
|
|||||||
if state = dsInsert then
|
if state = dsInsert then
|
||||||
begin
|
begin
|
||||||
if GetBookmarkFlag(ActiveBuffer) = bfEOF then
|
if GetBookmarkFlag(ActiveBuffer) = bfEOF then
|
||||||
// Append
|
|
||||||
// with (FIndexes[0] as TDoubleLinkedBufIndex) do
|
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
// FCurrentRecInd := FLastRecInd
|
|
||||||
{$ELSE}
|
|
||||||
// FCurrentRecBuf := FLastRecBuf
|
|
||||||
{$ENDIF}
|
|
||||||
FIndexes[0].ScrollLast
|
FIndexes[0].ScrollLast
|
||||||
else
|
else
|
||||||
// The active buffer is the newly created TDataset record,
|
// The active buffer is the newly created TDataset record,
|
||||||
@ -2004,32 +1787,18 @@ begin
|
|||||||
|
|
||||||
with FIndexes[0] do
|
with FIndexes[0] do
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
inc(FLastRecInd);
|
|
||||||
if FLastRecInd >= length(FRecordArray) then
|
|
||||||
SetLength(FRecordArray,length(FRecordArray)+FGrowBuffer);
|
|
||||||
Move(FRecordArray[FCurrentRecInd],FRecordArray[FCurrentRecInd+1],sizeof(Pointer)*(FLastRecInd-FCurrentRecInd));
|
|
||||||
FRecordArray[FCurrentRecInd]:=pointer(IntAllocRecordBuffer);
|
|
||||||
{$ELSE}
|
|
||||||
// Create the new record buffer
|
// Create the new record buffer
|
||||||
FCurrentIndex.InsertRecordBeforeCurrentRecord(IntAllocRecordBuffer);
|
FCurrentIndex.InsertRecordBeforeCurrentRecord(IntAllocRecordBuffer);
|
||||||
ScrollBackward;
|
ScrollBackward;
|
||||||
// FCurrentRecBuf := FCurrentRecBuf[IndNr].prior;
|
|
||||||
// Add the record to the other indexes
|
// Add the record to the other indexes
|
||||||
for i := 1 to FIndexesCount-1 do if ((i>1) or (FIndexes[i]=FCurrentIndex)) then
|
for i := 1 to FIndexesCount-1 do if ((i>1) or (FIndexes[i]=FCurrentIndex)) then
|
||||||
FIndexes[i].InsertRecordBeforeCurrentRecord(CurrentRecord);
|
FIndexes[i].InsertRecordBeforeCurrentRecord(CurrentRecord);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Link the newly created record buffer to the newly created TDataset record
|
// Link the newly created record buffer to the newly created TDataset record
|
||||||
with PBufBookmark(ActiveBuffer + FRecordSize)^ do
|
with PBufBookmark(ActiveBuffer + FRecordSize)^ do
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
BookmarkData := FCurrentIndex^.FCurrentRecInd;
|
|
||||||
{$ELSE}
|
|
||||||
// BookmarkData := (FCurrentIndex as TDoubleLinkedBufIndex).FCurrentRecBuf;
|
|
||||||
FCurrentIndex.StoreCurrentRecIntoBookmark(@BookmarkData);
|
FCurrentIndex.StoreCurrentRecIntoBookmark(@BookmarkData);
|
||||||
{$ENDIF}
|
|
||||||
BookmarkFlag := bfInserted;
|
BookmarkFlag := bfInserted;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2046,28 +1815,16 @@ begin
|
|||||||
FCurrentUpdateBuffer := length(FUpdateBuffer);
|
FCurrentUpdateBuffer := length(FUpdateBuffer);
|
||||||
SetLength(FUpdateBuffer,FCurrentUpdateBuffer+1);
|
SetLength(FUpdateBuffer,FCurrentUpdateBuffer+1);
|
||||||
|
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
with FCurrentIndex^ do
|
|
||||||
begin
|
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].Bookmark.BookmarkData := FCurrentRecInd;
|
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].Bookmark.BookMarkBuf := FRecordArray[FCurrentRecInd];
|
|
||||||
end;
|
|
||||||
{$ELSE}
|
|
||||||
// Store a bookmark of the current record into the updatebuffer's bookmark
|
// Store a bookmark of the current record into the updatebuffer's bookmark
|
||||||
FCurrentIndex.StoreCurrentRecIntoBookmark(@FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData);
|
FCurrentIndex.StoreCurrentRecIntoBookmark(@FUpdateBuffer[FCurrentUpdateBuffer].BookmarkData);
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
if state = dsEdit then
|
if state = dsEdit then
|
||||||
begin
|
begin
|
||||||
// Create an oldvalues buffer with the old values of the record
|
// Create an oldvalues buffer with the old values of the record
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer := intAllocRecordBuffer;
|
FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer := intAllocRecordBuffer;
|
||||||
with FCurrentIndex do
|
with FCurrentIndex do
|
||||||
{$IFDEF ARRAYBUF}
|
// Move only the real data
|
||||||
move(FRecordArray[FCurrentRecInd]^,FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer^,FRecordSize);
|
|
||||||
{$ELSE}
|
|
||||||
// Move alleen de data, en niet het reclinkitem!
|
|
||||||
move(CurrentBuffer^,FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer^,FRecordSize);
|
move(CurrentBuffer^,FUpdateBuffer[FCurrentUpdateBuffer].OldValuesBuffer^,FRecordSize);
|
||||||
{$ENDIF}
|
|
||||||
FUpdateBuffer[FCurrentUpdateBuffer].UpdateKind := ukModify;
|
FUpdateBuffer[FCurrentUpdateBuffer].UpdateKind := ukModify;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -2077,14 +1834,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
with FIndexes[0] do
|
|
||||||
move(ActiveBuffer^,FRecordArray[FCurrentRecInd]^,FRecordSize);
|
|
||||||
{$ELSE}
|
|
||||||
// CurrBuff := pchar(FCurrentIndex as TDoubleLinkedBufIndex).FCurrentRecBuf);
|
|
||||||
|
|
||||||
// tmpRecBuffer:=PBufRecLinkItem(CurrBuff);
|
|
||||||
// inc(Currbuff,sizeof(TBufRecLinkItem)*FMaxIndexesCount);
|
|
||||||
move(ActiveBuffer^,FCurrentIndex.CurrentBuffer^,FRecordSize);
|
move(ActiveBuffer^,FCurrentIndex.CurrentBuffer^,FRecordSize);
|
||||||
// CurrBuff:=pchar(tmpRecBuffer);
|
// CurrBuff:=pchar(tmpRecBuffer);
|
||||||
// The next part has to be rewritten.
|
// The next part has to be rewritten.
|
||||||
@ -2128,7 +1877,6 @@ begin
|
|||||||
AddRecordToIndex(PBufRecLinkItem(CurrBuff),tmpRecBuffer,FIndexes[i]);
|
AddRecordToIndex(PBufRecLinkItem(CurrBuff),tmpRecBuffer,FIndexes[i]);
|
||||||
end;
|
end;
|
||||||
end;}
|
end;}
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBufDataset.CalcRecordSize;
|
procedure TBufDataset.CalcRecordSize;
|
||||||
@ -2186,12 +1934,8 @@ end;
|
|||||||
procedure TBufDataset.SetRecNo(Value: Longint);
|
procedure TBufDataset.SetRecNo(Value: Longint);
|
||||||
|
|
||||||
var
|
var
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
ABookMark : TBufBookmark;
|
|
||||||
{$ELSE}
|
|
||||||
recnr : integer;
|
recnr : integer;
|
||||||
TmpRecBuffer : PBufRecLinkItem;
|
TmpRecBuffer : PBufRecLinkItem;
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
checkbrowsemode;
|
checkbrowsemode;
|
||||||
@ -2204,39 +1948,23 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
ABookMark.BookMarkBuf:=nil;
|
|
||||||
ABookMark.BookmarkData:=Value-1;
|
|
||||||
GotoBookmark(@ABookMark);
|
|
||||||
{$ELSE}
|
|
||||||
TmpRecBuffer := (FCurrentIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
|
TmpRecBuffer := (FCurrentIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
|
||||||
for recnr := 1 to value-1 do
|
for recnr := 1 to value-1 do
|
||||||
TmpRecBuffer := TmpRecBuffer^.next;
|
TmpRecBuffer := TmpRecBuffer^.next;
|
||||||
GotoBookmark(@TmpRecBuffer);
|
GotoBookmark(@TmpRecBuffer);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBufDataset.GetRecNo: Longint;
|
function TBufDataset.GetRecNo: Longint;
|
||||||
|
|
||||||
Var abuf : PChar;
|
Var abuf : PChar;
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
ABookMark : TBufBookmark;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
abuf := GetCurrentBuffer;
|
abuf := GetCurrentBuffer;
|
||||||
// If abuf isn't assigned, the recordset probably isn't opened.
|
// If abuf isn't assigned, the recordset probably isn't opened.
|
||||||
if assigned(abuf) and (FBRecordCount>0) and (state <> dsInsert) then
|
if assigned(abuf) and (FBRecordCount>0) and (state <> dsInsert) then
|
||||||
begin
|
Result:=FCurrentIndex.GetRecNo(PBufBookmark(abuf+FRecordSize))
|
||||||
{$IFDEF ARRAYBUF}
|
else
|
||||||
GetBookmarkData(abuf,@ABookMark);
|
result := 0;
|
||||||
recnr:=GetRecordFromBookmark(ABookMark);
|
|
||||||
inc(recnr);
|
|
||||||
{$ELSE}
|
|
||||||
{$ENDIF}
|
|
||||||
Result:=FCurrentIndex.GetRecNo(PBufBookmark(abuf+FRecordSize));
|
|
||||||
end
|
|
||||||
else result := 0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBufDataset.IsCursorOpen: Boolean;
|
function TBufDataset.IsCursorOpen: Boolean;
|
||||||
@ -2398,10 +2126,8 @@ procedure TBufDataset.AddIndex(const AName, AFields : string; AOptions : TIndexO
|
|||||||
begin
|
begin
|
||||||
if AFields='' then DatabaseError(SNoIndexFieldNameGiven);
|
if AFields='' then DatabaseError(SNoIndexFieldNameGiven);
|
||||||
|
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
if active and (FIndexesCount=FMaxIndexesCount) then
|
if active and (FIndexesCount=FMaxIndexesCount) then
|
||||||
DatabaseError(SMaxIndexes);
|
DatabaseError(SMaxIndexes);
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
// If not all packets are fetched, you can not sort properly.
|
// If not all packets are fetched, you can not sort properly.
|
||||||
if not active then
|
if not active then
|
||||||
@ -2421,8 +2147,8 @@ begin
|
|||||||
inc(FIndexesCount);
|
inc(FIndexesCount);
|
||||||
setlength(FIndexes,FIndexesCount); // This invalidates the currentindex! -> not anymore
|
setlength(FIndexes,FIndexesCount); // This invalidates the currentindex! -> not anymore
|
||||||
FCurrentIndex:=FIndexes[StoreIndNr];
|
FCurrentIndex:=FIndexes[StoreIndNr];
|
||||||
// FIndexes[FIndexesCount-1] := TDoubleLinkedBufIndex.Create(self);
|
FIndexes[FIndexesCount-1] := TDoubleLinkedBufIndex.Create(self);
|
||||||
FIndexes[FIndexesCount-1] := TArrayBufIndex.Create(self);
|
// FIndexes[FIndexesCount-1] := TArrayBufIndex.Create(self);
|
||||||
FIndexes[FIndexesCount-1].InitialiseIndex;
|
FIndexes[FIndexesCount-1].InitialiseIndex;
|
||||||
with (FIndexes[FIndexesCount-1] as TBufIndex) do
|
with (FIndexes[FIndexesCount-1] as TBufIndex) do
|
||||||
begin
|
begin
|
||||||
@ -2434,9 +2160,6 @@ begin
|
|||||||
IndNr:=FIndexesCount-1;
|
IndNr:=FIndexesCount-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
setlength(FIndexes[FIndexesCount-1].FRecordArray,FInitialBuffers);
|
|
||||||
{$ENDIF}
|
|
||||||
if Active then
|
if Active then
|
||||||
begin
|
begin
|
||||||
(FIndexes[FIndexesCount-1] as TDoubleLinkedBufIndex).FFirstRecBuf := pointer(IntAllocRecordBuffer);
|
(FIndexes[FIndexesCount-1] as TDoubleLinkedBufIndex).FFirstRecBuf := pointer(IntAllocRecordBuffer);
|
||||||
@ -2444,10 +2167,8 @@ begin
|
|||||||
(FCurrentIndex as TDoubleLinkedBufIndex).FCurrentRecBuf := (FIndexes[FIndexesCount-1] as TDoubleLinkedBufIndex).FLastRecBuf;
|
(FCurrentIndex as TDoubleLinkedBufIndex).FCurrentRecBuf := (FIndexes[FIndexesCount-1] as TDoubleLinkedBufIndex).FLastRecBuf;
|
||||||
BuildIndex(FIndexes[FIndexesCount-1]);
|
BuildIndex(FIndexes[FIndexesCount-1]);
|
||||||
end
|
end
|
||||||
{$IFNDEF ARRAYBUF}
|
|
||||||
else if FIndexesCount>FMaxIndexesCount then
|
else if FIndexesCount>FMaxIndexesCount then
|
||||||
FMaxIndexesCount := FIndexesCount;
|
FMaxIndexesCount := FIndexesCount;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBufDataset.DoFilterRecord(var Acceptable: Boolean);
|
procedure TBufDataset.DoFilterRecord(var Acceptable: Boolean);
|
||||||
@ -2555,9 +2276,6 @@ var CurrLinkItem : PBufRecLinkItem;
|
|||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
DatabaseError('Locate is not supported');
|
|
||||||
{$ELSE}
|
|
||||||
Result := False;
|
Result := False;
|
||||||
if IsEmpty then exit;
|
if IsEmpty then exit;
|
||||||
|
|
||||||
@ -2602,15 +2320,10 @@ begin
|
|||||||
// If a match is found, jump to the found record
|
// If a match is found, jump to the found record
|
||||||
if Result then
|
if Result then
|
||||||
begin
|
begin
|
||||||
{$IFDEF ARRAYBUF}
|
|
||||||
// bm.BookmarkData := CurrLinkItem;
|
|
||||||
{$ELSE}
|
|
||||||
bm.BookmarkData := CurrLinkItem;
|
bm.BookmarkData := CurrLinkItem;
|
||||||
{$ENDIF}
|
|
||||||
bm.BookmarkFlag := bfCurrent;
|
bm.BookmarkFlag := bfCurrent;
|
||||||
GotoBookmark(@bm);
|
GotoBookmark(@bm);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TArrayBufIndex }
|
{ TArrayBufIndex }
|
||||||
|
Loading…
Reference in New Issue
Block a user