| 1 |
<?php
|
| 2 |
// $Id: xapian.install,v 1.1 2008/05/11 10:47:39 simon Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Installation file for xapian search library as a drupal module
|
| 7 |
*
|
| 8 |
* Initial Development and sample view code by Lachlan Gunn
|
| 9 |
* http://drupal.org/user/277696
|
| 10 |
* Core patch, tighter drupal integration, adherance to drupal standards,
|
| 11 |
* making ready for release by Simon Lindsay
|
| 12 |
* http://drupal.org/user/143
|
| 13 |
* Additional cleanup by Jeremy Andrews
|
| 14 |
* http://drupal.org/user/409
|
| 15 |
*/
|
| 16 |
function xapian_install() {
|
| 17 |
switch ($GLOBALS['db_type']) {
|
| 18 |
case 'mysql':
|
| 19 |
case 'mysqli':
|
| 20 |
default:
|
| 21 |
db_query("CREATE TABLE {xapian_index_queue} (
|
| 22 |
xid int(11) NOT NULL auto_increment,
|
| 23 |
added timestamp NOT NULL default CURRENT_TIMESTAMP,
|
| 24 |
priority int(11) NULL default '0',
|
| 25 |
status int(1) NULL default '0',
|
| 26 |
nid int(11) NOT NULL default '0',
|
| 27 |
PRIMARY KEY (xid),
|
| 28 |
KEY (nid, status)
|
| 29 |
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
|
| 30 |
}
|
| 31 |
}
|
| 32 |
|
| 33 |
function xapian_uninstall() {
|
| 34 |
db_query('DROP TABLE {xapian_index_queue}');
|
| 35 |
|
| 36 |
variable_del('xapian_database_type');
|
| 37 |
variable_del('xapian_database_path');
|
| 38 |
variable_del('xapian_database_hostname');
|
| 39 |
variable_del('xapian_database_port');
|
| 40 |
variable_del('xapian_node_count_type');
|
| 41 |
variable_del('xapian_log_queries');
|
| 42 |
variable_del('xapian_index_immediately');
|
| 43 |
variable_del('xapian_indexing_throttle');
|
| 44 |
variable_del('xapian_search_results_per_page');
|
| 45 |
}
|
| 46 |
|
| 47 |
/**
|
| 48 |
* Rename from reindex_queue to index_queue. Cleanup.
|
| 49 |
*/
|
| 50 |
function xapian_update_0501() {
|
| 51 |
$ret = array();
|
| 52 |
|
| 53 |
switch ($GLOBALS['db_type']) {
|
| 54 |
case 'mysql':
|
| 55 |
case 'mysqli':
|
| 56 |
default:
|
| 57 |
// Development release, much easier to drop and recreate than to update.
|
| 58 |
$ret[] = update_sql('DROP TABLE {xapian_reindex_queue}');
|
| 59 |
$ret[] = update_sql("CREATE TABLE {xapian_index_queue} (
|
| 60 |
xid int(11) NOT NULL auto_increment,
|
| 61 |
added timestamp NOT NULL default CURRENT_TIMESTAMP,
|
| 62 |
priority int(11) NULL default '0',
|
| 63 |
nid int(11) NOT NULL default '0',
|
| 64 |
PRIMARY KEY (xid),
|
| 65 |
KEY (nid)
|
| 66 |
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
|
| 67 |
}
|
| 68 |
|
| 69 |
return $ret;
|
| 70 |
}
|
| 71 |
|
| 72 |
/**
|
| 73 |
* Add 'status' row for tracking content that is actively being indexed. If
|
| 74 |
* something prevents us from flushing the cache to disk, we can re-index the
|
| 75 |
* same content again.
|
| 76 |
*/
|
| 77 |
function xapian_update_0502() {
|
| 78 |
$ret = array();
|
| 79 |
|
| 80 |
switch ($GLOBALS['db_type']) {
|
| 81 |
case 'mysql':
|
| 82 |
case 'mysqli':
|
| 83 |
default:
|
| 84 |
$ret[] = update_sql("ALTER TABLE {xapian_index_queue} ADD status int(1) NULL default '0'");
|
| 85 |
$ret[] = update_sql("ALTER TABLE {xapian_index_queue} ADD KEY (nid, status)");
|
| 86 |
$ret[] = update_sql("ALTER TABLE {xapian_index_queue} DROP KEY nid");
|
| 87 |
}
|
| 88 |
|
| 89 |
return $ret;
|
| 90 |
}
|