diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-16 14:35:32 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-16 14:35:32 +0300 |
commit | 67ddb6507d58b08f88dfede96b057eae34d9d76e (patch) | |
tree | 5f28ca11d7940d4fc17b6b9182eda27bae88e70f /sql/sql_class.cc | |
parent | 6073049a3675363f7d7efe26f47525b528be9e2f (diff) | |
parent | c221bcdce7714a74b89a02de941e8d8df2994ce3 (diff) | |
download | mariadb-git-67ddb6507d58b08f88dfede96b057eae34d9d76e.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9078396a575..4eab241232b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4906,12 +4906,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 @@ -6251,6 +6245,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 |