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

Commit a845135

Browse files
DeanChensjDingshilun
authored andcommitted
Catalog for change column name
1 parent dd42a3b commit a845135

File tree

2 files changed

+40
-43
lines changed

2 files changed

+40
-43
lines changed

src/catalog/catalog.cpp

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "settings/settings_manager.h"
3636
#include "storage/storage_manager.h"
3737
#include "storage/table_factory.h"
38+
#include "storage/tile.h"
3839
#include "type/ephemeral_pool.h"
3940

4041
namespace peloton {
@@ -149,12 +150,12 @@ void Catalog::Bootstrap() {
149150
DatabaseMetricsCatalog::GetInstance(txn);
150151
TableMetricsCatalog::GetInstance(txn);
151152
IndexMetricsCatalog::GetInstance(txn);
152-
QueryMetricsCatalog::GetInstance(txn);
153+
QueryMetricsCatalog::GetInstance(txn);
153154
SettingsCatalog::GetInstance(txn);
154155
TriggerCatalog::GetInstance(txn);
155156
LanguageCatalog::GetInstance(txn);
156157
ProcCatalog::GetInstance(txn);
157-
158+
158159
if (settings::SettingsManager::GetBool(settings::SettingId::brain)) {
159160
QueryHistoryCatalog::GetInstance(txn);
160161
}
@@ -615,18 +616,18 @@ ResultType Catalog::DropIndex(oid_t index_oid,
615616

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

629-
return result;
630+
return result;
630631
}
631632

632633
//===--------------------------------------------------------------------===//
@@ -1164,11 +1165,11 @@ void Catalog::InitializeFunctions() {
11641165
/**
11651166
* decimal functions
11661167
*/
1167-
AddBuiltinFunction(
1168-
"abs", {type::TypeId::DECIMAL}, type::TypeId::DECIMAL, internal_lang,
1169-
"Abs", function::BuiltInFuncType{OperatorId::Abs,
1170-
function::DecimalFunctions::_Abs},
1171-
txn);
1168+
AddBuiltinFunction("abs", {type::TypeId::DECIMAL}, type::TypeId::DECIMAL,
1169+
internal_lang, "Abs",
1170+
function::BuiltInFuncType{
1171+
OperatorId::Abs, function::DecimalFunctions::_Abs},
1172+
txn);
11721173
AddBuiltinFunction(
11731174
"sqrt", {type::TypeId::TINYINT}, type::TypeId::DECIMAL, internal_lang,
11741175
"Sqrt", function::BuiltInFuncType{OperatorId::Sqrt,
@@ -1205,33 +1206,29 @@ void Catalog::InitializeFunctions() {
12051206
/**
12061207
* integer functions
12071208
*/
1208-
AddBuiltinFunction(
1209-
"abs", {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1210-
internal_lang, "Abs",
1211-
function::BuiltInFuncType{OperatorId::Abs,
1212-
function::DecimalFunctions::_Abs},
1213-
txn);
1209+
AddBuiltinFunction("abs", {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1210+
internal_lang, "Abs",
1211+
function::BuiltInFuncType{
1212+
OperatorId::Abs, function::DecimalFunctions::_Abs},
1213+
txn);
12141214

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

1222-
AddBuiltinFunction(
1223-
"abs", {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1224-
internal_lang, "Abs",
1225-
function::BuiltInFuncType{OperatorId::Abs,
1226-
function::DecimalFunctions::_Abs},
1227-
txn);
1221+
AddBuiltinFunction("abs", {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1222+
internal_lang, "Abs",
1223+
function::BuiltInFuncType{
1224+
OperatorId::Abs, function::DecimalFunctions::_Abs},
1225+
txn);
12281226

1229-
AddBuiltinFunction(
1230-
"abs", {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1231-
internal_lang, "Abs",
1232-
function::BuiltInFuncType{OperatorId::Abs,
1233-
function::DecimalFunctions::_Abs},
1234-
txn);
1227+
AddBuiltinFunction("abs", {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1228+
internal_lang, "Abs",
1229+
function::BuiltInFuncType{
1230+
OperatorId::Abs, function::DecimalFunctions::_Abs},
1231+
txn);
12351232

12361233
AddBuiltinFunction(
12371234
"floor", {type::TypeId::INTEGER}, type::TypeId::DECIMAL,

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();

0 commit comments

Comments
 (0)