|
@@ -161,10 +161,9 @@ type
|
|
// Inserts a record before the current record, or if the record is sorted,
|
|
// Inserts a record before the current record, or if the record is sorted,
|
|
// inserts it in the proper position
|
|
// inserts it in the proper position
|
|
procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); virtual; abstract;
|
|
procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); virtual; abstract;
|
|
|
|
+ procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); virtual; abstract;
|
|
procedure OrderCurrentRecord; virtual; abstract;
|
|
procedure OrderCurrentRecord; virtual; abstract;
|
|
procedure EndUpdate; virtual; abstract;
|
|
procedure EndUpdate; virtual; abstract;
|
|
-
|
|
|
|
- procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); virtual; abstract;
|
|
|
|
|
|
|
|
function CompareBookmarks(const ABookmark1, ABookmark2 : PBufBookmark) : boolean; virtual;
|
|
function CompareBookmarks(const ABookmark1, ABookmark2 : PBufBookmark) : boolean; virtual;
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; virtual; abstract;
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; virtual; abstract;
|
|
@@ -222,12 +221,12 @@ type
|
|
procedure InitialiseSpareRecord(const ASpareRecord : TRecordBuffer); override;
|
|
procedure InitialiseSpareRecord(const ASpareRecord : TRecordBuffer); override;
|
|
procedure ReleaseSpareRecord; override;
|
|
procedure ReleaseSpareRecord; override;
|
|
|
|
|
|
- procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); override;
|
|
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; override;
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; override;
|
|
|
|
|
|
procedure BeginUpdate; override;
|
|
procedure BeginUpdate; override;
|
|
procedure AddRecord; override;
|
|
procedure AddRecord; override;
|
|
procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); override;
|
|
procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); override;
|
|
|
|
+ procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); override;
|
|
procedure OrderCurrentRecord; override;
|
|
procedure OrderCurrentRecord; override;
|
|
procedure EndUpdate; override;
|
|
procedure EndUpdate; override;
|
|
end;
|
|
end;
|
|
@@ -268,12 +267,12 @@ type
|
|
procedure InitialiseSpareRecord(const ASpareRecord : TRecordBuffer); override;
|
|
procedure InitialiseSpareRecord(const ASpareRecord : TRecordBuffer); override;
|
|
procedure ReleaseSpareRecord; override;
|
|
procedure ReleaseSpareRecord; override;
|
|
|
|
|
|
- procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); override;
|
|
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; override;
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; override;
|
|
|
|
|
|
procedure BeginUpdate; override;
|
|
procedure BeginUpdate; override;
|
|
procedure AddRecord; override;
|
|
procedure AddRecord; override;
|
|
procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); override;
|
|
procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); override;
|
|
|
|
+ procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); override;
|
|
procedure OrderCurrentRecord; override;
|
|
procedure OrderCurrentRecord; override;
|
|
procedure EndUpdate; override;
|
|
procedure EndUpdate; override;
|
|
end;
|
|
end;
|
|
@@ -326,11 +325,11 @@ type
|
|
procedure ReleaseSpareRecord; override;
|
|
procedure ReleaseSpareRecord; override;
|
|
|
|
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; override;
|
|
Function GetRecNo(const ABookmark : PBufBookmark) : integer; override;
|
|
- procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); override;
|
|
|
|
- procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); override;
|
|
|
|
|
|
|
|
procedure BeginUpdate; override;
|
|
procedure BeginUpdate; override;
|
|
procedure AddRecord; override;
|
|
procedure AddRecord; override;
|
|
|
|
+ procedure InsertRecordBeforeCurrentRecord(Const ARecord : TRecordBuffer); override;
|
|
|
|
+ procedure RemoveRecordFromIndex(const ABookmark : TBufBookmark); override;
|
|
procedure EndUpdate; override;
|
|
procedure EndUpdate; override;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -401,9 +400,9 @@ type
|
|
FReadFromFile : boolean;
|
|
FReadFromFile : boolean;
|
|
FFileStream : TFileStream;
|
|
FFileStream : TFileStream;
|
|
FDatasetReader : TDataPacketReader;
|
|
FDatasetReader : TDataPacketReader;
|
|
|
|
+
|
|
FIndexes : array of TBufIndex;
|
|
FIndexes : array of TBufIndex;
|
|
FMaxIndexesCount: integer;
|
|
FMaxIndexesCount: integer;
|
|
-
|
|
|
|
FIndexesCount : integer;
|
|
FIndexesCount : integer;
|
|
FCurrentIndex : TBufIndex;
|
|
FCurrentIndex : TBufIndex;
|
|
|
|
|
|
@@ -520,7 +519,7 @@ type
|
|
procedure MergeChangeLog;
|
|
procedure MergeChangeLog;
|
|
procedure CancelUpdates; virtual;
|
|
procedure CancelUpdates; virtual;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
- function Locate(const keyfields: string; const keyvalues: Variant; options: TLocateOptions) : boolean; override;
|
|
|
|
|
|
+ function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions) : boolean; override;
|
|
function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant; override;
|
|
function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant; override;
|
|
function UpdateStatus: TUpdateStatus; override;
|
|
function UpdateStatus: TUpdateStatus; override;
|
|
function CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream; override;
|
|
function CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream; override;
|
|
@@ -1093,12 +1092,12 @@ end;
|
|
function TCustomBufDataset.IntAllocRecordBuffer: TRecordBuffer;
|
|
function TCustomBufDataset.IntAllocRecordBuffer: TRecordBuffer;
|
|
begin
|
|
begin
|
|
// Note: Only the internal buffers of TDataset provide bookmark information
|
|
// Note: Only the internal buffers of TDataset provide bookmark information
|
|
- result := AllocMem(FRecordsize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
|
|
|
|
|
|
+ result := AllocMem(FRecordSize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TCustomBufDataset.AllocRecordBuffer: TRecordBuffer;
|
|
function TCustomBufDataset.AllocRecordBuffer: TRecordBuffer;
|
|
begin
|
|
begin
|
|
- 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
|
|
InitRecord(result);
|
|
InitRecord(result);
|
|
@@ -1404,21 +1403,6 @@ begin
|
|
FFirstRecBuf:= nil;
|
|
FFirstRecBuf:= nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TDoubleLinkedBufIndex.RemoveRecordFromIndex(const ABookmark : TBufBookmark);
|
|
|
|
-var ARecord : PBufRecLinkItem;
|
|
|
|
-begin
|
|
|
|
- ARecord := ABookmark.BookmarkData;
|
|
|
|
- if ARecord = FCurrentRecBuf then DoScrollForward;
|
|
|
|
- if ARecord <> FFirstRecBuf then
|
|
|
|
- ARecord[IndNr].prior[IndNr].next := ARecord[IndNr].next
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- FFirstRecBuf := ARecord[IndNr].next;
|
|
|
|
- FLastRecBuf[IndNr].next := FFirstRecBuf;
|
|
|
|
- end;
|
|
|
|
- ARecord[IndNr].next[IndNr].prior := ARecord[IndNr].prior;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
function TDoubleLinkedBufIndex.GetRecNo(const ABookmark: PBufBookmark): integer;
|
|
function TDoubleLinkedBufIndex.GetRecNo(const ABookmark: PBufBookmark): integer;
|
|
Var TmpRecBuffer : PBufRecLinkItem;
|
|
Var TmpRecBuffer : PBufRecLinkItem;
|
|
recnr : integer;
|
|
recnr : integer;
|
|
@@ -1468,6 +1452,21 @@ begin
|
|
ANewRecord[IndNr].next[IndNr].prior:=ANewRecord;
|
|
ANewRecord[IndNr].next[IndNr].prior:=ANewRecord;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TDoubleLinkedBufIndex.RemoveRecordFromIndex(const ABookmark : TBufBookmark);
|
|
|
|
+var ARecord : PBufRecLinkItem;
|
|
|
|
+begin
|
|
|
|
+ ARecord := ABookmark.BookmarkData;
|
|
|
|
+ if ARecord = FCurrentRecBuf then DoScrollForward;
|
|
|
|
+ if ARecord <> FFirstRecBuf then
|
|
|
|
+ ARecord[IndNr].prior[IndNr].next := ARecord[IndNr].next
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ FFirstRecBuf := ARecord[IndNr].next;
|
|
|
|
+ FLastRecBuf[IndNr].next := FFirstRecBuf;
|
|
|
|
+ end;
|
|
|
|
+ ARecord[IndNr].next[IndNr].prior := ARecord[IndNr].prior;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TDoubleLinkedBufIndex.OrderCurrentRecord;
|
|
procedure TDoubleLinkedBufIndex.OrderCurrentRecord;
|
|
var ARecord: PBufRecLinkItem;
|
|
var ARecord: PBufRecLinkItem;
|
|
ABookmark: TBufBookmark;
|
|
ABookmark: TBufBookmark;
|
|
@@ -1531,18 +1530,6 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCustomBufDataset.InitDefaultIndexes;
|
|
|
|
-begin
|
|
|
|
- if FIndexesCount=0 then
|
|
|
|
- begin
|
|
|
|
- InternalAddIndex('DEFAULT_ORDER','',[],'','');
|
|
|
|
- FCurrentIndex:=FIndexes[0];
|
|
|
|
- if not IsUniDirectional then
|
|
|
|
- InternalAddIndex('','',[],'','');
|
|
|
|
- BookmarkSize := FCurrentIndex.BookmarkSize;
|
|
|
|
- end;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
procedure TCustomBufDataset.SetReadOnly(AValue: Boolean);
|
|
procedure TCustomBufDataset.SetReadOnly(AValue: Boolean);
|
|
begin
|
|
begin
|
|
FReadOnly:=AValue;
|
|
FReadOnly:=AValue;
|
|
@@ -1641,6 +1628,73 @@ begin
|
|
ACompareRec.NullBOff2:=ACompareRec.NullBOff1;
|
|
ACompareRec.NullBOff2:=ACompareRec.NullBOff1;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TCustomBufDataset.InitDefaultIndexes;
|
|
|
|
+begin
|
|
|
|
+ if FIndexesCount=0 then
|
|
|
|
+ begin
|
|
|
|
+ InternalAddIndex('DEFAULT_ORDER','',[],'','');
|
|
|
|
+ FCurrentIndex:=FIndexes[0];
|
|
|
|
+ if not IsUniDirectional then
|
|
|
|
+ InternalAddIndex('','',[],'','');
|
|
|
|
+ BookmarkSize := FCurrentIndex.BookmarkSize;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCustomBufDataset.AddIndex(const AName, AFields : string; AOptions : TIndexOptions; const ADescFields: string = '';
|
|
|
|
+ const ACaseInsFields: string = '');
|
|
|
|
+begin
|
|
|
|
+ CheckBiDirectional;
|
|
|
|
+ if AFields='' then DatabaseError(SNoIndexFieldNameGiven);
|
|
|
|
+
|
|
|
|
+ if FIndexesCount=0 then
|
|
|
|
+ InitDefaultIndexes;
|
|
|
|
+
|
|
|
|
+ if Active and (FIndexesCount=FMaxIndexesCount) then
|
|
|
|
+ DatabaseError(SMaxIndexes);
|
|
|
|
+
|
|
|
|
+ // If not all packets are fetched, you can not sort properly.
|
|
|
|
+ if not Active then
|
|
|
|
+ FPacketRecords:=-1;
|
|
|
|
+ InternalAddIndex(AName,AFields,AOptions,ADescFields,ACaseInsFields);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCustomBufDataset.InternalAddIndex(const AName, AFields : string; AOptions : TIndexOptions; const ADescFields: string;
|
|
|
|
+ const ACaseInsFields: string);
|
|
|
|
+var StoreIndNr : Integer;
|
|
|
|
+begin
|
|
|
|
+ if Active then FetchAll;
|
|
|
|
+ if FIndexesCount>0 then
|
|
|
|
+ StoreIndNr:=FCurrentIndex.IndNr
|
|
|
|
+ else
|
|
|
|
+ StoreIndNr:=0;
|
|
|
|
+ inc(FIndexesCount);
|
|
|
|
+ setlength(FIndexes,FIndexesCount); // This invalidates the currentindex! -> not anymore
|
|
|
|
+ FCurrentIndex:=FIndexes[StoreIndNr];
|
|
|
|
+ if IsUniDirectional then
|
|
|
|
+ FIndexes[FIndexesCount-1] := TUniDirectionalBufIndex.Create(self)
|
|
|
|
+ else
|
|
|
|
+ FIndexes[FIndexesCount-1] := TDoubleLinkedBufIndex.Create(self);
|
|
|
|
+// FIndexes[FIndexesCount-1] := TArrayBufIndex.Create(self);
|
|
|
|
+ FIndexes[FIndexesCount-1].InitialiseIndex;
|
|
|
|
+ with (FIndexes[FIndexesCount-1] as TBufIndex) do
|
|
|
|
+ begin
|
|
|
|
+ Name:=AName;
|
|
|
|
+ FieldsName:=AFields;
|
|
|
|
+ DescFields:=ADescFields;
|
|
|
|
+ CaseinsFields:=ACaseInsFields;
|
|
|
|
+ Options:=AOptions;
|
|
|
|
+ IndNr:=FIndexesCount-1;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ if Active then
|
|
|
|
+ begin
|
|
|
|
+ FIndexes[FIndexesCount-1].InitialiseSpareRecord(IntAllocRecordBuffer);
|
|
|
|
+ BuildIndex(FIndexes[FIndexesCount-1]);
|
|
|
|
+ end
|
|
|
|
+ else if FIndexesCount>FMaxIndexesCount then
|
|
|
|
+ FMaxIndexesCount := FIndexesCount;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TCustomBufDataset.SetIndexFieldNames(const AValue: String);
|
|
procedure TCustomBufDataset.SetIndexFieldNames(const AValue: String);
|
|
begin
|
|
begin
|
|
if AValue<>'' then
|
|
if AValue<>'' then
|
|
@@ -1649,7 +1703,7 @@ begin
|
|
InitDefaultIndexes;
|
|
InitDefaultIndexes;
|
|
FIndexes[1].FieldsName:=AValue;
|
|
FIndexes[1].FieldsName:=AValue;
|
|
FCurrentIndex:=FIndexes[1];
|
|
FCurrentIndex:=FIndexes[1];
|
|
- if active then
|
|
|
|
|
|
+ if Active then
|
|
begin
|
|
begin
|
|
FetchAll;
|
|
FetchAll;
|
|
BuildIndex(FIndexes[1]);
|
|
BuildIndex(FIndexes[1]);
|
|
@@ -1669,7 +1723,7 @@ begin
|
|
begin
|
|
begin
|
|
(FIndexes[i] as TDoubleLinkedBufIndex).FCurrentRecBuf:=(FCurrentIndex as TDoubleLinkedBufIndex).FCurrentRecBuf;
|
|
(FIndexes[i] as TDoubleLinkedBufIndex).FCurrentRecBuf:=(FCurrentIndex as TDoubleLinkedBufIndex).FCurrentRecBuf;
|
|
FCurrentIndex:=FIndexes[i];
|
|
FCurrentIndex:=FIndexes[i];
|
|
- if active then Resync([rmCenter]);
|
|
|
|
|
|
+ if Active then Resync([rmCenter]);
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -1731,7 +1785,7 @@ begin
|
|
|
|
|
|
i := 0;
|
|
i := 0;
|
|
pb := FIndexes[0].SpareBuffer;
|
|
pb := FIndexes[0].SpareBuffer;
|
|
- while ((i < FPacketRecords) or (FPacketRecords = -1)) and (loadbuffer(pb) = grOk) do
|
|
|
|
|
|
+ while ((i < FPacketRecords) or (FPacketRecords = -1)) and (LoadBuffer(pb) = grOk) do
|
|
begin
|
|
begin
|
|
with FIndexes[0] do
|
|
with FIndexes[0] do
|
|
begin
|
|
begin
|
|
@@ -2141,7 +2195,7 @@ begin
|
|
on E: EDatabaseError do
|
|
on E: EDatabaseError do
|
|
begin
|
|
begin
|
|
Inc(FailedCount);
|
|
Inc(FailedCount);
|
|
- if failedcount > word(MaxErrors) then Response := rrAbort
|
|
|
|
|
|
+ if FailedCount > word(MaxErrors) then Response := rrAbort
|
|
else Response := rrSkip;
|
|
else Response := rrSkip;
|
|
if assigned(FOnUpdateError) then
|
|
if assigned(FOnUpdateError) then
|
|
begin
|
|
begin
|
|
@@ -2168,7 +2222,7 @@ begin
|
|
inc(r);
|
|
inc(r);
|
|
end;
|
|
end;
|
|
finally
|
|
finally
|
|
- if failedcount = 0 then
|
|
|
|
|
|
+ if FailedCount = 0 then
|
|
MergeChangeLog;
|
|
MergeChangeLog;
|
|
|
|
|
|
InternalGotoBookmark(@StoreCurrRec);
|
|
InternalGotoBookmark(@StoreCurrRec);
|
|
@@ -2293,7 +2347,7 @@ begin
|
|
// 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);
|
|
|
|
|
|
- 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;
|
|
@@ -2585,24 +2639,6 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCustomBufDataset.AddIndex(const AName, AFields : string; AOptions : TIndexOptions; const ADescFields: string = '';
|
|
|
|
- const ACaseInsFields: string = '');
|
|
|
|
-begin
|
|
|
|
- CheckBiDirectional;
|
|
|
|
- if AFields='' then DatabaseError(SNoIndexFieldNameGiven);
|
|
|
|
-
|
|
|
|
- if FIndexesCount=0 then
|
|
|
|
- InitDefaultIndexes;
|
|
|
|
-
|
|
|
|
- if active and (FIndexesCount=FMaxIndexesCount) then
|
|
|
|
- DatabaseError(SMaxIndexes);
|
|
|
|
-
|
|
|
|
- // If not all packets are fetched, you can not sort properly.
|
|
|
|
- if not active then
|
|
|
|
- FPacketRecords:=-1;
|
|
|
|
- InternalAddIndex(AName,AFields,AOptions,ADescFields,ACaseInsFields);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
procedure TCustomBufDataset.SaveToFile(AFileName: string;
|
|
procedure TCustomBufDataset.SaveToFile(AFileName: string;
|
|
Format: TDataPacketFormat);
|
|
Format: TDataPacketFormat);
|
|
var AFileStream : TFileStream;
|
|
var AFileStream : TFileStream;
|
|
@@ -2935,43 +2971,6 @@ begin
|
|
BuildIndex(FIndexes[x]);
|
|
BuildIndex(FIndexes[x]);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCustomBufDataset.InternalAddIndex(const AName, AFields : string; AOptions : TIndexOptions; const ADescFields: string;
|
|
|
|
- const ACaseInsFields: string);
|
|
|
|
-var StoreIndNr : Integer;
|
|
|
|
-begin
|
|
|
|
- if Active then FetchAll;
|
|
|
|
- if FIndexesCount>0 then
|
|
|
|
- StoreIndNr:=FCurrentIndex.IndNr
|
|
|
|
- else
|
|
|
|
- StoreIndNr:=0;
|
|
|
|
- inc(FIndexesCount);
|
|
|
|
- setlength(FIndexes,FIndexesCount); // This invalidates the currentindex! -> not anymore
|
|
|
|
- FCurrentIndex:=FIndexes[StoreIndNr];
|
|
|
|
- if IsUniDirectional then
|
|
|
|
- FIndexes[FIndexesCount-1] := TUniDirectionalBufIndex.Create(self)
|
|
|
|
- else
|
|
|
|
- FIndexes[FIndexesCount-1] := TDoubleLinkedBufIndex.Create(self);
|
|
|
|
-// FIndexes[FIndexesCount-1] := TArrayBufIndex.Create(self);
|
|
|
|
- FIndexes[FIndexesCount-1].InitialiseIndex;
|
|
|
|
- with (FIndexes[FIndexesCount-1] as TBufIndex) do
|
|
|
|
- begin
|
|
|
|
- Name:=AName;
|
|
|
|
- FieldsName:=AFields;
|
|
|
|
- DescFields:=ADescFields;
|
|
|
|
- CaseinsFields:=ACaseInsFields;
|
|
|
|
- Options:=AOptions;
|
|
|
|
- IndNr:=FIndexesCount-1;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- if Active then
|
|
|
|
- begin
|
|
|
|
- FIndexes[FIndexesCount-1].InitialiseSpareRecord(IntAllocRecordBuffer);
|
|
|
|
- BuildIndex(FIndexes[FIndexesCount-1]);
|
|
|
|
- end
|
|
|
|
- else if FIndexesCount>FMaxIndexesCount then
|
|
|
|
- FMaxIndexesCount := FIndexesCount;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
procedure TCustomBufDataset.DoFilterRecord(out Acceptable: Boolean);
|
|
procedure TCustomBufDataset.DoFilterRecord(out Acceptable: Boolean);
|
|
begin
|
|
begin
|
|
Acceptable := true;
|
|
Acceptable := true;
|
|
@@ -3080,37 +3079,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TArrayBufIndex.GetRecordFromBookmark(ABookMark: TBufBookmark) : integer;
|
|
|
|
-begin
|
|
|
|
- // ABookmark.BookMarkBuf is nil if SetRecNo calls GotoBookmark
|
|
|
|
- if (ABookmark.BookmarkData<>nil) and (FRecordArray[ABookmark.BookmarkInt]<>ABookmark.BookmarkData) then
|
|
|
|
- begin
|
|
|
|
- // Start searching two records before the expected record
|
|
|
|
- if ABookmark.BookmarkInt > 2 then
|
|
|
|
- Result := ABookmark.BookmarkInt-2
|
|
|
|
- else
|
|
|
|
- Result := 0;
|
|
|
|
-
|
|
|
|
- while (Result<FLastRecInd) do
|
|
|
|
- begin
|
|
|
|
- if (FRecordArray[Result] = ABookmark.BookmarkData) then exit;
|
|
|
|
- inc(Result);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- Result:=0;
|
|
|
|
- while (Result<ABookmark.BookmarkInt) do
|
|
|
|
- begin
|
|
|
|
- if (FRecordArray[Result] = ABookmark.BookmarkData) then exit;
|
|
|
|
- inc(Result);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- DatabaseError(SInvalidBookmark)
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- Result := ABookmark.BookmarkInt;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-Function TCustomBufDataset.Locate(const KeyFields: string; const KeyValues: Variant; options: TLocateOptions) : boolean;
|
|
|
|
|
|
+Function TCustomBufDataset.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions) : boolean;
|
|
|
|
|
|
var CurrLinkItem : PBufRecLinkItem;
|
|
var CurrLinkItem : PBufRecLinkItem;
|
|
bm : TBufBookmark;
|
|
bm : TBufBookmark;
|
|
@@ -3148,10 +3117,10 @@ begin
|
|
// Set the filter buffer
|
|
// Set the filter buffer
|
|
StoreDSState:=SetTempState(dsFilter);
|
|
StoreDSState:=SetTempState(dsFilter);
|
|
FFilterBuffer:=FCurrentIndex.SpareBuffer;
|
|
FFilterBuffer:=FCurrentIndex.SpareBuffer;
|
|
- SetFieldValues(keyfields,KeyValues);
|
|
|
|
|
|
+ SetFieldValues(KeyFields,KeyValues);
|
|
CurrLinkItem := (FCurrentIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
|
|
CurrLinkItem := (FCurrentIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
|
|
FilterBuffer:=IntAllocRecordBuffer;
|
|
FilterBuffer:=IntAllocRecordBuffer;
|
|
- move((FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf^,FilterBuffer^,FRecordsize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
|
|
|
|
|
|
+ move((FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf^,FilterBuffer^,FRecordSize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
|
|
|
|
|
|
// Iterate through the records until a match is found
|
|
// Iterate through the records until a match is found
|
|
while (CurrLinkItem <> (FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf) do
|
|
while (CurrLinkItem <> (FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf) do
|
|
@@ -3355,6 +3324,36 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TArrayBufIndex.GetRecordFromBookmark(ABookMark: TBufBookmark) : integer;
|
|
|
|
+begin
|
|
|
|
+ // ABookmark.BookMarkBuf is nil if SetRecNo calls GotoBookmark
|
|
|
|
+ if (ABookmark.BookmarkData<>nil) and (FRecordArray[ABookmark.BookmarkInt]<>ABookmark.BookmarkData) then
|
|
|
|
+ begin
|
|
|
|
+ // Start searching two records before the expected record
|
|
|
|
+ if ABookmark.BookmarkInt > 2 then
|
|
|
|
+ Result := ABookmark.BookmarkInt-2
|
|
|
|
+ else
|
|
|
|
+ Result := 0;
|
|
|
|
+
|
|
|
|
+ while (Result<FLastRecInd) do
|
|
|
|
+ begin
|
|
|
|
+ if (FRecordArray[Result] = ABookmark.BookmarkData) then exit;
|
|
|
|
+ inc(Result);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ Result:=0;
|
|
|
|
+ while (Result<ABookmark.BookmarkInt) do
|
|
|
|
+ begin
|
|
|
|
+ if (FRecordArray[Result] = ABookmark.BookmarkData) then exit;
|
|
|
|
+ inc(Result);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ DatabaseError(SInvalidBookmark)
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ Result := ABookmark.BookmarkInt;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TArrayBufIndex.GotoBookmark(const ABookmark : PBufBookmark);
|
|
procedure TArrayBufIndex.GotoBookmark(const ABookmark : PBufBookmark);
|
|
begin
|
|
begin
|
|
FCurrentRecInd:=GetRecordFromBookmark(ABookmark^);
|
|
FCurrentRecInd:=GetRecordFromBookmark(ABookmark^);
|
|
@@ -3385,14 +3384,6 @@ begin
|
|
Result := GetRecordFromBookmark(ABookmark^)+1;
|
|
Result := GetRecordFromBookmark(ABookmark^)+1;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TArrayBufIndex.RemoveRecordFromIndex(const ABookmark : TBufBookmark);
|
|
|
|
-var ARecordInd : integer;
|
|
|
|
-begin
|
|
|
|
- ARecordInd:=GetRecordFromBookmark(ABookmark);
|
|
|
|
- Move(FRecordArray[ARecordInd+1],FRecordArray[ARecordInd],sizeof(Pointer)*(FLastRecInd-ARecordInd));
|
|
|
|
- dec(FLastRecInd);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
procedure TArrayBufIndex.InsertRecordBeforeCurrentRecord(const ARecord: TRecordBuffer);
|
|
procedure TArrayBufIndex.InsertRecordBeforeCurrentRecord(const ARecord: TRecordBuffer);
|
|
begin
|
|
begin
|
|
inc(FLastRecInd);
|
|
inc(FLastRecInd);
|
|
@@ -3404,6 +3395,14 @@ begin
|
|
inc(FCurrentRecInd);
|
|
inc(FCurrentRecInd);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TArrayBufIndex.RemoveRecordFromIndex(const ABookmark : TBufBookmark);
|
|
|
|
+var ARecordInd : integer;
|
|
|
|
+begin
|
|
|
|
+ ARecordInd:=GetRecordFromBookmark(ABookmark);
|
|
|
|
+ Move(FRecordArray[ARecordInd+1],FRecordArray[ARecordInd],sizeof(Pointer)*(FLastRecInd-ARecordInd));
|
|
|
|
+ dec(FLastRecInd);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TArrayBufIndex.BeginUpdate;
|
|
procedure TArrayBufIndex.BeginUpdate;
|
|
begin
|
|
begin
|
|
// inherited BeginUpdate;
|
|
// inherited BeginUpdate;
|
|
@@ -3692,11 +3691,6 @@ begin
|
|
FSPareBuffer:=nil;
|
|
FSPareBuffer:=nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TUniDirectionalBufIndex.RemoveRecordFromIndex(const ABookmark: TBufBookmark);
|
|
|
|
-begin
|
|
|
|
- DatabaseError(SUniDirectional);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
function TUniDirectionalBufIndex.GetRecNo(const ABookmark: PBufBookmark): integer;
|
|
function TUniDirectionalBufIndex.GetRecNo(const ABookmark: PBufBookmark): integer;
|
|
begin
|
|
begin
|
|
result := -1;
|
|
result := -1;
|
|
@@ -3717,6 +3711,11 @@ begin
|
|
// Do nothing
|
|
// Do nothing
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TUniDirectionalBufIndex.RemoveRecordFromIndex(const ABookmark: TBufBookmark);
|
|
|
|
+begin
|
|
|
|
+ DatabaseError(SUniDirectional);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TUniDirectionalBufIndex.OrderCurrentRecord;
|
|
procedure TUniDirectionalBufIndex.OrderCurrentRecord;
|
|
begin
|
|
begin
|
|
// Do nothing
|
|
// Do nothing
|