1
/*****************************************************************************
3
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/lock0lock.ic
21
The transaction lock system
23
Created 5/7/1996 Heikki Tuuri
24
*******************************************************/
26
#include "sync0sync.h"
28
#include "dict0dict.h"
33
#include "page0page.h"
38
#include "read0read.h"
41
/*********************************************************************//**
42
Calculates the fold value of a page file address: used in inserting or
43
searching for a lock in the hash table.
44
@return folded value */
49
ulint space, /*!< in: space */
50
ulint page_no)/*!< in: page number */
52
return(ut_fold_ulint_pair(space, page_no));
55
/*********************************************************************//**
56
Calculates the hash value of a page file address: used in inserting or
57
searching for a lock in the hash table.
58
@return hashed value */
63
ulint space, /*!< in: space */
64
ulint page_no)/*!< in: page number */
66
return(hash_calc_hash(lock_rec_fold(space, page_no),
70
/*********************************************************************//**
71
Checks if some transaction has an implicit x-lock on a record in a clustered
73
@return transaction which has the x-lock, or NULL */
76
lock_clust_rec_some_has_impl(
77
/*=========================*/
78
const rec_t* rec, /*!< in: user record */
79
dict_index_t* index, /*!< in: clustered index */
80
const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
84
ut_ad(mutex_own(&kernel_mutex));
85
ut_ad(dict_index_is_clust(index));
86
ut_ad(page_rec_is_user_rec(rec));
88
trx_id = row_get_rec_trx_id(rec, index, offsets);
90
if (trx_is_active(trx_id)) {
91
/* The modifying or inserting transaction is active */
93
return(trx_get_on_id(trx_id));
99
/*********************************************************************//**
100
Gets the heap_no of the smallest user record on a page.
101
@return heap_no of smallest user record, or PAGE_HEAP_NO_SUPREMUM */
104
lock_get_min_heap_no(
105
/*=================*/
106
const buf_block_t* block) /*!< in: buffer block */
108
const page_t* page = block->frame;
110
if (page_is_comp(page)) {
111
return(rec_get_heap_no_new(
113
+ rec_get_next_offs(page + PAGE_NEW_INFIMUM,
116
return(rec_get_heap_no_old(
118
+ rec_get_next_offs(page + PAGE_OLD_INFIMUM,