Skip to content

Commit 0320dda

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 d6c55de commit 0320dda

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
@@ -10477,17 +10477,13 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
1047710477
list_free(index_oid_list);
1047810478
}
1047910479

10480-
if (tuple_class->relkind == RELKIND_RELATION ||
10481-
tuple_class->relkind == RELKIND_MATVIEW)
10482-
{
10483-
/* If it has a toast table, recurse to change its ownership */
10484-
if (tuple_class->reltoastrelid != InvalidOid)
10485-
ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
10486-
true, lockmode);
10480+
/* If it has a toast table, recurse to change its ownership */
10481+
if (tuple_class->reltoastrelid != InvalidOid)
10482+
ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
10483+
true, lockmode);
1048710484

10488-
/* If it has dependent sequences, recurse to change them too */
10489-
change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
10490-
}
10485+
/* If it has dependent sequences, recurse to change them too */
10486+
change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
1049110487
}
1049210488

1049310489
InvokeObjectPostAlterHook(RelationRelationId, relationOid, 0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy