From 88b36f4713cd1ff371319e135d75bfea66334496 Mon Sep 17 00:00:00 2001 From: Chun Ni Date: Mon, 24 Apr 2023 13:26:32 -0700 Subject: [PATCH] Add ddst_dict_init api support for rocksdb dd Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- storage/rocksdb/ha_rocksdb.cc | 4 +++- storage/rocksdb/rdb_native_dd.cc | 23 +++++++++++++++++++++++ storage/rocksdb/rdb_native_dd.h | 7 +++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index d0ab517a4823..b7f29c6e28b4 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -56,6 +56,7 @@ #include "sql/dd/dictionary.h" // dd::Dictionary #include "sql/debug_sync.h" #include "sql/json_dom.h" +#include "sql/plugin_table.h" #include "sql/sql_audit.h" #include "sql/sql_class.h" #include "sql/sql_lex.h" @@ -7434,6 +7435,7 @@ static int rocksdb_init_internal(void *const p) { rocksdb_hton->clone_interface.clone_apply_end = rocksdb_clone_apply_end; rocksdb_hton->dict_register_dd_table_id = rocksdb_dict_register_dd_table_id; + rocksdb_hton->ddse_dict_init = rocksdb_ddse_dict_init; rocksdb_hton->flags = HTON_SUPPORTS_EXTENDED_KEYS | HTON_CAN_RECREATE; @@ -19036,7 +19038,7 @@ bool ha_rocksdb::get_se_private_data(dd::Table *, bool reset) { if (reset) { native_dd::clear_dd_table_ids(); } - + return false; } diff --git a/storage/rocksdb/rdb_native_dd.cc b/storage/rocksdb/rdb_native_dd.cc index 9e0e3d1fc598..0356621dc90c 100644 --- a/storage/rocksdb/rdb_native_dd.cc +++ b/storage/rocksdb/rdb_native_dd.cc @@ -22,6 +22,7 @@ /* MyRocks header files */ #include "ha_rocksdb.h" +#include "sql/plugin_table.h" namespace myrocks { std::unordered_set native_dd::s_dd_table_ids = {}; @@ -50,4 +51,26 @@ void rocksdb_dict_register_dd_table_id(dd::Object_id dd_table_id) { native_dd::insert_dd_table_ids(dd_table_id); }; +bool rocksdb_ddse_dict_init( + dict_init_mode_t dict_init_mode, uint, + [[maybe_unused]] List *tables, + List *tablespaces) { + // TODO: Remove assert(false); once we add the full rocksdb dd support + assert(false); + + assert(tables); + assert(tables->is_empty()); + assert(tablespaces); + assert(tablespaces->is_empty()); + + assert(dict_init_mode == DICT_INIT_CREATE_FILES || + dict_init_mode == DICT_INIT_CHECK_FILES); + + static Plugin_tablespace dd_space(rocksdb_dd_space_name, "", "", "", + rocksdb_hton_name); + tablespaces->push_back(&dd_space); + + return false; +} + } // namespace myrocks diff --git a/storage/rocksdb/rdb_native_dd.h b/storage/rocksdb/rdb_native_dd.h index 72673689b0c6..0ec05f0e9a76 100644 --- a/storage/rocksdb/rdb_native_dd.h +++ b/storage/rocksdb/rdb_native_dd.h @@ -20,6 +20,7 @@ /* MySQL header files */ #include "sql/dd/object_id.h" +#include "sql/handler.h" namespace dd { class Table; @@ -27,8 +28,14 @@ class Table; namespace myrocks { +constexpr const char *rocksdb_dd_space_name = "mysql"; + void rocksdb_dict_register_dd_table_id(dd::Object_id dd_table_id); +bool rocksdb_ddse_dict_init(dict_init_mode_t dict_init_mode, uint version, + List *tables, + List *tablespaces); + class native_dd { private: /* Set of ids of DD tables */