1/*****************************************************************************
2
3Copyright (c) 2007, 2014, Oracle and/or its affiliates. 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.,
1551 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17*****************************************************************************/
18
19/**************************************************//**
20@file include/lock0iter.h
21Lock queue iterator type and function prototypes.
22
23Created July 16, 2007 Vasil Dimov
24*******************************************************/
25
26#ifndef lock0iter_h
27#define lock0iter_h
28
29#include "univ.i"
30#include "lock0types.h"
31
32struct lock_queue_iterator_t {
33 const lock_t* current_lock;
34 /* In case this is a record lock queue (not table lock queue)
35 then bit_no is the record number within the heap in which the
36 record is stored. */
37 ulint bit_no;
38};
39
40/*******************************************************************//**
41Initialize lock queue iterator so that it starts to iterate from
42"lock". bit_no specifies the record number within the heap where the
43record is stored. It can be undefined (ULINT_UNDEFINED) in two cases:
441. If the lock is a table lock, thus we have a table lock queue;
452. If the lock is a record lock and it is a wait lock. In this case
46 bit_no is calculated in this function by using
47 lock_rec_find_set_bit(). There is exactly one bit set in the bitmap
48 of a wait lock. */
49void
50lock_queue_iterator_reset(
51/*======================*/
52 lock_queue_iterator_t* iter, /*!< out: iterator */
53 const lock_t* lock, /*!< in: lock to start from */
54 ulint bit_no);/*!< in: record number in the
55 heap */
56
57/*******************************************************************//**
58Gets the previous lock in the lock queue, returns NULL if there are no
59more locks (i.e. the current lock is the first one). The iterator is
60receded (if not-NULL is returned).
61@return previous lock or NULL */
62const lock_t*
63lock_queue_iterator_get_prev(
64/*=========================*/
65 lock_queue_iterator_t* iter); /*!< in/out: iterator */
66
67#endif /* lock0iter_h */
68