From: Marcel Werk Date: Mon, 2 Jan 2012 18:35:21 +0000 (+0100) Subject: Added fulltext index support for PostgreSQL X-Git-Tag: 2.0.0_Beta_1~1445^2~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9ac8e8b46840caf7a4e18f77d2481dabd7ad2032;p=GitHub%2FWoltLab%2FWCF.git Added fulltext index support for PostgreSQL --- diff --git a/wcfsetup/install/files/lib/system/database/editor/PostgreSQLDatabaseEditor.class.php b/wcfsetup/install/files/lib/system/database/editor/PostgreSQLDatabaseEditor.class.php index c9600ba11e..576bf85666 100644 --- a/wcfsetup/install/files/lib/system/database/editor/PostgreSQLDatabaseEditor.class.php +++ b/wcfsetup/install/files/lib/system/database/editor/PostgreSQLDatabaseEditor.class.php @@ -220,24 +220,25 @@ class PostgreSQLDatabaseEditor extends DatabaseEditor { * @see wcf\system\database\editor\DatabaseEditor::addIndex() */ public function addIndex($tableName, $indexName, $indexData) { + if (empty($indexName)) { + // create index name + // TODO: solve naming conflicts + $columns = ArrayUtil::trim(explode(',', $indexData['columns'])); + $indexName = $tableName.'_'.(!empty($columns[0]) ? $columns[0] : 'generic').'_key'; + } + else { + $indexName = $tableName.'_'.$indexName.'_key'; + } + + $sql = ''; if ($indexData['type'] == 'FULLTEXT') { - // TODO: implement fulltext search in postgresql + $sql = "CREATE INDEX ".$indexName." ON ".$tableName." USING gin(to_tsvector('english', \"".implode('" || \' \' || "', explode(',', $indexData['columns']))."\"))"; } else { - if (empty($indexName)) { - // create index name - // TODO: solve naming conflicts - $columns = ArrayUtil::trim(explode(',', $indexData['columns'])); - $indexName = $tableName.'_'.(!empty($columns[0]) ? $columns[0] : 'generic').'_key'; - } - else { - $indexName = $tableName.'_'.$indexName.'_key'; - } - $sql = "CREATE ".($indexData['type'] == 'UNIQUE' ? "UNIQUE " : "")."INDEX ".$indexName." ON ".$tableName." (".$indexData['columns'].")"; - $statement = $this->dbObj->prepareStatement($sql); - $statement->execute(); } + $statement = $this->dbObj->prepareStatement($sql); + $statement->execute(); } /**