Commit a65d9efc authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:2549], add Martin option

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@19652 c7de825b-a66e-492c-adef-691d508d4ae1
parent 19d70153
...@@ -2814,16 +2814,17 @@ bool ha_tokudb::may_table_be_empty() { ...@@ -2814,16 +2814,17 @@ bool ha_tokudb::may_table_be_empty() {
} }
void ha_tokudb::start_bulk_insert(ha_rows rows) { void ha_tokudb::start_bulk_insert(ha_rows rows) {
TOKUDB_DBUG_ENTER("ha_tokudb::start_bulk_insert");
THD* thd = ha_thd();
delay_updating_ai_metadata = true; delay_updating_ai_metadata = true;
ai_metadata_update_required = false; ai_metadata_update_required = false;
abort_loader = false; abort_loader = false;
if (share->try_table_lock) { if (share->try_table_lock) {
if (tokudb_prelock_empty && may_table_be_empty()) { if (tokudb_prelock_empty && may_table_be_empty()) {
if (using_ignore) { if (using_ignore || get_load_save_space(thd)) {
acquire_table_lock(transaction, lock_write); acquire_table_lock(transaction, lock_write);
} }
else { else {
THD* thd = ha_thd();
u_int32_t mult_put_flags[MAX_KEY + 1] = {DB_YESOVERWRITE}; u_int32_t mult_put_flags[MAX_KEY + 1] = {DB_YESOVERWRITE};
u_int32_t mult_dbt_flags[MAX_KEY + 1] = {DB_DBT_REALLOC}; u_int32_t mult_dbt_flags[MAX_KEY + 1] = {DB_DBT_REALLOC};
uint curr_num_DBs = table->s->keys + test(hidden_primary_key); uint curr_num_DBs = table->s->keys + test(hidden_primary_key);
...@@ -2858,6 +2859,7 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) { ...@@ -2858,6 +2859,7 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) {
share->try_table_lock = false; share->try_table_lock = false;
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
} }
DBUG_VOID_RETURN;
} }
// //
...@@ -2866,6 +2868,7 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) { ...@@ -2866,6 +2868,7 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) {
// this is guaranteed to be called. // this is guaranteed to be called.
// //
int ha_tokudb::end_bulk_insert() { int ha_tokudb::end_bulk_insert() {
TOKUDB_DBUG_ENTER("ha_tokudb::end_bulk_insert");
int error = 0; int error = 0;
if (ai_metadata_update_required) { if (ai_metadata_update_required) {
pthread_mutex_lock(&share->mutex); pthread_mutex_lock(&share->mutex);
...@@ -2916,7 +2919,7 @@ int ha_tokudb::end_bulk_insert() { ...@@ -2916,7 +2919,7 @@ int ha_tokudb::end_bulk_insert() {
if (error || loader_error) { if (error || loader_error) {
my_errno = error ? error : loader_error; my_errno = error ? error : loader_error;
} }
return error ? error : loader_error; TOKUDB_DBUG_RETURN(error ? error : loader_error);
} }
...@@ -6239,6 +6242,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -6239,6 +6242,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
THD* thd = ha_thd(); THD* thd = ha_thd();
DB_LOADER* loader = NULL; DB_LOADER* loader = NULL;
u_int32_t loader_flags = (get_load_save_space(thd)) ? LOADER_USE_PUTS : 0;
u_int32_t mult_put_flags[MAX_KEY + 1] = {DB_YESOVERWRITE}; u_int32_t mult_put_flags[MAX_KEY + 1] = {DB_YESOVERWRITE};
u_int32_t mult_dbt_flags[MAX_KEY + 1] = {DB_DBT_REALLOC}; u_int32_t mult_dbt_flags[MAX_KEY + 1] = {DB_DBT_REALLOC};
struct loader_context lc = {0}; struct loader_context lc = {0};
...@@ -6352,7 +6356,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -6352,7 +6356,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
&share->key_file[curr_num_DBs], &share->key_file[curr_num_DBs],
mult_put_flags, mult_put_flags,
mult_dbt_flags, mult_dbt_flags,
0 loader_flags
); );
if (error) { goto cleanup; } if (error) { goto cleanup; }
......
...@@ -84,6 +84,14 @@ static MYSQL_THDVAR_UINT(pk_insert_mode, ...@@ -84,6 +84,14 @@ static MYSQL_THDVAR_UINT(pk_insert_mode,
1 // blocksize 1 // blocksize
); );
static MYSQL_THDVAR_BOOL(load_save_space,
0,
"if on, intial loads are slower but take less space",
NULL,
NULL,
FALSE
);
static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer); static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer);
static void tokudb_cleanup_log_files(void); static void tokudb_cleanup_log_files(void);
...@@ -486,6 +494,10 @@ uint get_pk_insert_mode(THD* thd) { ...@@ -486,6 +494,10 @@ uint get_pk_insert_mode(THD* thd) {
return THDVAR(thd, pk_insert_mode); return THDVAR(thd, pk_insert_mode);
} }
bool get_load_save_space(THD* thd) {
return (THDVAR(thd, load_save_space) != 0);
}
typedef struct txn_progress_info { typedef struct txn_progress_info {
char status[200]; char status[200];
...@@ -1159,6 +1171,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { ...@@ -1159,6 +1171,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(write_lock_wait), MYSQL_SYSVAR(write_lock_wait),
MYSQL_SYSVAR(read_lock_wait), MYSQL_SYSVAR(read_lock_wait),
MYSQL_SYSVAR(pk_insert_mode), MYSQL_SYSVAR(pk_insert_mode),
MYSQL_SYSVAR(load_save_space),
MYSQL_SYSVAR(version), MYSQL_SYSVAR(version),
MYSQL_SYSVAR(init_flags), MYSQL_SYSVAR(init_flags),
MYSQL_SYSVAR(checkpointing_period), MYSQL_SYSVAR(checkpointing_period),
......
...@@ -14,6 +14,7 @@ extern DB *metadata_db; ...@@ -14,6 +14,7 @@ extern DB *metadata_db;
ulonglong get_write_lock_wait_time (THD* thd); ulonglong get_write_lock_wait_time (THD* thd);
ulonglong get_read_lock_wait_time (THD* thd); ulonglong get_read_lock_wait_time (THD* thd);
uint get_pk_insert_mode(THD* thd); uint get_pk_insert_mode(THD* thd);
bool get_load_save_space(THD* thd);
extern HASH tokudb_open_tables; extern HASH tokudb_open_tables;
extern pthread_mutex_t tokudb_mutex; extern pthread_mutex_t tokudb_mutex;
......
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