Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit b8cc76d

Browse files
Tianyi Chenapavlo
authored andcommitted
Change NeedsPlan to NeedsReplan for statement
1 parent 66105b3 commit b8cc76d

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

src/common/statement_cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void StatementCache::UpdateFromInvalidTableQueue() {
5656

5757
if (invalid_set.size()) {
5858
for (oid_t id : invalid_set)
59-
for (auto &statement : table_ref_[id]) statement->SetNeedsPlan(true);
59+
for (auto &statement : table_ref_[id]) statement->SetNeedsReplan(true);
6060
}
6161
}
6262

src/include/common/statement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class Statement : public Printable {
8181

8282
std::unique_ptr<parser::SQLStatementList> PassStmtParseTreeList() {return std::move(sql_stmt_list_);}
8383

84-
inline bool GetNeedsPlan() const { return (needs_replan_); }
84+
inline bool GetNeedsReplan() const { return (needs_replan_); }
8585

86-
inline void SetNeedsPlan(bool replan) { needs_replan_ = replan; }
86+
inline void SetNeedsReplan(bool replan) { needs_replan_ = replan; }
8787

8888
// Get a string representation for debugging
8989
const std::string GetInfo() const;

src/traffic_cop/traffic_cop.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,13 @@ ResultType TrafficCop::ExecuteStatement(
565565
default:
566566
// The statement may be out of date
567567
// It needs to be replan
568-
if (statement->GetNeedsPlan()) {
568+
if (statement->GetNeedsReplan()) {
569569
// TODO(Tianyi) Move Statement Replan into Statement's method
570570
// to increase coherence
571571
auto plan =
572572
optimizer_->BuildPelotonPlanTree(statement->GetStmtParseTreeList(), default_database_name_, tcop_txn_state_.top().first);
573573
statement->SetPlanTree(plan);
574+
statement->SetNeedsReplan(true);
574575
}
575576

576577
ExecuteHelper(statement->GetPlanTree(), params, result,

test/common/statement_cache_manager_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ TEST_F(StatementCacheTests, InvalidateOneTest) {
3434
auto statement = std::make_shared<Statement>(string_name, query);
3535
statement->SetReferencedTables(ref_table);
3636

37-
EXPECT_TRUE(!statement->GetNeedsPlan());
37+
EXPECT_TRUE(!statement->GetNeedsReplan());
3838
statement_cache.AddStatement(statement);
3939

4040
// Invalidate table oid 0
4141
statement_cache_manager->InvalidateTableOid(0);
4242

4343
// The plan need to replan now
4444
statement = statement_cache.GetStatement(string_name);
45-
EXPECT_TRUE(statement->GetNeedsPlan());
45+
EXPECT_TRUE(statement->GetNeedsReplan());
4646

4747
// Unregister the statement cache and invalidate again
48-
statement->SetNeedsPlan(false);
48+
statement->SetNeedsReplan(false);
4949
statement_cache_manager->UnRegisterStatementCache(&statement_cache);
5050
statement_cache_manager->InvalidateTableOids(ref_table);
5151
statement = statement_cache.GetStatement(string_name);
5252
// This one should not be affected, since the cache is already un-registered
53-
EXPECT_TRUE(!statement->GetNeedsPlan());
53+
EXPECT_TRUE(!statement->GetNeedsReplan());
5454
}
5555

5656
TEST_F(StatementCacheTests, InvalidateManyTest) {
@@ -69,7 +69,7 @@ TEST_F(StatementCacheTests, InvalidateManyTest) {
6969
cur_ref_table.insert(oid);
7070
statement->SetReferencedTables(cur_ref_table);
7171

72-
EXPECT_TRUE(!statement->GetNeedsPlan());
72+
EXPECT_TRUE(!statement->GetNeedsReplan());
7373
statement_cache.AddStatement(statement);
7474
}
7575

@@ -81,7 +81,7 @@ TEST_F(StatementCacheTests, InvalidateManyTest) {
8181
std::string string_name = "foo" + oid;
8282
auto statement = statement_cache.GetStatement(string_name);
8383

84-
EXPECT_TRUE(statement->GetNeedsPlan());
84+
EXPECT_TRUE(statement->GetNeedsReplan());
8585
}
8686
}
8787
} // namespace test

test/common/statement_cache_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TEST_F(StatementCacheTests, AddGetTest) {
2727
auto statement = std::make_shared<Statement>(string_name, query);
2828
EXPECT_EQ(string_name, statement->GetStatementName());
2929
EXPECT_EQ(query, statement->GetQueryString());
30-
EXPECT_TRUE(!statement->GetNeedsPlan());
30+
EXPECT_TRUE(!statement->GetNeedsReplan());
3131

3232
auto statement_cache = std::make_shared<StatementCache>();
3333
statement_cache->AddStatement(statement);
@@ -76,7 +76,7 @@ TEST_F(StatementCacheTests, DisableTableTest) {
7676
EXPECT_EQ(t_i != table, stmt->GetReferencedTables().count(t_i));
7777
}
7878
table++;
79-
EXPECT_TRUE(!stmt->GetNeedsPlan());
79+
EXPECT_TRUE(!stmt->GetNeedsReplan());
8080

8181
cache->AddStatement(stmt);
8282
}
@@ -90,9 +90,9 @@ TEST_F(StatementCacheTests, DisableTableTest) {
9090
auto stmt = cache->GetStatement(name);
9191
EXPECT_NE(nullptr, stmt);
9292
if (i != 2) {
93-
EXPECT_TRUE(stmt->GetNeedsPlan());
93+
EXPECT_TRUE(stmt->GetNeedsReplan());
9494
} else {
95-
EXPECT_FALSE(stmt->GetNeedsPlan());
95+
EXPECT_FALSE(stmt->GetNeedsReplan());
9696
}
9797
}
9898
}

0 commit comments

Comments
 (0)