drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
lock0iter.cc
1/*****************************************************************************
2
3Copyright (C) 2007, 2009, Innobase Oy. 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., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
26
27#define LOCK_MODULE_IMPLEMENTATION
28
29#include "univ.i"
30#include "lock0iter.h"
31#include "lock0lock.h"
32#include "lock0priv.h"
33#include "ut0dbg.h"
34#include "ut0lst.h"
35#ifdef UNIV_DEBUG
36# include "srv0srv.h" /* kernel_mutex */
37#endif /* UNIV_DEBUG */
38
39/*******************************************************************/
48UNIV_INTERN
49void
51/*======================*/
52 lock_queue_iterator_t* iter,
53 const lock_t* lock,
54 ulint bit_no)
56{
57 ut_ad(mutex_own(&kernel_mutex));
58
59 iter->current_lock = lock;
60
61 if (bit_no != ULINT_UNDEFINED) {
62
63 iter->bit_no = bit_no;
64 } else {
65
66 switch (lock_get_type_low(lock)) {
67 case LOCK_TABLE:
68 iter->bit_no = ULINT_UNDEFINED;
69 break;
70 case LOCK_REC:
71 iter->bit_no = lock_rec_find_set_bit(lock);
72 ut_a(iter->bit_no != ULINT_UNDEFINED);
73 break;
74 default:
76 }
77 }
78}
79
80/*******************************************************************/
85UNIV_INTERN
86const lock_t*
88/*=========================*/
89 lock_queue_iterator_t* iter)
90{
91 const lock_t* prev_lock;
92
93 ut_ad(mutex_own(&kernel_mutex));
94
95 switch (lock_get_type_low(iter->current_lock)) {
96 case LOCK_REC:
97 prev_lock = lock_rec_get_prev(
98 iter->current_lock, iter->bit_no);
99 break;
100 case LOCK_TABLE:
101 prev_lock = UT_LIST_GET_PREV(
102 un_member.tab_lock.locks, iter->current_lock);
103 break;
104 default:
105 ut_error;
106 }
107
108 if (prev_lock != NULL) {
109
110 iter->current_lock = prev_lock;
111 }
112
113 return(prev_lock);
114}
const lock_t * lock_queue_iterator_get_prev(lock_queue_iterator_t *iter)
Definition lock0iter.cc:87
UNIV_INTERN void lock_queue_iterator_reset(lock_queue_iterator_t *iter, const lock_t *lock, ulint bit_no)
Definition lock0iter.cc:50
#define LOCK_REC
Definition lock0lock.h:762
#define LOCK_TABLE
Definition lock0lock.h:761
UNIV_INTERN ulint lock_rec_find_set_bit(const lock_t *lock)
UNIV_INTERN const lock_t * lock_rec_get_prev(const lock_t *in_lock, ulint heap_no)
UNIV_INLINE ulint lock_get_type_low(const lock_t *lock)
#define ut_error
Definition ut0dbg.h:115
#define ut_ad(EXPR)
Definition ut0dbg.h:127
#define ut_a(EXPR)
Definition ut0dbg.h:105
#define UT_LIST_GET_PREV(NAME, N)
Definition ut0lst.h:208