Commit 6c1ec24d authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1833

do a DB_YESOVERWRITE put when doing "replace into" on a table with no secondary indexes

git-svn-id: file:///svn/mysql/tokudb-engine/src@12996 c7de825b-a66e-492c-adef-691d508d4ae1
parent bee55e74
......@@ -2367,6 +2367,7 @@ int ha_tokudb::write_row(uchar * record) {
DB_TXN* sub_trans = NULL;
DB_TXN* txn = NULL;
tokudb_trx_data *trx = NULL;
uint curr_num_DBs = table->s->keys + test(hidden_primary_key);
declare_lockretry;
//
......@@ -2434,6 +2435,23 @@ int ha_tokudb::write_row(uchar * record) {
if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
put_flags = DB_YESOVERWRITE;
}
//
// optimization for "REPLACE INTO..." command
// if we the command is "REPLACE INTO" and the only table
// is the main table, then we can simply insert the element
// with DB_YESOVERWRITE. If the element does not exist,
// it will act as a normal insert, and if it does exist, it
// will act as a replace, which is exactly what REPLACE INTO is supposed
// to do. We cannot do this if curr_num_DBs > 1, because then we lose
// consistency between indexes
//
if ( ( (thd_sql_command(thd) == SQLCOM_REPLACE) ||
(thd_sql_command(thd) == SQLCOM_REPLACE_SELECT)
) &&
(curr_num_DBs == 1)
) {
put_flags = DB_YESOVERWRITE;
}
trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (trx->table_lock_wanted) {
......
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