Skip to content

Commit 6953265

Browse files
committed
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 <[email protected]>
1 parent abd6b35 commit 6953265

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

core/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*/
3232
namespace OC\Core;
3333

34+
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
3435
use OC\Authentication\Events\RemoteWipeFinished;
3536
use OC\Authentication\Events\RemoteWipeStarted;
3637
use OC\Authentication\Listeners\RemoteWipeActivityListener;
@@ -119,7 +120,7 @@ function (GenericEvent $event) use ($container) {
119120
$subject->addHintForMissingSubject($table->getName(), 'fs_id_storage_size');
120121
}
121122

122-
if (!$table->hasIndex('fs_storage_path_prefix')) {
123+
if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) {
123124
$subject->addHintForMissingSubject($table->getName(), 'fs_storage_path_prefix');
124125
}
125126
}

core/Command/Db/AddMissingIndices.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*/
3434
namespace OC\Core\Command\Db;
3535

36+
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
3637
use OC\DB\Connection;
3738
use OC\DB\SchemaWrapper;
3839
use OCP\IDBConnection;
@@ -151,7 +152,7 @@ private function addCoreIndexes(OutputInterface $output) {
151152
$updated = true;
152153
$output->writeln('<info>Filecache table updated successfully.</info>');
153154
}
154-
if (!$table->hasIndex('fs_storage_path_prefix')) {
155+
if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) {
155156
$output->writeln('<info>Adding additional path index to the filecache table, this can take some time...</info>');
156157
$table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]);
157158
$this->connection->migrateToSchema($schema->getWrappedSchema());

core/Migrations/Version13000Date20170718121200.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*/
3232
namespace OC\Core\Migrations;
3333

34+
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
3435
use OCP\DB\Types;
3536
use OCP\DB\ISchemaWrapper;
3637
use OCP\IDBConnection;
@@ -264,7 +265,9 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
264265
$table->addIndex(['fileid', 'storage', 'size'], 'fs_id_storage_size');
265266
$table->addIndex(['mtime'], 'fs_mtime');
266267
$table->addIndex(['size'], 'fs_size');
267-
$table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]);
268+
if (!$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) {
269+
$table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]);
270+
}
268271
}
269272

270273
if (!$schema->hasTable('group_user')) {

lib/private/DB/SchemaWrapper.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
namespace OC\DB;
2525

26+
use Doctrine\DBAL\Exception;
27+
use Doctrine\DBAL\Platforms\AbstractPlatform;
2628
use Doctrine\DBAL\Schema\Schema;
2729
use OCP\DB\ISchemaWrapper;
2830

@@ -129,4 +131,15 @@ public function dropTable($tableName) {
129131
public function getTables() {
130132
return $this->schema->getTables();
131133
}
134+
135+
/**
136+
* Gets the DatabasePlatform for the database.
137+
*
138+
* @return AbstractPlatform
139+
*
140+
* @throws Exception
141+
*/
142+
public function getDatabasePlatform() {
143+
return $this->connection->getDatabasePlatform();
144+
}
132145
}

lib/public/DB/ISchemaWrapper.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
namespace OCP\DB;
2424

25+
use Doctrine\DBAL\Exception;
26+
use Doctrine\DBAL\Platforms\AbstractPlatform;
27+
2528
/**
2629
* Interface ISchemaWrapper
2730
*
@@ -81,12 +84,22 @@ public function getTables();
8184
* @since 13.0.0
8285
*/
8386
public function getTableNames();
84-
87+
8588
/**
8689
* Gets all table names
8790
*
8891
* @return array
8992
* @since 13.0.0
9093
*/
9194
public function getTableNamesWithoutPrefix();
95+
96+
/**
97+
* Gets the DatabasePlatform for the database.
98+
*
99+
* @return AbstractPlatform
100+
*
101+
* @throws Exception
102+
* @since 23.0.0
103+
*/
104+
public function getDatabasePlatform();
92105
}

0 commit comments

Comments
 (0)