Fix bug in SymbolTable

Summary:
This is a bugfix for D1836. It made `SymbolTable` return references to vector
elements, which then get invalidated and weird stuff happens.

This made a `DCHECK` in `rule_based_planner.hpp` trigger, and it was noticed by
@ipaljak 2 months later. All `DCHECK`s in `rule_based_planner.hpp` are now
changed to `CHECK`s.

Also, hash function for `Symbol` was wrong, because it also took
`user_declared` field into consideration, and `==` operator doesn't do that.

Reviewers: ipaljak, teon.banek, mferencevic, msantl

Reviewed By: msantl

Subscribers: pullbot, ipaljak

Differential Revision: https://phabricator.memgraph.io/D1938
This commit is contained in:
Marin Tomic
2019-04-02 16:13:41 +02:00
parent 3436094df6
commit dc231fe4e7
8 changed files with 55 additions and 45 deletions

View File

@@ -985,10 +985,10 @@ TEST_F(TestSymbolGenerator, MatchVariableLambdaSymbols) {
EXPECT_EQ(symbol_table.max_position(), 7);
// All symbols except `AS res` are anonymously generated.
for (const auto &symbol : symbol_table.table()) {
if (symbol.name() == "res") {
EXPECT_TRUE(symbol.user_declared());
if (symbol.second.name() == "res") {
EXPECT_TRUE(symbol.second.user_declared());
} else {
EXPECT_FALSE(symbol.user_declared());
EXPECT_FALSE(symbol.second.user_declared());
}
}
}