[development] varchar(255)

Jonathan Brown jbrown at bluedroplet.com
Sat Apr 25 19:54:27 UTC 2009

It would make sense to truncate strings to the field size before
inserting to ensure that they succeed.

Mysql silently changes varchar(65535) to mediumtext

I think this is because the max row size is 65535


On Thu, 2009-04-23 at 13:09 -0700, Dave Cohen wrote:
> In another recent thread (about watchdog), Frédéric suggested increasing the size of the watchdog.referer column.  And he's right to suggest it because strings that are too long are not written to the database.
> This brings to 3 the number of columns I increase to varchar(255) on my Drupal sites.  The three are watchdog.referer, users.mail, and sessions.sid.
> If my understanding of mysql is correct, there is no difference between a varchar(128) column filled with 128-byte strings and a varchar(255) column filled with 128-byte strings.  However, there is a huge difference between a varchar(128) column filled with 129-byte strings and a varchar(255) filled with 129-byte strings.  (The latter will work).
> So please, when developing for Drupal and wondering what size to make that varchar... stop wondering and use varchar(255).  
> Or if you need it even longer varchar(65535).  Note that lengths up to 255 can be represented in one byte, and 65535 in two bytes.
> Oh and please do correct me if I'm wrong about any of this,
> -Dave

More information about the development mailing list