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

Commit f0ecc68

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

File tree

7 files changed

+49
-87
lines changed

7 files changed

+49
-87
lines changed

src/catalog/catalog.cpp

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,14 @@
2626
#include "catalog/table_metrics_catalog.h"
2727
#include "catalog/trigger_catalog.h"
2828
#include "concurrency/transaction_manager_factory.h"
29-
#include "executor/executor_context.h"
3029
#include "function/date_functions.h"
3130
#include "function/decimal_functions.h"
3231
#include "function/old_engine_string_functions.h"
3332
#include "function/timestamp_functions.h"
3433
#include "index/index_factory.h"
35-
#include "planner/seq_scan_plan.h"
36-
#include "planner/insert_plan.h"
3734
#include "settings/settings_manager.h"
3835
#include "storage/storage_manager.h"
3936
#include "storage/table_factory.h"
40-
#include "storage/tile.h"
4137
#include "type/ephemeral_pool.h"
4238

4339
namespace peloton {
@@ -152,12 +148,12 @@ void Catalog::Bootstrap() {
152148
DatabaseMetricsCatalog::GetInstance(txn);
153149
TableMetricsCatalog::GetInstance(txn);
154150
IndexMetricsCatalog::GetInstance(txn);
155-
QueryMetricsCatalog::GetInstance(txn);
151+
QueryMetricsCatalog::GetInstance(txn);
156152
SettingsCatalog::GetInstance(txn);
157153
TriggerCatalog::GetInstance(txn);
158154
LanguageCatalog::GetInstance(txn);
159155
ProcCatalog::GetInstance(txn);
160-
156+
161157
if (settings::SettingsManager::GetBool(settings::SettingId::brain)) {
162158
QueryHistoryCatalog::GetInstance(txn);
163159
}
@@ -618,18 +614,18 @@ ResultType Catalog::DropIndex(oid_t index_oid,
618614

619615
ResultType Catalog::DropIndex(const std::string &index_name,
620616
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);
617+
if(txn == nullptr) {
618+
throw CatalogException("Do not have transaction to drop index " +
619+
index_name);
620+
}
621+
auto index_object = catalog::IndexCatalog::GetInstance()->GetIndexObject(
622+
index_name, txn);
623+
if(index_object == nullptr) {
624+
throw CatalogException("Index name " + index_name + " cannot be found");
625+
}
626+
ResultType result = DropIndex(index_object->GetIndexOid(), txn);
631627

632-
return result;
628+
return result;
633629
}
634630

635631
//===--------------------------------------------------------------------===//
@@ -1154,11 +1150,11 @@ void Catalog::InitializeFunctions() {
11541150
/**
11551151
* decimal functions
11561152
*/
1157-
AddBuiltinFunction("abs", {type::TypeId::DECIMAL}, type::TypeId::DECIMAL,
1158-
internal_lang, "Abs",
1159-
function::BuiltInFuncType{
1160-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1161-
txn);
1153+
AddBuiltinFunction(
1154+
"abs", {type::TypeId::DECIMAL}, type::TypeId::DECIMAL, internal_lang,
1155+
"Abs", function::BuiltInFuncType{OperatorId::Abs,
1156+
function::DecimalFunctions::_Abs},
1157+
txn);
11621158
AddBuiltinFunction(
11631159
"sqrt", {type::TypeId::TINYINT}, type::TypeId::DECIMAL, internal_lang,
11641160
"Sqrt", function::BuiltInFuncType{OperatorId::Sqrt,
@@ -1195,29 +1191,33 @@ void Catalog::InitializeFunctions() {
11951191
/**
11961192
* integer functions
11971193
*/
1198-
AddBuiltinFunction("abs", {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1199-
internal_lang, "Abs",
1200-
function::BuiltInFuncType{
1201-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1202-
txn);
1194+
AddBuiltinFunction(
1195+
"abs", {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1196+
internal_lang, "Abs",
1197+
function::BuiltInFuncType{OperatorId::Abs,
1198+
function::DecimalFunctions::_Abs},
1199+
txn);
12031200

1204-
AddBuiltinFunction("abs", {type::TypeId::SMALLINT},
1205-
type::TypeId::SMALLINT, internal_lang, "Abs",
1206-
function::BuiltInFuncType{
1207-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1208-
txn);
1201+
AddBuiltinFunction(
1202+
"abs", {type::TypeId::SMALLINT}, type::TypeId::SMALLINT,
1203+
internal_lang, "Abs",
1204+
function::BuiltInFuncType{OperatorId::Abs,
1205+
function::DecimalFunctions::_Abs},
1206+
txn);
12091207

1210-
AddBuiltinFunction("abs", {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1211-
internal_lang, "Abs",
1212-
function::BuiltInFuncType{
1213-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1214-
txn);
1208+
AddBuiltinFunction(
1209+
"abs", {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1210+
internal_lang, "Abs",
1211+
function::BuiltInFuncType{OperatorId::Abs,
1212+
function::DecimalFunctions::_Abs},
1213+
txn);
12151214

1216-
AddBuiltinFunction("abs", {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1217-
internal_lang, "Abs",
1218-
function::BuiltInFuncType{
1219-
OperatorId::Abs, function::DecimalFunctions::_Abs},
1220-
txn);
1215+
AddBuiltinFunction(
1216+
"abs", {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1217+
internal_lang, "Abs",
1218+
function::BuiltInFuncType{OperatorId::Abs,
1219+
function::DecimalFunctions::_Abs},
1220+
txn);
12211221

12221222
AddBuiltinFunction(
12231223
"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)