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

Commit 3d8a535

Browse files
Added DeleteLayouts to delete all layouts of a table_oid
1 parent b618603 commit 3d8a535

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/catalog/layout_catalog.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ bool LayoutCatalog::DeleteLayout(oid_t table_oid, oid_t layout_id,
134134
return DeleteWithIndexScan(index_offset, values, txn);
135135
}
136136

137+
bool LayoutCatalog::DeleteLayouts(oid_t table_oid,
138+
concurrency::TransactionContext *txn) {
139+
oid_t index_offset = IndexId::SKEY_TABLE_OID; // Index of table_oid
140+
std::vector<type::Value> values;
141+
values.push_back(type::ValueFactory::GetIntegerValue(table_oid).Copy());
142+
143+
// delete layouts from cache
144+
auto table_object =
145+
TableCatalog::GetInstance()->GetTableObject(table_oid, txn);
146+
table_object->EvictAllLayouts();
147+
148+
return DeleteWithIndexScan(index_offset, values, txn);
149+
}
150+
137151
const std::unordered_map<oid_t, std::shared_ptr<const storage::Layout>>
138152
LayoutCatalog::GetLayouts(oid_t table_oid,
139153
concurrency::TransactionContext *txn) {

src/include/catalog/layout_catalog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class LayoutCatalog : public AbstractCatalog {
5959

6060
bool DeleteLayout(oid_t table_oid, oid_t layout_id,
6161
concurrency::TransactionContext *txn);
62+
63+
bool DeleteLayouts(oid_t table_oid, concurrency::TransactionContext *txn);
6264
//===--------------------------------------------------------------------===//
6365
// Read Related API
6466
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)