[fpc-devel] TSdfDataset does not work with records larger then 255 chars
Martin Schreiber
fpmse at bluewin.ch
Mon Sep 8 08:48:11 CEST 2008
On Monday 08 September 2008 04.53:25 Felipe Monteiro de Carvalho wrote:
> Hello,
>
> Using TSdfDataset my records are cut to fit 255 chars, even when I
> change the new MaxRecordLength property to 2048. This is a very
> elusive bug, and I am searching all over for the cause without success
> =(
>
> I searched everywhere for a shortstring, which could be the cause, but
> didn't find any. Any ideas?
>
Possibly because FieldDefs[<n>].Size is too small. Did you setup
TSdfDataset.Schema according to your needs? The format is
<fieldname>=<fieldsize> AFAIK, MAXSTRLEN is a default value only. The new
MaxRecordLength property is actually unnecessary and a little bit misleading.
> I was not able to debug inside FCL, maybe the standard build comes
> without debug info?
Correct.
> I was able to debug the sdfdata unit because I am
> using it locally in my project, because I am using FPC 2.2.2 and when
> the flow of events comes to TFIXEDFORMATDATASET__SETFIELDDATA the
> string is already cutted and in TDBDRAWINGCODEMEMO__UPDATEDATA it was
> correct, so it must have been cutted in the FCL somewhere in between.
>
"
procedure TStringField.SetAsString(const AValue: string);
var Buf : TStringFieldBuffer;
begin
IF Length(AValue)=0 then
begin
Buf := #0;
SetData(@buf);
end
else if FTransliterate then
begin
DataSet.Translate(@AValue[1],Buf,True);
Buf[DataSize-1] := #0;
SetData(@buf);
end
else
begin
// The data is copied into the buffer, since some TDataset descendents
copy
// the whole buffer-length in SetData. (See bug 8477)
Buf := AValue;
// If length(AValue) > Datasize the buffer isn't terminated properly
Buf[DataSize-1] := #0; <<<<<<<<<<<<<-------- probably here
SetData(@Buf);
end;
end;
"
Martin
More information about the fpc-devel
mailing list