Skip to content

Commit 18c73fc

Browse files
committed
Revert "fix: hint table for columns where needed for sharded queries"
This reverts commit c897828.
1 parent 71fe82f commit 18c73fc

File tree

2 files changed

+48
-50
lines changed

2 files changed

+48
-50
lines changed

lib/ACL/RuleManager.php

+20-21
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ public function getRulesForFilesByPath(IUser $user, int $storageId, array $fileP
8484
$rows = [];
8585
foreach (array_chunk($hashes, 1000) as $chunk) {
8686
$query = $this->connection->getQueryBuilder();
87-
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'f.path'])
87+
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'path'])
8888
->from('group_folders_acl', 'a')
8989
->innerJoin('a', 'filecache', 'f', $query->expr()->eq('f.fileid', 'a.fileid'))
90-
->where($query->expr()->in('f.path_hash', $query->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)))
91-
->andWhere($query->expr()->eq('f.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
90+
->where($query->expr()->in('path_hash', $query->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)))
91+
->andWhere($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
9292
->andWhere($query->expr()->orX(...array_map(fn (IUserMapping $userMapping): ICompositeExpression => $query->expr()->andX(
9393
$query->expr()->eq('mapping_type', $query->createNamedParameter($userMapping->getType())),
9494
$query->expr()->eq('mapping_id', $query->createNamedParameter($userMapping->getId()))
@@ -117,20 +117,19 @@ public function getRulesForFilesByParent(IUser $user, int $storageId, string $pa
117117
}
118118

119119
$query = $this->connection->getQueryBuilder();
120-
$query->select(['f.fileid', 'a.mapping_type', 'a.mapping_id', 'a.mask', 'a.permissions', 'f.path'])
120+
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'path'])
121121
->from('filecache', 'f')
122122
->leftJoin('f', 'group_folders_acl', 'a', $query->expr()->eq('f.fileid', 'a.fileid'))
123-
->andWhere($query->expr()->eq('f.parent', $query->createNamedParameter($parentId, IQueryBuilder::PARAM_INT)))
124-
->andWhere($query->expr()->eq('f.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
123+
->andWhere($query->expr()->eq('parent', $query->createNamedParameter($parentId, IQueryBuilder::PARAM_INT)))
125124
->andWhere(
126125
$query->expr()->orX(
127126
$query->expr()->andX(
128-
$query->expr()->isNull('a.mapping_type'),
129-
$query->expr()->isNull('a.mapping_id')
127+
$query->expr()->isNull('mapping_type'),
128+
$query->expr()->isNull('mapping_id')
130129
),
131130
...array_map(fn (IUserMapping $userMapping): ICompositeExpression => $query->expr()->andX(
132-
$query->expr()->eq('a.mapping_type', $query->createNamedParameter($userMapping->getType())),
133-
$query->expr()->eq('a.mapping_id', $query->createNamedParameter($userMapping->getId()))
131+
$query->expr()->eq('mapping_type', $query->createNamedParameter($userMapping->getType())),
132+
$query->expr()->eq('mapping_id', $query->createNamedParameter($userMapping->getId()))
134133
), $userMappings)
135134
)
136135
);
@@ -171,11 +170,11 @@ private function getId(int $storageId, string $path): int {
171170
public function getAllRulesForPaths(int $storageId, array $filePaths): array {
172171
$hashes = array_map(fn (string $path): string => md5(trim($path, '/')), $filePaths);
173172
$query = $this->connection->getQueryBuilder();
174-
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'f.path'])
173+
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'path'])
175174
->from('group_folders_acl', 'a')
176175
->innerJoin('a', 'filecache', 'f', $query->expr()->eq('f.fileid', 'a.fileid'))
177-
->where($query->expr()->in('f.path_hash', $query->createNamedParameter($hashes, IQueryBuilder::PARAM_STR_ARRAY)))
178-
->andWhere($query->expr()->eq('f.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
176+
->where($query->expr()->in('path_hash', $query->createNamedParameter($hashes, IQueryBuilder::PARAM_STR_ARRAY)))
177+
->andWhere($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
179178

180179
$rows = $query->executeQuery()->fetchAll();
181180

@@ -204,14 +203,14 @@ private function rulesByPath(array $rows, array $result = []): array {
204203
*/
205204
public function getAllRulesForPrefix(int $storageId, string $prefix): array {
206205
$query = $this->connection->getQueryBuilder();
207-
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'f.path'])
206+
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'path'])
208207
->from('group_folders_acl', 'a')
209208
->innerJoin('a', 'filecache', 'f', $query->expr()->eq('f.fileid', 'a.fileid'))
210209
->where($query->expr()->orX(
211-
$query->expr()->like('f.path', $query->createNamedParameter($this->connection->escapeLikeParameter($prefix) . '/%')),
212-
$query->expr()->eq('f.path_hash', $query->createNamedParameter(md5($prefix)))
210+
$query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($prefix) . '/%')),
211+
$query->expr()->eq('path_hash', $query->createNamedParameter(md5($prefix)))
213212
))
214-
->andWhere($query->expr()->eq('f.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
213+
->andWhere($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
215214

216215
$rows = $query->executeQuery()->fetchAll();
217216

@@ -225,14 +224,14 @@ public function getRulesForPrefix(IUser $user, int $storageId, string $prefix):
225224
$userMappings = $this->userMappingManager->getMappingsForUser($user);
226225

227226
$query = $this->connection->getQueryBuilder();
228-
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'f.path'])
227+
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'path'])
229228
->from('group_folders_acl', 'a')
230229
->innerJoin('a', 'filecache', 'f', $query->expr()->eq('f.fileid', 'a.fileid'))
231230
->where($query->expr()->orX(
232-
$query->expr()->like('f.path', $query->createNamedParameter($this->connection->escapeLikeParameter($prefix) . '/%')),
233-
$query->expr()->eq('f.path_hash', $query->createNamedParameter(md5($prefix)))
231+
$query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($prefix) . '/%')),
232+
$query->expr()->eq('path_hash', $query->createNamedParameter(md5($prefix)))
234233
))
235-
->andWhere($query->expr()->eq('f.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
234+
->andWhere($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
236235
->andWhere($query->expr()->orX(...array_map(fn (IUserMapping $userMapping): ICompositeExpression => $query->expr()->andX(
237236
$query->expr()->eq('mapping_type', $query->createNamedParameter($userMapping->getType())),
238237
$query->expr()->eq('mapping_id', $query->createNamedParameter($userMapping->getId()))

lib/Folder/FolderManager.php

+28-29
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ private function joinQueryWithFileCache(IQueryBuilder $query, int $rootStorageId
123123
$query->leftJoin('f', 'filecache', 'c', $query->expr()->andX(
124124
// concat with empty string to work around missing cast to string
125125
$query->expr()->eq('c.name', $query->func()->concat('f.folder_id', $query->expr()->literal(''))),
126-
$query->expr()->eq('c.parent', $query->createNamedParameter($this->getGroupFolderRootId($rootStorageId))),
127-
$query->expr()->eq('c.storage', $query->createNamedParameter($rootStorageId)),
126+
$query->expr()->eq('c.parent', $query->createNamedParameter($this->getGroupFolderRootId($rootStorageId)))
128127
));
129128
}
130129

@@ -137,7 +136,7 @@ public function getAllFoldersWithSize(int $rootStorageId): array {
137136

138137
$query = $this->connection->getQueryBuilder();
139138

140-
$query->select('folder_id', 'mount_point', 'quota', 'c.size', 'acl')
139+
$query->select('folder_id', 'mount_point', 'quota', 'size', 'acl')
141140
->from('group_folders', 'f');
142141
$this->joinQueryWithFileCache($query, $rootStorageId);
143142

@@ -173,7 +172,7 @@ public function getAllFoldersForUserWithSize(int $rootStorageId, IUser $user): a
173172

174173
$query = $this->connection->getQueryBuilder();
175174

176-
$query->select('f.folder_id', 'mount_point', 'quota', 'c.size', 'acl')
175+
$query->select('f.folder_id', 'mount_point', 'quota', 'size', 'acl')
177176
->from('group_folders', 'f')
178177
->innerJoin(
179178
'f',
@@ -286,7 +285,7 @@ public function getFolder(int $id, int $rootStorageId = 0): ?array {
286285

287286
$query = $this->connection->getQueryBuilder();
288287

289-
$query->select('folder_id', 'mount_point', 'quota', 'c.size', 'acl')
288+
$query->select('folder_id', 'mount_point', 'quota', 'size', 'acl')
290289
->from('group_folders', 'f')
291290
->where($query->expr()->eq('folder_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
292291
$this->joinQueryWithFileCache($query, $rootStorageId);
@@ -497,18 +496,18 @@ public function getFoldersForGroup(string $groupId, int $rootStorageId = 0): arr
497496
'mount_point',
498497
'quota',
499498
'acl',
500-
'c.fileid',
501-
'c.storage',
502-
'c.path',
503-
'c.name',
504-
'c.mimetype',
505-
'c.mimepart',
506-
'c.size',
507-
'c.mtime',
508-
'c.storage_mtime',
509-
'c.etag',
510-
'c.encrypted',
511-
'c.parent'
499+
'fileid',
500+
'storage',
501+
'path',
502+
'name',
503+
'mimetype',
504+
'mimepart',
505+
'size',
506+
'mtime',
507+
'storage_mtime',
508+
'etag',
509+
'encrypted',
510+
'parent'
512511
)
513512
->selectAlias('a.permissions', 'group_permissions')
514513
->selectAlias('c.permissions', 'permissions')
@@ -547,18 +546,18 @@ public function getFoldersForGroups(array $groupIds, int $rootStorageId = 0): ar
547546
'mount_point',
548547
'quota',
549548
'acl',
550-
'c.fileid',
551-
'c.storage',
552-
'c.path',
553-
'c.name',
554-
'c.mimetype',
555-
'c.mimepart',
556-
'c.size',
557-
'c.mtime',
558-
'c.storage_mtime',
559-
'c.etag',
560-
'c.encrypted',
561-
'c.parent'
549+
'fileid',
550+
'storage',
551+
'path',
552+
'name',
553+
'mimetype',
554+
'mimepart',
555+
'size',
556+
'mtime',
557+
'storage_mtime',
558+
'etag',
559+
'encrypted',
560+
'parent'
562561
)
563562
->selectAlias('a.permissions', 'group_permissions')
564563
->selectAlias('c.permissions', 'permissions')

0 commit comments

Comments
 (0)