Skip to content

Commit

Permalink
fix(tianmu): ALTER TABLE prompt information is incorrect.(#1142)
Browse files Browse the repository at this point in the history
Print the specific information of known exceptions to better understand the cause of the problem
  • Loading branch information
DandreChen committed Jan 3, 2023
1 parent f84dbea commit bf52ffb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions storage/tianmu/core/tianmu_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,19 @@ void TianmuTable::Alter(const std::string &table_path, std::vector<Field *> &new
for (auto &p : fs::directory_iterator(tmp_dir / common::COLUMN_DIR)) fs::remove(p);

TABLE_META meta;
system::TianmuFile f;
f.OpenReadOnly(tab_dir / common::TABLE_DESC_FILE);
f.ReadExact(&meta, sizeof(meta));
{
system::TianmuFile f;
f.OpenReadOnly(tab_dir / common::TABLE_DESC_FILE);
f.ReadExact(&meta, sizeof(meta));
}
meta.id = ha_tianmu_engine_->GetNextTableId(); // only table id is updated

system::TianmuFile tempf;
tempf.OpenReadWrite(tmp_dir / common::TABLE_DESC_FILE);
tempf.WriteExact(&meta, sizeof(meta));
tempf.Flush();
{
system::TianmuFile tempf;
tempf.OpenReadWrite(tmp_dir / common::TABLE_DESC_FILE);
tempf.WriteExact(&meta, sizeof(meta));
tempf.Flush();
}

std::vector<common::TX_ID> old_versions(old_cols.size());
{
Expand Down
5 changes: 3 additions & 2 deletions storage/tianmu/handler/ha_tianmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,16 +1642,17 @@ bool ha_tianmu::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha
}
} catch (std::exception &e) {
TIANMU_LOG(LogCtl_Level::ERROR, "An exception is caught: %s", e.what());
my_message(static_cast<int>(common::ErrorCode::UNKNOWN_ERROR), e.what(), MYF(0));
} catch (...) {
TIANMU_LOG(LogCtl_Level::ERROR, "An unknown system exception error caught.");
my_message(static_cast<int>(common::ErrorCode::UNKNOWN_ERROR), "Unable to inplace alter table", MYF(0));
}

// if catch exception, remove tmp dir
fs::path tmp_dir = table_name_ + ".tmp";
if (fs::exists(tmp_dir))
fs::remove_all(tmp_dir);

my_message(static_cast<int>(common::ErrorCode::UNKNOWN_ERROR), "Unable to inplace alter table", MYF(0));

DBUG_RETURN(true);
}

Expand Down

0 comments on commit bf52ffb

Please sign in to comment.