Commit 7e71d5fd authored by Rich Prohaska's avatar Rich Prohaska

#142 remove tokudb meta dictionary

parent dde0c435
......@@ -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,133 +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;
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;
}
return error;
}
static int create_tokudb_trx_data_instance(tokudb_trx_data** out_trx) {
int error;
tokudb_trx_data* trx = NULL;
......@@ -1707,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();
......@@ -1724,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;
......@@ -7085,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) {
......@@ -7210,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,
......
......@@ -170,7 +170,6 @@ 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;
......@@ -309,7 +308,6 @@ static int tokudb_init_func(void *p) {
assert(r == 0);
db_env = NULL;
metadata_db = NULL;
tokudb_hton = (handlerton *) p;
......@@ -504,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
......@@ -541,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);
......@@ -586,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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment