Skip to content

Commit

Permalink
Fix table type dependency on owner
Browse files Browse the repository at this point in the history
Previously, when creating a table type, the underlying table had a dependency on both the table type and the the role that created it. The DROP OWNED BY <role> command will try to drop the table, and fail because the table depends on the table type. This commit removes the underlying table's dependency on the role, and instead adds a dependency for the table type on the role. This way, DROP OWNED BY <role> will try to drop the table type instead, and succeed in dropping both the table type and the underlying table.

Task: BABEL-2706
Author: Zitao Quan <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
  • Loading branch information
thephantomthief authored and nasbyj committed Feb 2, 2022
1 parent 8d9455b commit 905a4d9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/backend/commands/tablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,12 +1191,19 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
* created composite type as the desired table type.
* So, remove the composite type's dependency on the relation, and record
* the relation's dependency on the composite type.
* Also, remove the relation's dependency on the owner, and record the
* composite type's dependency on the owner.
*/
if (stmt->tsql_tabletype)
{
deleteDependencyRecordsForClass(typaddress->classId, typaddress->objectId,
RelationRelationId, DEPENDENCY_INTERNAL);
recordDependencyOn(&address, typaddress, DEPENDENCY_INTERNAL);

deleteSharedDependencyRecordsFor(address.classId, address.objectId,
address.objectSubId);
recordDependencyOnOwner(typaddress->classId, typaddress->objectId,
ownerId);
}

/*
Expand Down

0 comments on commit 905a4d9

Please sign in to comment.