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

Commit 8a51c36

Browse files
author
Dean Chen
committed
add gc logic
1 parent f8b10a5 commit 8a51c36

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/catalog/catalog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ ResultType Catalog::AlterTable(oid_t database_oid, oid_t table_oid, const std::s
10991099
txn);
11001100
column_offset++;
11011101
}
1102-
// TODO: Add gc logic
1103-
// txn->RecordDrop(database_oid, old_table->GetOid(), INVALID_OID);
1102+
// Garbage collection
1103+
txn->RecordDropTable(old_table);
11041104

11051105
// Final step of physical change should be moved to commit time
11061106
database->ReplaceTableWithOid(table_oid, new_table);

src/gc/transaction_level_gc_manager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ void TransactionLevelGCManager::AddToRecycleMap(
278278
LOG_DEBUG("GCing index %u", index_oid);
279279
}
280280

281+
for (auto table : txn_ctx->GetDroppedTables()) {
282+
LOG_TRACE("deleting table when txn commits");
283+
delete table;
284+
}
285+
281286
delete txn_ctx;
282287
}
283288

src/include/concurrency/transaction_context.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class TriggerSet;
3333
class TriggerData;
3434
} // namespace trigger
3535

36+
namespace storage {
37+
class DataTable;
38+
}
39+
3640
namespace concurrency {
3741

3842
//===--------------------------------------------------------------------===//
@@ -173,6 +177,14 @@ class TransactionContext : public Printable {
173177

174178
void RecordInsert(const ItemPointer &);
175179

180+
void RecordDropTable(storage::DataTable *table) {
181+
dropped_tables.push_back(table);
182+
}
183+
184+
std::vector<storage::DataTable *> &GetDroppedTables() {
185+
return dropped_tables;
186+
}
187+
176188
/**
177189
* @brief Delete the record.
178190
*
@@ -341,6 +353,9 @@ class TransactionContext : public Printable {
341353
IsolationLevelType isolation_level_;
342354

343355
std::unique_ptr<trigger::TriggerSet> on_commit_triggers_;
356+
357+
/** vector of dropped data tables **/
358+
std::vector<storage::DataTable *> dropped_tables;
344359
};
345360

346361
} // namespace concurrency

0 commit comments

Comments
 (0)