mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 22:14:25 +02:00
fcl-db: bufdataset: improves rev.25333; length indicator is saved only for variable length fields
git-svn-id: trunk@25337 -
This commit is contained in:
parent
108d3cb090
commit
b2e7364ae8
@ -386,6 +386,9 @@ type
|
|||||||
const
|
const
|
||||||
FpcBinaryIdent1 = 'BinBufDataset'; // Old version 1; support for transient period;
|
FpcBinaryIdent1 = 'BinBufDataset'; // Old version 1; support for transient period;
|
||||||
FpcBinaryIdent2 = 'BinBufDataSet';
|
FpcBinaryIdent2 = 'BinBufDataSet';
|
||||||
|
StringFieldTypes = [ftString,ftFixedChar,ftWideString,ftFixedWideChar];
|
||||||
|
BlobFieldTypes = [ftBlob,ftMemo,ftWideMemo];
|
||||||
|
VarLenFieldTypes = StringFieldTypes + BlobFieldTypes + [ftBytes,ftVarBytes];
|
||||||
var
|
var
|
||||||
FVersion: byte;
|
FVersion: byte;
|
||||||
public
|
public
|
||||||
@ -3591,14 +3594,22 @@ begin
|
|||||||
begin
|
begin
|
||||||
AField := Fields.FieldByNumber(FieldDefs[i].FieldNo);
|
AField := Fields.FieldByNumber(FieldDefs[i].FieldNo);
|
||||||
if AField=nil then continue;
|
if AField=nil then continue;
|
||||||
L := Stream.ReadDWord;
|
if AField.DataType in StringFieldTypes then
|
||||||
SetLength(B, L);
|
AField.AsString := Stream.ReadAnsiString
|
||||||
if L > 0 then
|
|
||||||
Stream.ReadBuffer(B[0], L);
|
|
||||||
if FieldDefs[i].DataType in [ftBlob, ftMemo, ftWideMemo] then
|
|
||||||
RestoreBlobField(ADataset, AField, @B[0], L)
|
|
||||||
else
|
else
|
||||||
AField.SetData(@B[0], False); // set it to the FilterBuffer
|
begin
|
||||||
|
if AField.DataType in VarLenFieldTypes then
|
||||||
|
L := Stream.ReadDWord
|
||||||
|
else
|
||||||
|
L := AField.DataSize;
|
||||||
|
SetLength(B, L);
|
||||||
|
if L > 0 then
|
||||||
|
Stream.ReadBuffer(B[0], L);
|
||||||
|
if AField.DataType in BlobFieldTypes then
|
||||||
|
RestoreBlobField(ADataset, AField, @B[0], L)
|
||||||
|
else
|
||||||
|
AField.SetData(@B[0], False); // set it to the FilterBuffer
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3624,11 +3635,17 @@ begin
|
|||||||
begin
|
begin
|
||||||
AField := Fields.FieldByNumber(FieldDefs[i].FieldNo);
|
AField := Fields.FieldByNumber(FieldDefs[i].FieldNo);
|
||||||
if AField=nil then continue;
|
if AField=nil then continue;
|
||||||
B := AField.AsBytes;
|
if AField.DataType in StringFieldTypes then
|
||||||
L := length(B);
|
Stream.WriteAnsiString(AField.AsString)
|
||||||
Stream.WriteDWord(L);
|
else
|
||||||
if L > 0 then
|
begin
|
||||||
Stream.WriteBuffer(B[0], L);
|
B := AField.AsBytes;
|
||||||
|
L := length(B);
|
||||||
|
if AField.DataType in VarLenFieldTypes then
|
||||||
|
Stream.WriteDWord(L);
|
||||||
|
if L > 0 then
|
||||||
|
Stream.WriteBuffer(B[0], L);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user