mysql@stripped (Mike Aubury) writes:
> I'm probably being a bit stupid - but I'm trying to determine (in code) the
> length of the string in the schema for a given table.
> So - for example :
> create table a (
> blah char(20)
> I want to return '20', but I'm getting '60' when I use mysql_list_fields..
> (Always seems to be 3x longer that I'm expecting)...
> Am I missing something ? (or should I just divide by 3!!)
Is the table or database using UTF-8? I think that if it is MySQL will
allocate space for each character and is forced to allocate 3x20 bytes
as a UTF-8 character can be up to 3-bytes in length. SHOW CREATE
TABLE a\G should show if this is the case.