<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=x-mac-ce" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
I am writting here to discuss bug
<a class="moz-txt-link-freetext" href="http://bugs.freepascal.org/view.php?id=17268">http://bugs.freepascal.org/view.php?id=17268</a><br>
(I do not want reopen bug and writte there because I am not sure about
my arguments)<br>
<br>
IMHO root of problem is in different definition of TFieldDef.Size and
TField.Size<br>
Documentation says, that<br>
1. TFieldDef.Size should be "For string and byte fields, <strong
class="selflink">Size</strong> is the number of bytes reserved " <br>
ΚΚΚ <a class="moz-txt-link-freetext" href="http://docwiki.embarcadero.com/VCL/en/DB.TFieldDef.Size">http://docwiki.embarcadero.com/VCL/en/DB.TFieldDef.Size</a><br>
2. TField.Size should be "the maximum number of characters in the
string" (for ftString and I guess that also for ftWideString)<br>
ΚΚΚ <a class="moz-txt-link-freetext" href="http://docwiki.embarcadero.com/VCL/en/DB.TField.Size">http://docwiki.embarcadero.com/VCL/en/DB.TField.Size</a><br>
ΚΚΚ <a class="moz-txt-link-freetext" href="http://docwiki.embarcadero.com/VCL/en/DB.TStringField.Size">http://docwiki.embarcadero.com/VCL/en/DB.TStringField.Size</a><br>
<br>
And now let's go look into fields.inc:<br>
1. Function TFieldDef.CreateField copies Result.Size:=FSize (so
TField.Size:=TFieldDef.Size)<br>
2. function TStringField.GetDataSize returns for ftString ... Size+1<br>
3. function TWideStringField.GetDataSize returns for ftWideString ...
(Size + 1) * 2<br>
<br>
Points 2,3 are clear Size is expected to be number of characters,
DataSize number of bytes.<br>
But point 1 says, that TFieldDef.Size and TField.Size should be the same<br>
<br>
And now let's go look into bufdataset.pas:<br>
4. function TCustomBufDataset.GetFieldSize works with TFieldDef and
returns number of bytes needed in record buffer<br>
Κ case FieldDef.DataType of<br>
ΚΚΚ ftString, ftGuid, ftFixedChar: result := FieldDef.Size + 1;<br>
ΚΚΚ ftFixedWideChar, ftWideString:result := (FieldDef.Size + 1)*2; <br>
ΚΚΚ ...<br>
So also here we can see, that FieldDef.Size is expected to be number of
characters not bytes.<br>
<br>
So IMHO logical conclusion will be say, that TFieldDef.Size for string
fields has same menaing as Field.Size, so it is number of characters<br>
(so documentation is wrong in this case ... also fast test in Delphi
shows, that FieldDef.Size=Field.Size=number of characters)<br>
<br>
Laco.<br>
</body>
</html>