Fix MATCH not allowed on replica (#709)
This commit is contained in:
parent
d72e7fa38d
commit
1f2a15e7c8
@ -91,18 +91,25 @@ bool ReadWriteTypeChecker::PreVisit([[maybe_unused]] Foreach &op) {
|
||||
bool ReadWriteTypeChecker::Visit(Once &) { return false; } // NOLINT(hicpp-named-parameter)
|
||||
|
||||
void ReadWriteTypeChecker::UpdateType(RWType op_type) {
|
||||
// Update type only if it's not the NONE type and the current operator's type
|
||||
// is different than the one that's currently inferred.
|
||||
if (type != RWType::NONE && type != op_type) {
|
||||
type = RWType::RW;
|
||||
}
|
||||
// Stop inference because RW is the most "dominant" type, i.e. it isn't
|
||||
// affected by the type of nodes in the plan appearing after the node for
|
||||
// which the type is set to RW.
|
||||
if (type == RWType::RW) {
|
||||
return;
|
||||
}
|
||||
if (type == RWType::NONE && op_type != RWType::NONE) {
|
||||
|
||||
// if op_type is NONE, type doesn't change.
|
||||
if (op_type == RWType::NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update type only if it's not the NONE type and the current operator's type
|
||||
// is different than the one that's currently inferred.
|
||||
if (type != RWType::NONE && type != op_type) {
|
||||
type = RWType::RW;
|
||||
}
|
||||
|
||||
if (type == RWType::NONE) {
|
||||
type = op_type;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace memgraph::query::plan {
|
||||
|
||||
class ReadWriteTypeChecker : public virtual HierarchicalLogicalOperatorVisitor {
|
||||
struct ReadWriteTypeChecker : public virtual HierarchicalLogicalOperatorVisitor {
|
||||
public:
|
||||
ReadWriteTypeChecker() = default;
|
||||
|
||||
@ -89,7 +89,6 @@ class ReadWriteTypeChecker : public virtual HierarchicalLogicalOperatorVisitor {
|
||||
|
||||
bool Visit(Once &) override;
|
||||
|
||||
private:
|
||||
void UpdateType(RWType op_type);
|
||||
};
|
||||
|
||||
|
@ -253,3 +253,31 @@ TEST_F(ReadWriteTypeCheckTest, Foreach) {
|
||||
std::shared_ptr<LogicalOperator> foreach = std::make_shared<plan::Foreach>(nullptr, nullptr, nullptr, x);
|
||||
CheckPlanType(foreach.get(), RWType::RW);
|
||||
}
|
||||
|
||||
TEST_F(ReadWriteTypeCheckTest, CheckUpdateType) {
|
||||
std::array<std::array<RWType, 3>, 16> scenarios = {{
|
||||
{RWType::NONE, RWType::NONE, RWType::NONE},
|
||||
{RWType::NONE, RWType::R, RWType::R},
|
||||
{RWType::NONE, RWType::W, RWType::W},
|
||||
{RWType::NONE, RWType::RW, RWType::RW},
|
||||
{RWType::R, RWType::NONE, RWType::R},
|
||||
{RWType::R, RWType::R, RWType::R},
|
||||
{RWType::R, RWType::W, RWType::RW},
|
||||
{RWType::R, RWType::RW, RWType::RW},
|
||||
{RWType::W, RWType::NONE, RWType::W},
|
||||
{RWType::W, RWType::R, RWType::RW},
|
||||
{RWType::W, RWType::W, RWType::W},
|
||||
{RWType::W, RWType::RW, RWType::RW},
|
||||
{RWType::RW, RWType::NONE, RWType::RW},
|
||||
{RWType::RW, RWType::R, RWType::RW},
|
||||
{RWType::RW, RWType::W, RWType::RW},
|
||||
{RWType::RW, RWType::RW, RWType::RW},
|
||||
}};
|
||||
|
||||
auto rw_type_checker = ReadWriteTypeChecker();
|
||||
for (auto scenario : scenarios) {
|
||||
rw_type_checker.type = scenario[0];
|
||||
rw_type_checker.UpdateType(scenario[1]);
|
||||
EXPECT_EQ(scenario[2], rw_type_checker.type);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user