-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix if-not-exists behavior of create index statements #4705
Changes from all commits
628b5a9
4ec0231
8a60842
8979834
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ void CreateEdgeIndexProcessor::process(const cpp2::CreateEdgeIndexReq& req) { | |
const auto& indexName = req.get_index_name(); | ||
auto& edgeName = req.get_edge_name(); | ||
const auto& fields = req.get_fields(); | ||
auto ifNotExists = req.get_if_not_exists(); | ||
|
||
std::set<std::string> columnSet; | ||
for (const auto& field : fields) { | ||
|
@@ -41,7 +42,7 @@ void CreateEdgeIndexProcessor::process(const cpp2::CreateEdgeIndexReq& req) { | |
// check if the space already exist index has the same index name | ||
auto ret = getIndexID(space, indexName); | ||
if (nebula::ok(ret)) { | ||
if (req.get_if_not_exists()) { | ||
if (ifNotExists) { | ||
handleErrorCode(nebula::cpp2::ErrorCode::SUCCEEDED); | ||
} else { | ||
LOG(INFO) << "Create Edge Index Failed: " << indexName << " has existed"; | ||
|
@@ -96,7 +97,15 @@ void CreateEdgeIndexProcessor::process(const cpp2::CreateEdgeIndexReq& req) { | |
} | ||
|
||
if (checkIndexExist(fields, item)) { | ||
resp_.code_ref() = nebula::cpp2::ErrorCode::E_EXISTED; | ||
if (ifNotExists) { | ||
resp_.code_ref() = nebula::cpp2::ErrorCode::SUCCEEDED; | ||
cpp2::ID thriftID; | ||
// Fill index id to avoid broken promise | ||
thriftID.index_id_ref() = item.get_index_id(); | ||
resp_.id_ref() = thriftID; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels a little weird this way
2 This place is to judge whether there are other indexes that contain this fields
When execute There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shows that the index creation is successful, but when show, the index name does not exist There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, this is the point just as you said.
In this way, the implementation layer does not need to verify the index name(line 45). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should try to avoid similar problems in GQL version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5.0 index design needs to consider this problem, thx @MuYiYong |
||
} else { | ||
resp_.code_ref() = nebula::cpp2::ErrorCode::E_EXISTED; | ||
} | ||
onFinished(); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use tools like
resp_.id_ref() = to(edgeIndex, EntryType::INDEX);
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just extract the id from the index item.