Skip to content

Commit 26b877d

Browse files
committed
Recurse to sequences on ownership change for all relkinds
When a table ownership is changed, we must apply that also to any owned sequences. (Otherwise, it would result in a situation that cannot be restored, because linked sequences must have the same owner as the table.) But this was previously only applied to regular tables and materialized views. But it should also apply to at least foreign tables. This patch removes the relkind check altogether, because it doesn't save very much and just introduces the possibility of similar omissions. Bug: #15238 Reported-by: Christoph Berg <christoph.berg@credativ.de>
1 parent a5361b5 commit 26b877d

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/backend/commands/tablecmds.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8718,17 +8718,13 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
87188718
list_free(index_oid_list);
87198719
}
87208720

8721-
if (tuple_class->relkind == RELKIND_RELATION ||
8722-
tuple_class->relkind == RELKIND_MATVIEW)
8723-
{
8724-
/* If it has a toast table, recurse to change its ownership */
8725-
if (tuple_class->reltoastrelid != InvalidOid)
8726-
ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
8727-
true, lockmode);
8721+
/* If it has a toast table, recurse to change its ownership */
8722+
if (tuple_class->reltoastrelid != InvalidOid)
8723+
ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
8724+
true, lockmode);
87288725

8729-
/* If it has dependent sequences, recurse to change them too */
8730-
change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
8731-
}
8726+
/* If it has dependent sequences, recurse to change them too */
8727+
change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
87328728
}
87338729

87348730
InvokeObjectPostAlterHook(RelationRelationId, relationOid, 0);

0 commit comments

Comments
 (0)