diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-01-31 09:34:34 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2019-01-31 09:34:34 +0100 |
commit | 560799ebd8efe11f4c4ae1bb9ed4d39185e03800 (patch) | |
tree | 58158a4194a2473679c1848c323bad918542c5c9 /storage | |
parent | 6e2af7d084ca1bba79e60f05616aaefb6028ee9d (diff) | |
parent | c2caca02ac39454e18db8de563e7e7c8eaf8b1c7 (diff) | |
download | mariadb-git-560799ebd8efe11f4c4ae1bb9ed4d39185e03800.tar.gz |
Merge branch '10.0-galera' into 10.1
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 64 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.h | 6 | ||||
-rw-r--r-- | storage/innobase/row/row0ins.cc | 39 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 62 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.h | 6 | ||||
-rw-r--r-- | storage/xtradb/row/row0ins.cc | 39 |
6 files changed, 159 insertions, 57 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 702f84a52d1..472fb86288f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -112,6 +112,7 @@ MYSQL_PLUGIN_IMPORT extern char mysql_unpacked_real_data_home[]; #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)) @@ -134,7 +135,7 @@ MYSQL_PLUGIN_IMPORT extern char mysql_unpacked_real_data_home[]; # 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> @@ -8449,7 +8450,8 @@ 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; @@ -8972,7 +8974,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; @@ -9036,7 +9039,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; @@ -10282,8 +10286,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 */ @@ -10291,7 +10309,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; @@ -10389,10 +10408,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 : @@ -10400,6 +10420,7 @@ wsrep_append_foreign_key( wsrep_thd_query(thd)); return DB_ERROR; } + strncpy(cache_key, (wsrep_protocol_version > 1) ? ((referenced) ? @@ -10444,7 +10465,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)); @@ -10466,15 +10487,16 @@ 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", - thd_get_thread_id(thd), (long long)trx->id, key_len, + wsrep_key_type_to_str(key_type), + wsrep_thd_thread_id(thd), trx->id, key_len, table_share->table_name.str, wsrep_thd_query(thd)); for (int i=0; i<key_len; i++) { fprintf(stderr, "%hhX, ", key[i]); @@ -10501,7 +10523,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)); @@ -10538,7 +10560,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 */ { @@ -10570,7 +10593,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 @@ -10623,10 +10646,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 @@ -10643,7 +10667,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); } } @@ -10659,7 +10683,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); } @@ -10669,7 +10693,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); } } diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 958a63b23a5..2429c8a3f86 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -26,6 +26,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0stats.h" +#ifdef WITH_WSREP +#include "../../../wsrep/wsrep_api.h" +#endif /* WITH_WSREP */ + /* Structure defines translation table between mysql index and innodb index structures */ struct innodb_idx_translate_t { @@ -115,7 +119,7 @@ class ha_innobase: public handler dict_index_t* innobase_get_index(uint keynr); #ifdef WITH_WSREP - int wsrep_append_keys(THD *thd, bool shared, + int wsrep_append_keys(THD *thd, wsrep_key_type key_type, const uchar* record0, const uchar* record1); #endif /* Init values for the class: */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index c50eaa2a653..c031c38163e 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -55,6 +55,11 @@ Created 4/20/1996 Heikki Tuuri #include "fts0types.h" #include "m_string.h" +#ifdef WITH_WSREP +#include "../../../wsrep/wsrep_api.h" +#include "wsrep_mysqld_c.h" +#endif /* WITH_WSREP */ + /************************************************************************* IMPORTANT NOTE: Any operation that generates redo MUST check that there is enough space in the redo log before for that operation. This is @@ -933,11 +938,11 @@ row_ins_invalidate_query_cache( } #ifdef WITH_WSREP dberr_t wsrep_append_foreign_key(trx_t *trx, - dict_foreign_t* foreign, - const rec_t* clust_rec, - dict_index_t* clust_index, - ibool referenced, - ibool shared); + dict_foreign_t* foreign, + const rec_t* clust_rec, + dict_index_t* clust_index, + ibool referenced, + enum wsrep_key_type key_type); #endif /* WITH_WSREP */ /*********************************************************************//** @@ -1296,7 +1301,7 @@ row_ins_foreign_check_on_constraint( foreign, clust_rec, clust_index, - FALSE, FALSE); + FALSE, WSREP_KEY_EXCLUSIVE); if (err != DB_SUCCESS) { fprintf(stderr, "WSREP: foreign key append failed: %d\n", err); @@ -1638,16 +1643,34 @@ run_again: } if (check_ref) { +#ifdef WITH_WSREP + enum wsrep_key_type key_type = WSREP_KEY_EXCLUSIVE; +#endif WITH_WSREP err = DB_SUCCESS; + #ifdef WITH_WSREP + if (upd_node != NULL) { + key_type = WSREP_KEY_SHARED; + } else { + switch (wsrep_certification_rules) { + case WSREP_CERTIFICATION_RULES_STRICT: + key_type = WSREP_KEY_EXCLUSIVE; + break; + case WSREP_CERTIFICATION_RULES_OPTIMIZED: + key_type = WSREP_KEY_SEMI; + break; + } + } + err = wsrep_append_foreign_key( thr_get_trx(thr), foreign, rec, check_index, check_ref, - (upd_node) ? TRUE : FALSE); -#endif /* WITH_WSREP */ + key_type); + #endif /* WITH_WSREP */ + goto end_scan; } else if (foreign->type != 0) { /* There is an ON UPDATE or ON DELETE diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index d3be5155d27..c9db941b4bf 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> @@ -8894,6 +8895,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; @@ -9035,7 +9037,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; @@ -9556,7 +9558,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; @@ -9619,7 +9622,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; @@ -10850,8 +10854,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 */ @@ -10859,7 +10877,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; @@ -10957,10 +10976,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 : @@ -10968,6 +10988,7 @@ wsrep_append_foreign_key( wsrep_thd_query(thd)); return DB_ERROR; } + strncpy(cache_key, (wsrep_protocol_version > 1) ? ((referenced) ? @@ -11012,7 +11033,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)); @@ -11034,14 +11055,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++) { @@ -11069,7 +11091,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)); @@ -11106,7 +11128,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 */ { @@ -11138,7 +11161,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 @@ -11191,10 +11214,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 @@ -11211,7 +11235,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); } } @@ -11227,7 +11251,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); } @@ -11237,7 +11261,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); } } diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index 97d822ac186..48ec8ba5bae 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -26,6 +26,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0stats.h" +#ifdef WITH_WSREP +#include "../../../wsrep/wsrep_api.h" +#endif /* WITH_WSREP */ + /* Structure defines translation table between mysql index and innodb index structures */ struct innodb_idx_translate_t { @@ -115,7 +119,7 @@ class ha_innobase: public handler dict_index_t* innobase_get_index(uint keynr); #ifdef WITH_WSREP - int wsrep_append_keys(THD *thd, bool shared, + int wsrep_append_keys(THD *thd, wsrep_key_type key_type, const uchar* record0, const uchar* record1); #endif /* Init values for the class: */ diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index 472be8ad848..f146d1f68b1 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -55,6 +55,11 @@ Created 4/20/1996 Heikki Tuuri #include "fts0types.h" #include "m_string.h" +#ifdef WITH_WSREP +#include "../../../wsrep/wsrep_api.h" +#include "wsrep_mysqld_c.h" +#endif /* WITH_WSREP */ + /************************************************************************* IMPORTANT NOTE: Any operation that generates redo MUST check that there is enough space in the redo log before for that operation. This is @@ -939,11 +944,11 @@ row_ins_invalidate_query_cache( } #ifdef WITH_WSREP dberr_t wsrep_append_foreign_key(trx_t *trx, - dict_foreign_t* foreign, - const rec_t* clust_rec, - dict_index_t* clust_index, - ibool referenced, - ibool shared); + dict_foreign_t* foreign, + const rec_t* clust_rec, + dict_index_t* clust_index, + ibool referenced, + enum wsrep_key_type key_type); #endif /* WITH_WSREP */ /*********************************************************************//** @@ -1302,7 +1307,7 @@ row_ins_foreign_check_on_constraint( foreign, clust_rec, clust_index, - FALSE, FALSE); + FALSE, WSREP_KEY_EXCLUSIVE); if (err != DB_SUCCESS) { fprintf(stderr, "WSREP: foreign key append failed: %d\n", err); @@ -1650,16 +1655,34 @@ run_again: } if (check_ref) { +#ifdef WITH_WSREP + enum wsrep_key_type key_type = WSREP_KEY_EXCLUSIVE; +#endif /* WITH_WSREP */ err = DB_SUCCESS; + #ifdef WITH_WSREP + if (upd_node != NULL) { + key_type = WSREP_KEY_SHARED; + } else { + switch (wsrep_certification_rules) { + case WSREP_CERTIFICATION_RULES_STRICT: + key_type = WSREP_KEY_EXCLUSIVE; + break; + case WSREP_CERTIFICATION_RULES_OPTIMIZED: + key_type = WSREP_KEY_SEMI; + break; + } + } + err = wsrep_append_foreign_key( thr_get_trx(thr), foreign, rec, check_index, check_ref, - (upd_node) ? TRUE : FALSE); -#endif /* WITH_WSREP */ + key_type); + #endif /* WITH_WSREP */ + goto end_scan; } else if (foreign->type != 0) { /* There is an ON UPDATE or ON DELETE |