Skip to content
Snippets Groups Projects
Unverified Commit af772679 authored by yaphet's avatar yaphet Committed by GitHub
Browse files

Group default conflict check (#905)


Co-authored-by: default avatarYee <2520865+yixinglu@users.noreply.github.com>
parent f1ca914b
No related branches found
No related tags found
No related merge requests found
......@@ -319,6 +319,10 @@ public:
groupName_.reset(name);
}
const std::string* groupName() const {
return groupName_.get();
}
void setComment(std::string *name) {
comment_.reset(name);
}
......
......@@ -92,6 +92,7 @@ Status CreateSpaceValidator::validateImpl() {
} else {
spaceDesc_.set_isolation_level(meta::cpp2::IsolationLevel::DEFAULT);
}
break;
}
case SpaceOptItem::GROUP_NAME: {
break;
......@@ -103,6 +104,10 @@ Status CreateSpaceValidator::validateImpl() {
spaceDesc_.set_comment(*sentence->comment());
}
if (sentence->groupName() != nullptr && *sentence->groupName() == "default") {
return Status::SemanticError("Group default conflict");
}
// if charset and collate are not specified, set default value
if (!(*spaceDesc_.charset_name_ref()).empty() && !(*spaceDesc_.collate_name_ref()).empty()) {
NG_RETURN_IF_ERROR(charsetInfo->charsetAndCollateMatch(*spaceDesc_.charset_name_ref(),
......
......@@ -477,6 +477,10 @@ Status ShowEdgeIndexStatusValidator::toPlan() {
}
Status AddGroupValidator::validateImpl() {
auto sentence = static_cast<AddGroupSentence *>(sentence_);
if (*sentence->groupName() == "default") {
return Status::SemanticError("Group default conflict");
}
return Status::OK();
}
......
......@@ -21,6 +21,9 @@ class TestSpace(NebulaTestSuite):
resp = self.client.execute('CREATE SPACE space_with_default_options')
self.check_resp_succeeded(resp)
resp = self.client.execute('CREATE SPACE space_on_default_group on default')
self.check_resp_failed(resp)
# check result
resp = self.client.execute('DESC SPACE space_with_default_options')
expect_result = [['space_with_default_options', 100, 1, 'utf8', 'utf8_bin',
......@@ -53,21 +56,28 @@ class TestSpace(NebulaTestSuite):
resp = self.client.execute('SHOW CREATE SPACE default_space')
self.check_resp_succeeded(resp)
create_space_str = 'CREATE SPACE `default_space` (partition_num = 9, '\
'replica_factor = 1, '\
'charset = utf8, '\
'collate = utf8_bin, '\
'vid_type = FIXED_STRING(8), '\
'atomic_edge = false) '\
'ON default'
create_space_str_result = 'CREATE SPACE `default_space` (partition_num = 9, '\
'replica_factor = 1, '\
'charset = utf8, '\
'collate = utf8_bin, '\
'vid_type = FIXED_STRING(8), '\
'atomic_edge = false) '\
'ON default'
expect_result = [['default_space', create_space_str]]
expect_result = [['default_space', create_space_str_result]]
self.check_result(resp, expect_result)
# check result from show create
resp = self.client.execute('DROP SPACE default_space')
self.check_resp_succeeded(resp)
create_space_str = 'CREATE SPACE `default_space` (partition_num = 9, '\
'replica_factor = 1, '\
'charset = utf8, '\
'collate = utf8_bin, '\
'vid_type = FIXED_STRING(8), '\
'atomic_edge = false)'
resp = self.client.execute(create_space_str)
self.check_resp_succeeded(resp)
......@@ -126,17 +136,17 @@ class TestSpace(NebulaTestSuite):
# not supported charset
resp = self.client.execute('CREATE SPACE space_charset_collate_nomatch (partition_num=9, '
'replica_factor=1, charset = gbk, collate=utf8_bin)')
'replica_factor=1, charset = gbk, collate=utf8_bin)')
self.check_resp_failed(resp)
# not supported charset
resp = self.client.execute('CREATE SPACE space_illegal_charset (partition_num=9, '
'replica_factor=1, charset = gbk)')
'replica_factor=1, charset = gbk)')
self.check_resp_failed(resp)
# not supported collate
resp = self.client.execute('CREATE SPACE space_illegal_collate (partition_num=9, '
'replica_factor=1, collate = gbk_bin)')
'replica_factor=1, collate = gbk_bin)')
self.check_resp_failed(resp)
resp = self.client.execute('CREATE SPACE space_illegal_collate (partition_num=9, '
......
......@@ -41,6 +41,9 @@ class TestZone(NebulaTestSuite):
resp = self.client.execute('ADD GROUP group_0 zone_0')
self.check_resp_succeeded(resp)
resp = self.client.execute('ADD GROUP default zone_0')
self.check_resp_failed(resp)
# Get Group
resp = self.client.execute('DESC GROUP group_0')
self.check_resp_succeeded(resp)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment