[fpc-pascal] SqlDB vs Zeos: TDataset.FieldDefs[].Size
Ludo Brands
ludo.brands at free.fr
Sat Apr 20 11:11:44 CEST 2013
On 04/19/2013 05:59 PM, Graeme Geldenhuys wrote:
> Hi,
>
> I have a Firebird database living on a FreeBSD server. I did not specify
> a charset when the database was created.
>
> I have a table with a string field defined as VarChar(10).
>
> When I use SqlDB and retrieve the Size of that field via...
>
> FDataset.FieldDefs[AIndex].Size
>
> SqlDB returns 10, which is correct.
>
> But when that exact same code above is run via Zeos, it returns 40.
>
> Anybody know why?
>
> I'm using Zeos from the SubVersion repository:
>
> http://svn.code.sf.net/p/zeoslib/code-0/trunk
> Revision: 2209
>
>
> The same result is returned using Zeos and a MySQL 5.5 database, where
> the field was also created as VarChar(10).
>
>
> Regards,
> - Graeme -
>
TFieldDef.Size is expressed in bytes. Zeos, IIRC, assumes a conversion
from any charset to utf8 could be made. Since UTF8 is up to 4 bytes per
char, a VarChar(10) can need up to 40 bytes to be represented in the
dataset. Don't forget that the translation to utf8 can happen in fe. the
client library (libmysql, fbclient,...).
Ludo
More information about the fpc-pascal
mailing list