Commit 1b8d0704 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1913, fix replace into with respect to unique checks

git-svn-id: file:///svn/mysql/tokudb-engine/src@13816 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3d50b6eb
...@@ -2431,10 +2431,16 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -2431,10 +2431,16 @@ int ha_tokudb::write_row(uchar * record) {
bool has_null; bool has_null;
DB_TXN* sub_trans = NULL; DB_TXN* sub_trans = NULL;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
bool is_replace_into;
tokudb_trx_data *trx = NULL; tokudb_trx_data *trx = NULL;
uint curr_num_DBs = table->s->keys + test(hidden_primary_key); uint curr_num_DBs = table->s->keys + test(hidden_primary_key);
declare_lockretry; declare_lockretry;
thd = ha_thd();
is_replace_into = (thd_sql_command(thd) == SQLCOM_REPLACE) ||
(thd_sql_command(thd) == SQLCOM_REPLACE_SELECT);
// //
// this can only fail if we have not opened the environment // this can only fail if we have not opened the environment
// yet. I want to assert that rather than check for the error // yet. I want to assert that rather than check for the error
...@@ -2499,8 +2505,7 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -2499,8 +2505,7 @@ int ha_tokudb::write_row(uchar * record) {
// first the primary key (because it must be unique, has highest chance of failure) // first the primary key (because it must be unique, has highest chance of failure)
// //
put_flags = share->key_type[primary_key]; put_flags = share->key_type[primary_key];
thd = ha_thd(); if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS) && !is_replace_into) {
if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
put_flags = DB_YESOVERWRITE; put_flags = DB_YESOVERWRITE;
} }
// //
...@@ -2513,11 +2518,7 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -2513,11 +2518,7 @@ int ha_tokudb::write_row(uchar * record) {
// to do. We cannot do this if curr_num_DBs > 1, because then we lose // to do. We cannot do this if curr_num_DBs > 1, because then we lose
// consistency between indexes // consistency between indexes
// //
if ( ( (thd_sql_command(thd) == SQLCOM_REPLACE) || if (is_replace_into && (curr_num_DBs == 1)) {
(thd_sql_command(thd) == SQLCOM_REPLACE_SELECT)
) &&
(curr_num_DBs == 1)
) {
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
} }
......
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