summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2019-08-14 12:42:06 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2019-08-14 12:42:06 +0300
commitb34c8645cdb301140327528a76a79a9e68c25611 (patch)
treecb49384a1f2715f859ecea334f20bf4a46ecbcce /sql/sql_class.cc
parent7772c7cd945cf674b212b82f4d156099c67344a2 (diff)
parent65d48b4a7bd7a57a27f2e9ca54473e1ae86223b5 (diff)
downloadmariadb-git-b-10.3-10.3-merge.tar.gz
Merge 10.3 into 10.4b-10.3-10.3-merge
Conflicts: mysql-test/suite/galera/disabled.def (resolved) mysql-test/suite/galera/r/MW-328A.result (run tests) mysql-test/suite/innodb/r/alter_copy.result (needs check) mysql-test/suite/innodb/t/trx_id_future.test (needs check) sql/opt_range.cc (needs check) sql/share/errmsg-utf8.txt (needs check) sql/sql_parse.cc (needs check) sql/sql_select.cc (needs check) sql/sql_table.cc (need check) sql/wsrep_mysqld.cc (resolved) sql/wsrep_sst.cc (resolved) sql/wsrep_thd.cc (resolved)
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