Commit 01f2fdde authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1869, move out of main. This change will not go in as is

git-svn-id: file:///svn/mysql/tokudb-engine/src@13487 c7de825b-a66e-492c-adef-691d508d4ae1
parent b17869b2
......@@ -1218,13 +1218,6 @@ int ha_tokudb::initialize_share(
init_auto_increment();
}
if (may_table_be_empty()) {
share->try_table_lock = true;
}
else {
share->try_table_lock = false;
}
error = 0;
exit:
my_free(newname, MYF(MY_ALLOW_ZERO_PTR));
......@@ -2359,61 +2352,12 @@ bool ha_tokudb::check_if_incompatible_data(HA_CREATE_INFO * info, uint table_cha
}
//
// This function returns true if the table MAY be empty.
// It is NOT meant to be a 100% check for emptiness.
// This is used for a bulk load optimization.
//
bool ha_tokudb::may_table_be_empty() {
int error;
bool ret_val = false;
DBC* tmp_cursor = NULL;
DB_TXN* txn = NULL;
error = db_env->txn_begin(db_env, 0, &txn, 0);
if (error) {
goto cleanup;
}
error = share->file->cursor(share->file, txn, &tmp_cursor, 0);
if (error) {
goto cleanup;
}
error = tmp_cursor->c_getf_next(tmp_cursor, 0, smart_dbt_opt_callback, NULL);
if (error == DB_NOTFOUND) {
ret_val = true;
}
else {
ret_val = false;
}
error = 0;
cleanup:
if (tmp_cursor) {
tmp_cursor->c_close(tmp_cursor);
tmp_cursor = NULL;
}
if (txn) {
int r = txn->commit(txn, 0);
assert(r == 0);
txn = NULL;
}
return ret_val;
}
void ha_tokudb::start_bulk_insert(ha_rows rows) {
//
// make sure delay_auto_inc_update is true
//
delay_auto_inc_update = true;
auto_inc_update_req = false;
if (share->try_table_lock) {
if (may_table_be_empty()) {
acquire_table_lock(transaction, lock_write);
}
pthread_mutex_lock(&share->mutex);
share->try_table_lock = false;
pthread_mutex_unlock(&share->mutex);
}
}
int ha_tokudb::end_bulk_insert() {
......
......@@ -62,14 +62,6 @@ typedef struct st_tokudb_share {
MULTI_COL_PACK_INFO mcp_info[MAX_KEY+1];
COL_PACK_INFO* cp_info[MAX_KEY+1];
u_int32_t num_offset_bytes; //number of bytes needed to encode the offset
//
// we want the following optimization for bulk loads, if the table is empty,
// attempt to grab a table lock. emptiness check can be expensive,
// so we try it once for a table. After that, we keep this variable around
// to tell us to not try it again.
//
bool try_table_lock;
} TOKUDB_SHARE;
#define HA_TOKU_VERSION 2
......@@ -281,7 +273,7 @@ class ha_tokudb : public handler {
void set_query_columns(uint keynr);
int prelock_range ( const key_range *start_key, const key_range *end_key);
bool may_table_be_empty();
public:
ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg);
......
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