diff --git a/src/meta/processors/index/DropEdgeIndexProcessor.cpp b/src/meta/processors/index/DropEdgeIndexProcessor.cpp index fdbb57ce803..02f8aa9d661 100644 --- a/src/meta/processors/index/DropEdgeIndexProcessor.cpp +++ b/src/meta/processors/index/DropEdgeIndexProcessor.cpp @@ -39,6 +39,27 @@ void DropEdgeIndexProcessor::process(const cpp2::DropEdgeIndexReq& req) { keys.emplace_back(MetaKeyUtils::indexIndexKey(spaceID, indexName)); keys.emplace_back(MetaKeyUtils::indexKey(spaceID, edgeIndexID)); + auto indexItemRet = doGet(keys.back()); + if (!nebula::ok(indexItemRet)) { + auto retCode = nebula::error(indexItemRet); + if (retCode == nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND) { + retCode = nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND; + } + LOG(ERROR) << "Drop Edge Index Failed: SpaceID " << spaceID << " Index Name: " << indexName + << " error: " << apache::thrift::util::enumNameSafe(retCode); + handleErrorCode(retCode); + onFinished(); + return; + } + + auto item = MetaKeyUtils::parseIndex(nebula::value(indexItemRet)); + if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::edge_type) { + LOG(ERROR) << "Drop Edge Index Failed: Index Name " << indexName << " is not EdgeIndex"; + resp_.set_code(nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND); + onFinished(); + return; + } + LOG(INFO) << "Drop Edge Index " << indexName; resp_.set_id(to(edgeIndexID, EntryType::INDEX)); doSyncMultiRemoveAndUpdate(std::move(keys)); diff --git a/src/meta/processors/index/DropTagIndexProcessor.cpp b/src/meta/processors/index/DropTagIndexProcessor.cpp index 4c392277645..b079a69aa71 100644 --- a/src/meta/processors/index/DropTagIndexProcessor.cpp +++ b/src/meta/processors/index/DropTagIndexProcessor.cpp @@ -38,6 +38,27 @@ void DropTagIndexProcessor::process(const cpp2::DropTagIndexReq& req) { keys.emplace_back(MetaKeyUtils::indexIndexKey(spaceID, indexName)); keys.emplace_back(MetaKeyUtils::indexKey(spaceID, tagIndexID)); + auto indexItemRet = doGet(keys.back()); + if (!nebula::ok(indexItemRet)) { + auto retCode = nebula::error(indexItemRet); + if (retCode == nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND) { + retCode = nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND; + } + LOG(ERROR) << "Drop Tag Index Failed: SpaceID " << spaceID << " Index Name: " << indexName + << " error: " << apache::thrift::util::enumNameSafe(retCode); + handleErrorCode(retCode); + onFinished(); + return; + } + + auto item = MetaKeyUtils::parseIndex(nebula::value(indexItemRet)); + if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::tag_id) { + LOG(ERROR) << "Drop Tag Index Failed: Index Name " << indexName << " is not TagIndex"; + resp_.set_code(nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND); + onFinished(); + return; + } + LOG(INFO) << "Drop Tag Index " << indexName; resp_.set_id(to(tagIndexID, EntryType::INDEX)); doSyncMultiRemoveAndUpdate(std::move(keys)); diff --git a/tests/tck/features/index/TagEdgeIndex.feature b/tests/tck/features/index/TagEdgeIndex.feature index 2d958badd44..40a12fbbd59 100644 --- a/tests/tck/features/index/TagEdgeIndex.feature +++ b/tests/tck/features/index/TagEdgeIndex.feature @@ -162,6 +162,12 @@ Feature: tag and edge index tests from pytest Then the result should be, in any order: | Tag Index Name | Create Tag Index | | 'multi_tag_index' | 'CREATE TAG INDEX `multi_tag_index` ON `tag_1` (\n `col2`,\n `col3`\n)' | + # Check if check tag/edge type before drop index + When executing query: + """ + DROP EDGE INDEX multi_tag_index + """ + Then an ExecutionError should be raised at runtime. When executing query: """ DROP TAG INDEX multi_tag_index @@ -405,6 +411,12 @@ Feature: tag and edge index tests from pytest Then the result should be, in any order: | Edge Index Name | Create Edge Index | | 'multi_edge_index' | 'CREATE EDGE INDEX `multi_edge_index` ON `edge_1` (\n `col2`,\n `col3`\n)' | + # Check if check tag/edge type before drop index + When executing query: + """ + DROP TAG INDEX multi_edge_index + """ + Then an ExecutionError should be raised at runtime. # Check if show create edge index works well When executing query: """