The Field SQL Storage test adds two indexes on value. This passes on InnoDB but it fails on MyISAM and it's plain invalid. http://dev.mysql.com/doc/refman/5.5/en/create-index.html

BLOB and TEXT columns also can be indexed, but a prefix length must be given.

Fix is trivial -- allow field indexes to add a prefix length which the schema API already does. Just need to expose this.

Comments

Status: Needs review » Needs work

The last submitted patch, fsst.patch, failed testing.

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new3.42 KB
Crell’s picture

Status: Needs review » Reviewed & tested by the community

A bug fix and a test fix. Hopefully that's not too many kittens. :-)

webchick’s picture

Title: field sql storage test is invalid » field sql storage test failing on various MySQL engines due to indexing unbound text fields.
Status: Reviewed & tested by the community » Fixed

I was a little confused about what this code was doing, but basically hook_schema() supports adding indexes as either array('column_name') or array('column_name', 255). Worked out a comment with chx on IRC above each section:

      // Indexes can be specified as either a column name or an array with
      // column name and length. Allow for either case.

Test changes look good. Committed and pushed to 8.x. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

rewritten fix

byrond’s picture

Version: 8.0.x-dev » 7.34
Issue summary: View changes
Status: Closed (fixed) » Needs review
StatusFileSize
new3.33 KB

Backported to D7.

jomarocas’s picture

i confirm patch #6 working in latest drupal core 7.35 in two sites for module advpoll

hargobind’s picture

Status: Needs review » Reviewed & tested by the community

Confirming that #6 works well with MySQL and is written with good conditionals that it doesn't break anything in 7.x.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: fsst-index-prefix-1812056-4.patch, failed testing.

Status: Needs work » Needs review
David_Rothstein’s picture

Version: 7.34 » 7.x-dev
Status: Needs review » Reviewed & tested by the community

Looks like a testbot fluke.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: fsst-index-prefix-1812056-4.patch, failed testing.

Status: Needs work » Needs review
David_Rothstein’s picture

Status: Needs review » Reviewed & tested by the community

Testbot fluke; back to RTBC.

jomarocas’s picture

#6 working good, waiting for next release of core, tested without problems

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +7.37 release notes

Committed to 7.x - thanks!

Fixed on commit:

diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.module b/modules/field/modules/field_sql_storage/field_sql_storage.module
index b49e95a..842893a 100644
--- a/modules/field/modules/field_sql_storage/field_sql_storage.module
+++ b/modules/field/modules/field_sql_storage/field_sql_storage.module
@@ -223,6 +223,8 @@ function _field_sql_storage_schema($field) {
   foreach ($field['indexes'] as $index_name => $columns) {
     $real_name = _field_sql_storage_indexname($field['field_name'], $index_name);
     foreach ($columns as $column_name) {
+      // Indexes can be specified as either a column name or an array with
+      // column name and length. Allow for either case.
       if (is_array($column_name)) {
         $current['indexes'][$real_name][] = array(
           _field_sql_storage_columnname($field['field_name'], $column_name[0]),
@@ -340,6 +342,8 @@ function field_sql_storage_field_storage_update_field($field, $prior_field, $has
         $real_name = _field_sql_storage_indexname($field['field_name'], $name);
         $real_columns = array();
         foreach ($columns as $column_name) {
+          // Indexes can be specified as either a column name or an array with
+          // column name and length. Allow for either case.
           if (is_array($column_name)) {
             $real_columns[] = array(
               _field_sql_storage_columnname($field['field_name'], $column_name[0]),

(i.e., I added the same code comments to Drupal 7 that were added to Drupal 8 in #4 - these did not make it into the patch)

  • David_Rothstein committed 880152a on 7.x
    Issue #1812056 by chx, byrond: Allow hook_field_schema() implementations...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.