OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: C api - mysql_list_fields

From: Joerg Bruehe (Joerg.BrueheSun.COM)
Date: Tue Oct 07 2008 - 08:35:40 CDT


Mike, all,

Mike Aubury wrote:
> [[...]]
>
> So - the next question is...
> Is there anyway in code I can find the 'fiddle' factor (1,3,or now possibly 4)
> that I need to use to divide by to get back to the character width specified
> in the CREATE TABLE ?

In the "information_schema" database, which you can use to access schema
information, MySQL differs between "CHARACTER_MAXIMUM_LENGTH" (the
number of characters) and "CHARACTER_OCTET_LENGTH" (number of bytes).

But this need not be the same factor for all columns:
If you specify one with "charset latin1", it is one octet (byte) per
character.

So I don't see any use in such a constant factor.
And sorry, no, off-hand I don't know a way to programmatically ask the
server for this factor.

If you need to know the number of characters specified for some column,
you should access the "information_schema" database and get all those
details, including character set and collation.

HTH,
Jörg

--
Joerg Bruehe, MySQL Build Team, joergmysql.com (+49 30) 417 01 487
Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB161028

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql