summaryrefslogtreecommitdiff
path: root/storage/innobase/include/mtr0mtr.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/mtr0mtr.ic')
-rw-r--r--storage/innobase/include/mtr0mtr.ic154
1 files changed, 89 insertions, 65 deletions
diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic
index 81eec3bfc92..a03a0271535 100644
--- a/storage/innobase/include/mtr0mtr.ic
+++ b/storage/innobase/include/mtr0mtr.ic
@@ -1,49 +1,66 @@
-/******************************************************
-Mini-transaction buffer
+/*****************************************************************************
+
+Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
+
+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
+Foundation; version 2 of the License.
-(c) 1995 Innobase Oy
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+*****************************************************************************/
+
+/**************************************************//**
+@file include/mtr0mtr.ic
+Mini-transaction buffer
Created 11/26/1995 Heikki Tuuri
*******************************************************/
-#include "sync0sync.h"
-#include "sync0rw.h"
+#ifndef UNIV_HOTBACKUP
+# include "sync0sync.h"
+# include "sync0rw.h"
+#endif /* !UNIV_HOTBACKUP */
#include "mach0data.h"
-/*******************************************************************
-Starts a mini-transaction and creates a mini-transaction handle
-and a buffer in the memory buffer given by the caller. */
+/***************************************************************//**
+Starts a mini-transaction. */
UNIV_INLINE
-mtr_t*
+void
mtr_start(
/*======*/
- /* out: mtr buffer which also acts as
- the mtr handle */
- mtr_t* mtr) /* in: memory buffer for the mtr buffer */
+ mtr_t* mtr) /*!< out: mini-transaction */
{
+ UNIV_MEM_INVALID(mtr, sizeof *mtr);
+
dyn_array_create(&(mtr->memo));
dyn_array_create(&(mtr->log));
mtr->log_mode = MTR_LOG_ALL;
mtr->modifications = FALSE;
+ mtr->inside_ibuf = FALSE;
mtr->n_log_recs = 0;
+ mtr->n_freed_pages = 0;
-#ifdef UNIV_DEBUG
- mtr->state = MTR_ACTIVE;
- mtr->magic_n = MTR_MAGIC_N;
-#endif
- return(mtr);
+ ut_d(mtr->state = MTR_ACTIVE);
+ ut_d(mtr->magic_n = MTR_MAGIC_N);
}
-/*******************************************************
+/***************************************************//**
Pushes an object to an mtr memo stack. */
UNIV_INLINE
void
mtr_memo_push(
/*==========*/
- mtr_t* mtr, /* in: mtr */
- void* object, /* in: object */
- ulint type) /* in: object type: MTR_MEMO_S_LOCK, ... */
+ mtr_t* mtr, /*!< in: mtr */
+ void* object, /*!< in: object */
+ ulint type) /*!< in: object type: MTR_MEMO_S_LOCK, ... */
{
dyn_array_t* memo;
mtr_memo_slot_t* slot;
@@ -53,44 +70,47 @@ mtr_memo_push(
ut_ad(type <= MTR_MEMO_X_LOCK);
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
+ ut_ad(mtr->state == MTR_ACTIVE);
memo = &(mtr->memo);
- slot = dyn_array_push(memo, sizeof(mtr_memo_slot_t));
+ slot = (mtr_memo_slot_t*) dyn_array_push(memo, sizeof *slot);
slot->object = object;
slot->type = type;
}
-/**************************************************************
-Sets and returns a savepoint in mtr. */
+/**********************************************************//**
+Sets and returns a savepoint in mtr.
+@return savepoint */
UNIV_INLINE
ulint
mtr_set_savepoint(
/*==============*/
- /* out: savepoint */
- mtr_t* mtr) /* in: mtr */
+ mtr_t* mtr) /*!< in: mtr */
{
dyn_array_t* memo;
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
+ ut_ad(mtr->state == MTR_ACTIVE);
memo = &(mtr->memo);
return(dyn_array_get_data_size(memo));
}
-/**************************************************************
+#ifndef UNIV_HOTBACKUP
+/**********************************************************//**
Releases the (index tree) s-latch stored in an mtr memo after a
savepoint. */
UNIV_INLINE
void
mtr_release_s_latch_at_savepoint(
/*=============================*/
- mtr_t* mtr, /* in: mtr */
- ulint savepoint, /* in: savepoint */
- rw_lock_t* lock) /* in: latch to release */
+ mtr_t* mtr, /*!< in: mtr */
+ ulint savepoint, /*!< in: savepoint */
+ rw_lock_t* lock) /*!< in: latch to release */
{
mtr_memo_slot_t* slot;
dyn_array_t* memo;
@@ -103,7 +123,7 @@ mtr_release_s_latch_at_savepoint(
ut_ad(dyn_array_get_data_size(memo) > savepoint);
- slot = dyn_array_get_element(memo, savepoint);
+ slot = (mtr_memo_slot_t*) dyn_array_get_element(memo, savepoint);
ut_ad(slot->object == lock);
ut_ad(slot->type == MTR_MEMO_S_LOCK);
@@ -113,17 +133,17 @@ mtr_release_s_latch_at_savepoint(
slot->object = NULL;
}
-#ifdef UNIV_DEBUG
-/**************************************************************
-Checks if memo contains the given item. */
+# ifdef UNIV_DEBUG
+/**********************************************************//**
+Checks if memo contains the given item.
+@return TRUE if contains */
UNIV_INLINE
ibool
mtr_memo_contains(
/*==============*/
- /* out: TRUE if contains */
- mtr_t* mtr, /* in: mtr */
- void* object, /* in: object to search */
- ulint type) /* in: type of object */
+ mtr_t* mtr, /*!< in: mtr */
+ const void* object, /*!< in: object to search */
+ ulint type) /*!< in: type of object */
{
mtr_memo_slot_t* slot;
dyn_array_t* memo;
@@ -131,6 +151,7 @@ mtr_memo_contains(
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
+ ut_ad(mtr->state == MTR_ACTIVE || mtr->state == MTR_COMMITTING);
memo = &(mtr->memo);
@@ -139,7 +160,7 @@ mtr_memo_contains(
while (offset > 0) {
offset -= sizeof(mtr_memo_slot_t);
- slot = dyn_array_get_element(memo, offset);
+ slot = (mtr_memo_slot_t*) dyn_array_get_element(memo, offset);
if ((object == slot->object) && (type == slot->type)) {
@@ -149,16 +170,17 @@ mtr_memo_contains(
return(FALSE);
}
-#endif /* UNIV_DEBUG */
+# endif /* UNIV_DEBUG */
+#endif /* !UNIV_HOTBACKUP */
-/*******************************************************************
-Returns the log object of a mini-transaction buffer. */
+/***************************************************************//**
+Returns the log object of a mini-transaction buffer.
+@return log */
UNIV_INLINE
dyn_array_t*
mtr_get_log(
/*========*/
- /* out: log */
- mtr_t* mtr) /* in: mini-transaction */
+ mtr_t* mtr) /*!< in: mini-transaction */
{
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
@@ -166,14 +188,14 @@ mtr_get_log(
return(&(mtr->log));
}
-/*******************************************************************
-Gets the logging mode of a mini-transaction. */
+/***************************************************************//**
+Gets the logging mode of a mini-transaction.
+@return logging mode: MTR_LOG_NONE, ... */
UNIV_INLINE
ulint
mtr_get_log_mode(
/*=============*/
- /* out: logging mode: MTR_LOG_NONE, ... */
- mtr_t* mtr) /* in: mtr */
+ mtr_t* mtr) /*!< in: mtr */
{
ut_ad(mtr);
ut_ad(mtr->log_mode >= MTR_LOG_ALL);
@@ -182,15 +204,15 @@ mtr_get_log_mode(
return(mtr->log_mode);
}
-/*******************************************************************
-Changes the logging mode of a mini-transaction. */
+/***************************************************************//**
+Changes the logging mode of a mini-transaction.
+@return old mode */
UNIV_INLINE
ulint
mtr_set_log_mode(
/*=============*/
- /* out: old mode */
- mtr_t* mtr, /* in: mtr */
- ulint mode) /* in: logging mode: MTR_LOG_NONE, ... */
+ mtr_t* mtr, /*!< in: mtr */
+ ulint mode) /*!< in: logging mode: MTR_LOG_NONE, ... */
{
ulint old_mode;
@@ -212,40 +234,42 @@ mtr_set_log_mode(
return(old_mode);
}
-/*************************************************************************
+#ifndef UNIV_HOTBACKUP
+/*********************************************************************//**
Locks a lock in s-mode. */
UNIV_INLINE
void
mtr_s_lock_func(
/*============*/
- rw_lock_t* lock, /* in: rw-lock */
- const char* file, /* in: file name */
- ulint line, /* in: line number */
- mtr_t* mtr) /* in: mtr */
+ rw_lock_t* lock, /*!< in: rw-lock */
+ const char* file, /*!< in: file name */
+ ulint line, /*!< in: line number */
+ mtr_t* mtr) /*!< in: mtr */
{
ut_ad(mtr);
ut_ad(lock);
- rw_lock_s_lock_func(lock, 0, file, line);
+ rw_lock_s_lock_inline(lock, 0, file, line);
mtr_memo_push(mtr, lock, MTR_MEMO_S_LOCK);
}
-/*************************************************************************
+/*********************************************************************//**
Locks a lock in x-mode. */
UNIV_INLINE
void
mtr_x_lock_func(
/*============*/
- rw_lock_t* lock, /* in: rw-lock */
- const char* file, /* in: file name */
- ulint line, /* in: line number */
- mtr_t* mtr) /* in: mtr */
+ rw_lock_t* lock, /*!< in: rw-lock */
+ const char* file, /*!< in: file name */
+ ulint line, /*!< in: line number */
+ mtr_t* mtr) /*!< in: mtr */
{
ut_ad(mtr);
ut_ad(lock);
- rw_lock_x_lock_func(lock, 0, file, line);
+ rw_lock_x_lock_inline(lock, 0, file, line);
mtr_memo_push(mtr, lock, MTR_MEMO_X_LOCK);
}
+#endif /* !UNIV_HOTBACKUP */