View source
<?php
function search_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {search_dataset} (\n sid int unsigned NOT NULL default '0',\n type varchar(16) default NULL,\n data longtext NOT NULL,\n KEY sid_type (sid, type)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {search_index} (\n word varchar(50) NOT NULL default '',\n sid int unsigned NOT NULL default '0',\n type varchar(16) default NULL,\n fromsid int unsigned NOT NULL default '0',\n fromtype varchar(16) default NULL,\n score float default NULL,\n KEY sid_type (sid, type),\n KEY from_sid_type (fromsid, fromtype),\n KEY word (word)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {search_total} (\n word varchar(50) NOT NULL default '',\n count float default NULL,\n PRIMARY KEY (word)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {search_dataset} (\n sid int_unsigned NOT NULL default '0',\n type varchar(16) default NULL,\n data text NOT NULL\n )");
db_query("CREATE INDEX {search_dataset}_sid_type_idx ON {search_dataset} (sid, type)");
db_query("CREATE TABLE {search_index} (\n word varchar(50) NOT NULL default '',\n sid int_unsigned NOT NULL default '0',\n type varchar(16) default NULL,\n fromsid int_unsigned NOT NULL default '0',\n fromtype varchar(16) default NULL,\n score float default NULL\n )");
db_query("CREATE INDEX {search_index}_sid_type_idx ON {search_index} (sid, type)");
db_query("CREATE INDEX {search_index}_from_sid_type_idx ON {search_index} (fromsid, fromtype)");
db_query("CREATE INDEX {search_index}_word_idx ON {search_index} (word)");
db_query("CREATE TABLE {search_total} (\n word varchar(50) NOT NULL default '',\n count float default NULL,\n PRIMARY KEY (word)\n )");
break;
}
}
function search_uninstall() {
db_query('DROP TABLE {search_dataset}');
db_query('DROP TABLE {search_index}');
db_query('DROP TABLE {search_total}');
variable_del('minimum_word_size');
variable_del('overlap_cjk');
variable_del('search_cron_limit');
}