~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to storage/innobase/include/lock0lock.ic

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
The transaction lock system
 
3
 
 
4
(c) 1996 Innobase Oy
 
5
 
 
6
Created 5/7/1996 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#include "sync0sync.h"
 
10
#include "srv0srv.h"
 
11
#include "dict0dict.h"
 
12
#include "row0row.h"
 
13
#include "trx0sys.h"
 
14
#include "trx0trx.h"
 
15
#include "buf0buf.h"
 
16
#include "page0page.h"
 
17
#include "page0cur.h"
 
18
#include "row0vers.h"
 
19
#include "que0que.h"
 
20
#include "btr0cur.h"
 
21
#include "read0read.h"
 
22
#include "log0recv.h"
 
23
 
 
24
/*************************************************************************
 
25
Calculates the fold value of a page file address: used in inserting or
 
26
searching for a lock in the hash table. */
 
27
UNIV_INLINE
 
28
ulint
 
29
lock_rec_fold(
 
30
/*==========*/
 
31
                        /* out: folded value */
 
32
        ulint   space,  /* in: space */
 
33
        ulint   page_no)/* in: page number */
 
34
{
 
35
        return(ut_fold_ulint_pair(space, page_no));
 
36
}
 
37
 
 
38
/*************************************************************************
 
39
Calculates the hash value of a page file address: used in inserting or
 
40
searching for a lock in the hash table. */
 
41
UNIV_INLINE
 
42
ulint
 
43
lock_rec_hash(
 
44
/*==========*/
 
45
                        /* out: hashed value */
 
46
        ulint   space,  /* in: space */
 
47
        ulint   page_no)/* in: page number */
 
48
{
 
49
        return(hash_calc_hash(lock_rec_fold(space, page_no),
 
50
                              lock_sys->rec_hash));
 
51
}
 
52
 
 
53
/*************************************************************************
 
54
Checks if some transaction has an implicit x-lock on a record in a clustered
 
55
index. */
 
56
UNIV_INLINE
 
57
trx_t*
 
58
lock_clust_rec_some_has_impl(
 
59
/*=========================*/
 
60
                                /* out: transaction which has the x-lock, or
 
61
                                NULL */
 
62
        rec_t*          rec,    /* in: user record */
 
63
        dict_index_t*   index,  /* in: clustered index */
 
64
        const ulint*    offsets)/* in: rec_get_offsets(rec, index) */
 
65
{
 
66
        dulint  trx_id;
 
67
 
 
68
        ut_ad(mutex_own(&kernel_mutex));
 
69
        ut_ad(index->type & DICT_CLUSTERED);
 
70
        ut_ad(page_rec_is_user_rec(rec));
 
71
 
 
72
        trx_id = row_get_rec_trx_id(rec, index, offsets);
 
73
 
 
74
        if (trx_is_active(trx_id)) {
 
75
                /* The modifying or inserting transaction is active */
 
76
 
 
77
                return(trx_get_on_id(trx_id));
 
78
        }
 
79
 
 
80
        return(NULL);
 
81
}