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

Commit dcbd71d

Browse files
Yingjun Wupoojanilangekar
authored andcommitted
fix bug in seq scan
1 parent 39fa518 commit dcbd71d

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/codegen/updater.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void Updater::Init(storage::DataTable *table,
3737
// Target list is kept since it is required at a new version update
3838
target_list_ =
3939
new TargetList(target_vector, target_vector + target_vector_size);
40+
41+
statement_write_set_ = new ReadWriteSet();
4042
}
4143

4244
char *Updater::GetDataPtr(uint32_t tile_group_id, uint32_t tuple_offset) {
@@ -74,7 +76,12 @@ char *Updater::Prepare(uint32_t tile_group_id, uint32_t tuple_offset) {
7476
}
7577

7678
char *Updater::PreparePK(uint32_t tile_group_id, uint32_t tuple_offset) {
79+
7780
PELOTON_ASSERT(table_ != nullptr && executor_context_ != nullptr);
81+
if (statement_write_set_->Contains(ItemPointer(tile_group_id, tuple_offset))) {
82+
return nullptr;
83+
}
84+
7885
auto *txn = executor_context_->GetTransaction();
7986
auto tile_group = table_->GetTileGroupById(tile_group_id).get();
8087
auto *tile_group_header = tile_group->GetHeader();
@@ -166,13 +173,15 @@ void Updater::UpdatePK() {
166173
return;
167174
}
168175
txn_manager.PerformInsert(txn, new_location_, index_entry_ptr);
176+
statement_write_set_->Insert(new_location_, RWType::INSERT);
169177
executor_context_->num_processed++;
170178
}
171179

172180
void Updater::TearDown() {
173181
// Updater object does not destruct its own data structures
174182
tile_.reset();
175183
delete target_list_;
184+
delete statement_write_set_;
176185
}
177186

178187
} // namespace codegen

src/executor/update_executor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,20 @@ bool UpdateExecutor::DInit() {
5353
PELOTON_ASSERT(target_table_);
5454
PELOTON_ASSERT(project_info_);
5555

56+
statement_write_set_.Clear();
57+
5658
return true;
5759
}
5860

5961
bool UpdateExecutor::PerformUpdatePrimaryKey(
6062
bool is_owner, storage::TileGroup *tile_group,
6163
storage::TileGroupHeader *tile_group_header, oid_t physical_tuple_id,
6264
ItemPointer &old_location) {
65+
66+
if (statement_write_set_.Contains(old_location)) {
67+
return true;
68+
}
69+
6370
auto &transaction_manager =
6471
concurrency::TransactionManagerFactory::GetInstance();
6572

@@ -136,6 +143,7 @@ bool UpdateExecutor::PerformUpdatePrimaryKey(
136143
}
137144

138145
transaction_manager.PerformInsert(current_txn, location, index_entry_ptr);
146+
statement_write_set_.Insert(location, RWType::INSERT);
139147

140148
return true;
141149
}

src/include/codegen/updater.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class Updater {
7575
// Target list and direct map list pointer from the update translator
7676
TargetList *target_list_;
7777

78+
// Write set for tracking newly created tuples inserted by the same statement
79+
ReadWriteSet *statement_write_set_;
80+
7881
// Ownership information
7982
bool is_owner_;
8083
bool acquired_ownership_;

src/include/executor/update_executor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class UpdateExecutor : public AbstractExecutor {
5252
private:
5353
storage::DataTable *target_table_ = nullptr;
5454
const planner::ProjectInfo *project_info_ = nullptr;
55+
56+
// Write set for tracking newly created tuples inserted by the same statement
57+
ReadWriteSet statement_write_set_;
5558
};
5659

5760
} // namespace executor

0 commit comments

Comments
 (0)