Skip to content

Commit

Permalink
Merge branch 'master' into disable-yield-var
Browse files Browse the repository at this point in the history
  • Loading branch information
czpmango committed Nov 23, 2021
2 parents 2ce72ad + 29f52ae commit f2055f9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
19 changes: 7 additions & 12 deletions src/meta/processors/BaseProcessor-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,22 +548,17 @@ nebula::cpp2::ErrorCode BaseProcessor<RESP>::ftIndexCheck(
template <typename RESP>
bool BaseProcessor<RESP>::checkIndexExist(const std::vector<cpp2::IndexFieldDef>& fields,
const cpp2::IndexItem& item) {
if (fields.size() == 0) {
LOG(ERROR) << "Index " << item.get_index_name() << " has existed";
return true;
const auto& itemFields = item.get_fields();
if (fields.size() != itemFields.size()) {
return false;
}

for (size_t i = 0; i < fields.size(); i++) {
if (fields[i].get_name() != item.get_fields()[i].get_name()) {
break;
}

if (i == fields.size() - 1) {
LOG(ERROR) << "Index " << item.get_index_name() << " has existed";
return true;
if (fields[i].get_name() != itemFields[i].get_name()) {
return false;
}
}
return false;
LOG(ERROR) << "Index " << item.get_index_name() << " has existed";
return true;
}

template <typename RESP>
Expand Down
28 changes: 0 additions & 28 deletions src/meta/test/IndexProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,6 @@ TEST(IndexProcessorTest, TagIndexTest) {
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code());
}
{
// Allow to create tag index on no fields
cpp2::CreateTagIndexReq req;
req.set_space_id(1);
req.set_tag_name("tag_0");
std::vector<cpp2::IndexFieldDef> fields{};
req.set_fields(std::move(fields));
req.set_index_name("no_field_index");
auto* processor = CreateTagIndexProcessor::instance(kv.get());
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_NE(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code());
}
{
cpp2::CreateTagIndexReq req;
req.set_space_id(1);
Expand Down Expand Up @@ -591,20 +577,6 @@ TEST(IndexProcessorTest, EdgeIndexTest) {
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code());
}
{
// Allow to create edge index on no fields
cpp2::CreateEdgeIndexReq req;
req.set_space_id(1);
req.set_edge_name("edge_0");
std::vector<cpp2::IndexFieldDef> fields{};
req.set_fields(std::move(fields));
req.set_index_name("no_field_index");
auto* processor = CreateEdgeIndexProcessor::instance(kv.get());
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_NE(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code());
}
{
cpp2::CreateEdgeIndexReq req;
req.set_space_id(1);
Expand Down
43 changes: 43 additions & 0 deletions tests/tck/features/index/Index.feature
Original file line number Diff line number Diff line change
Expand Up @@ -943,3 +943,46 @@ Feature: IndexTest_Vid_String
Then the result should be, in any order:
| Tag Index Name | Create Tag Index |
| "player_age_index" | "CREATE TAG INDEX `player_age_index` ON `player` (\n `age`\n)" |

Scenario: IndexTest existence check
Given an empty graph
And create a space with following options:
| partition_num | 9 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(30) |
| charset | utf8 |
| collate | utf8_bin |
And having executed:
"""
create tag recinfo(name string,tm bool,id int);
insert vertex recinfo(name,tm,id) values "r1":("czp",true,1);
create tag index recinfo_index on recinfo();
create tag index recinfo_name_index on recinfo(name(8));
create tag index recinfo_multi_index on recinfo(name(8),tm,id);
"""
When executing query:
"""
drop tag index recinfo_name_index
"""
Then the execution should be successful
When executing query:
"""
create tag index recinfo_name_index on recinfo(name(8));
"""
Then the execution should be successful
When executing query:
"""
create tag index recinfo_index on recinfo();
"""
Then a ExecutionError should be raised at runtime: Existed!
When executing query:
"""
drop tag index recinfo_index
"""
Then the execution should be successful
When executing query:
"""
create tag index recinfo_index on recinfo();
"""
Then the execution should be successful
Then drop the used space

0 comments on commit f2055f9

Please sign in to comment.