Compare commits
2 Commits
interleave
...
fix-explai
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bf635c119 | ||
|
|
c4c763d281 |
@@ -1,22 +0,0 @@
|
||||
# Path to sources
|
||||
sonar.sources = .
|
||||
# sonar.exclusions=
|
||||
sonar.inclusions=src,include,query_modules
|
||||
|
||||
# Path to tests
|
||||
sonar.tests = tests/
|
||||
# sonar.test.exclusions=
|
||||
# sonar.test.inclusions=
|
||||
|
||||
# Source encoding
|
||||
# sonar.sourceEncoding=
|
||||
|
||||
# Exclusions for copy-paste detection
|
||||
# sonar.cpd.exclusions=
|
||||
|
||||
# Python version (for python projects only)
|
||||
# sonar.python.version=
|
||||
|
||||
# C++ standard version (for C++ projects only)
|
||||
# If not specified, it defaults to the latest supported standard
|
||||
# sonar.cfamily.reportingCppStandardOverride=c++98|c++11|c++14|c++17|c++20
|
||||
@@ -132,7 +132,7 @@ State HandlePullDiscardV4(TSession &session, const State state, const Marker mar
|
||||
return State::Close;
|
||||
}
|
||||
|
||||
if (state != State::Result && state != State::Idle) {
|
||||
if (state != State::Result) {
|
||||
if constexpr (is_pull) {
|
||||
spdlog::trace("Unexpected PULL!");
|
||||
} else {
|
||||
@@ -264,7 +264,7 @@ State HandleRunV4(TSession &session, const State state, const Marker marker) {
|
||||
return State::Close;
|
||||
}
|
||||
|
||||
if (state != State::Idle && state != State::Result) {
|
||||
if (state != State::Idle) {
|
||||
// Client could potentially recover if we move to error state, but there is
|
||||
// no legitimate situation in which well working client would end up in this
|
||||
// situation.
|
||||
|
||||
@@ -127,8 +127,6 @@ storage::Result<Value> ToBoltValue(const query::TypedValue &value, const storage
|
||||
return Value(value.ValueLocalDateTime());
|
||||
case query::TypedValue::Type::Duration:
|
||||
return Value(value.ValueDuration());
|
||||
case query::TypedValue::Type::Function:
|
||||
throw communication::bolt::ValueException("Unsupported conversion from TypedValue::Function to Value");
|
||||
case query::TypedValue::Type::Graph:
|
||||
auto maybe_graph = ToBoltGraph(value.ValueGraph(), db, view);
|
||||
if (maybe_graph.HasError()) return maybe_graph.GetError();
|
||||
|
||||
@@ -65,13 +65,10 @@ void InitFromCypherlFile(memgraph::query::InterpreterContext &ctx, memgraph::dbm
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
if (!line.empty()) {
|
||||
try {
|
||||
auto results = interpreter.Prepare(line, {}, {});
|
||||
memgraph::query::DiscardValueResultStream stream;
|
||||
interpreter.Pull(&stream, {}, results.qid);
|
||||
} catch (const memgraph::query::UserAlreadyExistsException &e) {
|
||||
spdlog::warn("{} The rest of the init-file will be run.", e.what());
|
||||
}
|
||||
auto results = interpreter.Prepare(line, {}, {});
|
||||
memgraph::query::DiscardValueResultStream stream;
|
||||
interpreter.Pull(&stream, {}, results.qid);
|
||||
|
||||
if (audit_log) {
|
||||
audit_log->Record("", "", line, {}, memgraph::dbms::kDefaultDB);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -62,7 +62,6 @@ bool TypedValueCompare(const TypedValue &a, const TypedValue &b) {
|
||||
case TypedValue::Type::Edge:
|
||||
case TypedValue::Type::Path:
|
||||
case TypedValue::Type::Graph:
|
||||
case TypedValue::Type::Function:
|
||||
throw QueryRuntimeException("Comparison is not defined for values of type {}.", a.type());
|
||||
case TypedValue::Type::Null:
|
||||
LOG_FATAL("Invalid type");
|
||||
|
||||
@@ -126,12 +126,6 @@ class InfoInMulticommandTxException : public QueryException {
|
||||
SPECIALIZE_GET_EXCEPTION_NAME(InfoInMulticommandTxException)
|
||||
};
|
||||
|
||||
class UserAlreadyExistsException : public QueryException {
|
||||
public:
|
||||
using QueryException::QueryException;
|
||||
SPECIALIZE_GET_EXCEPTION_NAME(UserAlreadyExistsException)
|
||||
};
|
||||
|
||||
/**
|
||||
* An exception for an illegal operation that can not be detected
|
||||
* before the query starts executing over data.
|
||||
|
||||
@@ -8,42 +8,41 @@
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include "query/typed_value.hpp"
|
||||
#include "utils/fnv.hpp"
|
||||
#include "utils/memory.hpp"
|
||||
#include "utils/pmr/unordered_map.hpp"
|
||||
#include "utils/pmr/vector.hpp"
|
||||
namespace memgraph::query {
|
||||
|
||||
// Key is hash output, value is vector of unique elements
|
||||
using CachedType = utils::pmr::unordered_map<size_t, utils::pmr::vector<TypedValue>>;
|
||||
using CachedType = utils::pmr::unordered_map<size_t, std::vector<TypedValue>>;
|
||||
|
||||
struct CachedValue {
|
||||
using allocator_type = utils::Allocator<CachedValue>;
|
||||
|
||||
// Cached value, this can be probably templateized
|
||||
CachedType cache_;
|
||||
|
||||
explicit CachedValue(utils::MemoryResource *mem) : cache_{mem} {};
|
||||
CachedValue(const CachedValue &other, utils::MemoryResource *mem) : cache_(other.cache_, mem) {}
|
||||
CachedValue(CachedValue &&other, utils::MemoryResource *mem) : cache_(std::move(other.cache_), mem){};
|
||||
explicit CachedValue(utils::MemoryResource *mem) : cache_(mem) {}
|
||||
|
||||
CachedValue(CachedValue &&other) noexcept : CachedValue(std::move(other), other.GetMemoryResource()) {}
|
||||
CachedValue(CachedType &&cache, memgraph::utils::MemoryResource *memory) : cache_(std::move(cache), memory) {}
|
||||
|
||||
CachedValue(const CachedValue &other)
|
||||
: CachedValue(other, std::allocator_traits<allocator_type>::select_on_container_copy_construction(
|
||||
other.GetMemoryResource())
|
||||
.GetMemoryResource()) {}
|
||||
CachedValue(const CachedValue &other, memgraph::utils::MemoryResource *memory) : cache_(other.cache_, memory) {}
|
||||
|
||||
utils::MemoryResource *GetMemoryResource() const { return cache_.get_allocator().GetMemoryResource(); }
|
||||
CachedValue(CachedValue &&other, memgraph::utils::MemoryResource *memory) : cache_(std::move(other.cache_), memory) {}
|
||||
|
||||
CachedValue(CachedValue &&other) noexcept = delete;
|
||||
|
||||
/// Copy construction without memgraph::utils::MemoryResource is not allowed.
|
||||
CachedValue(const CachedValue &) = delete;
|
||||
|
||||
CachedValue &operator=(const CachedValue &) = delete;
|
||||
CachedValue &operator=(CachedValue &&) = delete;
|
||||
|
||||
~CachedValue() = default;
|
||||
|
||||
memgraph::utils::MemoryResource *GetMemoryResource() const noexcept {
|
||||
return cache_.get_allocator().GetMemoryResource();
|
||||
}
|
||||
|
||||
bool CacheValue(const TypedValue &maybe_list) {
|
||||
if (!maybe_list.IsList()) {
|
||||
return false;
|
||||
@@ -71,7 +70,7 @@ struct CachedValue {
|
||||
}
|
||||
|
||||
private:
|
||||
static bool IsValueInVec(const utils::pmr::vector<TypedValue> &vec_values, const TypedValue &value) {
|
||||
static bool IsValueInVec(const std::vector<TypedValue> &vec_values, const TypedValue &value) {
|
||||
return std::any_of(vec_values.begin(), vec_values.end(), [&value](auto &vec_value) {
|
||||
const auto is_value_equal = vec_value == value;
|
||||
if (is_value_equal.IsNull()) return false;
|
||||
@@ -83,70 +82,35 @@ struct CachedValue {
|
||||
// Class tracks keys for which user can cache values which help with faster search or faster retrieval
|
||||
// in the future. Used for IN LIST operator.
|
||||
class FrameChangeCollector {
|
||||
/** Allocator type so that STL containers are aware that we need one */
|
||||
using allocator_type = utils::Allocator<FrameChangeCollector>;
|
||||
|
||||
public:
|
||||
explicit FrameChangeCollector(utils::MemoryResource *mem = utils::NewDeleteResource()) : tracked_values_{mem} {}
|
||||
|
||||
FrameChangeCollector(FrameChangeCollector &&other, utils::MemoryResource *mem)
|
||||
: tracked_values_(std::move(other.tracked_values_), mem) {}
|
||||
FrameChangeCollector(const FrameChangeCollector &other, utils::MemoryResource *mem)
|
||||
: tracked_values_(other.tracked_values_, mem) {}
|
||||
|
||||
FrameChangeCollector(const FrameChangeCollector &other)
|
||||
: FrameChangeCollector(other, std::allocator_traits<allocator_type>::select_on_container_copy_construction(
|
||||
other.GetMemoryResource())
|
||||
.GetMemoryResource()){};
|
||||
|
||||
FrameChangeCollector(FrameChangeCollector &&other) noexcept
|
||||
: FrameChangeCollector(std::move(other), other.GetMemoryResource()) {}
|
||||
|
||||
/** Copy assign other, utils::MemoryResource of `this` is used */
|
||||
FrameChangeCollector &operator=(const FrameChangeCollector &) = default;
|
||||
|
||||
/** Move assign other, utils::MemoryResource of `this` is used. */
|
||||
FrameChangeCollector &operator=(FrameChangeCollector &&) noexcept = default;
|
||||
|
||||
utils::MemoryResource *GetMemoryResource() const { return tracked_values_.get_allocator().GetMemoryResource(); }
|
||||
explicit FrameChangeCollector() : tracked_values_(&memory_resource_){};
|
||||
|
||||
CachedValue &AddTrackingKey(const std::string &key) {
|
||||
const auto &[it, _] = tracked_values_.emplace(
|
||||
std::piecewise_construct, std::forward_as_tuple(utils::pmr::string(key, utils::NewDeleteResource())),
|
||||
std::forward_as_tuple());
|
||||
const auto &[it, _] = tracked_values_.emplace(key, tracked_values_.get_allocator().GetMemoryResource());
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool IsKeyTracked(const std::string &key) const {
|
||||
return tracked_values_.contains(utils::pmr::string(key, utils::NewDeleteResource()));
|
||||
}
|
||||
bool IsKeyTracked(const std::string &key) const { return tracked_values_.contains(key); }
|
||||
|
||||
bool IsKeyValueCached(const std::string &key) const {
|
||||
return IsKeyTracked(key) && !tracked_values_.at(utils::pmr::string(key, utils::NewDeleteResource())).cache_.empty();
|
||||
return IsKeyTracked(key) && !tracked_values_.at(key).cache_.empty();
|
||||
}
|
||||
|
||||
bool ResetTrackingValue(const std::string &key) {
|
||||
if (!tracked_values_.contains(utils::pmr::string(key, utils::NewDeleteResource()))) {
|
||||
if (!tracked_values_.contains(key)) {
|
||||
return false;
|
||||
}
|
||||
tracked_values_.erase(utils::pmr::string(key, utils::NewDeleteResource()));
|
||||
tracked_values_.erase(key);
|
||||
AddTrackingKey(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
CachedValue &GetCachedValue(const std::string &key) {
|
||||
return tracked_values_.at(utils::pmr::string(key, utils::NewDeleteResource()));
|
||||
}
|
||||
CachedValue &GetCachedValue(const std::string &key) { return tracked_values_.at(key); }
|
||||
|
||||
bool IsTrackingValues() const { return !tracked_values_.empty(); }
|
||||
|
||||
~FrameChangeCollector() = default;
|
||||
|
||||
private:
|
||||
struct PmrStringHash {
|
||||
size_t operator()(const utils::pmr::string &key) const { return utils::Fnv(key); }
|
||||
};
|
||||
|
||||
utils::pmr::unordered_map<utils::pmr::string, CachedValue, PmrStringHash> tracked_values_;
|
||||
utils::MonotonicBufferResource memory_resource_{0};
|
||||
memgraph::utils::pmr::unordered_map<std::string, CachedValue> tracked_values_;
|
||||
};
|
||||
} // namespace memgraph::query
|
||||
|
||||
@@ -593,7 +593,6 @@ TypedValue ValueType(const TypedValue *args, int64_t nargs, const FunctionContex
|
||||
case TypedValue::Type::Duration:
|
||||
return TypedValue("DURATION", ctx.memory);
|
||||
case TypedValue::Type::Graph:
|
||||
case TypedValue::Type::Function:
|
||||
throw QueryRuntimeException("Cannot fetch graph as it is not standardized openCypher type name");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <regex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -904,17 +903,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
return TypedValue(std::move(result), ctx_->memory);
|
||||
}
|
||||
|
||||
TypedValue Visit(Exists &exists) override {
|
||||
TypedValue &frame_exists_value = frame_->at(symbol_table_->at(exists));
|
||||
if (!frame_exists_value.IsFunction()) [[unlikely]] {
|
||||
throw QueryRuntimeException(
|
||||
"Unexpected behavior: Exists expected a function, got {}. Please report the problem on GitHub issues",
|
||||
frame_exists_value.type());
|
||||
}
|
||||
TypedValue result{ctx_->memory};
|
||||
frame_exists_value.ValueFunction()(&result);
|
||||
return result;
|
||||
}
|
||||
TypedValue Visit(Exists &exists) override { return TypedValue{frame_->at(symbol_table_->at(exists)), ctx_->memory}; }
|
||||
|
||||
TypedValue Visit(All &all) override {
|
||||
auto list_value = all.list_expression_->Accept(*this);
|
||||
|
||||
@@ -478,7 +478,7 @@ Callback HandleAuthQuery(AuthQuery *auth_query, InterpreterContext *interpreter_
|
||||
MG_ASSERT(password.IsString() || password.IsNull());
|
||||
if (!auth->CreateUser(username, password.IsString() ? std::make_optional(std::string(password.ValueString()))
|
||||
: std::nullopt)) {
|
||||
throw UserAlreadyExistsException("User '{}' already exists.", username);
|
||||
throw QueryRuntimeException("User '{}' already exists.", username);
|
||||
}
|
||||
|
||||
// If the license is not valid we create users with admin access
|
||||
|
||||
@@ -2500,16 +2500,13 @@ std::vector<Symbol> EvaluatePatternFilter::ModifiedSymbols(const SymbolTable &ta
|
||||
}
|
||||
|
||||
bool EvaluatePatternFilter::EvaluatePatternFilterCursor::Pull(Frame &frame, ExecutionContext &context) {
|
||||
OOMExceptionEnabler oom_exception;
|
||||
SCOPED_PROFILE_OP("EvaluatePatternFilter");
|
||||
std::function<void(TypedValue *)> function = [&frame, self = this->self_, input_cursor = this->input_cursor_.get(),
|
||||
&context](TypedValue *return_value) {
|
||||
OOMExceptionEnabler oom_exception;
|
||||
input_cursor->Reset();
|
||||
|
||||
*return_value = TypedValue(input_cursor->Pull(frame, context), context.evaluation_context.memory);
|
||||
};
|
||||
input_cursor_->Reset();
|
||||
|
||||
frame[self_.output_symbol_] = TypedValue(input_cursor_->Pull(frame, context), context.evaluation_context.memory);
|
||||
|
||||
frame[self_.output_symbol_] = TypedValue(std::move(function));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <stack>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "query/plan/preprocess.hpp"
|
||||
#include "utils/algorithm.hpp"
|
||||
#include "utils/exceptions.hpp"
|
||||
#include "utils/logging.hpp"
|
||||
@@ -515,27 +514,20 @@ bool HasBoundFilterSymbols(const std::unordered_set<Symbol> &bound_symbols, cons
|
||||
[&bound_symbols](const auto &symbol) { return bound_symbols.find(symbol) != bound_symbols.end(); });
|
||||
}
|
||||
|
||||
Expression *ExtractFilters(const std::unordered_set<Symbol> &bound_symbols, Filters &filters, AstStorage &storage) {
|
||||
Expression *ExtractFilters(const std::unordered_set<Symbol> &bound_symbols, Filters &filters, AstStorage &storage,
|
||||
Filters &all_filters) {
|
||||
Expression *filter_expr = nullptr;
|
||||
std::vector<FilterInfo> and_joinable_filters{};
|
||||
for (auto filters_it = filters.begin(); filters_it != filters.end();) {
|
||||
if (HasBoundFilterSymbols(bound_symbols, *filters_it)) {
|
||||
and_joinable_filters.emplace_back(*filters_it);
|
||||
filter_expr = impl::BoolJoin<AndOperator>(storage, filter_expr, filters_it->expression);
|
||||
filters_it = filters.erase(filters_it);
|
||||
} else {
|
||||
filters_it++;
|
||||
}
|
||||
}
|
||||
// Idea here is to join filters in a way
|
||||
// that pattern filter ( exists() ) is at the end
|
||||
// so if any of the AND filters before
|
||||
// evaluate to false we don't need to
|
||||
// evaluate pattern ( exists() ) filter
|
||||
std::partition(and_joinable_filters.begin(), and_joinable_filters.end(),
|
||||
[](const FilterInfo &filter_info) { return filter_info.type != FilterInfo::Type::Pattern; });
|
||||
for (auto &and_joinable_filter : and_joinable_filters) {
|
||||
filter_expr = impl::BoolJoin<AndOperator>(storage, filter_expr, and_joinable_filter.expression);
|
||||
}
|
||||
all_filters.SetFilters(std::move(and_joinable_filters));
|
||||
return filter_expr;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace impl {
|
||||
// Iterates over `Filters` joining them in one expression via
|
||||
// `AndOperator` if symbols they use are bound.. All the joined filters are
|
||||
// removed from `Filters`.
|
||||
Expression *ExtractFilters(const std::unordered_set<Symbol> &, Filters &, AstStorage &);
|
||||
Expression *ExtractFilters(const std::unordered_set<Symbol> &, Filters &, AstStorage &, Filters &);
|
||||
|
||||
/// Checks if the filters has all the bound symbols to be included in the current part of the query
|
||||
bool HasBoundFilterSymbols(const std::unordered_set<Symbol> &bound_symbols, const FilterInfo &filter);
|
||||
@@ -725,8 +725,9 @@ class RuleBasedPlanner {
|
||||
// Join regular filters with lambda filter expression, so that they
|
||||
// are done inline together. Semantic analysis should guarantee that
|
||||
// lambda filtering uses bound symbols.
|
||||
Filters all_filters;
|
||||
filter_lambda.expression = impl::BoolJoin<AndOperator>(
|
||||
storage, impl::ExtractFilters(bound_symbols, filters, storage), edge->filter_lambda_.expression);
|
||||
storage, impl::ExtractFilters(bound_symbols, filters, storage, all_filters), edge->filter_lambda_.expression);
|
||||
// At this point it's possible we have leftover filters for inline
|
||||
// filtering (they use the inner symbols. If they were not collected,
|
||||
// we have to remove them manually because no other filter-extraction
|
||||
@@ -862,9 +863,9 @@ class RuleBasedPlanner {
|
||||
std::unique_ptr<LogicalOperator> GenFilters(std::unique_ptr<LogicalOperator> last_op,
|
||||
const std::unordered_set<Symbol> &bound_symbols, Filters &filters,
|
||||
AstStorage &storage, const SymbolTable &symbol_table) {
|
||||
auto all_filters = filters;
|
||||
Filters all_filters{};
|
||||
auto pattern_filters = ExtractPatternFilters(filters, symbol_table, storage, bound_symbols);
|
||||
auto *filter_expr = impl::ExtractFilters(bound_symbols, filters, storage);
|
||||
auto *filter_expr = impl::ExtractFilters(bound_symbols, filters, storage, all_filters);
|
||||
|
||||
if (filter_expr) {
|
||||
last_op =
|
||||
|
||||
@@ -313,8 +313,6 @@ mgp_value_type FromTypedValueType(memgraph::query::TypedValue::Type type) {
|
||||
return MGP_VALUE_TYPE_LOCAL_DATE_TIME;
|
||||
case memgraph::query::TypedValue::Type::Duration:
|
||||
return MGP_VALUE_TYPE_DURATION;
|
||||
case memgraph::query::TypedValue::Type::Function:
|
||||
throw std::logic_error{"mgp_value for TypedValue::Type::Function doesn't exist."};
|
||||
case memgraph::query::TypedValue::Type::Graph:
|
||||
throw std::logic_error{"mgp_value for TypedValue::Type::Graph doesn't exist."};
|
||||
}
|
||||
@@ -3674,8 +3672,7 @@ std::ostream &PrintValue(const TypedValue &value, std::ostream *stream) {
|
||||
case TypedValue::Type::Edge:
|
||||
case TypedValue::Type::Path:
|
||||
case TypedValue::Type::Graph:
|
||||
case TypedValue::Type::Function:
|
||||
LOG_FATAL("value must not be a graph|function element");
|
||||
LOG_FATAL("value must not be a graph element");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "storage/v2/temporal.hpp"
|
||||
#include "utils/exceptions.hpp"
|
||||
#include "utils/fnv.hpp"
|
||||
#include "utils/logging.hpp"
|
||||
#include "utils/memory.hpp"
|
||||
|
||||
namespace memgraph::query {
|
||||
@@ -216,9 +215,6 @@ TypedValue::TypedValue(const TypedValue &other, utils::MemoryResource *memory) :
|
||||
case Type::Duration:
|
||||
new (&duration_v) utils::Duration(other.duration_v);
|
||||
return;
|
||||
case Type::Function:
|
||||
new (&function_v) std::function<void(TypedValue *)>(other.function_v);
|
||||
return;
|
||||
case Type::Graph:
|
||||
auto *graph_ptr = utils::Allocator<Graph>(memory_).new_object<Graph>(*other.graph_v);
|
||||
new (&graph_v) std::unique_ptr<Graph>(graph_ptr);
|
||||
@@ -272,9 +268,6 @@ TypedValue::TypedValue(TypedValue &&other, utils::MemoryResource *memory) : memo
|
||||
case Type::Duration:
|
||||
new (&duration_v) utils::Duration(other.duration_v);
|
||||
break;
|
||||
case Type::Function:
|
||||
new (&function_v) std::function<void(TypedValue *)>(other.function_v);
|
||||
break;
|
||||
case Type::Graph:
|
||||
if (other.GetMemoryResource() == memory_) {
|
||||
new (&graph_v) std::unique_ptr<Graph>(std::move(other.graph_v));
|
||||
@@ -350,7 +343,6 @@ DEFINE_VALUE_AND_TYPE_GETTERS(utils::Date, Date, date_v)
|
||||
DEFINE_VALUE_AND_TYPE_GETTERS(utils::LocalTime, LocalTime, local_time_v)
|
||||
DEFINE_VALUE_AND_TYPE_GETTERS(utils::LocalDateTime, LocalDateTime, local_date_time_v)
|
||||
DEFINE_VALUE_AND_TYPE_GETTERS(utils::Duration, Duration, duration_v)
|
||||
DEFINE_VALUE_AND_TYPE_GETTERS(std::function<void(TypedValue *)>, Function, function_v)
|
||||
|
||||
Graph &TypedValue::ValueGraph() {
|
||||
if (type_ != Type::Graph) {
|
||||
@@ -425,8 +417,6 @@ std::ostream &operator<<(std::ostream &os, const TypedValue::Type &type) {
|
||||
return os << "duration";
|
||||
case TypedValue::Type::Graph:
|
||||
return os << "graph";
|
||||
case TypedValue::Type::Function:
|
||||
return os << "function";
|
||||
}
|
||||
LOG_FATAL("Unsupported TypedValue::Type");
|
||||
}
|
||||
@@ -579,9 +569,6 @@ TypedValue &TypedValue::operator=(const TypedValue &other) {
|
||||
case Type::Duration:
|
||||
new (&duration_v) utils::Duration(other.duration_v);
|
||||
return *this;
|
||||
case Type::Function:
|
||||
new (&function_v) std::function<void(TypedValue *)>(other.function_v);
|
||||
return *this;
|
||||
}
|
||||
LOG_FATAL("Unsupported TypedValue::Type");
|
||||
}
|
||||
@@ -641,9 +628,6 @@ TypedValue &TypedValue::operator=(TypedValue &&other) noexcept(false) {
|
||||
case Type::Duration:
|
||||
new (&duration_v) utils::Duration(other.duration_v);
|
||||
break;
|
||||
case Type::Function:
|
||||
new (&function_v) std::function<void(TypedValue *)>{other.function_v};
|
||||
break;
|
||||
case Type::Graph:
|
||||
if (other.GetMemoryResource() == memory_) {
|
||||
new (&graph_v) std::unique_ptr<Graph>(std::move(other.graph_v));
|
||||
@@ -692,9 +676,6 @@ void TypedValue::DestroyValue() {
|
||||
case Type::LocalDateTime:
|
||||
case Type::Duration:
|
||||
break;
|
||||
case Type::Function:
|
||||
std::destroy_at(&function_v);
|
||||
break;
|
||||
case Type::Graph: {
|
||||
auto *graph = graph_v.release();
|
||||
std::destroy_at(&graph_v);
|
||||
@@ -1172,8 +1153,6 @@ size_t TypedValue::Hash::operator()(const TypedValue &value) const {
|
||||
case TypedValue::Type::Duration:
|
||||
return utils::DurationHash{}(value.ValueDuration());
|
||||
break;
|
||||
case TypedValue::Type::Function:
|
||||
throw TypedValueException("Unsupported hash function for Function");
|
||||
case TypedValue::Type::Graph:
|
||||
throw TypedValueException("Unsupported hash function for Graph");
|
||||
}
|
||||
|
||||
@@ -84,8 +84,7 @@ class TypedValue {
|
||||
LocalTime,
|
||||
LocalDateTime,
|
||||
Duration,
|
||||
Graph,
|
||||
Function
|
||||
Graph
|
||||
};
|
||||
|
||||
// TypedValue at this exact moment of compilation is an incomplete type, and
|
||||
@@ -421,9 +420,6 @@ class TypedValue {
|
||||
new (&graph_v) std::unique_ptr<Graph>(graph_ptr);
|
||||
}
|
||||
|
||||
explicit TypedValue(std::function<void(TypedValue *)> &&other)
|
||||
: function_v(std::move(other)), type_(Type::Function) {}
|
||||
|
||||
/**
|
||||
* Construct with the value of other.
|
||||
* Default utils::NewDeleteResource() is used for allocations. After the move,
|
||||
@@ -455,7 +451,6 @@ class TypedValue {
|
||||
TypedValue &operator=(const utils::LocalTime &);
|
||||
TypedValue &operator=(const utils::LocalDateTime &);
|
||||
TypedValue &operator=(const utils::Duration &);
|
||||
TypedValue &operator=(const std::function<void(TypedValue *)> &);
|
||||
|
||||
/** Copy assign other, utils::MemoryResource of `this` is used */
|
||||
TypedValue &operator=(const TypedValue &other);
|
||||
@@ -511,7 +506,6 @@ class TypedValue {
|
||||
DECLARE_VALUE_AND_TYPE_GETTERS(utils::LocalDateTime, LocalDateTime)
|
||||
DECLARE_VALUE_AND_TYPE_GETTERS(utils::Duration, Duration)
|
||||
DECLARE_VALUE_AND_TYPE_GETTERS(Graph, Graph)
|
||||
DECLARE_VALUE_AND_TYPE_GETTERS(std::function<void(TypedValue *)>, Function)
|
||||
|
||||
#undef DECLARE_VALUE_AND_TYPE_GETTERS
|
||||
|
||||
@@ -556,7 +550,6 @@ class TypedValue {
|
||||
utils::Duration duration_v;
|
||||
// As the unique_ptr is not allocator aware, it requires special attention when copying or moving graphs
|
||||
std::unique_ptr<Graph> graph_v;
|
||||
std::function<void(TypedValue *)> function_v;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
from typing import Set
|
||||
|
||||
import neo4j
|
||||
|
||||
MEMGRAPH_URL = "bolt://localhost:7687"
|
||||
|
||||
driver = neo4j.GraphDatabase.driver(MEMGRAPH_URL, auth=("", ""))
|
||||
|
||||
|
||||
def fill_db(tx):
|
||||
tx.run("UNWIND range(1, 2000) AS i CREATE (n:Node {id: i}) RETURN n")
|
||||
|
||||
|
||||
def run_queries(tx):
|
||||
tx.run("match (n) return n;") # A query that forces the result to have has_more=true
|
||||
tx.run("match (n) return n limit 1;") # Any query you can run
|
||||
|
||||
|
||||
with driver.session() as session:
|
||||
tx = session.begin_transaction()
|
||||
fill_db(tx)
|
||||
run_queries(tx)
|
||||
tx.commit()
|
||||
@@ -26,5 +26,4 @@ python3 max_query_length.py || exit 1
|
||||
python3 transactions.py || exit 1
|
||||
python3 path.py || exit 1
|
||||
python3 server_name.py || exit 1
|
||||
python3 explicit_tx_multiple_run.py || exit 1
|
||||
# python3 parallel_edge_import.py || exit 1
|
||||
|
||||
@@ -1,14 +1,38 @@
|
||||
# telemetry test binaries
|
||||
add_subdirectory(telemetry)
|
||||
|
||||
# ssl test binaries
|
||||
add_subdirectory(ssl)
|
||||
|
||||
# transactions test binaries
|
||||
add_subdirectory(transactions)
|
||||
|
||||
# auth test binaries
|
||||
add_subdirectory(auth)
|
||||
|
||||
# lba test binaries
|
||||
add_subdirectory(fine_grained_access)
|
||||
|
||||
# audit test binaries
|
||||
add_subdirectory(audit)
|
||||
|
||||
# ldap test binaries
|
||||
add_subdirectory(ldap)
|
||||
|
||||
# mg_import_csv test binaries
|
||||
add_subdirectory(mg_import_csv)
|
||||
|
||||
# license_check test binaries
|
||||
add_subdirectory(license_info)
|
||||
|
||||
#environment variable check binaries
|
||||
add_subdirectory(env_variable_check)
|
||||
|
||||
#flag check binaries
|
||||
add_subdirectory(flag_check)
|
||||
|
||||
#storage mode binaries
|
||||
add_subdirectory(storage_mode)
|
||||
|
||||
#run time settings binaries
|
||||
add_subdirectory(run_time_settings)
|
||||
add_subdirectory(init_file)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
set(target_name memgraph__integration__init_file)
|
||||
set(tester_target_name ${target_name}__tester)
|
||||
|
||||
add_executable(${tester_target_name} tester.cpp)
|
||||
set_target_properties(${tester_target_name} PROPERTIES OUTPUT_NAME tester)
|
||||
target_link_libraries(${tester_target_name} mg-communication)
|
||||
@@ -1 +0,0 @@
|
||||
CREATE USER memgraph1 IDENTIFIED BY '1234';
|
||||
@@ -1,60 +0,0 @@
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
PROJECT_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, "..", "..", ".."))
|
||||
BUILD_DIR = os.path.join(PROJECT_DIR, "build")
|
||||
INIT_FILE = os.path.join(SCRIPT_DIR, "auth.cypherl")
|
||||
SIGNAL_SIGTERM = 15
|
||||
|
||||
|
||||
def wait_for_server(port, delay=0.1):
|
||||
cmd = ["nc", "-z", "-w", "1", "127.0.0.1", str(port)]
|
||||
while subprocess.call(cmd) != 0:
|
||||
time.sleep(0.01)
|
||||
time.sleep(delay)
|
||||
|
||||
|
||||
def prepare_memgraph(memgraph_args):
|
||||
memgraph = subprocess.Popen(list(map(str, memgraph_args)))
|
||||
time.sleep(0.1)
|
||||
assert memgraph.poll() is None, "Memgraph process died prematurely!"
|
||||
wait_for_server(7687)
|
||||
return memgraph
|
||||
|
||||
|
||||
def terminate_memgraph(memgraph):
|
||||
pid = memgraph.pid
|
||||
try:
|
||||
os.kill(pid, SIGNAL_SIGTERM)
|
||||
except os.OSError:
|
||||
assert False, "Memgraph process didn't exit cleanly!"
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def execute_test_restart_memgraph_with_init_file(memgraph_binary: str, tester_binary: str) -> None:
|
||||
storage_directory = tempfile.TemporaryDirectory()
|
||||
tester_args = [tester_binary, "--username", "memgraph1", "--password", "1234"]
|
||||
memgraph = prepare_memgraph([memgraph_binary, "--data-directory", storage_directory.name, "--init-file", INIT_FILE])
|
||||
subprocess.run(tester_args, stdout=subprocess.PIPE, check=True).check_returncode()
|
||||
terminate_memgraph(memgraph)
|
||||
memgraph = prepare_memgraph([memgraph_binary, "--data-directory", storage_directory.name, "--init-file", INIT_FILE])
|
||||
subprocess.run(tester_args, stdout=subprocess.PIPE, check=True).check_returncode()
|
||||
terminate_memgraph(memgraph)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
memgraph_binary = os.path.join(PROJECT_DIR, "build", "memgraph")
|
||||
tester_binary = os.path.join(BUILD_DIR, "tests", "integration", "init_file", "tester")
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--memgraph", default=memgraph_binary)
|
||||
parser.add_argument("--tester", default=tester_binary)
|
||||
args = parser.parse_args()
|
||||
|
||||
execute_test_restart_memgraph_with_init_file(args.memgraph, args.tester)
|
||||
sys.exit(0)
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include "communication/bolt/client.hpp"
|
||||
#include "io/network/endpoint.hpp"
|
||||
#include "io/network/utils.hpp"
|
||||
#include "utils/logging.hpp"
|
||||
|
||||
DEFINE_string(address, "127.0.0.1", "Server address");
|
||||
DEFINE_int32(port, 7687, "Server port");
|
||||
DEFINE_string(username, "", "Username for the database");
|
||||
DEFINE_string(password, "", "Password for the database");
|
||||
DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server.");
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-exception-escape)
|
||||
int main(int argc, char **argv) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
memgraph::logging::RedirectToStderr();
|
||||
|
||||
memgraph::communication::SSLInit sslInit;
|
||||
|
||||
memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port);
|
||||
|
||||
memgraph::communication::ClientContext context(FLAGS_use_ssl);
|
||||
memgraph::communication::bolt::Client client(context);
|
||||
|
||||
client.Connect(endpoint, FLAGS_username, FLAGS_password);
|
||||
auto ret = client.Execute("SHOW USERS", {});
|
||||
auto size = ret.records.size();
|
||||
MG_ASSERT(size == 1, "Too much users returned for SHOW USERA (got {}, expected 1)!", size);
|
||||
auto row0_size = ret.records[0].size();
|
||||
MG_ASSERT(row0_size == 1, "Too much entries in query dump row (got {}, expected 1)!", row0_size);
|
||||
auto user = ret.records[0][0].ValueString();
|
||||
MG_ASSERT(user == "memgraph1", "Unexpected user returned for SHOW USERS (got {}, expected memgraph)!", user);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -177,8 +177,6 @@ inline constexpr uint8_t pullall_req[] = {0xb1, 0x3f, 0xa0};
|
||||
inline constexpr uint8_t pull_one_req[] = {0xb1, 0x3f, 0xa1, 0x81, 0x6e, 0x01};
|
||||
inline constexpr uint8_t reset_req[] = {0xb0, 0x0f};
|
||||
inline constexpr uint8_t goodbye[] = {0xb0, 0x02};
|
||||
inline constexpr uint8_t begin[] = {0xb1, 0x11, 0xa0};
|
||||
inline constexpr uint8_t commit[] = {0xb0, 0x12};
|
||||
inline constexpr uint8_t rollback[] = {0xb0, 0x13};
|
||||
} // namespace v4
|
||||
|
||||
@@ -210,6 +208,7 @@ constexpr std::string_view extra_w_127ms_timeout =
|
||||
"\x8a\x74\x78\x5F\x74\x69\x6D\x65\x6F\x75\x74" // String size 10 "tx_timeout"
|
||||
"\x7f"; // Integer 127 (representing 127ms)
|
||||
|
||||
inline constexpr uint8_t commit[] = {0xb0, 0x12};
|
||||
} // namespace v4_3
|
||||
|
||||
// Write bolt chunk header (length)
|
||||
@@ -281,21 +280,6 @@ void ExecuteInit(TestInputStream &input_stream, TestSession &session, std::vecto
|
||||
CheckOutput(output, response, 28);
|
||||
}
|
||||
|
||||
void ExecuteBeginTransaction(TestInputStream &input_stream, TestSession &session, std::vector<uint8_t> &output) {
|
||||
const auto *request = v4::begin;
|
||||
const auto request_size = sizeof(v4::begin);
|
||||
ExecuteCommand(input_stream, session, request, request_size);
|
||||
}
|
||||
|
||||
void ExecuteCommitTransaction(TestInputStream &input_stream, TestSession &session, std::vector<uint8_t> &output) {
|
||||
const auto *request = v4::commit;
|
||||
const auto request_size = sizeof(v4::commit);
|
||||
ExecuteCommand(input_stream, session, request, request_size);
|
||||
ASSERT_EQ(session.state_, State::Idle);
|
||||
PrintOutput(output);
|
||||
CheckSuccessMessage(output);
|
||||
}
|
||||
|
||||
// Write bolt encoded run request
|
||||
void WriteRunRequest(TestInputStream &input_stream, const char *str, const bool is_v4 = false,
|
||||
std::string_view extra = "\xA0") {
|
||||
@@ -1244,81 +1228,3 @@ TEST(BoltSession, PartialStream) {
|
||||
EXPECT_NE(find_msg, cend(output));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BoltSession, ExplicitTxBeginAndCommit) {
|
||||
{
|
||||
INIT_VARS;
|
||||
|
||||
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||
ExecuteInit(input_stream, session, output, true);
|
||||
ExecuteBeginTransaction(input_stream, session, output);
|
||||
ExecuteCommitTransaction(input_stream, session, output);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BoltSession, ExplicitTxBeginRunPullCommit) {
|
||||
{
|
||||
INIT_VARS;
|
||||
|
||||
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||
ExecuteInit(input_stream, session, output, true);
|
||||
ExecuteBeginTransaction(input_stream, session, output);
|
||||
WriteRunRequest(input_stream, kQueryReturn42, true, v4_3::extra_w_metadata);
|
||||
session.Execute();
|
||||
ASSERT_EQ(session.state_, State::Result);
|
||||
ExecuteCommand(input_stream, session, v4::pull_one_req, sizeof(v4::pull_one_req));
|
||||
ASSERT_EQ(session.state_, State::Idle);
|
||||
ExecuteCommitTransaction(input_stream, session, output);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BoltSession, ExplicitTxBeginRunPullAllCommit) {
|
||||
{
|
||||
INIT_VARS;
|
||||
|
||||
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||
ExecuteInit(input_stream, session, output, true);
|
||||
ExecuteBeginTransaction(input_stream, session, output);
|
||||
|
||||
WriteRunRequest(input_stream, kQueryReturn42, true, v4_3::extra_w_metadata);
|
||||
session.Execute();
|
||||
ASSERT_EQ(session.state_, State::Result);
|
||||
ExecuteCommand(input_stream, session, v4::pull_one_req, sizeof(v4::pull_one_req));
|
||||
ASSERT_EQ(session.state_, State::Idle);
|
||||
|
||||
WriteRunRequest(input_stream, kQueryReturnMultiple, true, v4_3::extra_w_metadata);
|
||||
session.Execute();
|
||||
ASSERT_EQ(session.state_, State::Result);
|
||||
ExecuteCommand(input_stream, session, v4::pullall_req, sizeof(v4::pullall_req));
|
||||
ASSERT_EQ(session.state_, State::Idle);
|
||||
constexpr std::array<uint8_t, 10> md_has_more_true{0x88, 0x68, 0x61, 0x73, 0x5F, 0x6D, 0x6F, 0x72, 0x65, 0xC3};
|
||||
auto find_has_more = std::search(cbegin(output), cend(output), cbegin(md_has_more_true), cend(md_has_more_true));
|
||||
EXPECT_EQ(find_has_more, cend(output));
|
||||
|
||||
ExecuteCommitTransaction(input_stream, session, output);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BoltSession, ExplicitTxBeginRunRunPullAllCommit) {
|
||||
{
|
||||
INIT_VARS;
|
||||
|
||||
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||
ExecuteInit(input_stream, session, output, true);
|
||||
ExecuteBeginTransaction(input_stream, session, output);
|
||||
|
||||
WriteRunRequest(input_stream, kQueryReturn42, true, v4_3::extra_w_metadata);
|
||||
session.Execute();
|
||||
ASSERT_EQ(session.state_, State::Result);
|
||||
WriteRunRequest(input_stream, kQueryReturnMultiple, true, v4_3::extra_w_metadata);
|
||||
session.Execute();
|
||||
ASSERT_EQ(session.state_, State::Result);
|
||||
ExecuteCommand(input_stream, session, v4::pull_one_req, sizeof(v4::pullall_req));
|
||||
ASSERT_EQ(session.state_, State::Idle);
|
||||
constexpr std::array<uint8_t, 10> md_has_more_true{0x88, 0x68, 0x61, 0x73, 0x5F, 0x6D, 0x6F, 0x72, 0x65, 0xC3};
|
||||
auto find_has_more = std::search(cbegin(output), cend(output), cbegin(md_has_more_true), cend(md_has_more_true));
|
||||
EXPECT_EQ(find_has_more, cend(output));
|
||||
|
||||
ExecuteCommitTransaction(input_stream, session, output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,8 +138,6 @@ inline std::string ToString(const memgraph::query::TypedValue &value, const TAcc
|
||||
break;
|
||||
case memgraph::query::TypedValue::Type::Graph:
|
||||
throw std::logic_error{"Not implemented"};
|
||||
case memgraph::query::TypedValue::Type::Function:
|
||||
throw std::logic_error{"Not implemented"};
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -84,14 +83,6 @@ class ExpressionEvaluatorTest : public ::testing::Test {
|
||||
return id;
|
||||
}
|
||||
|
||||
Exists *CreateExistsWithValue(std::string name, TypedValue &&value) {
|
||||
auto id = storage.template Create<Exists>();
|
||||
auto symbol = symbol_table.CreateSymbol(name, true);
|
||||
id->MapTo(symbol);
|
||||
frame[symbol] = std::move(value);
|
||||
return id;
|
||||
}
|
||||
|
||||
template <class TExpression>
|
||||
auto Eval(TExpression *expr) {
|
||||
ctx.properties = NamesToProperties(storage.properties_, &dba);
|
||||
@@ -158,33 +149,6 @@ TYPED_TEST(ExpressionEvaluatorTest, AndOperatorShortCircuit) {
|
||||
}
|
||||
}
|
||||
|
||||
TYPED_TEST(ExpressionEvaluatorTest, AndExistsOperatorShortCircuit) {
|
||||
{
|
||||
std::function<void(TypedValue *)> my_func = [](TypedValue * /*return_value*/) {
|
||||
throw QueryRuntimeException("This should not be evaluated");
|
||||
};
|
||||
TypedValue func_should_not_evaluate{std::move(my_func)};
|
||||
|
||||
auto *op = this->storage.template Create<AndOperator>(
|
||||
this->storage.template Create<PrimitiveLiteral>(false),
|
||||
this->CreateExistsWithValue("anon1", std::move(func_should_not_evaluate)));
|
||||
auto value = this->Eval(op);
|
||||
EXPECT_EQ(value.ValueBool(), false);
|
||||
}
|
||||
{
|
||||
std::function<void(TypedValue *)> my_func = [memory = this->ctx.memory](TypedValue *return_value) {
|
||||
*return_value = TypedValue(false, memory);
|
||||
};
|
||||
TypedValue should_evaluate{std::move(my_func)};
|
||||
|
||||
auto *op =
|
||||
this->storage.template Create<AndOperator>(this->storage.template Create<PrimitiveLiteral>(true),
|
||||
this->CreateExistsWithValue("anon1", std::move(should_evaluate)));
|
||||
auto value = this->Eval(op);
|
||||
EXPECT_EQ(value.ValueBool(), false);
|
||||
}
|
||||
}
|
||||
|
||||
TYPED_TEST(ExpressionEvaluatorTest, AndOperatorNull) {
|
||||
{
|
||||
// Null doesn't short circuit
|
||||
|
||||
@@ -853,26 +853,6 @@ TYPED_TEST(TestPlanner, MatchFilterPropIsNotNull) {
|
||||
}
|
||||
}
|
||||
|
||||
TYPED_TEST(TestPlanner, MatchFilterWhere) {
|
||||
// Test MATCH (n)-[r]-(m) WHERE exists((n)-[]-()) and n!=n and 7!=8 RETURN n
|
||||
auto *query = QUERY(SINGLE_QUERY(
|
||||
MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))),
|
||||
WHERE(AND(EXISTS(PATTERN(NODE("n"), EDGE("edge2", memgraph::query::EdgeAtom::Direction::BOTH, {}, false),
|
||||
NODE("node3", std::nullopt, false))),
|
||||
AND(NEQ(IDENT("n"), IDENT("n")), NEQ(LITERAL(7), LITERAL(8))))),
|
||||
RETURN("n")));
|
||||
|
||||
std::list<BaseOpChecker *> pattern_filter{new ExpectScanAll(), new ExpectExpand(), new ExpectLimit(),
|
||||
new ExpectEvaluatePatternFilter()};
|
||||
CheckPlan<TypeParam>(
|
||||
query, this->storage,
|
||||
ExpectFilter(), // 7!=8
|
||||
ExpectScanAll(),
|
||||
ExpectFilter(std::vector<std::list<BaseOpChecker *>>{pattern_filter}), // filter pulls from expand
|
||||
ExpectExpand(), ExpectProduce());
|
||||
DeleteListContent(&pattern_filter);
|
||||
}
|
||||
|
||||
TYPED_TEST(TestPlanner, MultiMatchWhere) {
|
||||
// Test MATCH (n) -[r]- (m) MATCH (l) WHERE n.prop < 42 RETURN n
|
||||
FakeDbAccessor dba;
|
||||
|
||||
@@ -14,13 +14,11 @@
|
||||
#include <climits>
|
||||
#include <utility>
|
||||
|
||||
#include "query/frontend/ast/ast.hpp"
|
||||
#include "query/frontend/semantic/symbol_generator.hpp"
|
||||
#include "query/frontend/semantic/symbol_table.hpp"
|
||||
#include "query/plan/operator.hpp"
|
||||
#include "query/plan/planner.hpp"
|
||||
#include "query/plan/preprocess.hpp"
|
||||
#include "utils/typeinfo.hpp"
|
||||
|
||||
namespace memgraph::query::plan {
|
||||
|
||||
@@ -199,29 +197,6 @@ class ExpectFilter : public OpChecker<Filter> {
|
||||
|
||||
filter.pattern_filters_[i]->Accept(check_updates);
|
||||
}
|
||||
// ordering in AND Operator must be ..., exists, exists, exists.
|
||||
auto *expr = filter.expression_;
|
||||
std::vector<Expression *> filter_expressions;
|
||||
while (auto *and_operator = utils::Downcast<AndOperator>(expr)) {
|
||||
auto *expr1 = and_operator->expression1_;
|
||||
auto *expr2 = and_operator->expression2_;
|
||||
filter_expressions.emplace_back(expr1);
|
||||
expr = expr2;
|
||||
}
|
||||
if (expr) filter_expressions.emplace_back(expr);
|
||||
|
||||
auto it = filter_expressions.begin();
|
||||
for (; it != filter_expressions.end(); it++) {
|
||||
if ((*it)->GetTypeInfo().name == query::Exists::kType.name) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (it != filter_expressions.end()) {
|
||||
ASSERT_TRUE((*it)->GetTypeInfo().name == query::Exists::kType.name)
|
||||
<< "Filter expression is '" << (*it)->GetTypeInfo().name << "' expected '" << query::Exists::kType.name
|
||||
<< "'!";
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::list<BaseOpChecker *>> pattern_filters_;
|
||||
|
||||
Reference in New Issue
Block a user