You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.8 KiB

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