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