The Text field type settings form allows a "Maximum length" to be anything— including very high values that break the field.

Suggested fix: set a maximum value in validation for the Maximum value text field of whatever is safe. Really, one thousand or two thousand let alone 10,000 or 20,000 should be plenty.

Anyhow, the safe number of characters is more than 20,000 but less than or equal to 25,000 on my MySQL setup.

Here's what happens if you put in 25,000:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1074 Column length too big for column 'field_otsnaeuhsaotheu_value' (max = 21845); use BLOB or TEXT instead: CREATE TABLE {field_data_field_otsnaeuhsaotheu} ( `entity_type` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'The entity type this data is attached to', `bundle` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', `deleted` TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted', `entity_id` INT unsigned NOT NULL COMMENT 'The entity id this data is attached to', `revision_id` INT unsigned NULL DEFAULT NULL COMMENT 'The entity revision id this data is attached to, or NULL if the entity type is not versioned', `language` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'The language for this data item.', `delta` INT unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', `field_otsnaeuhsaotheu_value` VARCHAR(25000) NULL DEFAULT NULL, `field_otsnaeuhsaotheu_format` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`entity_type`, `entity_id`, `deleted`, `delta`, `language`), INDEX `entity_type` (`entity_type`), INDEX `bundle` (`bundle`), INDEX `deleted` (`deleted`), INDEX `entity_id` (`entity_id`), INDEX `revision_id` (`revision_id`), INDEX `language` (`language`), INDEX `field_otsnaeuhsaotheu_format` (`field_otsnaeuhsaotheu_format`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Data storage for field 30 (field_otsnaeuhsaotheu)'; Array ( ) in db_create_table() (line 2588 of /home/ben/code/dgd7/drupal/includes/database/database.inc).

Trying to set the value back to something safe doesn't fly; this error is returned.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dgd7.field_data_field_poypi' doesn't exist: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {field_data_field_poypi} field_data_field_poypi0 WHERE (field_data_field_poypi0.deleted = :db_condition_placeholder_0) LIMIT 1 OFFSET 0) subquery; Array ( [:db_condition_placeholder_0] => 0 ) in field_sql_storage_field_storage_query() (line 569 of /home/ben/code/dgd7/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).

Comments

mlncn’s picture

Note: While it gives a max of 21845 in the error i broke it with 21844, with a different error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs: CREATE TABLE {field_data_field_oeu} ( `entity_type` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'The entity type this data is attached to', `bundle` VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', `deleted` TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted', `entity_id` INT unsigned NOT NULL COMMENT 'The entity id this data is attached to', `revision_id` INT unsigned NULL DEFAULT NULL COMMENT 'The entity revision id this data is attached to, or NULL if the entity type is not versioned', `language` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'The language for this data item.', `delta` INT unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', `field_oeu_value` VARCHAR(21844) NULL DEFAULT NULL, `field_oeu_format` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`entity_type`, `entity_id`, `deleted`, `delta`, `language`), INDEX `entity_type` (`entity_type`), INDEX `bundle` (`bundle`), INDEX `deleted` (`deleted`), INDEX `entity_id` (`entity_id`), INDEX `revision_id` (`revision_id`), INDEX `language` (`language`), INDEX `field_oeu_format` (`field_oeu_format`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Data storage for field 31 (field_oeu)'; Array ( ) in db_create_table() (line 2588 of /home/ben/code/dgd7/drupal/includes/database/database.inc).

droplet’s picture

Priority: Normal » Critical

Promote to Critical because it is a basic feature and broken whole websites (no simple way to restore).

we can change VARCHAR to other types cleverly and don't limit it. and it requires to warning or blocked change the value after it's created.

max value for VARCHAR is 65535 but here is used multi-bytes (UTF-8). so it is 65535/3.

webchick’s picture

Priority: Critical » Normal

Edge cases that only come up when you do something weird and out of the ordinary are not critical. It might be major, but even that I doubt.

TomiMikola’s picture

I wouldn't necessarily call this incident "out of ordinary". The user interface does not give any support choosing some suitable (large) value when you want to configure a large text field to be used for instance with wysiwyg editors. When a random blogger installs Drupal the first time with no knowledge of SQL, she wouldn't have slightest idea of a proper value for this setting.

And by the way, it is a bit annoying the figure out you cannot re-create the field with a proper (smaller) value using the same field name. Instead you'll get the "Add new field: the field name {field_name_here} exists" message.

oznate’s picture

I have been bitten by this bug today.

Promote to Critical because it is a basic feature and broken whole websites (no simple way to restore).

There is no help for this specific issue yet posted anywhere, in case you've accidently created a field too large.

Until this is fixed, what steps can be taken to rectify the nasty result?

oznate’s picture

I have posted in the forum for help on this issue at and will be checking both places.

droplet’s picture

let's move forward, what value should it use here ?? 255 ?? 1000 ??
if someone use it to save URL, the min length should be 2,083 (IE max length).
w3c standard don't have a limit on it

varchar max length is 65535 (LENGTH + 1byte, UTF8 string takes 3bytes, so (65535-1) / 3 = 21 844)

#5,
get into DB and remove entry in field_config / field_config_instance yourself (and clean all caches)

Damien Tournoud’s picture

A portable value would be 4000.

MySQL has a 65535/3 limit, but also limits the total size of the row
SQLite and PostgreSQL have no limits
SQL Server and Oracle have 4000

Damien Tournoud’s picture

Also field_create_field() is supposed to abort the creation of the field (and remove it from the field configuration table) when the creation of the storage (ie. the table here) failed. We need to investigate why it doesn't happen correctly here.

droplet’s picture