37 changed files with 1370 additions and 633 deletions
-
3CMakeLists.txt
-
9Makefile.am
-
2btr/btr0sea.c
-
4buf/buf0buf.c
-
104dict/dict0dict.c
-
5dict/dict0mem.c
-
9export.sh
-
8fsp/fsp0fsp.c
-
781handler/ha_innodb.cc
-
58handler/ha_innodb.h
-
6include/buf0buf.h
-
10include/buf0buf.ic
-
39include/dict0dict.h
-
4include/dict0mem.h
-
2include/fsp0fsp.h
-
52include/lock0iter.h
-
15include/lock0lock.h
-
101include/lock0priv.h
-
32include/lock0priv.ic
-
1include/row0mysql.h
-
10include/row0sel.h
-
3include/trx0trx.h
-
2include/univ.i
-
90lock/lock0iter.c
-
60lock/lock0lock.c
-
213log/log0recv.c
-
2mysql-test/have_innodb.inc
-
67mysql-test/innodb.result
-
109mysql-test/innodb.test
-
8mysql-test/innodb_trx_weight.test
-
3os/os0file.c
-
2plug.in
-
2row/row0mysql.c
-
166row/row0sel.c
-
18sync/sync0rw.c
-
1sync/sync0sync.c
-
2trx/trx0trx.c
781
handler/ha_innodb.cc
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,52 @@ |
|||
/****************************************************** |
|||
Lock queue iterator type and function prototypes. |
|||
|
|||
(c) 2007 Innobase Oy |
|||
|
|||
Created July 16, 2007 Vasil Dimov |
|||
*******************************************************/ |
|||
|
|||
#ifndef lock0iter_h |
|||
#define lock0iter_h |
|||
|
|||
#include "univ.i" |
|||
#include "lock0types.h" |
|||
|
|||
typedef struct lock_queue_iterator_struct { |
|||
const lock_t* current_lock; |
|||
/* In case this is a record lock queue (not table lock queue) |
|||
then bit_no is the record number within the heap in which the |
|||
record is stored. */ |
|||
ulint bit_no; |
|||
} lock_queue_iterator_t; |
|||
|
|||
/*********************************************************************** |
|||
Initialize lock queue iterator so that it starts to iterate from |
|||
"lock". bit_no specifies the record number within the heap where the |
|||
record is stored. It can be undefined (ULINT_UNDEFINED) in two cases: |
|||
1. If the lock is a table lock, thus we have a table lock queue; |
|||
2. If the lock is a record lock and it is a wait lock. In this case |
|||
bit_no is calculated in this function by using |
|||
lock_rec_find_set_bit(). There is exactly one bit set in the bitmap |
|||
of a wait lock. */ |
|||
|
|||
void |
|||
lock_queue_iterator_reset( |
|||
/*======================*/ |
|||
lock_queue_iterator_t* iter, /* out: iterator */ |
|||
const lock_t* lock, /* in: lock to start from */ |
|||
ulint bit_no);/* in: record number in the |
|||
heap */ |
|||
|
|||
/*********************************************************************** |
|||
Gets the previous lock in the lock queue, returns NULL if there are no |
|||
more locks (i.e. the current lock is the first one). The iterator is |
|||
receded (if not-NULL is returned). */ |
|||
|
|||
const lock_t* |
|||
lock_queue_iterator_get_prev( |
|||
/*=========================*/ |
|||
/* out: previous lock or NULL */ |
|||
lock_queue_iterator_t* iter); /* in/out: iterator */ |
|||
|
|||
#endif /* lock0iter_h */ |
|||
@ -0,0 +1,101 @@ |
|||
/****************************************************** |
|||
Lock module internal structures and methods. |
|||
|
|||
(c) 2007 Innobase Oy |
|||
|
|||
Created July 12, 2007 Vasil Dimov |
|||
*******************************************************/ |
|||
|
|||
#ifndef lock0priv_h |
|||
#define lock0priv_h |
|||
|
|||
#ifndef LOCK_MODULE_IMPLEMENTATION |
|||
/* If you need to access members of the structures defined in this |
|||
file, please write appropriate functions that retrieve them and put |
|||
those functions in lock/ */ |
|||
#error Do not include lock0priv.h outside of the lock/ module |
|||
#endif |
|||
|
|||
#include "univ.i" |
|||
#include "dict0types.h" |
|||
#include "hash0hash.h" |
|||
#include "trx0types.h" |
|||
#include "ut0lst.h" |
|||
|
|||
/* A table lock */ |
|||
typedef struct lock_table_struct lock_table_t; |
|||
struct lock_table_struct { |
|||
dict_table_t* table; /* database table in dictionary |
|||
cache */ |
|||
UT_LIST_NODE_T(lock_t) |
|||
locks; /* list of locks on the same |
|||
table */ |
|||
}; |
|||
|
|||
/* Record lock for a page */ |
|||
typedef struct lock_rec_struct lock_rec_t; |
|||
struct lock_rec_struct { |
|||
ulint space; /* space id */ |
|||
ulint page_no; /* page number */ |
|||
ulint n_bits; /* number of bits in the lock |
|||
bitmap; NOTE: the lock bitmap is |
|||
placed immediately after the |
|||
lock struct */ |
|||
}; |
|||
|
|||
/* Lock struct */ |
|||
struct lock_struct { |
|||
trx_t* trx; /* transaction owning the |
|||
lock */ |
|||
UT_LIST_NODE_T(lock_t) |
|||
trx_locks; /* list of the locks of the |
|||
transaction */ |
|||
ulint type_mode; /* lock type, mode, LOCK_GAP or |
|||
LOCK_REC_NOT_GAP, |
|||
LOCK_INSERT_INTENTION, |
|||
wait flag, ORed */ |
|||
hash_node_t hash; /* hash chain node for a record |
|||
lock */ |
|||
dict_index_t* index; /* index for a record lock */ |
|||
union { |
|||
lock_table_t tab_lock;/* table lock */ |
|||
lock_rec_t rec_lock;/* record lock */ |
|||
} un_member; |
|||
}; |
|||
|
|||
/************************************************************************* |
|||
Gets the type of a lock. */ |
|||
UNIV_INLINE |
|||
ulint |
|||
lock_get_type( |
|||
/*==========*/ |
|||
/* out: LOCK_TABLE or LOCK_REC */ |
|||
const lock_t* lock); /* in: lock */ |
|||
|
|||
/************************************************************************** |
|||
Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, |
|||
if none found. */ |
|||
|
|||
ulint |
|||
lock_rec_find_set_bit( |
|||
/*==================*/ |
|||
/* out: bit index == heap number of |
|||
the record, or ULINT_UNDEFINED if none found */ |
|||
const lock_t* lock); /* in: record lock with at least one bit set */ |
|||
|
|||
/************************************************************************* |
|||
Gets the previous record lock set on a record. */ |
|||
|
|||
const lock_t* |
|||
lock_rec_get_prev( |
|||
/*==============*/ |
|||
/* out: previous lock on the same |
|||
record, NULL if none exists */ |
|||
const lock_t* in_lock,/* in: record lock */ |
|||
ulint heap_no);/* in: heap number of the record */ |
|||
|
|||
#ifndef UNIV_NONINL |
|||
#include "lock0priv.ic" |
|||
#endif |
|||
|
|||
#endif /* lock0priv_h */ |
|||
@ -0,0 +1,32 @@ |
|||
/****************************************************** |
|||
Lock module internal inline methods. |
|||
|
|||
(c) 2007 Innobase Oy |
|||
|
|||
Created July 16, 2007 Vasil Dimov |
|||
*******************************************************/ |
|||
|
|||
/* This file contains only methods which are used in |
|||
lock/lock0* files, other than lock/lock0lock.c. |
|||
I.e. lock/lock0lock.c contains more internal inline |
|||
methods but they are used only in that file. */ |
|||
|
|||
#ifndef LOCK_MODULE_IMPLEMENTATION |
|||
#error Do not include lock0priv.ic outside of the lock/ module |
|||
#endif |
|||
|
|||
/************************************************************************* |
|||
Gets the type of a lock. */ |
|||
UNIV_INLINE |
|||
ulint |
|||
lock_get_type( |
|||
/*==========*/ |
|||
/* out: LOCK_TABLE or LOCK_REC */ |
|||
const lock_t* lock) /* in: lock */ |
|||
{ |
|||
ut_ad(lock); |
|||
|
|||
return(lock->type_mode & LOCK_TYPE_MASK); |
|||
} |
|||
|
|||
/* vim: set filetype=c: */ |
|||
@ -0,0 +1,90 @@ |
|||
/****************************************************** |
|||
Lock queue iterator. Can iterate over table and record |
|||
lock queues. |
|||
|
|||
(c) 2007 Innobase Oy |
|||
|
|||
Created July 16, 2007 Vasil Dimov |
|||
*******************************************************/ |
|||
|
|||
#define LOCK_MODULE_IMPLEMENTATION |
|||
|
|||
#include "univ.i" |
|||
#include "lock0iter.h" |
|||
#include "lock0lock.h" |
|||
#include "lock0priv.h" |
|||
#include "ut0dbg.h" |
|||
#include "ut0lst.h" |
|||
|
|||
/*********************************************************************** |
|||
Initialize lock queue iterator so that it starts to iterate from |
|||
"lock". bit_no specifies the record number within the heap where the |
|||
record is stored. It can be undefined (ULINT_UNDEFINED) in two cases: |
|||
1. If the lock is a table lock, thus we have a table lock queue; |
|||
2. If the lock is a record lock and it is a wait lock. In this case |
|||
bit_no is calculated in this function by using |
|||
lock_rec_find_set_bit(). There is exactly one bit set in the bitmap |
|||
of a wait lock. */ |
|||
|
|||
void |
|||
lock_queue_iterator_reset( |
|||
/*======================*/ |
|||
lock_queue_iterator_t* iter, /* out: iterator */ |
|||
const lock_t* lock, /* in: lock to start from */ |
|||
ulint bit_no) /* in: record number in the |
|||
heap */ |
|||
{ |
|||
iter->current_lock = lock; |
|||
|
|||
if (bit_no != ULINT_UNDEFINED) { |
|||
|
|||
iter->bit_no = bit_no; |
|||
} else { |
|||
|
|||
switch (lock_get_type(lock)) { |
|||
case LOCK_TABLE: |
|||
iter->bit_no = ULINT_UNDEFINED; |
|||
break; |
|||
case LOCK_REC: |
|||
iter->bit_no = lock_rec_find_set_bit(lock); |
|||
ut_a(iter->bit_no != ULINT_UNDEFINED); |
|||
break; |
|||
default: |
|||
ut_error; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/*********************************************************************** |
|||
Gets the previous lock in the lock queue, returns NULL if there are no |
|||
more locks (i.e. the current lock is the first one). The iterator is |
|||
receded (if not-NULL is returned). */ |
|||
|
|||
const lock_t* |
|||
lock_queue_iterator_get_prev( |
|||
/*=========================*/ |
|||
/* out: previous lock or NULL */ |
|||
lock_queue_iterator_t* iter) /* in/out: iterator */ |
|||
{ |
|||
const lock_t* prev_lock; |
|||
|
|||
switch (lock_get_type(iter->current_lock)) { |
|||
case LOCK_REC: |
|||
prev_lock = lock_rec_get_prev( |
|||
iter->current_lock, iter->bit_no); |
|||
break; |
|||
case LOCK_TABLE: |
|||
prev_lock = UT_LIST_GET_PREV( |
|||
un_member.tab_lock.locks, iter->current_lock); |
|||
break; |
|||
default: |
|||
ut_error; |
|||
} |
|||
|
|||
if (prev_lock != NULL) { |
|||
|
|||
iter->current_lock = prev_lock; |
|||
} |
|||
|
|||
return(prev_lock); |
|||
} |
|||
@ -1,4 +1,4 @@ |
|||
disable_query_log; |
|||
--require r/true.require |
|||
select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'innodb'; |
|||
select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'innodb'; |
|||
enable_query_log; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue