Skip to content

Commit

Permalink
fix invalid filter in GetProp make storage crashed (#4568)
Browse files Browse the repository at this point in the history
Co-authored-by: haowen <19355821+wenhaocs@users.noreply.github.com>
  • Loading branch information
2 people authored and Sophie-Xie committed Sep 7, 2022
1 parent e7663e6 commit 53dc8cc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/storage/exec/QueryUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class QueryUtils final {

if (nullType == NullType::UNKNOWN_PROP) {
VLOG(1) << "Fail to read prop " << propName;
if (!field) {
return value;
}
if (field->hasDefault()) {
DefaultValueContext expCtx;
ObjectPool pool;
Expand Down
51 changes: 51 additions & 0 deletions src/storage/test/GetPropTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,57 @@ TEST(GetPropTest, FilterTest) {
// }
ASSERT_EQ(expected, *resp.props_ref());
}
// invalid vertex filter
{
LOG(INFO) << "GetVertexPropInValue";
std::vector<VertexID> vertices = {"Tim Duncan"};
std::vector<std::pair<TagID, std::vector<std::string>>> tags;
tags.emplace_back(player, std::vector<std::string>{"name", "age", "avgScore"});
Expression* filter = RelationalExpression::makeEQ(
&pool,
TagPropertyExpression::make(&pool, std::to_string(player), "invalid_property"),
ConstantExpression::make(&pool, 42));
auto req = buildVertexRequest(totalParts, vertices, tags, filter);

auto* processor = GetPropProcessor::instance(env, nullptr, nullptr);
auto fut = processor->getFuture();
processor->process(req);
auto resp = std::move(fut).get();

ASSERT_EQ(0, (*resp.result_ref()).failed_parts.size());
nebula::DataSet expected;
expected.colNames = {kVid, "1.name", "1.age", "1.avgScore"};
ASSERT_EQ(expected, *resp.props_ref());
}
// invalid edge filter
{
std::vector<cpp2::EdgeKey> edgeKeys;
{
cpp2::EdgeKey edgeKey;
edgeKey.src_ref() = "Tim Duncan";
edgeKey.edge_type_ref() = 101;
edgeKey.ranking_ref() = 1997;
edgeKey.dst_ref() = "Spurs";
edgeKeys.emplace_back(std::move(edgeKey));
}
std::vector<std::pair<TagID, std::vector<std::string>>> edges;
edges.emplace_back(serve, std::vector<std::string>{"teamName", "startYear", "endYear"});
Expression* filter = RelationalExpression::makeEQ(
&pool,
EdgePropertyExpression::make(&pool, std::to_string(serve), "invalid_property"),
ConstantExpression::make(&pool, 42));
auto req = buildEdgeRequest(totalParts, edgeKeys, edges, filter);

auto* processor = GetPropProcessor::instance(env, nullptr, nullptr);
auto fut = processor->getFuture();
processor->process(req);
auto resp = std::move(fut).get();

ASSERT_EQ(0, (*resp.result_ref()).failed_parts.size());
nebula::DataSet expected;
expected.colNames = {"101.teamName", "101.startYear", "101.endYear"};
ASSERT_EQ(expected, *resp.props_ref());
}
}

TEST(GetPropTest, LimitTest) {
Expand Down

0 comments on commit 53dc8cc

Please sign in to comment.