Drizzled Public API Documentation

lock0iter.cc
1 /*****************************************************************************
2 
3 Copyright (C) 2007, 2009, Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
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 /*******************************************************************/
48 UNIV_INTERN
49 void
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:
75  ut_error;
76  }
77  }
78 }
79 
80 /*******************************************************************/
85 UNIV_INTERN
86 const 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 }