1/***************************************************************************** 2 3Copyright (c) 1996, 2009, Oracle and/or its affiliates. All Rights Reserved. 4 5This program is free software; you can redistribute it and/or modify 6it under the terms of the GNU General Public License, version 2.0, 7as published by the Free Software Foundation. 8 9This program is also distributed with certain software (including 10but not limited to OpenSSL) that is licensed under separate terms, 11as designated in a particular file or component or in included license 12documentation. The authors of MySQL hereby grant you an additional 13permission to link the program and your derivative works with the 14separately licensed software that they have included with MySQL. 15 16This program is distributed in the hope that it will be useful, 17but WITHOUT ANY WARRANTY; without even the implied warranty of 18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19GNU General Public License, version 2.0, for more details. 20 21You should have received a copy of the GNU General Public License along with 22this program; if not, write to the Free Software Foundation, Inc., 2351 Franklin Street, Suite 500, Boston, MA 02110-1335 USA 24 25*****************************************************************************/ 26 27/**************************************************//** 28@file include/lock0lock.ic 29The transaction lock system 30 31Created 5/7/1996 Heikki Tuuri 32*******************************************************/ 33 34#include "sync0sync.h" 35#include "srv0srv.h" 36#include "dict0dict.h" 37#include "row0row.h" 38#include "trx0sys.h" 39#include "trx0trx.h" 40#include "buf0buf.h" 41#include "page0page.h" 42#include "page0cur.h" 43#include "row0vers.h" 44#include "que0que.h" 45#include "btr0cur.h" 46#include "read0read.h" 47#include "log0recv.h" 48 49/*********************************************************************//** 50Calculates the fold value of a page file address: used in inserting or 51searching for a lock in the hash table. 52@return folded value */ 53UNIV_INLINE 54ulint 55lock_rec_fold( 56/*==========*/ 57 ulint space, /*!< in: space */ 58 ulint page_no)/*!< in: page number */ 59{ 60 return(ut_fold_ulint_pair(space, page_no)); 61} 62 63/*********************************************************************//** 64Calculates the hash value of a page file address: used in inserting or 65searching for a lock in the hash table. 66@return hashed value */ 67UNIV_INLINE 68ulint 69lock_rec_hash( 70/*==========*/ 71 ulint space, /*!< in: space */ 72 ulint page_no)/*!< in: page number */ 73{ 74 return(hash_calc_hash(lock_rec_fold(space, page_no), 75 lock_sys->rec_hash)); 76} 77 78/*********************************************************************//** 79Gets the heap_no of the smallest user record on a page. 80@return heap_no of smallest user record, or PAGE_HEAP_NO_SUPREMUM */ 81UNIV_INLINE 82ulint 83lock_get_min_heap_no( 84/*=================*/ 85 const buf_block_t* block) /*!< in: buffer block */ 86{ 87 const page_t* page = block->frame; 88 89 if (page_is_comp(page)) { 90 return(rec_get_heap_no_new( 91 page 92 + rec_get_next_offs(page + PAGE_NEW_INFIMUM, 93 TRUE))); 94 } else { 95 return(rec_get_heap_no_old( 96 page 97 + rec_get_next_offs(page + PAGE_OLD_INFIMUM, 98 FALSE))); 99 } 100} 101