Commit 8b112ba2 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #924

add_index now correctly computes number of existing DB files

git-svn-id: file:///svn/mysql/tokudb-engine/src@4590 c7de825b-a66e-492c-adef-691d508d4ae1
parent 8e1bc4e9
...@@ -3607,6 +3607,10 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -3607,6 +3607,10 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
uchar tmp_key_buff[2*table_arg->s->rec_buff_length]; uchar tmp_key_buff[2*table_arg->s->rec_buff_length];
// //
// number of DB files we have open currently, before add_index is executed
//
uint curr_num_DBs = table_arg->s->keys + test(hidden_primary_key);
//
// these variables are for error handling // these variables are for error handling
// //
uint num_files_created = 0; uint num_files_created = 0;
...@@ -3656,7 +3660,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -3656,7 +3660,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
// open all the DB files and set the appropriate variables in share // open all the DB files and set the appropriate variables in share
// they go to the end of share->key_file // they go to the end of share->key_file
// //
curr_index = table_arg->s->keys; curr_index = curr_num_DBs;
for (uint i = 0; i < num_of_keys; i++, curr_index++) { for (uint i = 0; i < num_of_keys; i++, curr_index++) {
error = open_secondary_table( error = open_secondary_table(
&share->key_file[curr_index], &share->key_file[curr_index],
...@@ -3697,7 +3701,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -3697,7 +3701,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
// are creating // are creating
// //
for (uint i = 0; i < num_of_keys; i++) { for (uint i = 0; i < num_of_keys; i++) {
uint curr_index = i + table_arg->s->keys; uint curr_index = i + curr_num_DBs;
error = share->key_file[curr_index]->pre_acquire_table_lock( error = share->key_file[curr_index]->pre_acquire_table_lock(
share->key_file[curr_index], share->key_file[curr_index],
txn txn
...@@ -3724,7 +3728,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -3724,7 +3728,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
for (uint i = 0; i < num_of_keys; i++) { for (uint i = 0; i < num_of_keys; i++) {
DBT secondary_key; DBT secondary_key;
create_dbt_key_from_key(&secondary_key,&key_info[i], tmp_key_buff, tmp_record); create_dbt_key_from_key(&secondary_key,&key_info[i], tmp_key_buff, tmp_record);
uint curr_index = i + table_arg->s->keys; uint curr_index = i + curr_num_DBs;
u_int32_t put_flags = share->key_type[curr_index]; u_int32_t put_flags = share->key_type[curr_index];
error = share->key_file[curr_index]->put(share->key_file[curr_index], txn, &secondary_key, &current_primary_key, put_flags); error = share->key_file[curr_index]->put(share->key_file[curr_index], txn, &secondary_key, &current_primary_key, put_flags);
...@@ -3760,7 +3764,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -3760,7 +3764,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
// We need to delete all the files that may have been created // We need to delete all the files that may have been created
// The DB's must be closed and removed // The DB's must be closed and removed
// //
for (uint i = table_arg->s->keys; i < table_arg->s->keys + num_DB_opened; i++) { for (uint i = curr_num_DBs; i < curr_num_DBs + num_DB_opened; i++) {
share->key_file[i]->close(share->key_file[i], 0); share->key_file[i]->close(share->key_file[i], 0);
share->key_file[i] = NULL; share->key_file[i] = NULL;
} }
......
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