]> granicus.if.org Git - postgresql/commitdiff
Recurse to sequences on ownership change for all relkinds
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 15 Jun 2018 03:22:14 +0000 (23:22 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 26 Sep 2018 18:20:17 +0000 (20:20 +0200)
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

index 29e648bdae4a0371a472ca1a3a074a7bc1cd7bc3..acc25e6a73e4d65727343982adb52e8ce7c2e0a9 100644 (file)
@@ -9222,17 +9222,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);