diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-12 18:23:42 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-12 18:25:35 +0300 |
commit | be33124c9dc284c4409d02e5405de568b467a167 (patch) | |
tree | 7188f6effdace66ce24af17fd1bd0d89f5b76999 /sql/sql_class.cc | |
parent | fe8181aca13cf7ba1835fa6c89f297a1d0e79856 (diff) | |
parent | 15c1ab52a9f2827724c5d007ce7b8c607dc8f0a9 (diff) | |
download | mariadb-git-be33124c9dc284c4409d02e5405de568b467a167.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b0c130611fd..0f6003264b6 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6120,6 +6120,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 |