Commit 193ef059 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:2266], do lazy update of auto inc val when it is not first column of key,...

[t:2266], do lazy update of auto inc val when it is not first column of key, before ,it used to only be when it was first column of a key

git-svn-id: file:///svn/mysql/tokudb-engine/src@16942 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0ea474c6
......@@ -2528,26 +2528,6 @@ DBT *ha_tokudb::pack_key(
DBUG_RETURN(key);
}
//
// There can only be one auto-inc field, so if the first field of any key is
// auto-inc, This returns true. If true, it sets keynr to be the value of the
// index that has the auto inc field as the first column of the key.
//
bool ha_tokudb::is_auto_inc_first_column (uint* keynr) {
bool ret_val = false;
for (uint i = 0; i < table->s->keys; i++) {
KEY *key = &table->s->key_info[i];
KEY_PART_INFO *key_part = &key->key_part[0];
Field *field = key_part->field;
if (field->flags & AUTO_INCREMENT_FLAG) {
ret_val = true;
*keynr = i;
break;
}
}
return ret_val;
}
//
// Reads the last element of dictionary of index keynr, and places
// the data into table->record[1].
......@@ -2781,11 +2761,7 @@ cleanup:
}
void ha_tokudb::start_bulk_insert(ha_rows rows) {
//
// make sure delay_updating_ai_metadata is true, iff the auto inc column
// is the first column of a key
//
delay_updating_ai_metadata = share->ai_first_col;
delay_updating_ai_metadata = true;
ai_metadata_update_required = false;
if (share->try_table_lock) {
if (tokudb_prelock_empty && may_table_be_empty()) {
......@@ -5887,25 +5863,7 @@ void ha_tokudb::init_auto_increment() {
if (error || value.size != sizeof(share->last_auto_increment)) {
share->last_auto_increment = 0;
}
if (is_auto_inc_first_column(&auto_inc_keynr)) {
share->ai_first_col = true;
(void) extra(HA_EXTRA_KEYREAD);
error = read_last(auto_inc_keynr);
(void) extra(HA_EXTRA_NO_KEYREAD);
if (!error) {
ulonglong last_entry = retrieve_auto_increment(
table->field[share->ai_field_index]->key_type(),
field_offset(table->field[share->ai_field_index], table),
table->record[1]
);
if (last_entry > share->last_auto_increment) {
share->last_auto_increment = last_entry;
}
}
}
else {
share->ai_first_col = false;
}
//
// Now retrieve the initial auto increment value, as specified by create table
// so if a user does "create table t1 (a int auto_increment, primary key (a)) auto_increment=100",
......
......@@ -52,7 +52,6 @@ typedef struct st_tokudb_share {
// index of auto increment column in table->field, if auto_inc exists
//
uint ai_field_index;
bool ai_first_col;
KEY_AND_COL_INFO kc_info;
......@@ -467,5 +466,4 @@ private:
int read_full_row(uchar * buf);
int __close(int mutex_is_locked);
int read_last(uint keynr);
bool is_auto_inc_first_column (uint* keynr);
};
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