#include "binding.hpp"
#include "my_dbug.h"
#include "rust_callbacks.hpp"
#include "safe_name.hpp"
bool RustHandlerBase::bulk_load_check(THD *thd) const {
DBUG_TRACE;
if (!rust_ctx_) return false;
return rust__handler__bulk_load_check(rust_ctx_,
static_cast<const void *>(thd));
}
size_t RustHandlerBase::bulk_load_available_memory(THD *thd) const {
DBUG_TRACE;
if (!rust_ctx_) return 0;
return rust__handler__bulk_load_available_memory(
rust_ctx_, static_cast<const void *>(thd));
}
void *RustHandlerBase::bulk_load_begin(THD *thd, size_t data_size,
size_t memory, size_t num_threads) {
DBUG_TRACE;
if (!rust_ctx_) return nullptr;
return rust__handler__bulk_load_begin(rust_ctx_,
static_cast<const void *>(thd),
data_size, memory, num_threads);
}
int RustHandlerBase::bulk_load_execute(THD *thd, void *load_ctx,
size_t thread_idx,
const Rows_mysql &rows,
Bulk_load::Stat_callbacks &wait_cbk) {
DBUG_TRACE;
if (!rust_ctx_) return HA_ERR_INTERNAL_ERROR;
return rust__handler__bulk_load_execute(
rust_ctx_, static_cast<const void *>(thd), load_ctx, thread_idx,
static_cast<const void *>(&rows), static_cast<const void *>(&wait_cbk));
}
int RustHandlerBase::bulk_load_end(THD *thd, void *load_ctx, bool is_error) {
DBUG_TRACE;
if (!rust_ctx_) return HA_ERR_INTERNAL_ERROR;
return rust__handler__bulk_load_end(
rust_ctx_, static_cast<const void *>(thd), load_ctx, is_error);
}
int RustHandlerBase::load_table(const TABLE &table,
bool *skip_metadata_update) {
DBUG_TRACE;
if (!rust_ctx_) return HA_ERR_INTERNAL_ERROR;
return rust__handler__load_table(rust_ctx_,
static_cast<const void *>(&table),
skip_metadata_update);
}
int RustHandlerBase::unload_table(const char *db_name, const char *table_name,
bool error_if_not_loaded) {
DBUG_TRACE;
if (!rust_ctx_ || !db_name || !table_name) return HA_ERR_INTERNAL_ERROR;
return rust__handler__unload_table(
rust_ctx_, reinterpret_cast<const uint8_t *>(db_name),
shim::safe_name_len(db_name),
reinterpret_cast<const uint8_t *>(table_name),
shim::safe_name_len(table_name), error_if_not_loaded);
}