| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. |
| 4 | Copyright (c) 2020, 2021, MariaDB Corporation. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it under |
| 7 | the terms of the GNU General Public License as published by the Free Software |
| 8 | Foundation; version 2 of the License. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License along with |
| 15 | this program; if not, write to the Free Software Foundation, Inc., |
| 16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 17 | |
| 18 | *****************************************************************************/ |
| 19 | |
| 20 | /**************************************************//** |
| 21 | @file lock/lock0iter.cc |
| 22 | Lock queue iterator. Can iterate over table and record |
| 23 | lock queues. |
| 24 | |
| 25 | Created July 16, 2007 Vasil Dimov |
| 26 | *******************************************************/ |
| 27 | |
| 28 | #define LOCK_MODULE_IMPLEMENTATIONcxx . . $ `storage/innobase/lock/lock0iter.cc:28:9`! |
| 29 | |
| 30 | #include "dict0mem.h"cxx . . $ `<file>/storage/innobase/include/dict0mem.h`/ |
| 31 | #include "lock0iter.h"cxx . . $ `<file>/storage/innobase/include/lock0iter.h`/ |
| 32 | #include "lock0lock.h"cxx . . $ `<file>/storage/innobase/include/lock0lock.h`/ |
| 33 | #include "lock0priv.h"cxx . . $ `<file>/storage/innobase/include/lock0priv.h`/ |
| 34 | |
| 35 | /*******************************************************************//** |
| 36 | Initialize lock queue iterator so that it starts to iterate from |
| 37 | "lock". bit_no specifies the record number within the heap where the |
| 38 | record is stored. It can be undefined (ULINT_UNDEFINED) in two cases: |
| 39 | 1. If the lock is a table lock, thus we have a table lock queue; |
| 40 | 2. If the lock is a record lock and it is a wait lock. In this case |
| 41 | bit_no is calculated in this function by using |
| 42 | lock_rec_find_set_bit(). There is exactly one bit set in the bitmap |
| 43 | of a wait lock. */ |
| 44 | void |
| 45 | lock_queue_iterator_resetcxx . . $ lock_queue_iterator_reset(367edde5b0aebf1).( |
| 46 | /*======================*/ |
| 47 | lock_queue_iterator_tcxx . . $ lock_queue_iterator_t#* iter, /*!< out: iterator */ |
| 48 | const lock_tcxx . . $ `/build/tmp.NxIY9EeyJN/package/storage/innobase/include/lock0types.h:34:9`!* lock, /*!< in: lock to start from */ |
| 49 | ulintcxx . . $ ulint# bit_no) /*!< in: record number in the |
| 50 | heap */ |
| 51 | { |
| 52 | lock_syscxx . . $ lock_sys..assert_lockedcxx . . $ lock_sys_t#assert_locked(45efc5c48be9bd55).(*lock); |
| 53 | |
| 54 | iter->current_lockcxx . . $ lock_queue_iterator_t#current_lock. = lock; |
| 55 | |
| 56 | if (bit_no != ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!); |
| 57 | else if (lock->is_table()) |
| 58 | bit_no= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!; |
| 59 | else |
| 60 | { |
| 61 | bit_no= lock_rec_find_set_bitcxx . . $ lock_rec_find_set_bit(fbdb7f62ea435a77).(lock); |
| 62 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(bit_no != ULINT_UNDEFINED); |
| 63 | } |
| 64 | |
| 65 | iter->bit_nocxx . . $ lock_queue_iterator_t#bit_no.= bit_no; |
| 66 | } |
| 67 | |
| 68 | /*******************************************************************//** |
| 69 | Gets the previous lock in the lock queue, returns NULL if there are no |
| 70 | more locks (i.e. the current lock is the first one). The iterator is |
| 71 | receded (if not-NULL is returned). |
| 72 | @return previous lock or NULL */ |
| 73 | const lock_tcxx . . $ `/build/tmp.NxIY9EeyJN/package/storage/innobase/include/lock0types.h:34:9`!* |
| 74 | lock_queue_iterator_get_prevcxx . . $ lock_queue_iterator_get_prev(ccd244996cc30165).( |
| 75 | /*=========================*/ |
| 76 | lock_queue_iterator_tcxx . . $ lock_queue_iterator_t#* iter) /*!< in/out: iterator */ |
| 77 | { |
| 78 | lock_syscxx . . $ lock_sys..assert_lockedcxx . . $ lock_sys_t#assert_locked(45efc5c48be9bd55).(*iter->current_lockcxx . . $ lock_queue_iterator_t#current_lock.); |
| 79 | |
| 80 | const lock_tcxx . . $ `/build/tmp.NxIY9EeyJN/package/storage/innobase/include/lock0types.h:34:9`! *prev_lock= !iter->current_lockcxx . . $ lock_queue_iterator_t#current_lock.->is_table() |
| 81 | ? lock_rec_get_prevcxx . . $ lock_rec_get_prev(9f4355d3c8a9a08e).(iter->current_lockcxx . . $ lock_queue_iterator_t#current_lock., iter->bit_nocxx . . $ lock_queue_iterator_t#bit_no.) |
| 82 | : UT_LIST_GET_PREVcxx . . $ `storage/innobase/include/ut0lst.h:408:9`!(un_member.tab_lock.locks, iter->current_lock); |
| 83 | |
| 84 | if (prev_lock) |
| 85 | iter->current_lockcxx . . $ lock_queue_iterator_t#current_lock.= prev_lock; |
| 86 | |
| 87 | return prev_lock; |
| 88 | } |