#include "binding.hpp"
#include "my_dbug.h"
#include "rust_callbacks.hpp"
#include "safe_name.hpp"
int RustHandlerBase::delete_table(const char *name,
const dd::Table *table_def) {
DBUG_TRACE;
if (!rust_ctx_ || !name) return HA_ERR_INTERNAL_ERROR;
return rust__handler__delete_table(
rust_ctx_, reinterpret_cast<const uint8_t *>(name),
shim::safe_name_len(name), static_cast<const void *>(table_def));
}
int RustHandlerBase::rename_table(const char *from, const char *to,
const dd::Table *from_table_def,
dd::Table *to_table_def) {
DBUG_TRACE;
if (!rust_ctx_ || !from || !to) return HA_ERR_INTERNAL_ERROR;
return rust__handler__rename_table(
rust_ctx_, reinterpret_cast<const uint8_t *>(from),
shim::safe_name_len(from), reinterpret_cast<const uint8_t *>(to),
shim::safe_name_len(to), static_cast<const void *>(from_table_def),
static_cast<const void *>(to_table_def));
}
void RustHandlerBase::drop_table(const char *name) {
DBUG_TRACE;
if (!name) return;
handler::drop_table(name);
if (!rust_ctx_) return;
rust__handler__drop_table(rust_ctx_,
reinterpret_cast<const uint8_t *>(name),
shim::safe_name_len(name));
}
int RustHandlerBase::truncate(dd::Table *table_def) {
DBUG_TRACE;
if (!rust_ctx_) return HA_ERR_INTERNAL_ERROR;
return rust__handler__truncate(rust_ctx_,
static_cast<const void *>(table_def));
}
void RustHandlerBase::change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) {
DBUG_TRACE;
handler::change_table_ptr(table_arg, share);
if (!rust_ctx_) return;
rust__handler__change_table_ptr(rust_ctx_, table_arg, share);
}
bool RustHandlerBase::get_se_private_data(dd::Table *dd_table, bool reset) {
DBUG_TRACE;
if (!rust_ctx_) return false;
return rust__handler__get_se_private_data(
rust_ctx_, static_cast<const void *>(dd_table), reset);
}
int RustHandlerBase::get_extra_columns_and_keys(
const HA_CREATE_INFO *create_info, const List<Create_field> *create_list,
const KEY *key_info, uint key_count, dd::Table *table_obj) {
DBUG_TRACE;
if (!rust_ctx_) return HA_ERR_INTERNAL_ERROR;
return rust__handler__get_extra_columns_and_keys(
rust_ctx_, static_cast<const void *>(create_info),
static_cast<const void *>(create_list),
static_cast<const void *>(key_info), key_count,
static_cast<const void *>(table_obj));
}
bool RustHandlerBase::upgrade_table(THD *thd, const char *dbname,
const char *table_name,
dd::Table *dd_table) {
DBUG_TRACE;
if (!rust_ctx_) return true;
if (!dbname || !table_name) return true;
return rust__handler__upgrade_table(
rust_ctx_, static_cast<const void *>(thd),
reinterpret_cast<const uint8_t *>(dbname), shim::safe_name_len(dbname),
reinterpret_cast<const uint8_t *>(table_name),
shim::safe_name_len(table_name), static_cast<const void *>(dd_table));
}