mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 00:47:52 +02:00
* Fix from Werner Pamler to fix locate. Fixes issue #40748
This commit is contained in:
parent
67a614e48d
commit
0d71273adc
@ -2066,45 +2066,49 @@ var
|
||||
lIndexDef: TDbfIndexDef;
|
||||
lIndexFile, lSaveIndexFile: TIndexFile;
|
||||
begin
|
||||
lCursor := nil;
|
||||
lSaveCursor := nil;
|
||||
lIndexFile := nil;
|
||||
lSaveIndexFile := FIndexFile;
|
||||
if (FCursor is TIndexCursor)
|
||||
and (TIndexCursor(FCursor).IndexFile.Expression = KeyFields) then
|
||||
if not (loCaseInsensitive in Options) then
|
||||
begin
|
||||
lCursor := FCursor;
|
||||
end else begin
|
||||
lIndexDef := FIndexDefs.GetIndexByField(KeyFields);
|
||||
if lIndexDef <> nil then
|
||||
lCursor := nil;
|
||||
lSaveCursor := nil;
|
||||
lIndexFile := nil;
|
||||
lSaveIndexFile := FIndexFile;
|
||||
if (FCursor is TIndexCursor)
|
||||
and (TIndexCursor(FCursor).IndexFile.Expression = KeyFields) then
|
||||
begin
|
||||
lIndexName := ParseIndexName(lIndexDef.IndexFile);
|
||||
lIndexFile := FDbfFile.GetIndexByName(lIndexName);
|
||||
if lIndexFile <> nil then
|
||||
lCursor := FCursor;
|
||||
end else begin
|
||||
lIndexDef := FIndexDefs.GetIndexByField(KeyFields);
|
||||
if lIndexDef <> nil then
|
||||
begin
|
||||
lSaveCursor := FCursor;
|
||||
lCursor := TIndexCursor.Create(lIndexFile);
|
||||
lSaveIndexName := lIndexFile.IndexName;
|
||||
lIndexFile.IndexName := lIndexName;
|
||||
FIndexFile := lIndexFile;
|
||||
lIndexName := ParseIndexName(lIndexDef.IndexFile);
|
||||
lIndexFile := FDbfFile.GetIndexByName(lIndexName);
|
||||
if lIndexFile <> nil then
|
||||
begin
|
||||
lSaveCursor := FCursor;
|
||||
lCursor := TIndexCursor.Create(lIndexFile);
|
||||
lSaveIndexName := lIndexFile.IndexName;
|
||||
lIndexFile.IndexName := lIndexName;
|
||||
FIndexFile := lIndexFile;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if lCursor <> nil then
|
||||
begin
|
||||
FCursor := lCursor;
|
||||
Result := LocateRecordIndex(KeyFields, KeyValues, Options);
|
||||
if lSaveCursor <> nil then
|
||||
if lCursor <> nil then
|
||||
begin
|
||||
FCursor.Free;
|
||||
FCursor := lSaveCursor;
|
||||
end;
|
||||
if lIndexFile <> nil then
|
||||
begin
|
||||
FLocateRecNo := FIndexFile.PhysicalRecNo;
|
||||
lIndexFile.IndexName := lSaveIndexName;
|
||||
FIndexFile := lSaveIndexFile;
|
||||
end;
|
||||
FCursor := lCursor;
|
||||
Result := LocateRecordIndex(KeyFields, KeyValues, Options);
|
||||
if lSaveCursor <> nil then
|
||||
begin
|
||||
FCursor.Free;
|
||||
FCursor := lSaveCursor;
|
||||
end;
|
||||
if lIndexFile <> nil then
|
||||
begin
|
||||
FLocateRecNo := FIndexFile.PhysicalRecNo;
|
||||
lIndexFile.IndexName := lSaveIndexName;
|
||||
FIndexFile := lSaveIndexFile;
|
||||
end;
|
||||
end else
|
||||
Result := LocateRecordLinear(KeyFields, KeyValues, Options);
|
||||
end else
|
||||
Result := LocateRecordLinear(KeyFields, KeyValues, Options);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user