Index: src/backend/commands/command.c =================================================================== RCS file: /var/lib/cvs/pgsql/src/backend/commands/command.c,v retrieving revision 1.160 diff -c -r1.160 command.c *** src/backend/commands/command.c 6 Mar 2002 19:58:26 -0000 1.160 --- src/backend/commands/command.c 8 Mar 2002 05:47:20 -0000 *************** *** 1619,1629 **** CatalogCloseIndices(Num_pg_class_indices, idescs); /* ! * If we are operating on a table, also change the ownership ! * of all of its indexes. */ if (tuple_class->relkind == RELKIND_RELATION) { Relation target_rel; List *index_oid_list, *i; --- 1619,1631 ---- CatalogCloseIndices(Num_pg_class_indices, idescs); /* ! * 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; *************** *** 1639,1644 **** --- 1641,1652 ---- } 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); *************** *** 1654,1663 **** case RELKIND_INDEX: case RELKIND_VIEW: case RELKIND_SEQUENCE: /* ok to change owner */ break; default: ! elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table, index, view, or sequence", NameStr(tuple_class->relname)); } } --- 1662,1672 ---- 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, TOAST table, index, view, or sequence", NameStr(tuple_class->relname)); } }