Skip to content

Commit

Permalink
fix storage crash
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Nov 22, 2021
1 parent c02c2ca commit f2d46e4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
36 changes: 23 additions & 13 deletions src/storage/exec/IndexScanNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,30 @@ std::string Path::encodeValue(const Value& value,
std::string& key) {
std::string val;
bool isNull = false;
if (colDef.get_type() == ::nebula::cpp2::PropertyType::GEOGRAPHY) {
CHECK_EQ(value.type(), Value::Type::STRING);
val = value.getStr();
} else if (value.type() == Value::Type::STRING) {
val = IndexKeyUtils::encodeValue(value, *colDef.get_type_length());
if (val.back() != '\0') {
strategySet_.insert(QualifiedStrategy::constant<QualifiedStrategy::UNCERTAIN>());
switch (colDef.get_type()) {
case ::nebula::cpp2::PropertyType::STRING:
case ::nebula::cpp2::PropertyType::FIXED_STRING: {
if (value.type() == Value::Type::NULLVALUE) {
val = IndexKeyUtils::encodeNullValue(Value::Type::STRING, colDef.get_type_length());
isNull = true;
} else {
val = IndexKeyUtils::encodeValue(value, *colDef.get_type_length());
if (val.back() != '\0') {
strategySet_.insert(QualifiedStrategy::constant<QualifiedStrategy::UNCERTAIN>());
}
}
break;
}
default: {
if (value.type() == Value::Type::NULLVALUE) {
auto vType = IndexKeyUtils::toValueType(colDef.get_type());
val = IndexKeyUtils::encodeNullValue(vType, colDef.get_type_length());
isNull = true;
} else {
val = IndexKeyUtils::encodeValue(value);
}
break;
}
} else if (value.type() == Value::Type::NULLVALUE) {
auto vtype = IndexKeyUtils::toValueType(colDef.get_type());
val = IndexKeyUtils::encodeNullValue(vtype, colDef.get_type_length());
isNull = true;
} else {
val = IndexKeyUtils::encodeValue(value);
}
// If the current colDef can be null, then it is necessary to additionally determine whether the
// corresponding value under a nullable is null when parsing the key (the encoding of the maximum
Expand Down
1 change: 0 additions & 1 deletion tests/tck/features/match/Base.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2020 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
@jmq
Feature: Basic match

Background:
Expand Down

0 comments on commit f2d46e4

Please sign in to comment.