diff options
Diffstat (limited to 'storage/xtradb/handler/ha_innodb.cc')
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 42cb57b0daf..45efec385aa 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -110,6 +110,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "fts0priv.h" #include "page0zip.h" #include "fil0pagecompress.h" +#include "dict0priv.h" #define thd_get_trx_isolation(X) ((enum_tx_isolation)thd_tx_isolation(X)) @@ -133,7 +134,7 @@ this program; if not, write to the Free Software Foundation, Inc., # endif /* MYSQL_PLUGIN_IMPORT */ #ifdef WITH_WSREP -#include "dict0priv.h" +#include "../../../wsrep/wsrep_api.h" #include "../storage/innobase/include/ut0byte.h" #include <mysql/service_md5.h> @@ -8857,6 +8858,7 @@ no_commit: error = row_insert_for_mysql((byte*) record, prebuilt); DEBUG_SYNC(user_thd, "ib_after_row_insert"); + /* Handle duplicate key errors */ if (auto_inc_used) { ulonglong auto_inc; @@ -8998,7 +9000,7 @@ report_error: && wsrep_thd_exec_mode(user_thd) == LOCAL_STATE && !wsrep_consistency_check(user_thd) && !wsrep_thd_ignore_table(user_thd)) { - if (wsrep_append_keys(user_thd, false, record, NULL)) { + if (wsrep_append_keys(user_thd, WSREP_KEY_EXCLUSIVE, record, NULL)) { DBUG_PRINT("wsrep", ("row key failed")); error_result = HA_ERR_INTERNAL_ERROR; goto wsrep_error; @@ -9519,7 +9521,8 @@ func_exit: { DBUG_PRINT("wsrep", ("update row key")); - if (wsrep_append_keys(user_thd, false, old_row, new_row)) { + if (wsrep_append_keys(user_thd, WSREP_KEY_EXCLUSIVE, old_row, + new_row)) { WSREP_DEBUG("WSREP: UPDATE_ROW_KEY FAILED"); DBUG_PRINT("wsrep", ("row key failed")); err = HA_ERR_INTERNAL_ERROR; @@ -9582,7 +9585,8 @@ ha_innobase::delete_row( wsrep_on(user_thd) && !wsrep_thd_ignore_table(user_thd)) { - if (wsrep_append_keys(user_thd, false, record, NULL)) { + if (wsrep_append_keys(user_thd, WSREP_KEY_EXCLUSIVE, record, + NULL)) { DBUG_PRINT("wsrep", ("delete fail")); error = (dberr_t) HA_ERR_INTERNAL_ERROR; goto wsrep_error; @@ -10813,8 +10817,22 @@ wsrep_dict_foreign_find_index( ibool check_charsets, ulint check_null); +inline +const char* +wsrep_key_type_to_str(wsrep_key_type type) +{ + switch (type) { + case WSREP_KEY_SHARED: + return "shared"; + case WSREP_KEY_SEMI: + return "semi"; + case WSREP_KEY_EXCLUSIVE: + return "exclusive"; + }; + return "unknown"; +} -extern dberr_t +ulint wsrep_append_foreign_key( /*===========================*/ trx_t* trx, /*!< in: trx */ @@ -10822,7 +10840,8 @@ wsrep_append_foreign_key( const rec_t* rec, /*!<in: clustered index record */ dict_index_t* index, /*!<in: clustered index */ ibool referenced, /*!<in: is check for referenced table */ - ibool shared) /*!<in: is shared access */ + wsrep_key_type key_type) /*!< in: access type of this key + (shared, exclusive, semi...) */ { ut_a(trx); THD* thd = (THD*)trx->mysql_thd; @@ -10920,10 +10939,11 @@ wsrep_append_foreign_key( rcode = wsrep_rec_get_foreign_key( &key[1], &len, rec, index, idx, wsrep_protocol_version > 1); + if (rcode != DB_SUCCESS) { WSREP_ERROR( - "FK key set failed: %lu (%lu %lu), index: %s %s, %s", - rcode, referenced, shared, + "FK key set failed: %lu (%lu %s), index: %s %s, %s", + rcode, referenced, wsrep_key_type_to_str(key_type), (index && index->name) ? index->name : "void index", (index && index->table_name) ? index->table_name : @@ -10931,6 +10951,7 @@ wsrep_append_foreign_key( wsrep_thd_query(thd)); return DB_ERROR; } + strncpy(cache_key, (wsrep_protocol_version > 1) ? ((referenced) ? @@ -10975,7 +10996,7 @@ wsrep_append_foreign_key( wsrep_ws_handle(thd, trx), &wkey, 1, - shared ? WSREP_KEY_SHARED : WSREP_KEY_EXCLUSIVE, + key_type, copy); if (rcode) { DBUG_PRINT("wsrep", ("row key failed: %zu", rcode)); @@ -10997,14 +11018,15 @@ wsrep_append_key( TABLE *table, const char* key, uint16_t key_len, - bool shared + wsrep_key_type key_type /*!< in: access type of this key + (shared, exclusive, semi...) */ ) { DBUG_ENTER("wsrep_append_key"); bool const copy = true; #ifdef WSREP_DEBUG_PRINT fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s\n Query: %s ", - (shared) ? "Shared" : "Exclusive", + wsrep_key_type_to_str(key_type), thd_get_thread_id(thd), (long long)trx->id, key_len, table_share->table_name.str, wsrep_thd_query(thd)); for (int i=0; i<key_len; i++) { @@ -11032,7 +11054,7 @@ wsrep_append_key( wsrep_ws_handle(thd, trx), &wkey, 1, - shared ? WSREP_KEY_SHARED : WSREP_KEY_EXCLUSIVE, + key_type, copy); if (rcode) { DBUG_PRINT("wsrep", ("row key failed: %d", rcode)); @@ -11069,7 +11091,8 @@ int ha_innobase::wsrep_append_keys( /*==================*/ THD *thd, - bool shared, + wsrep_key_type key_type, /*!< in: access type of this key + (shared, exclusive, semi...) */ const uchar* record0, /* in: row in MySQL format */ const uchar* record1) /* in: row in MySQL format */ { @@ -11101,7 +11124,7 @@ ha_innobase::wsrep_append_keys( if (!is_null) { rcode = wsrep_append_key( thd, trx, table_share, table, keyval, - len, shared); + len, key_type); if (rcode) DBUG_RETURN(rcode); } else @@ -11154,10 +11177,11 @@ ha_innobase::wsrep_append_keys( if (!is_null) { rcode = wsrep_append_key( thd, trx, table_share, table, - keyval0, len+1, shared); + keyval0, len+1, key_type); if (rcode) DBUG_RETURN(rcode); - if (key_info->flags & HA_NOSAME || shared) + if (key_info->flags & HA_NOSAME || + key_type == WSREP_KEY_SHARED) key_appended = true; } else @@ -11174,7 +11198,7 @@ ha_innobase::wsrep_append_keys( rcode = wsrep_append_key( thd, trx, table_share, table, - keyval1, len+1, shared); + keyval1, len+1, key_type); if (rcode) DBUG_RETURN(rcode); } } @@ -11190,7 +11214,7 @@ ha_innobase::wsrep_append_keys( wsrep_calc_row_hash(digest, record0, table, prebuilt, thd); if ((rcode = wsrep_append_key(thd, trx, table_share, table, (const char*) digest, 16, - shared))) { + key_type))) { DBUG_RETURN(rcode); } @@ -11200,7 +11224,7 @@ ha_innobase::wsrep_append_keys( if ((rcode = wsrep_append_key(thd, trx, table_share, table, (const char*) digest, - 16, shared))) { + 16, key_type))) { DBUG_RETURN(rcode); } } |