3103 Marko Mäkelä 2011-05-24 [merge]
Merge mysql-5.5 to mysql-trunk.
modified:
storage/innobase/include/lock0priv.h
storage/innobase/include/lock0priv.ic
storage/innobase/include/row0row.h
storage/innobase/include/row0row.ic
storage/innobase/lock/lock0lock.c
storage/innobase/row/row0row.c
3102 Marko Mäkelä 2011-05-24 [merge]
Merge from mysql-5.5 to mysql-trunk (no diff).
=== modified file 'storage/innobase/include/lock0priv.h'
--- a/storage/innobase/include/lock0priv.h revid:marko.makela@stripped24084251-vjmufmstzrymzwfg
+++ b/storage/innobase/include/lock0priv.h revid:marko.makela@stripped7g9fzyka7pswlvxw
@@ -118,9 +118,10 @@ UNIV_INLINE
trx_id_t
lock_clust_rec_some_has_impl(
/*=========================*/
- const rec_t* rec, /*!< in: user record */
- dict_index_t* index, /*!< in: clustered index */
- const ulint* offsets); /*!< in: rec_get_offsets(rec, index) */
+ const rec_t* rec, /*!< in: user record */
+ const dict_index_t* index, /*!< in: clustered index */
+ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
+ __attribute__((nonnull, warn_unused_result));
#ifndef UNIV_NONINL
#include "lock0priv.ic"
=== modified file 'storage/innobase/include/lock0priv.ic'
--- a/storage/innobase/include/lock0priv.ic revid:marko.makela@stripped524084251-vjmufmstzrymzwfg
+++ b/storage/innobase/include/lock0priv.ic revid:marko.makela@stripped7-7g9fzyka7pswlvxw
@@ -54,9 +54,9 @@ UNIV_INLINE
trx_id_t
lock_clust_rec_some_has_impl(
/*=========================*/
- const rec_t* rec, /*!< in: user record */
- dict_index_t* index, /*!< in: clustered index */
- const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
+ const rec_t* rec, /*!< in: user record */
+ const dict_index_t* index, /*!< in: clustered index */
+ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
{
ut_ad(dict_index_is_clust(index));
ut_ad(page_rec_is_user_rec(rec));
=== modified file 'storage/innobase/include/row0row.h'
--- a/storage/innobase/include/row0row.h revid:marko.makela@stripped
+++ b/storage/innobase/include/row0row.h revid:marko.makela@oracle.com-20110524120557-7g9fzyka7pswlvxw
@@ -41,13 +41,24 @@ Created 4/20/1996 Heikki Tuuri
Gets the offset of the trx id field, in bytes relative to the origin of
a clustered index record.
@return offset of DATA_TRX_ID */
-UNIV_INTERN
+UNIV_INLINE
ulint
-row_get_trx_id_offset(
-/*==================*/
- const rec_t* rec, /*!< in: record */
- dict_index_t* index, /*!< in: clustered index */
- const ulint* offsets);/*!< in: rec_get_offsets(rec, index) */
+row_get_trx_id_offset_func(
+/*=======================*/
+#ifdef UNIV_DEBUG
+ const rec_t* rec, /*!< in: record */
+#endif /* UNIV_DEBUG */
+ const dict_index_t* index, /*!< in: clustered index */
+ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
+ __attribute__((nonnull, warn_unused_result));
+#ifdef UNIV_DEBUG
+# define row_get_trx_id_offset(rec, index, offsets) \
+ row_get_trx_id_offset_func(rec, index, offsets)
+#else /* UNIV_DEBUG */
+# define row_get_trx_id_offset(rec, index, offsets) \
+ row_get_trx_id_offset_func(index, offsets)
+#endif /* UNIV_DEBUG */
+
/*********************************************************************//**
Reads the trx id field from a clustered index record.
@return value of the field */
@@ -55,9 +66,10 @@ UNIV_INLINE
trx_id_t
row_get_rec_trx_id(
/*===============*/
- const rec_t* rec, /*!< in: record */
- dict_index_t* index, /*!< in: clustered index */
- const ulint* offsets);/*!< in: rec_get_offsets(rec, index) */
+ const rec_t* rec, /*!< in: record */
+ const dict_index_t* index, /*!< in: clustered index */
+ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
+ __attribute__((nonnull, warn_unused_result));
/*********************************************************************//**
Reads the roll pointer field from a clustered index record.
@return value of the field */
=== modified file 'storage/innobase/include/row0row.ic'
--- a/storage/innobase/include/row0row.ic revid:marko.makela@stripped
+++ b/storage/innobase/include/row0row.ic revid:marko.makela@oracle.com-20110524120557-7g9fzyka7pswlvxw
@@ -28,15 +28,45 @@ Created 4/20/1996 Heikki Tuuri
#include "trx0undo.h"
/*********************************************************************//**
+Gets the offset of trx id field, in bytes relative to the origin of
+a clustered index record.
+@return offset of DATA_TRX_ID */
+UNIV_INLINE
+ulint
+row_get_trx_id_offset_func(
+/*=======================*/
+#ifdef UNIV_DEBUG
+ const rec_t* rec, /*!< in: record */
+#endif /* UNIV_DEBUG */
+ const dict_index_t* index, /*!< in: clustered index */
+ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
+{
+ ulint pos;
+ ulint offset;
+ ulint len;
+
+ ut_ad(dict_index_is_clust(index));
+ ut_ad(rec_offs_validate(rec, index, offsets));
+
+ pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
+
+ offset = rec_get_nth_field_offs(offsets, pos, &len);
+
+ ut_ad(len == DATA_TRX_ID_LEN);
+
+ return(offset);
+}
+
+/*********************************************************************//**
Reads the trx id field from a clustered index record.
@return value of the field */
UNIV_INLINE
trx_id_t
row_get_rec_trx_id(
/*===============*/
- const rec_t* rec, /*!< in: record */
- dict_index_t* index, /*!< in: clustered index */
- const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
+ const rec_t* rec, /*!< in: record */
+ const dict_index_t* index, /*!< in: clustered index */
+ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
{
ulint offset;
=== modified file 'storage/innobase/lock/lock0lock.c'
--- a/storage/innobase/lock/lock0lock.c revid:marko.makela@stripped-20110524084251-vjmufmstzrymzwfg
+++ b/storage/innobase/lock/lock0lock.c revid:marko.makela@stripped557-7g9fzyka7pswlvxw
@@ -361,6 +361,7 @@ ibool
lock_validate(void);
/*===============*/
+# ifdef UNIV_DEBUG_LOCK_VALIDATE
/*********************************************************************//**
Validates the record lock queues on a page.
@return TRUE if ok */
@@ -368,13 +369,9 @@ static
ibool
lock_rec_validate_page(
/*===================*/
- ibool locked_lock_trx_sys, /*!< in: if the caller holds
- both the lock mutex and
- trx_sys_t->lock. */
- ulint space, /*!< in: space id */
- ulint zip_size, /*!< in: compressed page size
- in bytes or 0 for uncompressed pages */
- ulint page_no); /*!< in: page number */
+ const buf_block_t* block) /*!< in: buffer block */
+ __attribute__((nonnull, warn_unused_result));
+# endif /* UNIV_DEBUG_LOCK_VALIDATE */
#endif /* UNIV_DEBUG */
/* The lock system */
@@ -1135,10 +1132,10 @@ lock_rec_reset_nth_bit(
Gets the first or next record lock on a page.
@return next lock, NULL if none exists */
UNIV_INLINE
-lock_t*
-lock_rec_get_next_on_page(
-/*======================*/
- lock_t* lock) /*!< in: a record lock */
+const lock_t*
+lock_rec_get_next_on_page_const(
+/*============================*/
+ const lock_t* lock) /*!< in: a record lock */
{
ulint space;
ulint page_no;
@@ -1171,12 +1168,12 @@ lock_rec_get_next_on_page(
Gets the first or next record lock on a page.
@return next lock, NULL if none exists */
UNIV_INLINE
-const lock_t*
-lock_rec_get_next_on_page_const(
-/*============================*/
- const lock_t* lock) /*!< in: a record lock */
+lock_t*
+lock_rec_get_next_on_page(
+/*======================*/
+ lock_t* lock) /*!< in: a record lock */
{
- return(lock_rec_get_next_on_page((lock_t*) lock));
+ return((lock_t*) lock_rec_get_next_on_page_const(lock));
}
/*********************************************************************//**
@@ -2780,10 +2777,7 @@ lock_move_reorganize_page(
mem_heap_free(heap);
#ifdef UNIV_DEBUG_LOCK_VALIDATE
- ut_ad(lock_rec_validate_page(FALSE,
- buf_block_get_space(block),
- buf_block_get_zip_size(block),
- buf_block_get_page_no(block)));
+ ut_ad(lock_rec_validate_page(block));
#endif
}
@@ -2871,14 +2865,8 @@ lock_move_rec_list_end(
lock_mutex_exit();
#ifdef UNIV_DEBUG_LOCK_VALIDATE
- ut_ad(lock_rec_validate_page(FALSE,
- buf_block_get_space(block),
- buf_block_get_zip_size(block),
- buf_block_get_page_no(block)));
- ut_ad(lock_rec_validate_page(FALSE,
- buf_block_get_space(new_block),
- buf_block_get_zip_size(block),
- buf_block_get_page_no(new_block)));
+ ut_ad(lock_rec_validate_page(block));
+ ut_ad(lock_rec_validate_page(new_block));
#endif
}
@@ -2987,10 +2975,7 @@ lock_move_rec_list_start(
lock_mutex_exit();
#ifdef UNIV_DEBUG_LOCK_VALIDATE
- ut_ad(lock_rec_validate_page(FALSE,
- buf_block_get_space(block),
- buf_block_get_zip_size(block),
- buf_block_get_page_no(block)));
+ ut_ad(lock_rec_validate_page(block));
#endif
}
@@ -4075,17 +4060,18 @@ Checks if other transactions have an inc
the lock queue.
@return lock or NULL */
UNIV_INLINE
-lock_t*
+const lock_t*
lock_table_other_has_incompatible(
/*==============================*/
- trx_t* trx, /*!< in: transaction, or NULL if all
- transactions should be included */
- ulint wait, /*!< in: LOCK_WAIT if also waiting locks are
- taken into account, or 0 if not */
- dict_table_t* table, /*!< in: table */
- enum lock_mode mode) /*!< in: lock mode */
+ const trx_t* trx, /*!< in: transaction, or NULL if all
+ transactions should be included */
+ ulint wait, /*!< in: LOCK_WAIT if also
+ waiting locks are taken into
+ account, or 0 if not */
+ const dict_table_t* table, /*!< in: table */
+ enum lock_mode mode) /*!< in: lock mode */
{
- lock_t* lock;
+ const lock_t* lock;
ut_ad(lock_mutex_own());
@@ -4121,7 +4107,7 @@ lock_table(
{
trx_t* trx;
ulint err;
- lock_t* lock;
+ const lock_t* lock;
ut_ad(table && thr);
@@ -5080,9 +5066,9 @@ static
ibool
lock_table_queue_validate(
/*======================*/
- dict_table_t* table) /*!< in: table */
+ const dict_table_t* table) /*!< in: table */
{
- lock_t* lock;
+ const lock_t* lock;
ut_ad(lock_mutex_own());
#ifdef UNIV_SYNC_DEBUG
@@ -5128,7 +5114,7 @@ lock_rec_queue_validate(
trx_sys_t->lock. */
const buf_block_t* block, /*!< in: buffer block containing rec */
const rec_t* rec, /*!< in: record to look at */
- dict_index_t* index, /*!< in: index, or NULL if not known */
+ const dict_index_t* index, /*!< in: index, or NULL if not known */
const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
{
const trx_t* impl_trx;
@@ -5235,59 +5221,30 @@ func_exit:
/*********************************************************************//**
Validates the record lock queues on a page.
@return TRUE if ok */
-static
+static __attribute__((nonnull, warn_unused_result))
ibool
-lock_rec_validate_page(
-/*===================*/
- ibool locked_lock_trx_sys, /*!< in: if the caller holds
- both the lock mutex and
- trx_sys_t->lock. */
- ulint space, /*!< in: space id */
- ulint zip_size, /*!< in: compressed page size
- in bytes or 0 for uncompressed pages */
- ulint page_no) /*!< in: page number */
+lock_rec_validate_page_low(
+/*=======================*/
+ const buf_block_t* block) /*!< in: buffer block */
{
- dict_index_t* index;
- buf_block_t* block;
- const page_t* page;
const lock_t* lock;
const rec_t* rec;
ulint nth_lock = 0;
ulint nth_bit = 0;
ulint i;
- mtr_t mtr;
mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_;
rec_offs_init(offsets_);
- /* This is to preserve latching order. */
- if (locked_lock_trx_sys) {
- lock_mutex_exit();
- rw_lock_s_unlock(&trx_sys->lock);
- }
-
- ut_ad(!lock_mutex_own());
+ ut_ad(lock_mutex_own());
#ifdef UNIV_SYNC_DEBUG
- ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
- ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_EX));
+ ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
#endif /* UNIV_SYNC_DEBUG */
- mtr_start(&mtr);
-
- ut_ad(zip_size != ULINT_UNDEFINED);
- block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, &mtr);
- buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
-
- page = block->frame;
-
- /* Either way we need to (re)acquire the mutexes. */
- lock_mutex_enter();
-
- rw_lock_s_lock(&trx_sys->lock);
-
loop:
- lock = lock_rec_get_first_on_page_addr(space, page_no);
+ lock = lock_rec_get_first_on_page_addr(buf_block_get_space(block),
+ buf_block_get_page_no(block));
if (!lock) {
goto function_exit;
@@ -5315,15 +5272,14 @@ loop:
if (i == 1 || lock_rec_get_nth_bit(lock, i)) {
- index = lock->index;
- rec = page_find_rec_with_heap_no(page, i);
+ rec = page_find_rec_with_heap_no(block->frame, i);
ut_a(rec);
- offsets = rec_get_offsets(rec, index, offsets,
+ offsets = rec_get_offsets(rec, lock->index, offsets,
ULINT_UNDEFINED, &heap);
#if 0
fprintf(stderr,
- "Validating %lu %lu\n",
- (ulong) space, (ulong) page_no);
+ "Validating %u %u\n",
+ block->page.space, block->page.offset);
#endif
/* If this thread is holding the file space
latch (fil_space_t::latch), the following
@@ -5331,7 +5287,7 @@ loop:
cause a deadlock of threads. */
lock_rec_queue_validate(
- TRUE, block, rec, index, offsets);
+ TRUE, block, rec, lock->index, offsets);
nth_bit = i + 1;
@@ -5345,20 +5301,34 @@ loop:
goto loop;
function_exit:
-
- mtr_commit(&mtr);
-
- if (!locked_lock_trx_sys) {
- lock_mutex_exit();
- rw_lock_s_unlock(&trx_sys->lock);
- }
-
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
return(TRUE);
}
+#ifdef UNIV_DEBUG_LOCK_VALIDATE
+/*********************************************************************//**
+Validates the record lock queues on a page.
+@return TRUE if ok */
+static
+ibool
+lock_rec_validate_page(
+/*===================*/
+ const buf_block_t* block) /*!< in: buffer block */
+{
+ ibool valid;
+
+ lock_mutex_enter();
+ rw_lock_s_lock(&trx_sys->lock);
+ valid = lock_rec_validate_page_low(block);
+ lock_mutex_exit();
+ rw_lock_s_unlock(&trx_sys->lock);
+
+ return(valid);
+}
+#endif /* UNIV_DEBUG_LOCK_VALIDATE */
+
/*********************************************************************//**
Validates the lock system.
@return TRUE if ok */
@@ -5369,8 +5339,6 @@ lock_validate(void)
{
const lock_t* lock;
const trx_t* trx;
- ulint space;
- ulint page_no;
ulint i;
lock_mutex_enter();
@@ -5396,9 +5364,13 @@ lock_validate(void)
}
for (i = 0; i < hash_get_n_cells(lock_sys->rec_hash); i++) {
- ib_uint64_t limit = 0;
+ ulint space;
+ ulint page_no;
+ ib_uint64_t limit = 0;
for (;;) {
+ mtr_t mtr;
+ buf_block_t* block;
for (lock = HASH_GET_FIRST(lock_sys->rec_hash, i);
lock != NULL;
@@ -5419,11 +5391,16 @@ lock_validate(void)
break;
}
- lock_rec_validate_page(
- TRUE, space,
- fil_space_get_zip_size(space), page_no);
+ mtr_start(&mtr);
+ block = buf_page_get(
+ space, fil_space_get_zip_size(space),
+ page_no, RW_X_LATCH, &mtr);
+ buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
+
+ ut_ad(lock_rec_validate_page_low(block));
+ mtr_commit(&mtr);
- limit = ut_ull_create(space, page_no + 1);
+ limit++;
}
}
=== modified file 'storage/innobase/row/row0row.c'
--- a/storage/innobase/row/row0row.c revid:marko.makela@strippedm-20110524084251-vjmufmstzrymzwfg
+++ b/storage/innobase/row/row0row.c revid:marko.makela@stripped7-7g9fzyka7pswlvxw
@@ -47,35 +47,6 @@ Created 4/20/1996 Heikki Tuuri
#include "read0read.h"
#include "ut0mem.h"
-/*********************************************************************//**
-Gets the offset of trx id field, in bytes relative to the origin of
-a clustered index record.
-@return offset of DATA_TRX_ID */
-UNIV_INTERN
-ulint
-row_get_trx_id_offset(
-/*==================*/
- const rec_t* rec __attribute__((unused)),
- /*!< in: record */
- dict_index_t* index, /*!< in: clustered index */
- const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
-{
- ulint pos;
- ulint offset;
- ulint len;
-
- ut_ad(dict_index_is_clust(index));
- ut_ad(rec_offs_validate(rec, index, offsets));
-
- pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
-
- offset = rec_get_nth_field_offs(offsets, pos, &len);
-
- ut_ad(len == DATA_TRX_ID_LEN);
-
- return(offset);
-}
-
/*****************************************************************//**
When an insert or purge to a table is performed, this function builds
the entry to be inserted into or purged from an index on the table.
Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110524120557-7g9fzyka7pswlvxw.bundle
| Thread |
|---|
| • bzr push into mysql-trunk branch (marko.makela:3102 to 3103) | marko.makela | 24 May |