mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
Merge branch 'meta142'
This commit is contained in:
commit
e56f12d496
3 changed files with 3 additions and 215 deletions
|
@ -500,16 +500,6 @@ static int smart_dbt_do_nothing (DBT const *key, DBT const *row, void *context)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int smart_dbt_metacallback (DBT const *key, DBT const *row, void *context) {
|
||||
DBT* val = (DBT *)context;
|
||||
val->data = tokudb_my_malloc(row->size, MYF(MY_WME|MY_ZEROFILL));
|
||||
if (val->data == NULL) return ENOMEM;
|
||||
memcpy(val->data, row->data, row->size);
|
||||
val->size = row->size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
smart_dbt_callback_rowread_ptquery (DBT const *key, DBT const *row, void *context) {
|
||||
SMART_DBT_INFO info = (SMART_DBT_INFO)context;
|
||||
|
@ -991,135 +981,6 @@ static uchar* pack_toku_field_blob(
|
|||
return (to_tokudb + len_bytes + length);
|
||||
}
|
||||
|
||||
|
||||
static int add_table_to_metadata(const char *name, TABLE* table, DB_TXN* txn) {
|
||||
int error = 0;
|
||||
DBT key;
|
||||
DBT val;
|
||||
uchar hidden_primary_key = (table->s->primary_key >= MAX_KEY);
|
||||
assert(txn);
|
||||
|
||||
memset((void *)&key, 0, sizeof(key));
|
||||
memset((void *)&val, 0, sizeof(val));
|
||||
key.data = (void *)name;
|
||||
key.size = strlen(name) + 1;
|
||||
val.data = &hidden_primary_key;
|
||||
val.size = sizeof(hidden_primary_key);
|
||||
error = metadata_db->put(
|
||||
metadata_db,
|
||||
txn,
|
||||
&key,
|
||||
&val,
|
||||
0
|
||||
);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int drop_table_from_metadata(const char *name, DB_TXN* txn) {
|
||||
int error = 0;
|
||||
DBT key;
|
||||
DBT data;
|
||||
assert(txn);
|
||||
memset((void *)&key, 0, sizeof(key));
|
||||
memset((void *)&data, 0, sizeof(data));
|
||||
key.data = (void *)name;
|
||||
key.size = strlen(name) + 1;
|
||||
error = metadata_db->del(
|
||||
metadata_db,
|
||||
txn,
|
||||
&key ,
|
||||
DB_DELETE_ANY
|
||||
);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int rename_table_in_metadata(const char *from, const char *to, DB_TXN* txn) {
|
||||
int error = 0;
|
||||
DBT from_key;
|
||||
DBT to_key;
|
||||
DBT val;
|
||||
assert(txn);
|
||||
|
||||
memset((void *)&from_key, 0, sizeof(from_key));
|
||||
memset((void *)&to_key, 0, sizeof(to_key));
|
||||
memset((void *)&val, 0, sizeof(val));
|
||||
from_key.data = (void *)from;
|
||||
from_key.size = strlen(from) + 1;
|
||||
to_key.data = (void *)to;
|
||||
to_key.size = strlen(to) + 1;
|
||||
|
||||
error = metadata_db->getf_set(
|
||||
metadata_db,
|
||||
txn,
|
||||
0,
|
||||
&from_key,
|
||||
smart_dbt_metacallback,
|
||||
&val
|
||||
);
|
||||
|
||||
if (error) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
error = metadata_db->put(
|
||||
metadata_db,
|
||||
txn,
|
||||
&to_key,
|
||||
&val,
|
||||
0
|
||||
);
|
||||
if (error) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
error = metadata_db->del(
|
||||
metadata_db,
|
||||
txn,
|
||||
&from_key,
|
||||
DB_DELETE_ANY
|
||||
);
|
||||
if (error) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
|
||||
cleanup:
|
||||
tokudb_my_free(val.data);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static int check_table_in_metadata(const char *name, bool* table_found, DB_TXN* txn) {
|
||||
int error = 0;
|
||||
DBT key;
|
||||
pthread_mutex_lock(&tokudb_meta_mutex);
|
||||
memset((void *)&key, 0, sizeof(key));
|
||||
key.data = (void *)name;
|
||||
key.size = strlen(name) + 1;
|
||||
|
||||
error = metadata_db->getf_set(
|
||||
metadata_db,
|
||||
txn,
|
||||
0,
|
||||
&key,
|
||||
smart_dbt_do_nothing,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (error == 0) {
|
||||
*table_found = true;
|
||||
}
|
||||
else if (error == DB_NOTFOUND){
|
||||
*table_found = false;
|
||||
error = 0;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&tokudb_meta_mutex);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int create_tokudb_trx_data_instance(tokudb_trx_data** out_trx) {
|
||||
int error;
|
||||
tokudb_trx_data* trx = NULL;
|
||||
|
@ -1709,7 +1570,6 @@ int ha_tokudb::initialize_share(
|
|||
{
|
||||
int error = 0;
|
||||
uint64_t num_rows = 0;
|
||||
bool table_exists;
|
||||
DB_TXN* txn = NULL;
|
||||
bool do_commit = false;
|
||||
THD* thd = ha_thd();
|
||||
|
@ -1726,18 +1586,6 @@ int ha_tokudb::initialize_share(
|
|||
|
||||
DBUG_PRINT("info", ("share->use_count %u", share->use_count));
|
||||
|
||||
table_exists = true;
|
||||
error = check_table_in_metadata(name, &table_exists, txn);
|
||||
|
||||
if (error) {
|
||||
goto exit;
|
||||
}
|
||||
if (!table_exists) {
|
||||
sql_print_error("table %s does not exist in metadata, was it moved from someplace else? Not opening table", name);
|
||||
error = HA_ADMIN_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
error = get_status(txn);
|
||||
if (error) {
|
||||
goto exit;
|
||||
|
@ -6951,6 +6799,8 @@ static inline enum row_type row_format_to_row_type(srv_row_format_t row_format)
|
|||
return ROW_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
volatile int tokudb_create_wait = 0;
|
||||
|
||||
//
|
||||
// Creates a new table
|
||||
// Parameters:
|
||||
|
@ -6963,6 +6813,7 @@ static inline enum row_type row_format_to_row_type(srv_row_format_t row_format)
|
|||
//
|
||||
int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_info) {
|
||||
TOKUDB_DBUG_ENTER("ha_tokudb::create %p %s", this, name);
|
||||
while (tokudb_create_wait) sleep(1);
|
||||
int error;
|
||||
DB *status_block = NULL;
|
||||
uint version;
|
||||
|
@ -6976,8 +6827,6 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
|
|||
bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
|
||||
memset(&kc_info, 0, sizeof(kc_info));
|
||||
|
||||
pthread_mutex_lock(&tokudb_meta_mutex);
|
||||
|
||||
trx = (tokudb_trx_data *) thd_data_get(ha_thd(), tokudb_hton->slot);
|
||||
|
||||
const enum row_type row_type = ((create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)
|
||||
|
@ -7086,9 +6935,6 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
|
|||
}
|
||||
}
|
||||
|
||||
error = add_table_to_metadata(name, form, txn);
|
||||
if (error) { goto cleanup; }
|
||||
|
||||
error = 0;
|
||||
cleanup:
|
||||
if (status_block != NULL) {
|
||||
|
@ -7105,7 +6951,6 @@ cleanup:
|
|||
}
|
||||
}
|
||||
tokudb_my_free(newname);
|
||||
pthread_mutex_unlock(&tokudb_meta_mutex);
|
||||
TOKUDB_DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -7201,7 +7046,6 @@ int ha_tokudb::delete_or_rename_table (const char* from_name, const char* to_nam
|
|||
DBT curr_val;
|
||||
memset(&curr_key, 0, sizeof(curr_key));
|
||||
memset(&curr_val, 0, sizeof(curr_val));
|
||||
pthread_mutex_lock(&tokudb_meta_mutex);
|
||||
|
||||
DB_TXN *parent_txn = NULL;
|
||||
tokudb_trx_data *trx = NULL;
|
||||
|
@ -7213,17 +7057,6 @@ int ha_tokudb::delete_or_rename_table (const char* from_name, const char* to_nam
|
|||
error = txn_begin(db_env, parent_txn, &txn, 0, thd);
|
||||
if (error) { goto cleanup; }
|
||||
|
||||
//
|
||||
// modify metadata db
|
||||
//
|
||||
if (is_delete) {
|
||||
error = drop_table_from_metadata(from_name, txn);
|
||||
}
|
||||
else {
|
||||
error = rename_table_in_metadata(from_name, to_name, txn);
|
||||
}
|
||||
if (error) { goto cleanup; }
|
||||
|
||||
//
|
||||
// open status db,
|
||||
// create cursor,
|
||||
|
@ -7292,7 +7125,6 @@ cleanup:
|
|||
commit_txn(txn, 0);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&tokudb_meta_mutex);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,10 +170,8 @@ const char *ha_tokudb_ext = ".tokudb";
|
|||
char *tokudb_data_dir;
|
||||
ulong tokudb_debug;
|
||||
DB_ENV *db_env;
|
||||
DB* metadata_db;
|
||||
HASH tokudb_open_tables;
|
||||
pthread_mutex_t tokudb_mutex;
|
||||
pthread_mutex_t tokudb_meta_mutex;
|
||||
|
||||
#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
|
||||
static my_bool tokudb_gdb_on_fatal;
|
||||
|
@ -310,12 +308,10 @@ static int tokudb_init_func(void *p) {
|
|||
assert(r == 0);
|
||||
|
||||
db_env = NULL;
|
||||
metadata_db = NULL;
|
||||
|
||||
tokudb_hton = (handlerton *) p;
|
||||
|
||||
pthread_mutex_init(&tokudb_mutex, MY_MUTEX_INIT_FAST);
|
||||
pthread_mutex_init(&tokudb_meta_mutex, MY_MUTEX_INIT_FAST);
|
||||
(void) my_hash_init(&tokudb_open_tables, table_alias_charset, 32, 0, 0, (my_hash_get_key) tokudb_get_key, 0, 0);
|
||||
|
||||
tokudb_hton->state = SHOW_OPTION_YES;
|
||||
|
@ -506,35 +502,6 @@ static int tokudb_init_func(void *p) {
|
|||
toku_global_status_rows = (TOKU_ENGINE_STATUS_ROW_S*)tokudb_my_malloc(sizeof(*toku_global_status_rows)*toku_global_status_max_rows, mem_flags);
|
||||
}
|
||||
|
||||
r = db_create(&metadata_db, db_env, 0);
|
||||
if (r) {
|
||||
DBUG_PRINT("info", ("failed to create metadata db %d\n", r));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
r= metadata_db->open(metadata_db, NULL, TOKU_METADB_NAME, NULL, DB_BTREE, DB_THREAD, 0);
|
||||
if (r) {
|
||||
if (r != ENOENT) {
|
||||
sql_print_error("Got error %d when trying to open metadata_db", r);
|
||||
goto error;
|
||||
}
|
||||
r = metadata_db->close(metadata_db,0);
|
||||
assert(r == 0);
|
||||
r = db_create(&metadata_db, db_env, 0);
|
||||
if (r) {
|
||||
DBUG_PRINT("info", ("failed to create metadata db %d\n", r));
|
||||
goto error;
|
||||
}
|
||||
|
||||
r= metadata_db->open(metadata_db, NULL, TOKU_METADB_NAME, NULL, DB_BTREE, DB_THREAD | DB_CREATE | DB_EXCL, my_umask);
|
||||
if (r) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
tokudb_primary_key_bytes_inserted = create_partitioned_counter();
|
||||
|
||||
//3938: succeeded, set the init status flag and unlock
|
||||
|
@ -543,10 +510,6 @@ static int tokudb_init_func(void *p) {
|
|||
DBUG_RETURN(false);
|
||||
|
||||
error:
|
||||
if (metadata_db) {
|
||||
int rr = metadata_db->close(metadata_db, 0);
|
||||
assert(rr==0);
|
||||
}
|
||||
if (db_env) {
|
||||
int rr= db_env->close(db_env, 0);
|
||||
assert(rr==0);
|
||||
|
@ -567,7 +530,6 @@ static int tokudb_done_func(void *p) {
|
|||
toku_global_status_rows = NULL;
|
||||
my_hash_free(&tokudb_open_tables);
|
||||
pthread_mutex_destroy(&tokudb_mutex);
|
||||
pthread_mutex_destroy(&tokudb_meta_mutex);
|
||||
#if defined(_WIN64)
|
||||
toku_ydb_destroy();
|
||||
#endif
|
||||
|
@ -589,10 +551,6 @@ int tokudb_end(handlerton * hton, ha_panic_function type) {
|
|||
rw_wrlock(&tokudb_hton_initialized_lock);
|
||||
assert(tokudb_hton_initialized);
|
||||
|
||||
if (metadata_db) {
|
||||
int r = metadata_db->close(metadata_db, 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
if (db_env) {
|
||||
if (tokudb_init_flags & DB_INIT_LOG)
|
||||
tokudb_cleanup_log_files();
|
||||
|
|
|
@ -96,7 +96,6 @@ PATENT RIGHTS GRANT:
|
|||
extern handlerton *tokudb_hton;
|
||||
|
||||
extern DB_ENV *db_env;
|
||||
extern DB *metadata_db;
|
||||
|
||||
enum srv_row_format_enum {
|
||||
SRV_ROW_FORMAT_UNCOMPRESSED = 0,
|
||||
|
@ -379,7 +378,6 @@ static uint64_t tokudb_get_loader_memory_size_callback(void) {
|
|||
|
||||
extern HASH tokudb_open_tables;
|
||||
extern pthread_mutex_t tokudb_mutex;
|
||||
extern pthread_mutex_t tokudb_meta_mutex;
|
||||
extern uint32_t tokudb_write_status_frequency;
|
||||
extern uint32_t tokudb_read_status_frequency;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue