Skip to content

Commit

Permalink
feat(StoneDB 8.0): dd::Table * parameter is added by MySQL 8.0 in han…
Browse files Browse the repository at this point in the history
…dle api. (#595)

[summary]
1 Add 'dd::Table *' type parameter in tianmu engine to indicate the parameter;
  • Loading branch information
DandreChen committed Sep 29, 2022
1 parent fb4c729 commit bed66a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
10 changes: 6 additions & 4 deletions storage/tianmu/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ uint32_t Engine::GetNextTableId() {
return seq;
}

std::shared_ptr<TableOption> Engine::GetTableOption(const std::string &table, TABLE *form) {
std::shared_ptr<TableOption> Engine::GetTableOption(const std::string &table, TABLE *form, [[maybe_unused]] dd::Table *table_def) {
auto opt = std::make_shared<TableOption>();

int power = has_pack(form->s->comment);
Expand All @@ -604,7 +604,8 @@ std::shared_ptr<TableOption> Engine::GetTableOption(const std::string &table, TA
return opt;
}

void Engine::CreateTable(const std::string &table, TABLE *form) { RCTable::CreateNew(GetTableOption(table, form)); }
void Engine::CreateTable(const std::string &table, TABLE *form, [[maybe_unused]] dd::Table *table_def) {
RCTable::CreateNew(GetTableOption(table, form, table_def)); }

AttributeTypeInfo Engine::GetAttrTypeInfo(const Field &field) {
bool auto_inc = field.is_flag_set(AUTO_INCREMENT_FLAG);
Expand Down Expand Up @@ -748,7 +749,7 @@ void Engine::Rollback(THD *thd, bool all, bool force_error_message) {
thd->transaction_rollback_request = false;
}

void Engine::DeleteTable(const char *table, [[maybe_unused]] THD *thd) {
void Engine::DeleteTable(const char *table, [[maybe_unused]] const dd::Table *table_def, [[maybe_unused]] THD *thd) {
{
std::unique_lock<std::shared_mutex> index_guard(tables_keys_mutex);
index::RCTableIndex::DropIndexTable(table);
Expand All @@ -775,7 +776,7 @@ void Engine::DeleteTable(const char *table, [[maybe_unused]] THD *thd) {
TIANMU_LOG(LogCtl_Level::INFO, "Drop table %s, ID = %u", table, id);
}

void Engine::TruncateTable(const std::string &table_path, [[maybe_unused]] THD *thd) {
void Engine::TruncateTable(const std::string &table_path, [[maybe_unused]] dd::Table *table_def, [[maybe_unused]] THD *thd) {
auto indextab = GetTableIndex(table_path);
if (indextab != nullptr) {
indextab->TruncateIndexTable();
Expand Down Expand Up @@ -1056,6 +1057,7 @@ int get_parameter(THD *thd, enum tianmu_var_name vn, longlong &result, std::stri
}

void Engine::RenameTable([[maybe_unused]] Transaction *trans_, const std::string &from, const std::string &to,
[[maybe_unused]] const dd::Table *from_table_def, [[maybe_unused]] dd::Table *to_table_def,
[[maybe_unused]] THD *thd) {
UnRegisterTable(from);
auto id = RCTable::GetTableId(from + common::TIANMU_EXT);
Expand Down
10 changes: 5 additions & 5 deletions storage/tianmu/core/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class Engine final {
~Engine();

int Init(uint engine_slot);
void CreateTable(const std::string &table, TABLE *from);
void DeleteTable(const char *table, THD *thd);
void TruncateTable(const std::string &table_path, THD *thd);
void RenameTable(Transaction *trans_, const std::string &from, const std::string &to, THD *thd);
void CreateTable(const std::string &table, TABLE *from, dd::Table *table_def);
void DeleteTable(const char *table, const dd::Table *table_def, THD *thd);
void TruncateTable(const std::string &table_path, dd::Table *table_def, THD *thd);
void RenameTable(Transaction *trans_, const std::string &from, const std::string &to, const dd::Table *from_table_def, dd::Table *to_table_def, THD *thd);
void PrepareAlterTable(const std::string &table_path, std::vector<Field *> &new_cols, std::vector<Field *> &old_cols,
THD *thd);

Expand Down Expand Up @@ -171,7 +171,7 @@ class Engine final {
static std::unique_ptr<system::IOParameters> CreateIOParameters(const std::string &path, void *arg);
static std::unique_ptr<system::IOParameters> CreateIOParameters(THD *thd, TABLE *table, void *arg);
void LogStat();
std::shared_ptr<TableOption> GetTableOption(const std::string &table, TABLE *form);
std::shared_ptr<TableOption> GetTableOption(const std::string &table, TABLE *form, dd::Table *table_def);
std::shared_ptr<TableShare> getTableShare(const std::string &table_path);
void ProcessDelayedInsert();
void ProcessDelayedMerge();
Expand Down
8 changes: 4 additions & 4 deletions storage/tianmu/handler/tianmu_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ int TianmuHandler::delete_all_rows() {
int TianmuHandler::rename_table(const char *from, const char *to, const dd::Table *from_table_def,
dd::Table *to_table_def) { // stonedb8 TODO
try {
ha_rcengine_->RenameTable(current_txn_, from, to, ha_thd());
ha_rcengine_->RenameTable(current_txn_, from, to, from_table_def, to_table_def, ha_thd());
return 0;
} catch (std::exception &e) {
my_message(static_cast<int>(common::ErrorCode::UNKNOWN_ERROR), e.what(), MYF(0));
Expand Down Expand Up @@ -1156,7 +1156,7 @@ int TianmuHandler::delete_table(const char *name, const dd::Table *table_def) {
DBUG_ENTER(__PRETTY_FUNCTION__);
int ret = 1;
try {
ha_rcengine_->DeleteTable(name, ha_thd());
ha_rcengine_->DeleteTable(name, table_def, ha_thd());
ret = 0;
} catch (std::exception &e) {
my_message(static_cast<int>(common::ErrorCode::UNKNOWN_ERROR), e.what(), MYF(0));
Expand Down Expand Up @@ -1196,7 +1196,7 @@ int TianmuHandler::create(const char *name, TABLE *table_arg, [[maybe_unused]] H
dd::Table *table_def) { // stonedb8 TODO
DBUG_ENTER(__PRETTY_FUNCTION__);
try {
ha_rcengine_->CreateTable(name, table_arg);
ha_rcengine_->CreateTable(name, table_arg, table_def);
DBUG_RETURN(0);
} catch (common::AutoIncException &e) {
my_message(ER_WRONG_AUTO_KEY, e.what(), MYF(0));
Expand All @@ -1219,7 +1219,7 @@ int TianmuHandler::create(const char *name, TABLE *table_arg, [[maybe_unused]] H
int TianmuHandler::truncate(dd::Table *table_def) { // stonedb8 TODO
int ret = 0;
try {
ha_rcengine_->TruncateTable(m_table_name, ha_thd());
ha_rcengine_->TruncateTable(m_table_name, table_def, ha_thd());
} catch (std::exception &e) {
TIANMU_LOG(LogCtl_Level::ERROR, "An exception is caught: %s", e.what());
ret = 1;
Expand Down

0 comments on commit bed66a8

Please sign in to comment.