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