diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-06-04 16:12:00 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-06-04 16:12:00 +0300 |
commit | b50685af82508ca1cc83e1743dff527770e6e64b (patch) | |
tree | abbbc2a2ca9f4f80b4cb0da2d775e037575204ab /storage/innobase | |
parent | cac41001864ca503a7812b7f2a3b312435fb4ec4 (diff) | |
parent | 8dc70c862b8ec115fd9a3c2b37c746ffc4f0d3cc (diff) | |
download | mariadb-git-b50685af82508ca1cc83e1743dff527770e6e64b.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'storage/innobase')
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 32 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 18 | ||||
-rw-r--r-- | storage/innobase/include/dict0dict.h | 10 | ||||
-rw-r--r-- | storage/innobase/include/dict0dict.ic | 14 | ||||
-rw-r--r-- | storage/innobase/include/dict0mem.h | 39 | ||||
-rw-r--r-- | storage/innobase/log/log0crypt.cc | 11 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 16 | ||||
-rw-r--r-- | storage/innobase/row/row0upd.cc | 2 |
8 files changed, 76 insertions, 66 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index e7acead269c..9415624465f 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -2612,37 +2612,7 @@ dict_index_remove_from_cache_low( UT_LIST_REMOVE(table->indexes, index); /* Remove the index from affected virtual column index list */ - if (dict_index_has_virtual(index)) { - const dict_col_t* col; - const dict_v_col_t* vcol; - - for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - col = dict_index_get_nth_col(index, i); - if (col->is_virtual()) { - vcol = reinterpret_cast<const dict_v_col_t*>( - col); - - /* This could be NULL, when we do add virtual - column, add index together. We do not need to - track this virtual column's index */ - if (vcol->v_indexes == NULL) { - continue; - } - - dict_v_idx_list::iterator it; - - for (it = vcol->v_indexes->begin(); - it != vcol->v_indexes->end(); ++it) { - dict_v_idx_t v_index = *it; - if (v_index.index == index) { - vcol->v_indexes->erase(it); - break; - } - } - } - - } - } + index->detach_columns(); dict_mem_index_free(index); } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 769eced242c..08963ceff3e 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -58,10 +58,6 @@ Smart ALTER TABLE #include "ha_innodb.h" #include "ut0new.h" #include "ut0stage.h" -#ifdef WITH_WSREP -//#include "wsrep_api.h" -#include <sql_acl.h> // PROCESS_ACL -#endif static const char *MSG_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN= "INPLACE ADD or DROP of virtual columns cannot be " @@ -289,6 +285,16 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx @return whether the table will be rebuilt */ bool need_rebuild () const { return(old_table != new_table); } + /** Clear uncommmitted added indexes after a failed operation. */ + void clear_added_indexes() + { + for (ulint i = 0; i < num_to_add_index; i++) { + if (!add_index[i]->is_committed()) { + add_index[i]->detach_columns(); + } + } + } + /** Convert table-rebuilding ALTER to instant ALTER. */ void prepare_instant() { @@ -6726,7 +6732,8 @@ check_if_can_drop_indexes: for (dict_index_t* index = dict_table_get_first_index(indexed_table); index != NULL; index = dict_table_get_next_index(index)) { - if (!index->to_be_dropped && index->is_corrupted()) { + if (!index->to_be_dropped && index->is_committed() + && index->is_corrupted()) { my_error(ER_INDEX_CORRUPT, MYF(0), index->name()); goto err_exit; } @@ -7293,6 +7300,7 @@ oom: that we hold at most a shared lock on the table. */ m_prebuilt->trx->error_info = NULL; ctx->trx->error_state = DB_SUCCESS; + ctx->clear_added_indexes(); DBUG_RETURN(true); } diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 5538b3e98ec..66b64f96128 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -731,13 +731,9 @@ dict_index_is_spatial( /*==================*/ const dict_index_t* index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); -/** Check whether the index contains a virtual column. -@param[in] index index -@return nonzero for index on virtual column, zero for other indexes */ -UNIV_INLINE -ulint -dict_index_has_virtual( - const dict_index_t* index); + +#define dict_index_has_virtual(index) (index)->has_virtual() + /********************************************************************//** Check whether the index is the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 4c6c45a3b1e..db1be6513b1 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -314,20 +314,6 @@ dict_index_is_spatial( return ulint(UNIV_EXPECT(index->type & DICT_SPATIAL, 0)); } -/** Check whether the index contains a virtual column -@param[in] index index -@return nonzero for the index has virtual column, zero for other indexes */ -UNIV_INLINE -ulint -dict_index_has_virtual( - const dict_index_t* index) -{ - ut_ad(index); - ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); - - return(index->type & DICT_VIRTUAL); -} - /********************************************************************//** Check whether the index is the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 6c116b9a428..154a503f1b3 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -588,6 +588,10 @@ struct dict_col_t{ 3072 (REC_VERSION_56_MAX_INDEX_COL_LEN) bytes. */ + /** Detach the column from an index. + @param[in] index index to be detached from */ + inline void detach(const dict_index_t& index); + /** Data for instantly added columns */ struct { /** original default value of instantly added column */ @@ -1045,9 +1049,24 @@ struct dict_index_t{ return DICT_CLUSTERED == (type & (DICT_CLUSTERED | DICT_IBUF)); } + /** @return whether the index includes virtual columns */ + bool has_virtual() const { return type & DICT_VIRTUAL; } + /** @return whether the index is corrupted */ inline bool is_corrupted() const; + /** Detach the columns from the index that is to be freed. */ + void detach_columns() + { + if (has_virtual()) { + for (unsigned i = 0; i < n_fields; i++) { + fields[i].col->detach(*this); + } + + n_fields = 0; + } + } + /** Determine how many fields of a given prefix can be set NULL. @param[in] n_prefix number of fields in the prefix @return number of fields 0..n_prefix-1 that can be set NULL */ @@ -1112,6 +1131,26 @@ struct dict_index_t{ vers_history_row(const rec_t* rec, bool &history_row); }; +/** Detach a column from an index. +@param[in] index index to be detached from */ +inline void dict_col_t::detach(const dict_index_t& index) +{ + if (!is_virtual()) { + return; + } + + if (dict_v_idx_list* v_indexes = reinterpret_cast<const dict_v_col_t*> + (this)->v_indexes) { + for (dict_v_idx_list::iterator i = v_indexes->begin(); + i != v_indexes->end(); i++) { + if (i->index == &index) { + v_indexes->erase(i); + return; + } + } + } +} + /** The status of online index creation */ enum online_index_status { /** the index is complete and ready for access */ diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc index 980b26d448c..dff9661c6eb 100644 --- a/storage/innobase/log/log0crypt.cc +++ b/storage/innobase/log/log0crypt.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. -Copyright (C) 2014, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2014, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -160,7 +160,7 @@ static bool init_crypt_key(crypt_info_t* info, bool upgrade = false) << "Obtaining redo log encryption key version " << info->key_version << " failed (" << rc << "). Maybe the key or the required encryption " - << " key management plugin was not found."; + "key management plugin was not found."; return false; } @@ -280,7 +280,12 @@ log_crypt_101_read_block(byte* buf) } } - return false; + if (infos_used == 0) { + return false; + } + /* MariaDB Server 10.1 would use the first key if it fails to + find a key for the current checkpoint. */ + info = infos; found: byte dst[OS_FILE_LOG_BLOCK_SIZE]; uint dst_len; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 0de383c24b4..b2c66bd389b 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -858,12 +858,11 @@ recv_find_max_checkpoint_0(ulint* max_field) /** Determine if a pre-MySQL 5.7.9/MariaDB 10.2.2 redo log is clean. @param[in] lsn checkpoint LSN +@param[in] crypt whether the log might be encrypted @return error code @retval DB_SUCCESS if the redo log is clean @retval DB_ERROR if the redo log is corrupted or dirty */ -static -dberr_t -recv_log_format_0_recover(lsn_t lsn) +static dberr_t recv_log_format_0_recover(lsn_t lsn, bool crypt) { log_mutex_enter(); const lsn_t source_offset = log_sys.log.calc_lsn_offset(lsn); @@ -891,7 +890,13 @@ recv_log_format_0_recover(lsn_t lsn) } if (log_block_get_data_len(buf) - != (source_offset & (OS_FILE_LOG_BLOCK_SIZE - 1))) { + == (source_offset & (OS_FILE_LOG_BLOCK_SIZE - 1))) { + } else if (crypt) { + ib::error() << "Cannot decrypt log for upgrading." + " The encrypted log was created" + " before MariaDB 10.2.2."; + return DB_ERROR; + } else { ib::error() << NO_UPGRADE_RECOVERY_MSG << "."; return(DB_ERROR); } @@ -3153,7 +3158,8 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) switch (log_sys.log.format) { case 0: log_mutex_exit(); - return(recv_log_format_0_recover(checkpoint_lsn)); + return recv_log_format_0_recover(checkpoint_lsn, + buf[20 + 32 * 9] == 2); default: if (end_lsn == 0) { break; diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index e2197f845f3..bca7464bc66 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -581,7 +581,7 @@ row_upd_changes_field_size_or_external( /* We should ignore virtual field if the index is not a virtual index */ if (upd_fld_is_virtual_col(upd_field) - && dict_index_has_virtual(index) != DICT_VIRTUAL) { + && !index->has_virtual()) { continue; } |