After installing the schema module and checking the report, I saw these mismatches regarding the core search module:

* search_dataset
          - column type - difference on: length
            declared: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => 16, 'not null' => FALSE)
            actual: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => '64', 'not null' => FALSE)
* search_index
          - column type - difference on: length
            declared: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => 16, 'not null' => FALSE)
            actual: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => '64', 'not null' => FALSE)
* search_node_links
          - column type - difference on: length
            declared: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => '')
            actual: array('description' => t('TODO: please describe this field!'), 'type' => 'varchar', 'length' => '64', 'not null' => TRUE, 'default' => '')
CommentFileSizeAuthor
#10 schema_alter_fix.patch743 bytesletapjar

Comments

jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

I have no idea why your search tables have lenght 64 on those tables. When I install the search module, the fields are length 16. Have you modified them manually, or perhaps used a contrbuted module that modified them?

klonos’s picture

Priority: Normal » Minor
Status: Postponed (maintainer needs more info) » Active

Nope, haven't touched the module - I almost never do that with core unless it is really-really-really necessary to. I have only applied the patch from post #146 in #269877: path_set_alias() doesn't account for same alias in different languages, but that doesn't touch search.module at all or the db, only path.module is modified. Please, take a look for yourself, it's just a 5-or-so liner: http://drupal.org/files/issues/path-module_269877-D6_1.patch

As for any contrib module messin' where it shouldn't... how could I figure out which one it could be. I cannot start by disabling all + uninstalling them and start over, since I am on a live site. Would I know by looking at their .install files or is this done during run-time? Is there any string I can search for in the modules' files?

I honestly want to help track this one down, but my list of modules is huge. I can provide a list of modules and their respective versions, but I don't like to pollute the issue with long posts. Perhaps I'll dump it in a .txt file and upload. Let me know if that would help.

Let me also add that this issue doesn't have any other quirks than that error in the site's status report. I haven't enabled search in my site yet, so I cannot know if/what it will cause. I am simply reporting it because earlier experience has shown that problems not dealt with in time come back to bite you later on. So I'll 'downgrade' this issue to minor till someone reports real problems caused by it. Please do guide me in troubleshooting this further though.

Thanx in advance.

jhodgdon’s picture

Category: bug » support

It would likely be in a contributed module's .install file, actually in the function [module_name]_enable() or [module_name]_install(). It could be done during run time...

I would look first at any module that you've installed that is related in any way to searching, since I cannot imagine why a non-search-related module would want to change the search tables. And the module would have the strings {search_dataset}, {search_index}, and {search_node_links} in it somewhere. So if you know how to use grep, you could grep through your sites/all/modules directory for those strings.

And since I am pretty sure this isn't a core Drupal bug, I am changing it to a support request. I'll be interested to see what you find out though!

klonos’s picture

Got it! Its the Data module:

root@www:/var/www/hellas247/sites/all/modules# grep -r "{search_dataset}" *
data/data_search/data_search.module:    $result = db_query_range("SELECT dt.{$base_field} id FROM {{$name}} dt LEFT JOIN {search_dataset} d ON d.type = '{$name}' AND d.sid = dt.{$base_field} WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, dt.{$base_field} ASC", 0, $limit);
data/data_search/data_search.module:    db_query("DELETE sd, si, snl FROM {search_dataset} sd LEFT JOIN {{$name}} dt ON sd.type = '{$name}' AND sd.sid = dt.{$base_field} LEFT JOIN {search_index} si ON sd.sid = si.sid AND sd.type = si.type LEFT JOIN {search_node_links} snl ON sd.sid = snl.sid AND sd.type = snl.type WHERE dt.{$base_field} IS NULL");
data/data_search/data_search.module:        db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = '%s'", time(), $name);
data/data_search/data_search.module:        $remaining = $remaining + db_result(db_query("SELECT COUNT(*) FROM {{$name}} dt LEFT JOIN {search_dataset} d ON d.type = '{$name}' AND d.sid = dt.{$base_field} WHERE (d.sid IS NULL OR d.reindex <> 0)"));
data/data_search/data_search.module:  db_query("DELETE s FROM {search_dataset} s LEFT JOIN {{$name}} t ON s.sid = t.$field WHERE s.type = '%s' AND t.$field IS NULL", $table->get('name'));
data/data_search/data_search.install:  db_query("ALTER TABLE {search_dataset} CHANGE COLUMN type type VARCHAR(64)");
root@www:/var/www/hellas247/sites/all/modules# grep -r "{search_index}" *
data/data_search/data_search.module:    db_query("DELETE sd, si, snl FROM {search_dataset} sd LEFT JOIN {{$name}} dt ON sd.type = '{$name}' AND sd.sid = dt.{$base_field} LEFT JOIN {search_index} si ON sd.sid = si.sid AND sd.type = si.type LEFT JOIN {search_node_links} snl ON sd.sid = snl.sid AND sd.type = snl.type WHERE dt.{$base_field} IS NULL");
data/data_search/data_search.module:  db_query("DELETE s FROM {search_index} s LEFT JOIN {{$name}} t ON s.sid = t.$field WHERE s.type = '%s' AND t.$field IS NULL", $table->get('name'));
data/data_search/data_search.install:  db_query("ALTER TABLE {search_index} CHANGE COLUMN type type VARCHAR(64)");
root@www:/var/www/hellas247/sites/all/modules# grep -r "{search_node_links}" *
data/data_search/data_search.module:    db_query("DELETE sd, si, snl FROM {search_dataset} sd LEFT JOIN {{$name}} dt ON sd.type = '{$name}' AND sd.sid = dt.{$base_field} LEFT JOIN {search_index} si ON sd.sid = si.sid AND sd.type = si.type LEFT JOIN {search_node_links} snl ON sd.sid = snl.sid AND sd.type = snl.type WHERE dt.{$base_field} IS NULL");
data/data_search/data_search.install:  db_query("ALTER TABLE {search_node_links} CHANGE COLUMN type type VARCHAR(64)");

taking it there...

klonos’s picture

Project: Drupal core » Data
Version: 6.16 » 6.x-1.x-dev
Component: search.module » Code

Coming from the core search.module...

In data_search.install lines 12, 13 &14:

  db_query("ALTER TABLE {search_dataset} CHANGE COLUMN type type VARCHAR(64)");
  db_query("ALTER TABLE {search_index} CHANGE COLUMN type type VARCHAR(64)");
  db_query("ALTER TABLE {search_node_links} CHANGE COLUMN type type VARCHAR(64)");

alter the respective fields' lengths from 16 to 64. Is this necessary?

Schema module reports table mismatches. Please take a look at #0

alex_b’s picture

Title: search_dataset, search_index, search_node_links schema table mismatches (declared length=16, actual length=64) » Reflect changes to search tables with hook_schema_alter()
Category: support » task

This is the reason:

// Adjust length of type columns for data tables with names of a max length of 64.

To avoid schema module complaining, we should also alter the schema information about the respective search tables. For the record though, the mismatch does not cause any actual problems.

klonos’s picture

Thanx for taking the time alex. I kinda knew no actual problems were caused. That's why it's set to 'minor' ;)

letapjar’s picture

This should really be fixed - altering a core module's table without properly updating the schema is not a friendly way to do things.

Non-programmers who install data_search module (which requires the core search module) will constantly get a warning message about schema inconsistencies - this causes drupal admins to waste time tracking
down an issue due to bad programming practice.

at the very least this should be an issue to be fixed before a beta version is released.

danoprey’s picture

I have the exact same problem outlined above. How do I edit the schema to make the error message go away? It's fine that it causes no problems but I have to hand the site over to someone else, ideally error (message) free!

letapjar’s picture

Status: Active » Needs review
StatusFileSize
new743 bytes

Try the following patch - it simply implements hook_schema_alter within the data_search module.

note - this will solve the problem of the error message - but there is another larger issue about the fact that if someone installs data_search and later uninstalls the module - the core tables for search module are now mis-matched to their schema.

to apply the patch simply copy the file to your 'sites/all/modules/data' folder and then in your shell
change to that directory and type patch -p0 < schema_alter_fix.patch

I was able to eliminate the error message on a clean drupal install where the error message popped up after generating 50 pages of content with devel.

klonos’s picture

I'll test this on first chance, but I trust your experience anyways so I believe it'll simply work ;)

...concerning this:

...but there is another larger issue about the fact that if someone installs data_search and later uninstalls the module - the core tables for search module are now mis-matched to their schema.

I wouldn't know code-wise, but how about undoing the changes during module uninstallation then. I am not talking about when simply disabling the module, but rather when offering an uninstallation option in the 'uninstall' tab (I think it has to do with hook_uninstall()).

letapjar’s picture

I don't know much about this module - but if content longer than the original 16 characters was stored in the search_dataset or search_index or search_node_links tables - then changing the field length back to 16 on uninstall might cause problems - at the very least data would be truncated. I think this is something for the original module developers to work out.

joachim’s picture

Category: task » bug
Status: Needs review » Needs work

> if content longer than the original 16 characters was stored in the search_dataset or search_index

Logically, anything that does not depend on Data module (and its alteration of the column length) would have had its data truncated to 16 characters on insert if Data module wasn't there anyway. So it would be a bug in that module, and getting it truncated when Data is uninstalled is just delaying the inevitable ;)

Setting to needs work as we need a hook_uninstall() too as pointed out above.