aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-03-14 22:44:50 +0000
committerBruce Momjian <bruce@momjian.us>2002-03-14 22:44:50 +0000
commit31effd10feb9d402f171a82b8d953a7441c0d082 (patch)
tree6cbab314a6c17c072aaf992cdae7dbe90bd3ebc1 /src
parent01e322652b14c2aeac1737f29f8bcf9e18d1060e (diff)
downloadpostgresql-31effd10feb9d402f171a82b8d953a7441c0d082.tar.gz
postgresql-31effd10feb9d402f171a82b8d953a7441c0d082.zip
The attached patch changes ALTER TABLE OWNER to also change the
ownership of any toast tables that belong to the table that is being operated upon (as suggested by Tom Lane). Neil Conway
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/command.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index b166ed539cd..c32be8b02f3 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -8,7 +8,7 @@
*
*
* 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
@@ -1619,11 +1619,13 @@ AlterTableOwnerId(Oid relationOid, int32 newOwnerSysId)
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;
@@ -1639,6 +1641,12 @@ AlterTableOwnerId(Oid relationOid, int32 newOwnerSysId)
}
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,10 +1662,11 @@ CheckTupleType(Form_pg_class tuple_class)
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));
}
}