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:
lacak 2013-08-23 11:56:53 +00:00
parent 108d3cb090
commit b2e7364ae8

View File

@ -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;