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

Commit 88a397c

Browse files
DeanChensjDingshilun
authored andcommitted
add change column catalog
1 parent d07920e commit 88a397c

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/catalog/catalog.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
#include "catalog/trigger_catalog.h"
2828
#include "concurrency/transaction_manager_factory.h"
2929
#include "executor/executor_context.h"
30-
<<<<<<< HEAD
31-
=======
32-
#include "executor/insert_executor.h"
33-
#include "executor/seq_scan_executor.h"
34-
>>>>>>> add alter table catalog
3530
#include "function/date_functions.h"
3631
#include "function/decimal_functions.h"
3732
#include "function/old_engine_string_functions.h"

src/catalog/table_catalog.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,15 @@ std::shared_ptr<ColumnCatalogObject> TableCatalogObject::GetColumnObject(
303303
return nullptr;
304304
}
305305

306+
void TableCatalogObject::ChangeColumnName(
307+
const std::vector<oid_t> &columns,
308+
UNUSED_ATTRIBUTE const std::vector<std::string> &names) {
309+
// TODO: Change column_names
310+
// TODO: Change column_objects
311+
TableCatalogObject::EvictColumnObject(columns[0]);
312+
return;
313+
}
314+
306315
TableCatalog *TableCatalog::GetInstance(storage::Database *pg_catalog,
307316
type::AbstractPool *pool,
308317
concurrency::TransactionContext *txn) {
@@ -394,7 +403,8 @@ bool TableCatalog::InsertTable(oid_t table_oid, const std::string &table_name,
394403
* @param txn TransactionContext
395404
* @return Whether deletion is Successful
396405
*/
397-
bool TableCatalog::DeleteTable(oid_t table_oid, concurrency::TransactionContext *txn) {
406+
bool TableCatalog::DeleteTable(oid_t table_oid,
407+
concurrency::TransactionContext *txn) {
398408
oid_t index_offset = IndexId::PRIMARY_KEY; // Index of table_oid
399409
std::vector<type::Value> values;
400410
values.push_back(type::ValueFactory::GetIntegerValue(table_oid).Copy());

src/include/catalog/table_catalog.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class TableCatalogObject {
4545
friend class ColumnCatalog;
4646

4747
public:
48-
TableCatalogObject(executor::LogicalTile *tile, concurrency::TransactionContext *txn,
49-
int tupleId = 0);
48+
TableCatalogObject(executor::LogicalTile *tile,
49+
concurrency::TransactionContext *txn, int tupleId = 0);
5050

5151
public:
5252
// Get indexes
@@ -71,6 +71,9 @@ class TableCatalogObject {
7171
std::shared_ptr<ColumnCatalogObject> GetColumnObject(
7272
const std::string &column_name, bool cached_only = false);
7373

74+
void ChangeColumnName(const std::vector<oid_t> &columns,
75+
const std::vector<std::string> &names);
76+
7477
inline oid_t GetTableOid() { return table_oid; }
7578
inline const std::string &GetTableName() { return table_name; }
7679
inline oid_t GetDatabaseOid() { return database_oid; }
@@ -119,9 +122,10 @@ class TableCatalog : public AbstractCatalog {
119122
~TableCatalog();
120123

121124
// Global Singleton, only the first call requires passing parameters.
122-
static TableCatalog *GetInstance(storage::Database *pg_catalog = nullptr,
123-
type::AbstractPool *pool = nullptr,
124-
concurrency::TransactionContext *txn = nullptr);
125+
static TableCatalog *GetInstance(
126+
storage::Database *pg_catalog = nullptr,
127+
type::AbstractPool *pool = nullptr,
128+
concurrency::TransactionContext *txn = nullptr);
125129

126130
inline oid_t GetNextOid() { return oid_++ | TABLE_OID_MASK; }
127131

0 commit comments

Comments
 (0)