1 /***************************************************************************** 2 3 Copyright (c) 2007, 2018, 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, version 2.0, as published by the 7 Free Software Foundation. 8 9 This program is also distributed with certain software (including but not 10 limited to OpenSSL) that is licensed under separate terms, as designated in a 11 particular file or component or in included license documentation. The authors 12 of MySQL hereby grant you an additional permission to link the program and 13 your derivative works with the separately licensed software that they have 14 included with MySQL. 15 16 This program is distributed in the hope that it will be useful, but WITHOUT 17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, 19 for more details. 20 21 You should have received a copy of the GNU General Public License along with 22 this program; if not, write to the Free Software Foundation, Inc., 23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 25 *****************************************************************************/ 26 27 /** @file include/lock0iter.h 28 Lock queue iterator type and function prototypes. 29 30 Created July 16, 2007 Vasil Dimov 31 *******************************************************/ 32 33 #ifndef lock0iter_h 34 #define lock0iter_h 35 36 #include "lock0types.h" 37 #include "univ.i" 38 39 struct lock_queue_iterator_t { 40 const lock_t *current_lock; 41 /* In case this is a record lock queue (not table lock queue) 42 then bit_no is the record number within the heap in which the 43 record is stored. */ 44 ulint bit_no; 45 }; 46 47 /** Initialize lock queue iterator so that it starts to iterate from 48 "lock". bit_no specifies the record number within the heap where the 49 record is stored. It can be undefined (ULINT_UNDEFINED) in two cases: 50 1. If the lock is a table lock, thus we have a table lock queue; 51 2. If the lock is a record lock and it is a wait lock. In this case 52 bit_no is calculated in this function by using 53 lock_rec_find_set_bit(). There is exactly one bit set in the bitmap 54 of a wait lock. */ 55 void lock_queue_iterator_reset( 56 lock_queue_iterator_t *iter, /*!< out: iterator */ 57 const lock_t *lock, /*!< in: lock to start from */ 58 ulint bit_no); /*!< in: record number in the 59 heap */ 60 61 /** Gets the previous lock in the lock queue, returns NULL if there are no 62 more locks (i.e. the current lock is the first one). The iterator is 63 receded (if not-NULL is returned). 64 @return previous lock or NULL */ 65 const lock_t *lock_queue_iterator_get_prev( 66 lock_queue_iterator_t *iter); /*!< in/out: iterator */ 67 68 #endif /* lock0iter_h */ 69