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

[t:2401],[t:2358], remove unnecessary uniqueness check and make insert ignore...

[t:2401],[t:2358], remove unnecessary uniqueness check and make insert ignore as fast as replace into on tables with no secondary indexes

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@18033 c7de825b-a66e-492c-adef-691d508d4ae1
parent 42494d6b
...@@ -1431,6 +1431,13 @@ int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, KEY_AND_ ...@@ -1431,6 +1431,13 @@ int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, KEY_AND_
return error; return error;
} }
static bool is_insert_ignore (THD* thd) {
//
// from http://lists.mysql.com/internals/37735
//
return thd->lex->ignore && thd->lex->duplicates == DUP_ERROR;
}
int ha_tokudb::initialize_share( int ha_tokudb::initialize_share(
const char* name, const char* name,
...@@ -2894,6 +2901,12 @@ int ha_tokudb::do_uniqueness_checks(uchar* record, DB_TXN* txn, THD* thd) { ...@@ -2894,6 +2901,12 @@ int ha_tokudb::do_uniqueness_checks(uchar* record, DB_TXN* txn, THD* thd) {
for (uint keynr = 0; keynr < table_share->keys; keynr++) { for (uint keynr = 0; keynr < table_share->keys; keynr++) {
bool is_unique_key = table->key_info[keynr].flags & HA_NOSAME; bool is_unique_key = table->key_info[keynr].flags & HA_NOSAME;
bool is_unique = false; bool is_unique = false;
//
// don't need to do check for primary key
//
if (keynr == primary_key) {
continue;
}
if (!is_unique_key) { if (!is_unique_key) {
continue; continue;
} }
...@@ -3037,6 +3050,10 @@ int ha_tokudb::insert_row_to_main_dictionary(uchar* record, DBT* pk_key, DBT* pk ...@@ -3037,6 +3050,10 @@ int ha_tokudb::insert_row_to_main_dictionary(uchar* record, DBT* pk_key, DBT* pk
put_flags = DB_YESOVERWRITE; // original put_flags can only be DB_YESOVERWRITE or DB_NOOVERWRITE put_flags = DB_YESOVERWRITE; // original put_flags can only be DB_YESOVERWRITE or DB_NOOVERWRITE
} }
if (is_insert_ignore(thd)) {
put_flags = DB_NOOVERWRITE_NO_ERROR;
}
lockretryN(wait_lock_time){ lockretryN(wait_lock_time){
error = share->file->put( error = share->file->put(
share->file, share->file,
...@@ -3190,9 +3207,6 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -3190,9 +3207,6 @@ int ha_tokudb::write_row(uchar * record) {
// //
fix_mult_rec_buff(); fix_mult_rec_buff();
error = do_uniqueness_checks(record, txn, thd);
if (error) { goto cleanup; }
if (tokudb_debug & TOKUDB_DEBUG_CHECK_KEY) { if (tokudb_debug & TOKUDB_DEBUG_CHECK_KEY) {
error = test_row_packing(record,&prim_key,&row); error = test_row_packing(record,&prim_key,&row);
if (error) { goto cleanup; } if (error) { goto cleanup; }
...@@ -3203,6 +3217,9 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -3203,6 +3217,9 @@ int ha_tokudb::write_row(uchar * record) {
if (error) { goto cleanup; } if (error) { goto cleanup; }
} }
else { else {
error = do_uniqueness_checks(record, txn, thd);
if (error) { goto cleanup; }
error = insert_rows_to_dictionaries_mult(&prim_key, &row, txn, thd); error = insert_rows_to_dictionaries_mult(&prim_key, &row, txn, thd);
if (error) { goto cleanup; } if (error) { goto cleanup; }
} }
......
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