List:Internals« Previous MessageNext Message »
From:Jani Tolonen Date:August 7 2001 9:42am
Subject:How do you actually calculate MYSQL_FIELD->length ?
View as plain text  
Philip Mateescu writes:
 > Hi,

Hi Philip,

 > I've been browsing the source files trying to figure out how do you actually
 > calculate the width of a field. It seems to be no relation (or at least to me)
 > between the size of the field as reported by the 'show columns from..' command
 > and the value reported by MYSQL_FIELD->length...

That is the real width of the column.

 > Would you please be so kind to clear me out ?

What probably has confused you is that there is an extension to
ANSI/ISO SQL92 standard supported by MySQL for optionally specifying
the display width of an integral value in parentheses following the
base keyword for the type (for example, INT(4)). This optional width
specification is used to left-pad the display of values whose width is
less than the width specified for the column, but does not constrain
the range of values that can be stored in the column, nor the number
of digits that will be displayed for values whose width exceeds that
specified for the column.

This display width is the number that you can see with SHOW COLUMNS
FROM -command, for example, but is not necessarily the true length
of the column.

 > Thanx,
 > philip

Regards,

- Jani

For technical support contracts, visit https://order.mysql.com/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Jani Tolonen <jani@stripped>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Full-Time Developer
/_/  /_/\_, /___/\___\_\___/   Helsinki, Finland
       <___/   www.mysql.com
Thread
How do you actually calculate MYSQL_FIELD->length ?Philip Mateescu6 Aug
  • How do you actually calculate MYSQL_FIELD->length ?Jani Tolonen7 Aug
  • Re: How do you actually calculate MYSQL_FIELD->length ?Sinisa Milivojevic7 Aug