1/***************************************************************************** 2 3Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved. 4 5This program is free software; you can redistribute it and/or modify 6it under the terms of the GNU General Public License, version 2.0, 7as published by the Free Software Foundation. 8 9This program is also distributed with certain software (including 10but not limited to OpenSSL) that is licensed under separate terms, 11as designated in a particular file or component or in included license 12documentation. The authors of MySQL hereby grant you an additional 13permission to link the program and your derivative works with the 14separately licensed software that they have included with MySQL. 15 16This program is distributed in the hope that it will be useful, 17but WITHOUT ANY WARRANTY; without even the implied warranty of 18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19GNU General Public License, version 2.0, for more details. 20 21You should have received a copy of the GNU General Public License along with 22this program; if not, write to the Free Software Foundation, Inc., 2351 Franklin Street, Suite 500, Boston, MA 02110-1335 USA 24 25*****************************************************************************/ 26 27/**************************************************//** 28@file include/row0log.ic 29Modification log for online index creation and online table rebuild 30 31Created 2012-10-18 Marko Makela 32*******************************************************/ 33 34#include "dict0dict.h" 35 36/******************************************************//** 37Free the row log for an index on which online creation was aborted. */ 38UNIV_INLINE 39void 40row_log_abort_sec( 41/*===============*/ 42 dict_index_t* index) /*!< in/out: index (x-latched) */ 43{ 44#ifdef UNIV_SYNC_DEBUG 45 ut_ad(rw_lock_own(dict_index_get_lock(index), RW_LOCK_EX)); 46#endif /* UNIV_SYNC_DEBUG */ 47 48 ut_ad(!dict_index_is_clust(index)); 49 dict_index_set_online_status(index, ONLINE_INDEX_ABORTED); 50 row_log_free(index->online_log); 51} 52 53/******************************************************//** 54Try to log an operation to a secondary index that is 55(or was) being created. 56@retval true if the operation was logged or can be ignored 57@retval false if online index creation is not taking place */ 58UNIV_INLINE 59bool 60row_log_online_op_try( 61/*==================*/ 62 dict_index_t* index, /*!< in/out: index, S or X latched */ 63 const dtuple_t* tuple, /*!< in: index tuple */ 64 trx_id_t trx_id) /*!< in: transaction ID for insert, 65 or 0 for delete */ 66{ 67#ifdef UNIV_SYNC_DEBUG 68 ut_ad(rw_lock_own(dict_index_get_lock(index), RW_LOCK_SHARED) 69 || rw_lock_own(dict_index_get_lock(index), RW_LOCK_EX)); 70#endif /* UNIV_SYNC_DEBUG */ 71 72 switch (dict_index_get_online_status(index)) { 73 case ONLINE_INDEX_COMPLETE: 74 /* This is a normal index. Do not log anything. 75 The caller must perform the operation on the 76 index tree directly. */ 77 return(false); 78 case ONLINE_INDEX_CREATION: 79 /* The index is being created online. Log the 80 operation. */ 81 row_log_online_op(index, tuple, trx_id); 82 break; 83 case ONLINE_INDEX_ABORTED: 84 case ONLINE_INDEX_ABORTED_DROPPED: 85 /* The index was created online, but the operation was 86 aborted. Do not log the operation and tell the caller 87 to skip the operation. */ 88 break; 89 } 90 91 return(true); 92} 93