Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Sep 8, 2021
1 parent 829416d commit d2ceddf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions conf/nebula-graphd.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
# Whether to treat partial success as an error.
# This flag is only used for Read-only access, and Modify access always treats partial success as an error.
--accept_partial_success=false
# Maximum sentence length, unit byte
--max_allowed_query_size=4194304

########## networking ##########
# Comma separated Meta Server Addresses
Expand Down
2 changes: 2 additions & 0 deletions conf/nebula-graphd.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
# Whether to treat partial success as an error.
# This flag is only used for Read-only access, and Modify access always treats partial success as an error.
--accept_partial_success=false
# Maximum sentence length, unit byte
--max_allowed_query_size=4194304

########## networking ##########
# Comma separated Meta Server Addresses
Expand Down
6 changes: 0 additions & 6 deletions src/graph/validator/SequentialValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "graph/service/PermissionCheck.h"

DECLARE_uint32(max_allowed_statements);
DECLARE_uint32(max_allowed_query_size);

namespace nebula {
namespace graph {
Expand All @@ -25,11 +24,6 @@ Status SequentialValidator::validateImpl() {
"given.",
static_cast<int64_t>(sentence_->kind()));
}
size_t querySize = sentence_->toString().size();
size_t maxAllowedQuerySize = static_cast<size_t>(FLAGS_max_allowed_query_size);
if (querySize > maxAllowedQuerySize) {
return Status::SemanticError("Query is too large (%ld > %ld).", querySize, maxAllowedQuerySize);
}
auto seqSentence = static_cast<SequentialSentences*>(sentence_);
auto sentences = seqSentence->sentences();

Expand Down
2 changes: 1 addition & 1 deletion src/graph/validator/test/QueryValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ TEST_F(QueryValidatorTest, TestMaxAllowedQuerySize) {
query.append(",\"person_2\":(\"person_2\", 2);");
auto result = checkResult(query);
EXPECT_FALSE(result);
EXPECT_EQ(std::string(result.message()), "SemanticError: Query is too large (271 > 256).");
EXPECT_EQ(std::string(result.message()), "SyntaxError: Query is too large (282 > 256).");
FLAGS_max_allowed_query_size = 4194304;
}

Expand Down
9 changes: 7 additions & 2 deletions src/parser/GQLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "parser/GraphParser.hpp"
#include "parser/GraphScanner.h"

DECLARE_uint32(max_allowed_query_size);
namespace nebula {

class GQLParser {
Expand Down Expand Up @@ -39,8 +40,12 @@ class GQLParser {
}

StatusOr<std::unique_ptr<Sentence>> parse(std::string query) {
// Since GraphScanner needs a writable buffer, we have to copy the query
// string
// Since GraphScanner needs a writable buffer, we have to copy the query string
size_t querySize = query.size();
size_t maxAllowedQuerySize = static_cast<size_t>(FLAGS_max_allowed_query_size);
if (querySize > maxAllowedQuerySize) {
return Status::SyntaxError("Query is too large (%ld > %ld).", querySize, maxAllowedQuerySize);
}
buffer_ = std::move(query);
pos_ = &buffer_[0];
end_ = pos_ + buffer_.size();
Expand Down

0 comments on commit d2ceddf

Please sign in to comment.