diff --git a/mysql-test/suite/tianmu/t/dropdb.testbak b/mysql-test/suite/tianmu/t/dropdb.test similarity index 100% rename from mysql-test/suite/tianmu/t/dropdb.testbak rename to mysql-test/suite/tianmu/t/dropdb.test diff --git a/sql/handler.cc b/sql/handler.cc index 4ef1914c8..bd7f02484 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -854,8 +854,8 @@ int ha_initialize_handlerton(st_plugin_int *plugin) { case DB_TYPE_INNODB: innodb_hton = hton; break; - case DB_TYPE_TIANMU: // stonedb8 - tianmu_hton = hton; // stonedb8 + case DB_TYPE_TIANMU: + tianmu_hton = hton; break; default: break; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5ef5ee2fb..a7aaf3e48 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1231,7 +1231,7 @@ handlerton *heap_hton; handlerton *temptable_hton; handlerton *myisam_hton; handlerton *innodb_hton; -handlerton *tianmu_hton; // stonedb8 +handlerton *tianmu_hton; char *opt_disabled_storage_engines; uint opt_server_id_bits = 0; diff --git a/sql/mysqld.h b/sql/mysqld.h index f51e780ff..e6177877e 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -379,7 +379,7 @@ extern handlerton *myisam_hton; extern handlerton *heap_hton; extern handlerton *temptable_hton; extern handlerton *innodb_hton; -extern handlerton *tianmu_hton; // stonedb8 +extern handlerton *tianmu_hton; extern uint opt_server_id_bits; extern ulong opt_server_id_mask; diff --git a/storage/tianmu/core/engine.cpp b/storage/tianmu/core/engine.cpp index 401e77ad9..12032a2b4 100644 --- a/storage/tianmu/core/engine.cpp +++ b/storage/tianmu/core/engine.cpp @@ -822,7 +822,7 @@ void Engine::UpdateAndStoreColumnComment(TABLE *table, int field_id, Field *sour CHARSET_INFO *cs) { // stonedb8 start convert orig_table to table, MySQL 8.0 don't have orig_table, idea from // ha_innodb.cc:create_table_def - if (source_field->table->s->db_type() == rcbase_hton) { // do not use table (cont. default values) + if (source_field->table->s->db_type() == tianmu_hton) { // do not use table (cont. default values) char buf_size[256] = {0}; char buf_ratio[256] = {0}; uint buf_size_count = 0; @@ -1609,7 +1609,7 @@ Query_Route_To Engine::RouteTo(THD *thd, TABLE_LIST *table_list, Query_block *se } bool Engine::IsTianmuTable(TABLE *table) { - return table && table->s->db_type() == rcbase_hton; // table->db_type is always NULL + return table && table->s->db_type() == tianmu_hton; // table->db_type is always NULL } const char *Engine::GetFilename(Query_block *selects_list, int &is_dumpfile) { // stonedb8 diff --git a/storage/tianmu/core/engine.h b/storage/tianmu/core/engine.h index 22bd000ca..bf8d96109 100644 --- a/storage/tianmu/core/engine.h +++ b/storage/tianmu/core/engine.h @@ -43,7 +43,6 @@ #include "util/mapped_circular_buffer.h" #include "util/thread_pool.h" -extern handlerton *rcbase_hton; class Field; namespace Tianmu { diff --git a/storage/tianmu/handler/ha_rcengine.cpp b/storage/tianmu/handler/ha_rcengine.cpp index 84a0843cb..d5debcdc4 100644 --- a/storage/tianmu/handler/ha_rcengine.cpp +++ b/storage/tianmu/handler/ha_rcengine.cpp @@ -26,7 +26,6 @@ #include "mm/initializer.h" #include "system/file_out.h" -handlerton *rcbase_hton; struct SYS_VAR { MYSQL_PLUGIN_VAR_HEADER; @@ -184,23 +183,32 @@ static int init_variables() { return 0; } +// Gives the file extension of an Tianmu single-table tablespace. +static const char *ha_tianmu_exts[] = {common::TIANMU_EXT, NullS}; + int rcbase_init_func(void *p) { DBUG_ENTER(__PRETTY_FUNCTION__); - rcbase_hton = (handlerton *)p; + + // move hton here, just like other storate like innodb, myisam, csv... does. + // handlerton is a singleton structure - one instance per storage engine. + // defined in sql/handler.h + handlerton *tianmu_hton; + tianmu_hton = (handlerton *)p; if (init_variables()) { DBUG_RETURN(1); } - rcbase_hton->state = SHOW_OPTION_YES; - rcbase_hton->db_type = DB_TYPE_TIANMU; - rcbase_hton->create = rcbase_create_handler; - rcbase_hton->flags = HTON_NO_FLAGS; - rcbase_hton->panic = rcbase_panic_func; - rcbase_hton->close_connection = rcbase_close_connection; - rcbase_hton->commit = rcbase_commit; - rcbase_hton->rollback = rcbase_rollback; - rcbase_hton->show_status = rcbase_show_status; + tianmu_hton->state = SHOW_OPTION_YES; + tianmu_hton->db_type = DB_TYPE_TIANMU; + tianmu_hton->create = rcbase_create_handler; + tianmu_hton->flags = HTON_NO_FLAGS; + tianmu_hton->panic = rcbase_panic_func; + tianmu_hton->close_connection = rcbase_close_connection; + tianmu_hton->commit = rcbase_commit; + tianmu_hton->rollback = rcbase_rollback; + tianmu_hton->show_status = rcbase_show_status; + tianmu_hton->file_extensions = ha_tianmu_exts; // When mysqld runs as bootstrap mode, we do not need to initialize // memmanager. @@ -222,7 +230,7 @@ int rcbase_init_func(void *p) { ha_kvstore_ = new index::KVStore(); ha_kvstore_->Init(); ha_rcengine_ = new core::Engine(); - ret = ha_rcengine_->Init(rcbase_hton->slot); // stonedb8 + ret = ha_rcengine_->Init(tianmu_hton->slot); { TIANMU_LOG(LogCtl_Level::INFO, "\n" diff --git a/storage/tianmu/handler/ha_tianmu.cpp b/storage/tianmu/handler/ha_tianmu.cpp index 3ce0ebe69..762fe96ff 100644 --- a/storage/tianmu/handler/ha_tianmu.cpp +++ b/storage/tianmu/handler/ha_tianmu.cpp @@ -159,14 +159,6 @@ TianmuHandler::TianmuHandler(handlerton *hton, TABLE_SHARE *table_arg, bool part ref_length = sizeof(uint64_t); } -// stonedb8 -/* -const char **TianmuHandler::bas_ext() const { - static const char *ha_rcbase_exts[] = {common::TIANMU_EXT, 0}; - return ha_rcbase_exts; -} -*/ - namespace { std::vector GetAttrsUseIndicator(TABLE *table) { int col_id = 0; @@ -272,9 +264,9 @@ int TianmuHandler::external_lock(THD *thd, int lock_type) { tx->AddTableRD(share); } else { tx->AddTableWR(share); - trans_register_ha(thd, false, rcbase_hton, NULL); + trans_register_ha(thd, false, tianmu_hton, NULL); if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) - trans_register_ha(thd, true, rcbase_hton, NULL); + trans_register_ha(thd, true, tianmu_hton, NULL); } } ret = 0; @@ -1106,9 +1098,9 @@ int TianmuHandler::extra([[maybe_unused]] enum ha_extra_function operation) { int TianmuHandler::start_stmt(THD *thd, thr_lock_type lock_type) { try { if (lock_type == TL_WRITE_CONCURRENT_INSERT || lock_type == TL_WRITE_DEFAULT || lock_type == TL_WRITE) { - trans_register_ha(thd, false, rcbase_hton, NULL); + trans_register_ha(thd, false, tianmu_hton, NULL); if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { - trans_register_ha(thd, true, rcbase_hton, NULL); + trans_register_ha(thd, true, tianmu_hton, NULL); } current_txn_ = ha_rcengine_->GetTx(thd); current_txn_->AddTableWRIfNeeded(share); @@ -1146,7 +1138,7 @@ bool TianmuHandler::register_query_cache_table(THD *thd, char *table_key, size_t If you do not implement this, the default delete_table() is called from handler.cc and it will delete all files with the file extentions returned - by bas_ext(). + by bas_ext(). // stonedb8 TODO bas_ext() has been deleted in mysql8.0 Called from handler.cc by delete_table and ha_create_table(). Only used during create if the table_flag HA_DROP_BEFORE_CREATE was specified for @@ -1687,4 +1679,4 @@ void TianmuHandler::key_convert(const uchar *key, uint key_len, std::vector