Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bdf11d6

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 e513a3d commit bdf11d6

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
@@ -9222,17 +9222,13 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
92229222
list_free(index_oid_list);
92239223
}
92249224

9225-
if (tuple_class->relkind == RELKIND_RELATION ||
9226-
tuple_class->relkind == RELKIND_MATVIEW)
9227-
{
9228-
/* If it has a toast table, recurse to change its ownership */
9229-
if (tuple_class->reltoastrelid != InvalidOid)
9230-
ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
9231-
true, lockmode);
9225+
/* If it has a toast table, recurse to change its ownership */
9226+
if (tuple_class->reltoastrelid != InvalidOid)
9227+
ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
9228+
true, lockmode);
92329229

9233-
/* If it has dependent sequences, recurse to change them too */
9234-
change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
9235-
}
9230+
/* If it has dependent sequences, recurse to change them too */
9231+
change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
92369232
}
92379233

92389234
InvokeObjectPostAlterHook(RelationRelationId, relationOid, 0);

0 commit comments

Comments
 (0)