Skip to content

Commit

Permalink
fix LabelIndexSeek crash (#5890)
Browse files Browse the repository at this point in the history
  • Loading branch information
Salieri-004 authored May 28, 2024
1 parent 4297195 commit fee249b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/graph/planner/match/LabelIndexSeek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,18 @@ StatusOr<SubPlan> LabelIndexSeek::transformNode(NodeContext* nodeCtx) {
auto* filter = ExpressionUtils::rewriteInnerInExpr(nodeCtx->bindWhereClause->filter);
const auto& nodeAlias = nodeCtx->info->alias;
const auto& schemaName = nodeCtx->scanInfo.schemaNames.back();

if (filter->kind() == Expression::Kind::kLogicalOr) {
auto exprs = ExpressionUtils::collectAll(filter, {Expression::Kind::kLabelTagProperty});
auto exprs = ExpressionUtils::collectAll(
filter, {Expression::Kind::kLabelTagProperty, Expression::Kind::kLabelAttribute});
bool matched = exprs.empty() ? false : true;
for (auto* expr : exprs) {
if (expr->kind() == Expression::Kind::kLabelAttribute) {
// The LabelAttributeExpression should not be encoded. For attributes on vertices, they
// should be rewritten as LabelTagPropertyExpression, and for attributes on edges, they
// should not be embedded into this planNode.
matched = false;
break;
}
auto tagPropExpr = static_cast<const LabelTagPropertyExpression*>(expr);
if (static_cast<const PropertyExpression*>(tagPropExpr->label())->prop() != nodeAlias ||
tagPropExpr->sym() != schemaName) {
Expand Down
29 changes: 29 additions & 0 deletions tests/tck/features/bugfix/LabelIndexCrash.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2024 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: label index bug fix

Background:
Given a graph with space named "nba"

@testmark
Scenario: attribute expression encode crash
When try to execute query:
"""
MATCH (x:bachelor)
WHERE x.bachelor.name == "Tim Duncan"
or x.name == "Tim Duncan"
RETURN x.bachelor.name;
"""
Then the result should be, in any order:
| x.bachelor.name |
| "Tim Duncan" |
When try to execute query:
"""
MATCH (v:bachelor)-[e:serve]-(v2)
WHERE v.bachelor.name == "Tim Duncan" or e.start_year > 2000
RETURN v.bachelor.name,e.start_year
"""
Then the result should be, in any order:
| v.bachelor.name | e.start_year |
| "Tim Duncan" | 1997 |

0 comments on commit fee249b

Please sign in to comment.