Skip to content

Commit

Permalink
Fix crash of null path expression. (#3915)
Browse files Browse the repository at this point in the history
* Fix crash of null path expression.

* Add test case.

Co-authored-by: jakevin <[email protected]>
  • Loading branch information
Shylock-Hg and jackwener authored Feb 21, 2022
1 parent 6ed92c7 commit fdcaa0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/graph/planner/match/MatchClausePlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ Status MatchClausePlanner::projectColumnsBySymbols(MatchClauseContext* matchClau
auto iter = std::find_if(aliases.begin(), aliases.end(), [](const auto& alias) {
return alias.second == AliasType::kPath;
});
if (iter != aliases.end()) {
if (iter != aliases.end() && path.pathBuild != nullptr) {
auto& alias = iter->first;
columns->addColumn(buildPathColumn(path.pathBuild, alias));
colNames.emplace_back(alias);
Expand Down
17 changes: 17 additions & 0 deletions tests/tck/features/bugfix/CrashWhenNullPathExpr.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2022 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: Test crash when null path expression

Background:
Given a graph with space named "nba"

Scenario: Null path expression in multiple patterns
When executing query:
"""
MATCH (p:player {name: 'Yao Ming'} ), (t:team {name: 'Rockets'}), pth = (p)-[:serve*1..4]-(t)
RETURN pth
"""
Then the result should be, in any order, with relax comparison:
| pth |
| <("Yao Ming":player{age:38,name:"Yao Ming"})-[:serve@0{end_year:2011,start_year:2002}]->("Rockets":team{name:"Rockets"})> |

0 comments on commit fdcaa0a

Please sign in to comment.