diff options
author | Robin Appelman <robin@icewind.nl> | 2021-08-26 14:25:17 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-10-21 18:33:43 +0200 |
commit | c3d9471fe0debb09823495270f66853131f71e0d (patch) | |
tree | e7174d387be8585c7b7a30f4cea395f334b6dbd7 | |
parent | d4fc462980b1223b14bcf91c3412ec897b0facde (diff) | |
download | nextcloud-server-c3d9471fe0debb09823495270f66853131f71e0d.tar.gz nextcloud-server-c3d9471fe0debb09823495270f66853131f71e0d.zip |
disable path prefix index on postgresql for now
having the index work properly for the queries we need it for requires some additional options which dbal does not support at the momement.
to prevent making it harder to add the correct index later on we don't create the index for now on postgresql
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | core/Application.php | 3 | ||||
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 3 | ||||
-rw-r--r-- | core/Migrations/Version13000Date20170718121200.php | 5 | ||||
-rw-r--r-- | lib/private/DB/SchemaWrapper.php | 13 | ||||
-rw-r--r-- | lib/public/DB/ISchemaWrapper.php | 15 |
5 files changed, 35 insertions, 4 deletions
diff --git a/core/Application.php b/core/Application.php index 03ff1be681e..05e45f4084f 100644 --- a/core/Application.php +++ b/core/Application.php @@ -32,6 +32,7 @@ namespace OC\Core; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use OC\Authentication\Events\RemoteWipeFinished; use OC\Authentication\Events\RemoteWipeStarted; use OC\Authentication\Listeners\RemoteWipeActivityListener; @@ -116,7 +117,7 @@ class Application extends App { $subject->addHintForMissingSubject($table->getName(), 'fs_size'); } - if (!$table->hasIndex('fs_storage_path_prefix')) { + if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) { $subject->addHintForMissingSubject($table->getName(), 'fs_storage_path_prefix'); } } diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 1cf64c27c31..7079c68fcdb 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -33,6 +33,7 @@ declare(strict_types=1); namespace OC\Core\Command\Db; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use OC\DB\Connection; use OC\DB\SchemaWrapper; use OCP\IDBConnection; @@ -144,7 +145,7 @@ class AddMissingIndices extends Command { $updated = true; $output->writeln('<info>Filecache table updated successfully.</info>'); } - if (!$table->hasIndex('fs_storage_path_prefix')) { + if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) { $output->writeln('<info>Adding additional path index to the filecache table, this can take some time...</info>'); $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]); $this->connection->migrateToSchema($schema->getWrappedSchema()); diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index d023942e0ec..8b675506095 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -30,6 +30,7 @@ namespace OC\Core\Migrations; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use OCP\DB\Types; use OCP\DB\ISchemaWrapper; use OCP\IDBConnection; @@ -262,7 +263,9 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); $table->addIndex(['mtime'], 'fs_mtime'); $table->addIndex(['size'], 'fs_size'); - $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]); + if (!$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) { + $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]); + } } if (!$schema->hasTable('group_user')) { diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php index 20ae5b6faa6..9f7623bac44 100644 --- a/lib/private/DB/SchemaWrapper.php +++ b/lib/private/DB/SchemaWrapper.php @@ -24,6 +24,8 @@ namespace OC\DB; +use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Schema; use OCP\DB\ISchemaWrapper; @@ -130,4 +132,15 @@ class SchemaWrapper implements ISchemaWrapper { public function getTables() { return $this->schema->getTables(); } + + /** + * Gets the DatabasePlatform for the database. + * + * @return AbstractPlatform + * + * @throws Exception + */ + public function getDatabasePlatform() { + return $this->connection->getDatabasePlatform(); + } } diff --git a/lib/public/DB/ISchemaWrapper.php b/lib/public/DB/ISchemaWrapper.php index 3d58a10d2d2..1eac5c4f755 100644 --- a/lib/public/DB/ISchemaWrapper.php +++ b/lib/public/DB/ISchemaWrapper.php @@ -23,6 +23,9 @@ namespace OCP\DB; +use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\AbstractPlatform; + /** * Interface ISchemaWrapper * @@ -82,7 +85,7 @@ interface ISchemaWrapper { * @since 13.0.0 */ public function getTableNames(); - + /** * Gets all table names * @@ -90,4 +93,14 @@ interface ISchemaWrapper { * @since 13.0.0 */ public function getTableNamesWithoutPrefix(); + + /** + * Gets the DatabasePlatform for the database. + * + * @return AbstractPlatform + * + * @throws Exception + * @since 23.0.0 + */ + public function getDatabasePlatform(); } |