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

Commit 4fa49f7

Browse files
author
GustavoAngulo
committed
Accidently rollbacked previous commit
1 parent aaa5472 commit 4fa49f7

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

test/optimizer/selectivity_test.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ TEST_F(SelectivityTests, RangeSelectivityTest) {
7878
oid_t table_id = table->GetOid();
7979
std::string column_name = "test.id"; // first column
8080
auto stats_storage = StatsStorage::GetInstance();
81-
auto table_stats = stats_storage->GetTableStats(db_id, table_id);
81+
txn = txn_manager.BeginTransaction();
82+
auto table_stats = stats_storage->GetTableStats(db_id, table_id, txn);
83+
txn_manager.CommitTransaction(txn);
8284
type::Value value1 = type::ValueFactory::GetIntegerValue(nrow / 4);
8385
ValueCondition condition{column_name, ExpressionType::COMPARE_LESSTHAN,
8486
value1};
@@ -91,7 +93,9 @@ TEST_F(SelectivityTests, RangeSelectivityTest) {
9193
TestingSQLUtil::ExecuteSQLQuery("ANALYZE test");
9294

9395
// Get updated table stats and check new selectivity
94-
table_stats = stats_storage->GetTableStats(db_id, table_id);
96+
txn = txn_manager.BeginTransaction();
97+
table_stats = stats_storage->GetTableStats(db_id, table_id, txn);
98+
txn_manager.CommitTransaction(txn);
9599
double less_than_sel =
96100
Selectivity::ComputeSelectivity(table_stats, condition);
97101
ExpectSelectivityEqual(less_than_sel, 0.25);
@@ -134,8 +138,11 @@ TEST_F(SelectivityTests, LikeSelectivityTest) {
134138
oid_t table_id = data_table->GetOid();
135139

136140
auto stats_storage = StatsStorage::GetInstance();
137-
auto table_stats = stats_storage->GetTableStats(db_id, table_id);
138-
table_stats->SetTupleSampler(std::make_shared<TupleSampler>(data_table.get()));
141+
txn = txn_manager.BeginTransaction();
142+
auto table_stats = stats_storage->GetTableStats(db_id, table_id, txn);
143+
txn_manager.CommitTransaction(txn);
144+
table_stats->SetTupleSampler(
145+
std::make_shared<TupleSampler>(data_table.get()));
139146

140147
type::Value value = type::ValueFactory::GetVarcharValue("%3");
141148
ValueCondition condition1{"test_table.COL_D", ExpressionType::COMPARE_LIKE,
@@ -179,7 +186,9 @@ TEST_F(SelectivityTests, EqualSelectivityTest) {
179186
oid_t table_id = table->GetOid();
180187
std::string column_name1 = "test.b";
181188
auto stats_storage = StatsStorage::GetInstance();
182-
auto table_stats = stats_storage->GetTableStats(db_id, table_id);
189+
txn = txn_manager.BeginTransaction();
190+
auto table_stats = stats_storage->GetTableStats(db_id, table_id, txn);
191+
txn_manager.CommitTransaction(txn);
183192

184193
type::Value value1 = type::ValueFactory::GetDecimalValue(1.0);
185194

@@ -191,7 +200,9 @@ TEST_F(SelectivityTests, EqualSelectivityTest) {
191200

192201
// Run analyze
193202
TestingSQLUtil::ExecuteSQLQuery("ANALYZE test");
194-
table_stats = stats_storage->GetTableStats(db_id, table_id);
203+
txn = txn_manager.BeginTransaction();
204+
table_stats = stats_storage->GetTableStats(db_id, table_id, txn);
205+
txn_manager.CommitTransaction(txn);
195206

196207
// Check selectivity
197208
// equal, in mcv
@@ -222,7 +233,9 @@ TEST_F(SelectivityTests, EqualSelectivityTest) {
222233

223234
// Run analyze
224235
TestingSQLUtil::ExecuteSQLQuery("ANALYZE test");
225-
table_stats = stats_storage->GetTableStats(db_id, table_id);
236+
txn = txn_manager.BeginTransaction();
237+
table_stats = stats_storage->GetTableStats(db_id, table_id, txn);
238+
txn_manager.CommitTransaction(txn);
226239

227240
// Check selectivity
228241
// equal, not in mcv
@@ -248,4 +261,4 @@ TEST_F(SelectivityTests, EqualSelectivityTest) {
248261
}
249262

250263
} // namespace test
251-
} // namespace peloton
264+
} // namespace peloton

test/optimizer/stats_storage_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,12 @@ TEST_F(StatsStorageTests, GetTableStatsTest) {
245245
stats_storage->AnalyzeStatsForAllTables(txn);
246246
txn_manager.CommitTransaction(txn);
247247

248+
txn = txn_manager.BeginTransaction();
248249
std::shared_ptr<TableStats> table_stats = stats_storage->GetTableStats(
249-
data_table->GetDatabaseOid(), data_table->GetOid());
250+
data_table->GetDatabaseOid(), data_table->GetOid(), txn);
251+
txn_manager.CommitTransaction(txn);
250252
EXPECT_EQ(table_stats->num_rows, tuple_count);
251253
}
252254

253255
} // namespace test
254-
} // namespace peloton
256+
} // namespace peloton

0 commit comments

Comments
 (0)