1
/******************************************************
2
Lock queue iterator. Can iterate over table and record
7
Created July 16, 2007 Vasil Dimov
8
*******************************************************/
10
#define LOCK_MODULE_IMPLEMENTATION
13
#include "lock0iter.h"
14
#include "lock0lock.h"
15
#include "lock0priv.h"
19
/***********************************************************************
20
Initialize lock queue iterator so that it starts to iterate from
21
"lock". bit_no specifies the record number within the heap where the
22
record is stored. It can be undefined (ULINT_UNDEFINED) in two cases:
23
1. If the lock is a table lock, thus we have a table lock queue;
24
2. If the lock is a record lock and it is a wait lock. In this case
25
bit_no is calculated in this function by using
26
lock_rec_find_set_bit(). There is exactly one bit set in the bitmap
30
lock_queue_iterator_reset(
31
/*======================*/
32
lock_queue_iterator_t* iter, /* out: iterator */
33
lock_t* lock, /* in: lock to start from */
34
ulint bit_no) /* in: record number in the
37
iter->current_lock = lock;
39
if (bit_no != ULINT_UNDEFINED) {
41
iter->bit_no = bit_no;
44
switch (lock_get_type(lock)) {
46
iter->bit_no = ULINT_UNDEFINED;
49
iter->bit_no = lock_rec_find_set_bit(lock);
50
ut_a(iter->bit_no != ULINT_UNDEFINED);
58
/***********************************************************************
59
Gets the previous lock in the lock queue, returns NULL if there are no
60
more locks (i.e. the current lock is the first one). The iterator is
61
receded (if not-NULL is returned). */
64
lock_queue_iterator_get_prev(
65
/*=========================*/
66
/* out: previous lock or NULL */
67
lock_queue_iterator_t* iter) /* in/out: iterator */
71
switch (lock_get_type(iter->current_lock)) {
73
prev_lock = lock_rec_get_prev(
74
iter->current_lock, iter->bit_no);
77
prev_lock = UT_LIST_GET_PREV(
78
un_member.tab_lock.locks, iter->current_lock);
84
if (prev_lock != NULL) {
86
iter->current_lock = prev_lock;