summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc48
1 files changed, 42 insertions, 6 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 64cfcb89ac6..363c5d35499 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -4881,12 +4881,6 @@ extern "C" int thd_slave_thread(const MYSQL_THD thd)
}
-extern "C" int thd_rpl_stmt_based(const MYSQL_THD thd)
-{
- return thd &&
- !thd->is_current_stmt_binlog_format_row() &&
- !thd->is_current_stmt_binlog_disabled();
-}
/* Returns high resolution timestamp for the start
@@ -6226,6 +6220,48 @@ int THD::decide_logging_format(TABLE_LIST *tables)
DBUG_RETURN(0);
}
+int THD::decide_logging_format_low(TABLE *table)
+{
+ /*
+ INSERT...ON DUPLICATE KEY UPDATE on a table with more than one unique keys
+ can be unsafe.
+ */
+ if(wsrep_binlog_format() <= BINLOG_FORMAT_STMT &&
+ !is_current_stmt_binlog_format_row() &&
+ !lex->is_stmt_unsafe() &&
+ lex->sql_command == SQLCOM_INSERT &&
+ lex->duplicates == DUP_UPDATE)
+ {
+ uint unique_keys= 0;
+ uint keys= table->s->keys, i= 0;
+ Field *field;
+ for (KEY* keyinfo= table->s->key_info;
+ i < keys && unique_keys <= 1; i++, keyinfo++)
+ if (keyinfo->flags & HA_NOSAME &&
+ !(keyinfo->key_part->field->flags & AUTO_INCREMENT_FLAG &&
+ //User given auto inc can be unsafe
+ !keyinfo->key_part->field->val_int()))
+ {
+ for (uint j= 0; j < keyinfo->user_defined_key_parts; j++)
+ {
+ field= keyinfo->key_part[j].field;
+ if(!bitmap_is_set(table->write_set,field->field_index))
+ goto exit;
+ }
+ unique_keys++;
+exit:;
+ }
+
+ if (unique_keys > 1)
+ {
+ lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS);
+ binlog_unsafe_warning_flags|= lex->get_stmt_unsafe_flags();
+ set_current_stmt_binlog_format_row_if_mixed();
+ return 1;
+ }
+ }
+ return 0;
+}
/*
Implementation of interface to write rows to the binary log through the