MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lock0iter.cc
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2007, 2009, Oracle and/or its affiliates. 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.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 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 
36 /*******************************************************************/
45 UNIV_INTERN
46 void
48 /*======================*/
49  lock_queue_iterator_t* iter,
50  const lock_t* lock,
51  ulint bit_no)
53 {
55 
56  iter->current_lock = lock;
57 
58  if (bit_no != ULINT_UNDEFINED) {
59 
60  iter->bit_no = bit_no;
61  } else {
62 
63  switch (lock_get_type_low(lock)) {
64  case LOCK_TABLE:
65  iter->bit_no = ULINT_UNDEFINED;
66  break;
67  case LOCK_REC:
68  iter->bit_no = lock_rec_find_set_bit(lock);
69  ut_a(iter->bit_no != ULINT_UNDEFINED);
70  break;
71  default:
72  ut_error;
73  }
74  }
75 }
76 
77 /*******************************************************************/
82 UNIV_INTERN
83 const lock_t*
85 /*=========================*/
86  lock_queue_iterator_t* iter)
87 {
88  const lock_t* prev_lock;
89 
91 
92  switch (lock_get_type_low(iter->current_lock)) {
93  case LOCK_REC:
94  prev_lock = lock_rec_get_prev(
95  iter->current_lock, iter->bit_no);
96  break;
97  case LOCK_TABLE:
98  prev_lock = UT_LIST_GET_PREV(
99  un_member.tab_lock.locks, iter->current_lock);
100  break;
101  default:
102  ut_error;
103  }
104 
105  if (prev_lock != NULL) {
106 
107  iter->current_lock = prev_lock;
108  }
109 
110  return(prev_lock);
111 }