'length' parameter is supported by MySQL for 'int' type, and the documentation as well mentions this,

'length': The maximal length of a type 'varchar', 'text' or 'int' field. Ignored for other field types.

But, it isn't working. I can confirm this problem on both Windows and CentOS with mysql version 5.1. I think the problem resides in the function _db_create_field_sql:

function _db_create_field_sql($name, $spec) {
  $sql = "`". $name ."` ". $spec['mysql_type'];

  if (in_array($spec['type'], array('varchar', 'char', 'text')) && isset($spec['length'])) {
    $sql .= '('. $spec['length'] .')';
  }

Clearly, 'length' parameter is ignored for the 'int' type. Including 'int' in the above array solves the problem.

Comments

klonos’s picture

subscribing...

damien tournoud’s picture

This parameter is of no use at all for numeric types. Let's just fix the documentation.

damien tournoud’s picture

Version: 6.16 » 6.x-dev

7.x is already fixed:

'length': The maximal length of a type 'char', 'varchar' or 'text' field. Ignored for other field types.

Bumping for fixing in 6.x.

publicmind’s picture

This parameter is of no use at all for numeric types. Let's just fix the documentation.

I do not agree with the generality of your statement. Of course 'length' parameter makes sense and that's why it exists for numeric type on all major databases.

Regards,

damien tournoud’s picture

@publicmind: AFAIK, that parameter is not used anywhere in the MySQL server code. It's just supposedly useful for some clients. It is completely and utterly useless with Drupal.

damien tournoud’s picture

And by the way, PostgreSQL doesn't have that concept of 'length' at all. Don't confuse size for length.

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.