From 9ac8e8b46840caf7a4e18f77d2481dabd7ad2032 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 2 Jan 2012 19:35:21 +0100 Subject: [PATCH] Added fulltext index support for PostgreSQL --- .../editor/PostgreSQLDatabaseEditor.class.php | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) 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(); } /** -- 2.20.1