postgres.git / summary / log / commit / refs

commit    992f8542a370d6885fc19e79e0fc46a1ebf902cb
Author:   Peter Eisentraut <peter_e@gmx.net>
Date:     Fri Jun 15 03:22:14 2018 +0000
First released in: 12.0, 9.3.25, 9.4.20, 9.5.15, 9.6.11, 10.6, 11.0

    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>


src/backend/commands/tablecmds.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 572477f7c21..5e48ea5518e 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -9192,17 +9192,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); [parent: 69a5686368c9]