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

Commit e61451e

Browse files
DeanChensjDingshilun
authored andcommitted
add alter table catalog
1 parent 397cf24 commit e61451e

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

src/catalog/catalog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "function/old_engine_string_functions.h"
3333
#include "function/timestamp_functions.h"
3434
#include "index/index_factory.h"
35+
#include "planner/seq_scan_plan.h"
36+
#include "planner/insert_plan.h"
3537
#include "settings/settings_manager.h"
3638
#include "storage/storage_manager.h"
3739
#include "storage/table_factory.h"

src/include/catalog/catalog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <mutex>
1616

1717
#include "catalog/catalog_defaults.h"
18+
#include "catalog/column_catalog.h"
1819
#include "function/functions.h"
1920

2021
namespace peloton {

src/include/storage/database.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ class Database : public Printable {
7272
std::string GetDBName();
7373
void setDBName(const std::string &database_name);
7474

75+
storage::DataTable *ReplaceTableWithOid(const oid_t table_oid,
76+
storage::DataTable *new_table);
77+
7578
protected:
7679
//===--------------------------------------------------------------------===//
7780
// MEMBERS

src/storage/database.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,25 @@ void Database::setDBName(const std::string &database_name) {
184184
Database::database_name = database_name;
185185
}
186186

187+
storage::DataTable *Database::ReplaceTableWithOid(
188+
const oid_t table_oid, storage::DataTable *new_table) {
189+
{
190+
std::lock_guard<std::mutex> lock(database_mutex);
191+
192+
oid_t table_offset = 0;
193+
for (auto table : tables) {
194+
if (table->GetOid() == table_oid) {
195+
break;
196+
}
197+
table_offset++;
198+
}
199+
PL_ASSERT(table_offset < tables.size());
200+
201+
auto old_table = tables.at(table_offset);
202+
tables[table_offset] = new_table;
203+
return old_table;
204+
}
205+
}
206+
187207
} // namespace storage
188208
} // namespace peloton

0 commit comments

Comments
 (0)