aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-06-14 23:22:14 -0400
committerPeter Eisentraut <peter_e@gmx.net>2018-09-26 20:19:44 +0200
commit5f6b0e6d69f1087847c8456b3f69761c950d52c6 (patch)
treecb608f3ce780d3b56f601b3586079bb2e992d1fe
parentcb822ffb798019b3cfb779f73725925d0416f6c8 (diff)
downloadpostgresql-5f6b0e6d69f1087847c8456b3f69761c950d52c6.tar.gz
postgresql-5f6b0e6d69f1087847c8456b3f69761c950d52c6.zip
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>
-rw-r--r--src/backend/commands/tablecmds.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 0b518cf6721..d9187a86c0e 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -10045,17 +10045,13 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
list_free(index_oid_list);
}
- if (tuple_class->relkind == RELKIND_RELATION ||
- tuple_class->relkind == RELKIND_MATVIEW)
- {
- /* If it has a toast table, recurse to change its ownership */
- if (tuple_class->reltoastrelid != InvalidOid)
- ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
- true, lockmode);
+ /* If it has a toast table, recurse to change its ownership */
+ if (tuple_class->reltoastrelid != InvalidOid)
+ ATExecChangeOwner(tuple_class->reltoastrelid, newOwnerId,
+ true, lockmode);
- /* If it has dependent sequences, recurse to change them too */
- change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
- }
+ /* If it has dependent sequences, recurse to change them too */
+ change_owner_recurse_to_sequences(relationOid, newOwnerId, lockmode);
}
InvokeObjectPostAlterHook(RelationRelationId, relationOid, 0);