diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b21826d735f..866d45ff701 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3452,8 +3452,9 @@ end_with_restore_list: #ifdef WITH_WSREP for (TABLE_LIST *table= all_tables; table; table= table->next_global) { - if (!thd->is_current_stmt_binlog_format_row() || - !find_temporary_table(thd, table)) + if (!lex->drop_temporary && + (!thd->is_current_stmt_binlog_format_row() || + !find_temporary_table(thd, table))) { WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); break; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 9c639410fef..1b211ab4226 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7358,6 +7358,8 @@ ha_innobase::wsrep_append_keys( const uchar* record1) /* in: row in MySQL format */ { DBUG_ENTER("wsrep_append_keys"); + + bool key_appended = false; trx_t *trx = thd_to_trx(thd); if (table_share && table_share->tmp_table != NO_TMP_TABLE) { @@ -7369,29 +7371,6 @@ ha_innobase::wsrep_append_keys( DBUG_RETURN(0); } - /* if no PK, calculate hash of full row, to be the key value */ - if (prebuilt->clust_index_was_generated && wsrep_certify_nonPK) { - uchar digest[16]; - int rcode; - - wsrep_calc_row_hash(digest, record0, table, prebuilt, thd); - if ((rcode = wsrep_append_key(thd, trx, table_share, table, - (const char*) digest, 16, - shared))) { - DBUG_RETURN(rcode); - } - - if (record1) { - wsrep_calc_row_hash(digest, record1, table, prebuilt, thd); - if ((rcode = wsrep_append_key(thd, trx, table_share, - table, - (const char*) digest, - 16, shared))) { - DBUG_RETURN(rcode); - } - } - DBUG_RETURN(0); - } if (wsrep_protocol_version == 0) { uint len; char keyval[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; @@ -7430,6 +7409,8 @@ ha_innobase::wsrep_append_keys( if (key_info->flags & HA_NOSAME || referenced_by_foreign_key()) { + if (key_info->flags & HA_NOSAME || shared) + key_appended = true; len = wsrep_store_key_val_for_row( table, i, key0, key_info->key_length, @@ -7460,6 +7441,32 @@ ha_innobase::wsrep_append_keys( } } } + + /* if no PK, calculate hash of full row, to be the key value */ + if (!key_appended && wsrep_certify_nonPK) { + uchar digest[16]; + int rcode; + + wsrep_calc_row_hash(digest, record0, table, prebuilt, thd); + if ((rcode = wsrep_append_key(thd, trx, table_share, table, + (const char*) digest, 16, + shared))) { + DBUG_RETURN(rcode); + } + + if (record1) { + wsrep_calc_row_hash( + digest, record1, table, prebuilt, thd); + if ((rcode = wsrep_append_key(thd, trx, table_share, + table, + (const char*) digest, + 16, shared))) { + DBUG_RETURN(rcode); + } + } + DBUG_RETURN(0); + } + DBUG_RETURN(0); } #endif diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 4d69cf585fe..fc68878d860 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -8274,6 +8274,8 @@ ha_innobase::wsrep_append_keys( const uchar* record1) /* in: row in MySQL format */ { DBUG_ENTER("wsrep_append_keys"); + + bool key_appended = false; trx_t *trx = thd_to_trx(thd); if (table_share && table_share->tmp_table != NO_TMP_TABLE) { @@ -8285,29 +8287,6 @@ ha_innobase::wsrep_append_keys( DBUG_RETURN(0); } - /* if no PK, calculate hash of full row, to be the key value */ - if (prebuilt->clust_index_was_generated && wsrep_certify_nonPK) { - uchar digest[16]; - int rcode; - - wsrep_calc_row_hash(digest, record0, table, prebuilt, thd); - if ((rcode = wsrep_append_key(thd, trx, table_share, table, - (const char*) digest, 16, - shared))) { - DBUG_RETURN(rcode); - } - - if (record1) { - wsrep_calc_row_hash(digest, record1, table, prebuilt, thd); - if ((rcode = wsrep_append_key(thd, trx, table_share, - table, - (const char*) digest, - 16, shared))) { - DBUG_RETURN(rcode); - } - } - DBUG_RETURN(0); - } if (wsrep_protocol_version == 0) { uint len; char keyval[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; @@ -8346,6 +8325,8 @@ ha_innobase::wsrep_append_keys( if (key_info->flags & HA_NOSAME || referenced_by_foreign_key()) { + if (key_info->flags & HA_NOSAME || shared) + key_appended = true; len = wsrep_store_key_val_for_row( table, i, key0, key_info->key_length, @@ -8376,6 +8357,32 @@ ha_innobase::wsrep_append_keys( } } } + + /* if no PK, calculate hash of full row, to be the key value */ + if (!key_appended && wsrep_certify_nonPK) { + uchar digest[16]; + int rcode; + + wsrep_calc_row_hash(digest, record0, table, prebuilt, thd); + if ((rcode = wsrep_append_key(thd, trx, table_share, table, + (const char*) digest, 16, + shared))) { + DBUG_RETURN(rcode); + } + + if (record1) { + wsrep_calc_row_hash( + digest, record1, table, prebuilt, thd); + if ((rcode = wsrep_append_key(thd, trx, table_share, + table, + (const char*) digest, + 16, shared))) { + DBUG_RETURN(rcode); + } + } + DBUG_RETURN(0); + } + DBUG_RETURN(0); } #endif