diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-11-13 14:04:08 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-11-13 14:04:08 +0000 |
commit | 17d1527e3d76fb791b61e89a4736afe0e0adefc6 (patch) | |
tree | d42bd6fbb2d9e816173c88371c6d1a0293395575 /modules/system/system.install | |
parent | f68f52540107a625f326448f413bc323e2138f31 (diff) | |
download | brdo-17d1527e3d76fb791b61e89a4736afe0e0adefc6.tar.gz brdo-17d1527e3d76fb791b61e89a4736afe0e0adefc6.tar.bz2 |
- Patch #146466 by douggreen, Steven et al: Remove temporary table usage from search module
Diffstat (limited to 'modules/system/system.install')
-rw-r--r-- | modules/system/system.install | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index bcbff8847..a38fde80f 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -4467,6 +4467,64 @@ function system_update_6035() { } /** + * Change the search index and for reindexing. + */ +function system_update_6036() { + $ret = array(); + if (db_table_exists('search_index')) { + if ($GLOBALS['db_type'] == 'mysql') { + // Create the search_dataset.reindex column. + db_add_field($ret, 'search_dataset', 'reindex', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); + + // Drop the search_index.from fields which are no longer used. + db_drop_index($ret, 'search_index', 'from_sid_type'); + db_drop_field($ret, 'search_index', 'fromsid'); + db_drop_field($ret, 'search_index', 'fromtype'); + + // Drop the search_dataset.sid_type index, so that it can be made unique. + db_drop_index($ret, 'search_dataset', 'sid_type'); + + // Create the search_node_links Table. + $search_node_links_schema = array( + 'fields' => array( + 'sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), + 'type' => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''), + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), + 'caption' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE), + ), + 'primary key' => array('sid', 'type', 'nid'), + 'indexes' => array('nid' => array('nid')), + ); + db_create_table($ret, 'search_node_links', $search_node_links_schema); + + // with the change to search_dataset.reindex, the search queue is handled differently, + // and this is no longer needed + variable_del('node_cron_last'); + + // Everything needs to be reindexed. + $ret[] = update_sql("UPDATE {search_dataset} SET reindex = 1"); + + // Add a unique index for the search_index. + // Since it's possible that some existing sites have duplicates, + // create the index using the IGNORE keyword, which ignores duplicate errors. + // However, pgsql doesn't support it + $ret[] = update_sql("ALTER IGNORE TABLE {search_index} ADD UNIQUE KEY sid_word_type (sid, word, type)"); + $ret[] = update_sql("ALTER IGNORE TABLE {search_dataset} ADD UNIQUE KEY sid_type (sid, type)"); + } + else { + // Drop the existing tables + db_query('DROP TABLE {search_dataset}'); + db_query('DROP TABLE {search_index}'); + db_query('DROP TABLE {search_total}'); + + // Create the new tables and do a full re-index + search_install(); + } + } + return $ret; +} + +/** * @} End of "defgroup updates-5.x-to-6.x" * The next series of updates should start at 7000. */ |