~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/******************************************************
2
Lock module internal structures and methods.
3
4
(c) 2007 Innobase Oy
5
6
Created July 12, 2007 Vasil Dimov
7
*******************************************************/
8
9
#ifndef lock0priv_h
10
#define lock0priv_h
11
12
#ifndef LOCK_MODULE_IMPLEMENTATION
13
/* If you need to access members of the structures defined in this
14
file, please write appropriate functions that retrieve them and put
15
those functions in lock/ */
16
#error Do not include lock0priv.h outside of the lock/ module
17
#endif
18
19
#include "univ.i"
20
#include "dict0types.h"
21
#include "hash0hash.h"
22
#include "trx0types.h"
23
#include "ut0lst.h"
24
25
/* A table lock */
26
typedef struct lock_table_struct	lock_table_t;
27
struct lock_table_struct {
28
	dict_table_t*	table;		/* database table in dictionary
29
					cache */
30
	UT_LIST_NODE_T(lock_t)
31
			locks;		/* list of locks on the same
32
					table */
33
};
34
35
/* Record lock for a page */
36
typedef struct lock_rec_struct		lock_rec_t;
37
struct lock_rec_struct {
38
	ulint	space;			/* space id */
39
	ulint	page_no;		/* page number */
40
	ulint	n_bits;			/* number of bits in the lock
41
					bitmap; NOTE: the lock bitmap is
42
					placed immediately after the
43
					lock struct */
44
};
45
46
/* Lock struct */
47
struct lock_struct {
48
	trx_t*		trx;		/* transaction owning the
49
					lock */
50
	UT_LIST_NODE_T(lock_t)
51
			trx_locks;	/* list of the locks of the
52
					transaction */
53
	ulint		type_mode;	/* lock type, mode, LOCK_GAP or
54
					LOCK_REC_NOT_GAP,
55
					LOCK_INSERT_INTENTION,
56
					wait flag, ORed */
57
	hash_node_t	hash;		/* hash chain node for a record
58
					lock */
59
	dict_index_t*	index;		/* index for a record lock */
60
	union {
61
		lock_table_t	tab_lock;/* table lock */
62
		lock_rec_t	rec_lock;/* record lock */
63
	} un_member;
64
};
65
66
/*************************************************************************
67
Gets the type of a lock. */
68
UNIV_INLINE
69
ulint
70
lock_get_type(
71
/*==========*/
72
				/* out: LOCK_TABLE or LOCK_REC */
73
	const lock_t*	lock);	/* in: lock */
74
75
/**************************************************************************
76
Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED,
77
if none found. */
78
79
ulint
80
lock_rec_find_set_bit(
81
/*==================*/
82
			/* out: bit index == heap number of the record, or
83
			ULINT_UNDEFINED if none found */
84
	lock_t*	lock);	/* in: record lock with at least one bit set */
85
86
/*************************************************************************
87
Gets the previous record lock set on a record. */
88
89
lock_t*
90
lock_rec_get_prev(
91
/*==============*/
92
			/* out: previous lock on the same record, NULL if
93
			none exists */
94
	lock_t*	in_lock,/* in: record lock */
95
	ulint	heap_no);/* in: heap number of the record */
96
97
#ifndef UNIV_NONINL
98
#include "lock0priv.ic"
99
#endif
100
101
#endif /* lock0priv_h */