From: Marcel Werk Date: Tue, 26 Jun 2012 11:52:39 +0000 (+0200) Subject: Changed the behaviour of fulltext indices for PostgreSQL X-Git-Tag: 2.0.0_Beta_1~1051 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0dc41b7ca1d7254b2fc06593304560f457b11b06;p=GitHub%2FWoltLab%2FWCF.git Changed the behaviour of fulltext indices 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 bdc05e6dc0..973b7d4fcb 100644 --- a/wcfsetup/install/files/lib/system/database/editor/PostgreSQLDatabaseEditor.class.php +++ b/wcfsetup/install/files/lib/system/database/editor/PostgreSQLDatabaseEditor.class.php @@ -238,13 +238,36 @@ class PostgreSQLDatabaseEditor extends DatabaseEditor { } if ($indexData['type'] == 'FULLTEXT') { - $sql = "CREATE INDEX ".$indexName." ON ".$tableName." USING gin(to_tsvector('english', \"".implode('" || \' \' || "', $columns)."\"))"; + // add new column for fulltext index + $sql = "ALTER TABLE ".$tableName." ADD COLUMN ".$indexName." tsvector"; + $statement = $this->dbObj->prepareStatement($sql); + $statement->execute(); + + // add gin index + $sql = "CREATE INDEX ".$tableName."_".$indexName."_fulltext_key ON ".$tableName." USING gin(".$indexName.")"; + $statement = $this->dbObj->prepareStatement($sql); + $statement->execute(); + + // update fulltext index + $sql = "UPDATE ".$tableName." + SET ".$indexName." = to_tsvector('english', \"".implode('" || \' \' || "', $columns)."\")"; + $statement = $this->dbObj->prepareStatement($sql); + $statement->execute(); + + // add trigger + $sql = "CREATE TRIGGER ".$tableName."_".$indexName."_trigger + BEFORE INSERT OR UPDATE + ON ".$tableName." + FOR EACH ROW EXECUTE PROCEDURE + tsvector_update_trigger(".$indexName.", 'pg_catalog.english', ".implode(', ', $columns).");"; + $statement = $this->dbObj->prepareStatement($sql); + $statement->execute(); } else { $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(); } /**