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

Commit f344a55

Browse files
dingshilunDingshilun
authored andcommitted
Revert "Merge pull request #1 from DeanChensj/catlog"
This reverts commit 6704d0e, reversing changes made to 39fa518.
1 parent 098a35a commit f344a55

File tree

7 files changed

+47
-96
lines changed

7 files changed

+47
-96
lines changed

src/catalog/catalog.cpp

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@
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"
3735
#include "settings/settings_manager.h"
3836
#include "storage/storage_manager.h"
3937
#include "storage/table_factory.h"
40-
#include "storage/tile.h"
4138
#include "type/ephemeral_pool.h"
4239

4340
namespace peloton {
@@ -618,18 +615,18 @@ ResultType Catalog::DropIndex(oid_t index_oid,
618615

619616
ResultType Catalog::DropIndex(const std::string &index_name,
620617
concurrency::TransactionContext *txn) {
621-
if (txn == nullptr) {
622-
throw CatalogException("Do not have transaction to drop index " +
623-
index_name);
624-
}
625-
auto index_object =
626-
catalog::IndexCatalog::GetInstance()->GetIndexObject(index_name, txn);
627-
if (index_object == nullptr) {
628-
throw CatalogException("Index name " + index_name + " cannot be found");
629-
}
630-
ResultType result = DropIndex(index_object->GetIndexOid(), txn);
618+
if(txn == nullptr) {
619+
throw CatalogException("Do not have transaction to drop index " +
620+
index_name);
621+
}
622+
auto index_object = catalog::IndexCatalog::GetInstance()->GetIndexObject(
623+
index_name, txn);
624+
if(index_object == nullptr) {
625+
throw CatalogException("Index name " + index_name + " cannot be found");
626+
}
627+
ResultType result = DropIndex(index_object->GetIndexOid(), txn);
631628

632-
return result;
629+
return result;
633630
}
634631

635632
//===--------------------------------------------------------------------===//
@@ -814,7 +811,6 @@ ResultType Catalog::AddColumn(
814811
return ResultType::SUCCESS;
815812
}
816813

817-
<<<<<<< bc9252fda7aeecaeb325a11f30bc23a27569f932
818814
ResultType Catalog::DropColumn(
819815
UNUSED_ATTRIBUTE const std::string &database_name,
820816
UNUSED_ATTRIBUTE const std::string &table_name,
@@ -828,13 +824,6 @@ ResultType Catalog::ChangeColumnName(const std::string &database_name,
828824
const std::vector<std::string> &old_names,
829825
const std::vector<std::string> &names,
830826
concurrency::TransactionContext *txn) {
831-
=======
832-
ResultType ChangeColumnName(const std::string &database_name,
833-
const std::string &table_name,
834-
const std::vector<std::string> &old_names,
835-
const std::vector<std::string> &names,
836-
concurrency::TransactionContext *txn) {
837-
>>>>>>> add change column catalog
838827
if (txn == nullptr) {
839828
throw CatalogException("Change Column requires transaction.");
840829
}
@@ -843,12 +832,8 @@ ResultType ChangeColumnName(const std::string &database_name,
843832
throw CatalogException("No names are given.");
844833
}
845834

846-
<<<<<<< bc9252fda7aeecaeb325a11f30bc23a27569f932
847835
LOG_TRACE("Change Column Name %s to %s", old_names[0].c_str(),
848836
names[0].c_str());
849-
=======
850-
LOG_TRACE("Change Column Name %s to %s", old_names[0], names[0]);
851-
>>>>>>> add change column catalog
852837

853838
try {
854839
// Get table from the name
@@ -1166,11 +1151,11 @@ void Catalog::InitializeFunctions() {
11661151
/**
11671152
* decimal functions
11681153
*/
1169-
AddBuiltinFunction("abs", {type::TypeId::DECIMAL}, type::TypeId::DECIMAL,
1170-
internal_lang, "Abs",
1171-
function::BuiltInFuncType{
1172-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1173-
txn);
1154+
AddBuiltinFunction(
1155+
"abs", {type::TypeId::DECIMAL}, type::TypeId::DECIMAL, internal_lang,
1156+
"Abs", function::BuiltInFuncType{OperatorId::Abs,
1157+
function::DecimalFunctions::_Abs},
1158+
txn);
11741159
AddBuiltinFunction(
11751160
"sqrt", {type::TypeId::TINYINT}, type::TypeId::DECIMAL, internal_lang,
11761161
"Sqrt", function::BuiltInFuncType{OperatorId::Sqrt,
@@ -1207,29 +1192,33 @@ void Catalog::InitializeFunctions() {
12071192
/**
12081193
* integer functions
12091194
*/
1210-
AddBuiltinFunction("abs", {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1211-
internal_lang, "Abs",
1212-
function::BuiltInFuncType{
1213-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1214-
txn);
1195+
AddBuiltinFunction(
1196+
"abs", {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1197+
internal_lang, "Abs",
1198+
function::BuiltInFuncType{OperatorId::Abs,
1199+
function::DecimalFunctions::_Abs},
1200+
txn);
12151201

1216-
AddBuiltinFunction("abs", {type::TypeId::SMALLINT},
1217-
type::TypeId::SMALLINT, internal_lang, "Abs",
1218-
function::BuiltInFuncType{
1219-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1220-
txn);
1202+
AddBuiltinFunction(
1203+
"abs", {type::TypeId::SMALLINT}, type::TypeId::SMALLINT,
1204+
internal_lang, "Abs",
1205+
function::BuiltInFuncType{OperatorId::Abs,
1206+
function::DecimalFunctions::_Abs},
1207+
txn);
12211208

1222-
AddBuiltinFunction("abs", {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1223-
internal_lang, "Abs",
1224-
function::BuiltInFuncType{
1225-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1226-
txn);
1209+
AddBuiltinFunction(
1210+
"abs", {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1211+
internal_lang, "Abs",
1212+
function::BuiltInFuncType{OperatorId::Abs,
1213+
function::DecimalFunctions::_Abs},
1214+
txn);
12271215

1228-
AddBuiltinFunction("abs", {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1229-
internal_lang, "Abs",
1230-
function::BuiltInFuncType{
1231-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1232-
txn);
1216+
AddBuiltinFunction(
1217+
"abs", {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1218+
internal_lang, "Abs",
1219+
function::BuiltInFuncType{OperatorId::Abs,
1220+
function::DecimalFunctions::_Abs},
1221+
txn);
12331222

12341223
AddBuiltinFunction(
12351224
"floor", {type::TypeId::INTEGER}, type::TypeId::DECIMAL,

src/catalog/table_catalog.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,6 @@ 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-
315306
TableCatalog *TableCatalog::GetInstance(storage::Database *pg_catalog,
316307
type::AbstractPool *pool,
317308
concurrency::TransactionContext *txn) {
@@ -403,8 +394,7 @@ bool TableCatalog::InsertTable(oid_t table_oid, const std::string &table_name,
403394
* @param txn TransactionContext
404395
* @return Whether deletion is Successful
405396
*/
406-
bool TableCatalog::DeleteTable(oid_t table_oid,
407-
concurrency::TransactionContext *txn) {
397+
bool TableCatalog::DeleteTable(oid_t table_oid, concurrency::TransactionContext *txn) {
408398
oid_t index_offset = IndexId::PRIMARY_KEY; // Index of table_oid
409399
std::vector<type::Value> values;
410400
values.push_back(type::ValueFactory::GetIntegerValue(table_oid).Copy());

src/include/catalog/catalog.h

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

1717
#include "catalog/catalog_defaults.h"
18-
#include "catalog/column_catalog.h"
1918
#include "function/functions.h"
2019

2120
namespace peloton {

src/include/catalog/schema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class Schema : public Printable {
196196
}
197197

198198
// Get the default value for the column
199-
inline type::Value *GetDefaultValue(const oid_t column_id) const {
199+
inline type::Value* GetDefaultValue(const oid_t column_id) const {
200200
for (auto constraint : columns[column_id].GetConstraints()) {
201201
if (constraint.GetType() == ConstraintType::DEFAULT) {
202202
return constraint.getDefaultValue();

src/include/catalog/table_catalog.h

Lines changed: 5 additions & 9 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,
49-
concurrency::TransactionContext *txn, int tupleId = 0);
48+
TableCatalogObject(executor::LogicalTile *tile, concurrency::TransactionContext *txn,
49+
int tupleId = 0);
5050

5151
public:
5252
// Get indexes
@@ -71,9 +71,6 @@ 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-
7774
inline oid_t GetTableOid() { return table_oid; }
7875
inline const std::string &GetTableName() { return table_name; }
7976
inline oid_t GetDatabaseOid() { return database_oid; }
@@ -122,10 +119,9 @@ class TableCatalog : public AbstractCatalog {
122119
~TableCatalog();
123120

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

130126
inline oid_t GetNextOid() { return oid_++ | TABLE_OID_MASK; }
131127

src/include/storage/database.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ 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-
7875
protected:
7976
//===--------------------------------------------------------------------===//
8077
// MEMBERS

src/storage/database.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,5 @@ 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-
207187
} // namespace storage
208188
} // namespace peloton

0 commit comments

Comments
 (0)