List:General Discussion« Previous MessageNext Message »
From:Simon J Mudd Date:October 7 2008 10:44am
Subject:Re: C api - mysql_list_fields
View as plain text  
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.

C api - mysql_list_fieldsMike Aubury6 Oct
  • Re: C api - mysql_list_fieldsDoug Bridgens7 Oct
  • Re: C api - mysql_list_fieldsSimon J Mudd7 Oct
  • Re: C api - mysql_list_fieldsJoerg Bruehe7 Oct
    • Re: C api - mysql_list_fieldsMike Aubury7 Oct
      • Re: C api - mysql_list_fieldswalter harms7 Oct
        • Re: C api - mysql_list_fieldsMike Aubury7 Oct
      • Re: C api - mysql_list_fieldsJoerg Bruehe7 Oct