mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 18:00:43 +02:00
fcl-db/dbase:
+ support for stream-backed memo file which satisfies TTestSpecificTDBF.TestMemoClose test * fix default record size 64 for (V)FP memo files git-svn-id: trunk@24395 -
This commit is contained in:
parent
679a8d9dd6
commit
c577f630d9
@ -186,7 +186,6 @@ This method should be called from InternalOpen, and should
|
||||
initialize FieldDef definitions for all fields in a record.
|
||||
It should add these definitions to the FFielddefs object.
|
||||
|
||||
|
||||
procedure InternalInitRecord(Buffer: PChar); virtual; abstract;
|
||||
---------------------------------------------------------------
|
||||
This method is called to initialize a field buffer when the dataset
|
||||
|
@ -157,6 +157,7 @@ type
|
||||
FParser: TDbfParser;
|
||||
FBlobStreams: PDbfBlobList;
|
||||
FUserStream: TStream; // user stream to open
|
||||
FUserMemoStream: TStream; // user-provided/expected stream backing memo file storage
|
||||
FTableName: string; // table path and file name
|
||||
FRelativePath: string;
|
||||
FAbsolutePath: string;
|
||||
@ -397,7 +398,10 @@ type
|
||||
property PhysicalRecordCount: Integer read GetPhysicalRecordCount;
|
||||
property KeySize: Integer read GetKeySize;
|
||||
property DbfFile: TDbfFile read FDbfFile;
|
||||
// Storage for data file if using memory storage
|
||||
property UserStream: TStream read FUserStream write FUserStream;
|
||||
// Storage for memo file - if any - when using memory storage
|
||||
property UserMemoStream: TStream read FUserMemoStream write FUserMemoStream;
|
||||
property DisableResyncOnPost: Boolean read FDisableResyncOnPost write FDisableResyncOnPost;
|
||||
published
|
||||
property DateTimeHandling: TDateTimeHandling
|
||||
@ -1145,6 +1149,7 @@ begin
|
||||
if FStorage = stoMemory then
|
||||
begin
|
||||
FDbfFile.Stream := FUserStream;
|
||||
FDbfFile.MemoStream := FUserMemoStream;
|
||||
FDbfFile.Mode := FileModeToMemMode[FileOpenMode];
|
||||
end else begin
|
||||
FDbfFile.FileName := FAbsolutePath + FTableName;
|
||||
@ -1548,9 +1553,12 @@ begin
|
||||
else
|
||||
FDbfFile.FinishCreate(ADbfFieldDefs, 512);
|
||||
|
||||
// if creating memory table, copy stream pointer
|
||||
// if creating memory table, use user-designated stream
|
||||
if FStorage = stoMemory then
|
||||
begin
|
||||
FUserStream := FDbfFile.Stream;
|
||||
FUserMemoStream := FDbfFile.MemoStream;
|
||||
end;
|
||||
|
||||
// create all indexes
|
||||
for I := 0 to FIndexDefs.Count-1 do
|
||||
|
@ -47,6 +47,7 @@ type
|
||||
protected
|
||||
FMdxFile: TIndexFile;
|
||||
FMemoFile: TMemoFile;
|
||||
FMemoStream: TStream;
|
||||
FFieldDefs: TDbfFieldDefs;
|
||||
FIndexNames: TStringList;
|
||||
FIndexFiles: TList;
|
||||
@ -138,6 +139,8 @@ type
|
||||
procedure RecordRecalled(RecNo: Integer; Buffer: TRecordBuffer);
|
||||
|
||||
property MemoFile: TMemoFile read FMemoFile;
|
||||
// Backing stream for stream/memory-based memo "files"
|
||||
property MemoStream: TStream read FMemoStream write FMemoStream;
|
||||
property FieldDefs: TDbfFieldDefs read FFieldDefs;
|
||||
property IndexNames: TStringList read FIndexNames;
|
||||
property IndexFiles: TList read FIndexFiles;
|
||||
@ -505,6 +508,8 @@ begin
|
||||
MemoFileClass := TDbaseMemoFile; //fallback/default
|
||||
FMemoFile := MemoFileClass.Create(Self);
|
||||
FMemoFile.FileName := lMemoFileName;
|
||||
if (Mode in [pfMemoryOpen,pfMemoryCreate]) then
|
||||
FMemoFile.Stream:=FMemoStream;
|
||||
FMemoFile.Mode := Mode;
|
||||
FMemoFile.AutoCreate := true;
|
||||
FMemoFile.MemoRecordSize := 0;
|
||||
@ -869,6 +874,8 @@ begin
|
||||
else
|
||||
FMemoFile := TDbaseMemoFile.Create(Self);
|
||||
FMemoFile.FileName := lMemoFileName;
|
||||
if (Mode in [pfMemoryOpen,pfMemoryCreate]) then
|
||||
FMemoFile.Stream:=FMemoStream;
|
||||
FMemoFile.Mode := Mode;
|
||||
FMemoFile.AutoCreate := AutoCreate;
|
||||
FMemoFile.MemoRecordSize := MemoSize;
|
||||
@ -1386,7 +1393,10 @@ begin
|
||||
if FMemoFile <> nil then
|
||||
DestDbfFile.FinishCreate(DestFieldDefs, FMemoFile.RecordSize)
|
||||
else
|
||||
DestDbfFile.FinishCreate(DestFieldDefs, 512);
|
||||
if (DestDbfFile.DbfVersion in [xFoxPro,xVisualFoxPro]) then
|
||||
DestDbfFile.FinishCreate(DestFieldDefs, 64) {VFP default}
|
||||
else
|
||||
DestDbfFile.FinishCreate(DestFieldDefs, 512);
|
||||
|
||||
// adjust size and offsets of fields
|
||||
GetMem(RestructFieldInfo, sizeof(TRestructFieldInfo)*DestFieldDefs.Count);
|
||||
|
@ -386,9 +386,15 @@ const
|
||||
var
|
||||
ds : TDBF;
|
||||
i: integer;
|
||||
DBFStream: TMemoryStream;
|
||||
MemoStream: TMemoryStream;
|
||||
begin
|
||||
ds := TDBF.Create(nil);
|
||||
ds.Storage:=stoMemory;
|
||||
DBFStream:=TMemoryStream.Create;
|
||||
MemoStream:=TMemoryStream.Create;
|
||||
DS.Storage:=stoMemory;
|
||||
DS.UserStream:=DBFStream;
|
||||
DS.UserMemoStream:=MemoStream;
|
||||
DS.FieldDefs.Add('ID',ftInteger);
|
||||
DS.FieldDefs.Add('NAME',ftMemo);
|
||||
DS.OpenMode:=omAutoCreate; //let dbf code create memo etc files when needed
|
||||
@ -416,6 +422,8 @@ begin
|
||||
DS.Close;
|
||||
|
||||
ds.free;
|
||||
DBFStream.Free;
|
||||
MemoStream.Free;
|
||||
end;
|
||||
|
||||
procedure TTestSpecificTDBF.TestLargeString;
|
||||
|
Loading…
Reference in New Issue
Block a user