-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dict_register_dd_table_id api support for rocksdb dd (#1298)
Summary: We are adding support for data dictionary related rocksdb_hton functions. This will include the current diff and couple of following diffs. Each diff will add support for one or several rocksdb_hton function. This current adds support for rocksdb_hton->dict_register_dd_table_id. It contains several part 1. Add a rdb_native_dd file. The file is dedicated to rocksdb data dictionary related function and objects. 2. Add dd table check in rename_table/delete_table/truncate_table. These table operations are not allowed for dd tables. Fail the operation if it's operated on dd tables. 3. Maintain a dd table id set. Pull Request resolved: #1298 Reviewed By: luqun Differential Revision: D45332365 Pulled By: sunshine-Chun fbshipit-source-id: 95aebf8
- Loading branch information
1 parent
35a178a
commit 1a0f581
Showing
5 changed files
with
134 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
Copyright (c) 2023 Meta, Inc | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
|
||
/* This C++ file's header file */ | ||
#include "rdb_native_dd.h" | ||
|
||
/* MySQL header files */ | ||
#include "sql/dd/types/table.h" // dd::Table | ||
|
||
/* MyRocks header files */ | ||
#include "ha_rocksdb.h" | ||
|
||
namespace myrocks { | ||
std::unordered_set<dd::Object_id> native_dd::s_dd_table_ids = {}; | ||
|
||
bool native_dd::is_dd_table_id(dd::Object_id id) { | ||
return (native_dd::s_dd_table_ids.find(id) != | ||
native_dd::s_dd_table_ids.end()); | ||
} | ||
|
||
int native_dd::reject_if_dd_table(const dd::Table *table_def) { | ||
if (table_def != nullptr && is_dd_table_id(table_def->se_private_id())) { | ||
my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); | ||
return HA_ERR_UNSUPPORTED; | ||
} | ||
|
||
return (0); | ||
} | ||
|
||
void native_dd::insert_dd_table_ids(dd::Object_id dd_table_id) { | ||
s_dd_table_ids.insert(dd_table_id); | ||
} | ||
|
||
void native_dd::clear_dd_table_ids() { s_dd_table_ids.clear(); } | ||
|
||
void rocksdb_dict_register_dd_table_id(dd::Object_id dd_table_id) { | ||
native_dd::insert_dd_table_ids(dd_table_id); | ||
}; | ||
|
||
} // namespace myrocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright (c) 2023 Meta, Inc | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
#pragma once | ||
|
||
/* C++ standard header files */ | ||
#include <unordered_set> | ||
|
||
/* MySQL header files */ | ||
#include "sql/dd/object_id.h" | ||
|
||
namespace dd { | ||
class Table; | ||
} | ||
|
||
namespace myrocks { | ||
|
||
void rocksdb_dict_register_dd_table_id(dd::Object_id dd_table_id); | ||
|
||
class native_dd { | ||
private: | ||
/* Set of ids of DD tables */ | ||
static std::unordered_set<dd::Object_id> s_dd_table_ids; | ||
|
||
public: | ||
static bool is_dd_table_id(dd::Object_id id); | ||
|
||
static void insert_dd_table_ids(dd::Object_id dd_table_id); | ||
|
||
static void clear_dd_table_ids(); | ||
|
||
static int reject_if_dd_table(const dd::Table *table_def); | ||
}; | ||
|
||
} // namespace myrocks |