Skip to content

Commit b167d57

Browse files
committed
Ignore tablespace ACLs when ignoring schema ACLs.
The ALTER TABLE ALTER TYPE implementation can issue DROP INDEX and CREATE INDEX to refit existing indexes for the new column type. Since this CREATE INDEX is an implementation detail of an index alteration, the ensuing DefineIndex() should skip ACL checks specific to index creation. It already skips the namespace ACL check. Make it skip the tablespace ACL check, too. Back-patch to 9.2 (all supported versions). Reviewed by Tom Lane.
1 parent 4dd4e3f commit b167d57

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/backend/commands/indexcmds.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ CheckIndexCompatible(Oid oldId,
285285
* 'indexRelationId': normally InvalidOid, but during bootstrap can be
286286
* nonzero to specify a preselected OID for the index.
287287
* 'is_alter_table': this is due to an ALTER rather than a CREATE operation.
288-
* 'check_rights': check for CREATE rights in the namespace. (This should
289-
* be true except when ALTER is deleting/recreating an index.)
288+
* 'check_rights': check for CREATE rights in namespace and tablespace. (This
289+
* should be true except when ALTER is deleting/recreating an index.)
290290
* 'skip_build': make the catalog entries but leave the index file empty;
291291
* it will be filled later.
292292
* 'quiet': suppress the NOTICE chatter ordinarily provided for constraints.
@@ -421,8 +421,9 @@ DefineIndex(Oid relationId,
421421
/* note InvalidOid is OK in this case */
422422
}
423423

424-
/* Check permissions except when using database's default */
425-
if (OidIsValid(tablespaceId) && tablespaceId != MyDatabaseTableSpace)
424+
/* Check tablespace permissions */
425+
if (check_rights &&
426+
OidIsValid(tablespaceId) && tablespaceId != MyDatabaseTableSpace)
426427
{
427428
AclResult aclresult;
428429

0 commit comments

Comments
 (0)