88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.160 2002/03/06 19:58:26 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.161 2002/03/14 22:44:50 momjian Exp $
1212 *
1313 * NOTES
1414 * The PerformAddAttribute() code, like most of the relation
@@ -1619,11 +1619,13 @@ AlterTableOwnerId(Oid relationOid, int32 newOwnerSysId)
16191619CatalogCloseIndices (Num_pg_class_indices ,idescs );
16201620
16211621/*
1622- * If we are operating on a table, also change the ownership
1623- * of all of its indexes.
1622+ * If we are operating on a table, also change the ownership of any
1623+ * indexes that belong to the table, as well as the table's toast
1624+ * table (if it has one)
16241625 */
16251626if (tuple_class -> relkind == RELKIND_RELATION )
16261627{
1628+ /* Search for indexes belonging to this table */
16271629Relation target_rel ;
16281630List * index_oid_list ,* i ;
16291631
@@ -1639,6 +1641,12 @@ AlterTableOwnerId(Oid relationOid, int32 newOwnerSysId)
16391641}
16401642
16411643freeList (index_oid_list );
1644+
1645+ /* If it has a toast table, recurse to change its ownership */
1646+ if (tuple_class -> reltoastrelid != InvalidOid )
1647+ {
1648+ AlterTableOwnerId (tuple_class -> reltoastrelid ,newOwnerSysId );
1649+ }
16421650}
16431651
16441652heap_freetuple (tuple );
@@ -1654,10 +1662,11 @@ CheckTupleType(Form_pg_class tuple_class)
16541662case RELKIND_INDEX :
16551663case RELKIND_VIEW :
16561664case RELKIND_SEQUENCE :
1665+ case RELKIND_TOASTVALUE :
16571666/* ok to change owner */
16581667break ;
16591668default :
1660- elog (ERROR ,"ALTER TABLE: relation \"%s\" is not a table, index, view, or sequence" ,
1669+ elog (ERROR ,"ALTER TABLE: relation \"%s\" is not a table,TOAST table, index, view, or sequence" ,
16611670NameStr (tuple_class -> relname ));
16621671}
16631672}