*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.160 2002/03/06 19:58:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.161 2002/03/14 22:44:50 momjian Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
CatalogCloseIndices(Num_pg_class_indices, idescs);
/*
- * If we are operating on a table, also change the ownership
- * of all of its indexes.
+ * If we are operating on a table, also change the ownership of any
+ * indexes that belong to the table, as well as the table's toast
+ * table (if it has one)
*/
if (tuple_class->relkind == RELKIND_RELATION)
{
+ /* Search for indexes belonging to this table */
Relation target_rel;
List *index_oid_list, *i;
}
freeList(index_oid_list);
+
+ /* If it has a toast table, recurse to change its ownership */
+ if (tuple_class->reltoastrelid != InvalidOid)
+ {
+ AlterTableOwnerId(tuple_class->reltoastrelid, newOwnerSysId);
+ }
}
heap_freetuple(tuple);
case RELKIND_INDEX:
case RELKIND_VIEW:
case RELKIND_SEQUENCE:
+ case RELKIND_TOASTVALUE:
/* ok to change owner */
break;
default:
- elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table, index, view, or sequence",
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table, TOAST table, index, view, or sequence",
NameStr(tuple_class->relname));
}
}