From 92a30a7eb0cadb008e18053f199af7de3fc1abaa Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 13 Apr 2016 23:33:31 -0400 Subject: Fix broken dependency-mongering for index operator classes/families. For a long time, opclasscmds.c explained that "we do not create a dependency link to the AM [for an opclass or opfamily], because we don't currently support DROP ACCESS METHOD". Commit 473b93287040b200 invented DROP ACCESS METHOD, but it batted only 1 for 2 on adding the dependency links, and 0 for 2 on updating the comments about the topic. In passing, undo the same commit's entirely inappropriate decision to blow away an existing index as a side-effect of create_am.sql. --- src/backend/commands/opclasscmds.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/backend') diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index ac559fc9b41..5f665cf3a20 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -285,14 +285,18 @@ CreateOpFamily(char *amname, char *opfname, Oid namespaceoid, Oid amoid) heap_freetuple(tup); /* - * Create dependencies for the opfamily proper. Note: we do not create a - * dependency link to the AM, because we don't currently support DROP - * ACCESS METHOD. + * Create dependencies for the opfamily proper. */ myself.classId = OperatorFamilyRelationId; myself.objectId = opfamilyoid; myself.objectSubId = 0; + /* dependency on access method */ + referenced.classId = AccessMethodRelationId; + referenced.objectId = amoid; + referenced.objectSubId = 0; + recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); + /* dependency on namespace */ referenced.classId = NamespaceRelationId; referenced.objectId = namespaceoid; @@ -670,20 +674,13 @@ DefineOpClass(CreateOpClassStmt *stmt) EventTriggerCollectCreateOpClass(stmt, opclassoid, operators, procedures); /* - * Create dependencies for the opclass proper. Note: we do not create a - * dependency link to the AM, because we don't currently support DROP - * ACCESS METHOD. + * Create dependencies for the opclass proper. Note: we do not need a + * dependency link to the AM, because that exists through the opfamily. */ myself.classId = OperatorClassRelationId; myself.objectId = opclassoid; myself.objectSubId = 0; - /* dependency on access method */ - referenced.classId = AccessMethodRelationId; - referenced.objectId = amoid; - referenced.objectSubId = 0; - recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); - /* dependency on namespace */ referenced.classId = NamespaceRelationId; referenced.objectId = namespaceoid; -- cgit v1.2.3