@@ -615,18 +615,18 @@ ResultType Catalog::DropIndex(oid_t index_oid,
615
615
616
616
ResultType Catalog::DropIndex (const std::string &index_name,
617
617
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);
618
+ if (txn == nullptr ) {
619
+ throw CatalogException (" Do not have transaction to drop index " +
620
+ index_name);
621
+ }
622
+ auto index_object =
623
+ catalog::IndexCatalog::GetInstance ()-> GetIndexObject ( 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);
628
628
629
- return result;
629
+ return result;
630
630
}
631
631
632
632
// ===--------------------------------------------------------------------===//
@@ -837,19 +837,18 @@ ResultType Catalog::AddColumn(
837
837
* @return TransactionContext ResultType(SUCCESS or FAILURE)
838
838
*/
839
839
840
- ResultType Catalog::DropColumn (
841
- const std::string &database_name,
842
- const std::string &table_name,
843
- const std::vector<std::string> &columns,
844
- concurrency::TransactionContext *txn) {
840
+ ResultType Catalog::DropColumn (const std::string &database_name,
841
+ const std::string &table_name,
842
+ const std::vector<std::string> &columns,
843
+ concurrency::TransactionContext *txn) {
845
844
try {
846
845
oid_t table_oid = Catalog::GetInstance ()
847
- ->GetTableObject (database_name, table_name, txn)
848
- ->GetTableOid ();
849
- for (std::string name: columns) {
846
+ ->GetTableObject (database_name, table_name, txn)
847
+ ->GetTableOid ();
848
+ for (std::string name : columns) {
850
849
catalog::ColumnCatalog::GetInstance ()->DeleteColumn (table_oid, name, txn);
851
850
}
852
- } catch (CatalogException &e){
851
+ } catch (CatalogException &e) {
853
852
return ResultType::FAILURE;
854
853
}
855
854
return ResultType::SUCCESS;
@@ -876,8 +875,7 @@ ResultType Catalog::RenameColumn(const std::string &database_name,
876
875
throw CatalogException (" Name can not be empty string." );
877
876
}
878
877
879
- LOG_TRACE (" Change Column Name %s to %s" , old_name.c_str (),
880
- new_name.c_str ());
878
+ LOG_TRACE (" Change Column Name %s to %s" , old_name.c_str (), new_name.c_str ());
881
879
882
880
try {
883
881
// Get table from the name
@@ -900,17 +898,15 @@ ResultType Catalog::RenameColumn(const std::string &database_name,
900
898
// Change column name in the global schema
901
899
schema->ChangeColumnName (columnId, new_name);
902
900
903
- // Change cached ColumnCatalog
901
+ // Modify the pg_table
904
902
oid_t table_oid = Catalog::GetInstance ()
905
903
->GetTableObject (database_name, table_name, txn)
906
904
->GetTableOid ();
907
- catalog::ColumnCatalog::GetInstance ()->DeleteColumn (table_oid, old_name,
908
- txn);
909
- auto new_column = schema->GetColumn (columnId);
910
- catalog::ColumnCatalog::GetInstance ()->InsertColumn (
911
- table_oid, new_column.GetName (), columnId, new_column.GetOffset (),
912
- new_column.GetType (), new_column.IsInlined (),
913
- new_column.GetConstraints (), pool_.get (), txn);
905
+ bool res = catalog::ColumnCatalog::GetInstance ()->RenameColumn (
906
+ table_oid, old_name, new_name, txn);
907
+ if (!res) {
908
+ throw CatalogException (" Change Column name failed." );
909
+ }
914
910
915
911
} catch (CatalogException &e) {
916
912
return ResultType::FAILURE;
@@ -1195,11 +1191,11 @@ void Catalog::InitializeFunctions() {
1195
1191
/* *
1196
1192
* decimal functions
1197
1193
*/
1198
- AddBuiltinFunction (
1199
- " abs " , {type::TypeId::DECIMAL}, type::TypeId::DECIMAL, internal_lang,
1200
- " Abs " , function::BuiltInFuncType{OperatorId::Abs,
1201
- function::DecimalFunctions::_Abs},
1202
- txn);
1194
+ AddBuiltinFunction (" abs " , {type::TypeId::DECIMAL}, type::TypeId::DECIMAL,
1195
+ internal_lang, " Abs " ,
1196
+ function::BuiltInFuncType{
1197
+ OperatorId::Abs, function::DecimalFunctions::_Abs},
1198
+ txn);
1203
1199
AddBuiltinFunction (
1204
1200
" sqrt" , {type::TypeId::TINYINT}, type::TypeId::DECIMAL, internal_lang,
1205
1201
" Sqrt" , function::BuiltInFuncType{OperatorId::Sqrt,
@@ -1236,33 +1232,29 @@ void Catalog::InitializeFunctions() {
1236
1232
/* *
1237
1233
* integer functions
1238
1234
*/
1239
- AddBuiltinFunction (
1240
- " abs" , {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1241
- internal_lang, " Abs" ,
1242
- function::BuiltInFuncType{OperatorId::Abs,
1243
- function::DecimalFunctions::_Abs},
1244
- txn);
1235
+ AddBuiltinFunction (" abs" , {type::TypeId::TINYINT}, type::TypeId::TINYINT,
1236
+ internal_lang, " Abs" ,
1237
+ function::BuiltInFuncType{
1238
+ OperatorId::Abs, function::DecimalFunctions::_Abs},
1239
+ txn);
1245
1240
1246
- AddBuiltinFunction (
1247
- " abs" , {type::TypeId::SMALLINT}, type::TypeId::SMALLINT,
1248
- internal_lang, " Abs" ,
1249
- function::BuiltInFuncType{OperatorId::Abs,
1250
- function::DecimalFunctions::_Abs},
1251
- txn);
1241
+ AddBuiltinFunction (" abs" , {type::TypeId::SMALLINT},
1242
+ type::TypeId::SMALLINT, internal_lang, " Abs" ,
1243
+ function::BuiltInFuncType{
1244
+ OperatorId::Abs, function::DecimalFunctions::_Abs},
1245
+ txn);
1252
1246
1253
- AddBuiltinFunction (
1254
- " abs" , {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1255
- internal_lang, " Abs" ,
1256
- function::BuiltInFuncType{OperatorId::Abs,
1257
- function::DecimalFunctions::_Abs},
1258
- txn);
1247
+ AddBuiltinFunction (" abs" , {type::TypeId::INTEGER}, type::TypeId::INTEGER,
1248
+ internal_lang, " Abs" ,
1249
+ function::BuiltInFuncType{
1250
+ OperatorId::Abs, function::DecimalFunctions::_Abs},
1251
+ txn);
1259
1252
1260
- AddBuiltinFunction (
1261
- " abs" , {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1262
- internal_lang, " Abs" ,
1263
- function::BuiltInFuncType{OperatorId::Abs,
1264
- function::DecimalFunctions::_Abs},
1265
- txn);
1253
+ AddBuiltinFunction (" abs" , {type::TypeId::BIGINT}, type::TypeId::BIGINT,
1254
+ internal_lang, " Abs" ,
1255
+ function::BuiltInFuncType{
1256
+ OperatorId::Abs, function::DecimalFunctions::_Abs},
1257
+ txn);
1266
1258
1267
1259
AddBuiltinFunction (
1268
1260
" floor" , {type::TypeId::INTEGER}, type::TypeId::DECIMAL,
0 commit comments