Commit 46b8fd92 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge mysql-5.1-innodb to mysql-5.5-innodb.

parents 6dee4b50 0c2b4951
...@@ -76,6 +76,23 @@ struct thr_local_struct{ ...@@ -76,6 +76,23 @@ struct thr_local_struct{
/** The value of thr_local_struct::magic_n */ /** The value of thr_local_struct::magic_n */
#define THR_LOCAL_MAGIC_N 1231234 #define THR_LOCAL_MAGIC_N 1231234
#ifdef UNIV_DEBUG
/*******************************************************************//**
Validates thread local data.
@return TRUE if valid */
static
ibool
thr_local_validate(
/*===============*/
const thr_local_t* local) /*!< in: data to validate */
{
ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
ut_ad(local->slot_no < OS_THREAD_MAX_N);
ut_ad(local->in_ibuf == FALSE || local->in_ibuf == TRUE);
return(TRUE);
}
#endif /* UNIV_DEBUG */
/*******************************************************************//** /*******************************************************************//**
Returns the local storage struct for a thread. Returns the local storage struct for a thread.
@return local storage */ @return local storage */
...@@ -96,7 +113,8 @@ thr_local_get( ...@@ -96,7 +113,8 @@ thr_local_get(
local = NULL; local = NULL;
HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id), HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
thr_local_t*, local,, os_thread_eq(local->id, id)); thr_local_t*, local, ut_ad(thr_local_validate(local)),
os_thread_eq(local->id, id));
if (local == NULL) { if (local == NULL) {
mutex_exit(&thr_local_mutex); mutex_exit(&thr_local_mutex);
...@@ -107,7 +125,7 @@ thr_local_get( ...@@ -107,7 +125,7 @@ thr_local_get(
goto try_again; goto try_again;
} }
ut_ad(local->magic_n == THR_LOCAL_MAGIC_N); ut_ad(thr_local_validate(local));
return(local); return(local);
} }
...@@ -220,7 +238,8 @@ thr_local_free( ...@@ -220,7 +238,8 @@ thr_local_free(
/* Look for the local struct in the hash table */ /* Look for the local struct in the hash table */
HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id), HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
thr_local_t*, local,, os_thread_eq(local->id, id)); thr_local_t*, local, ut_ad(thr_local_validate(local)),
os_thread_eq(local->id, id));
if (local == NULL) { if (local == NULL) {
mutex_exit(&thr_local_mutex); mutex_exit(&thr_local_mutex);
...@@ -233,6 +252,7 @@ thr_local_free( ...@@ -233,6 +252,7 @@ thr_local_free(
mutex_exit(&thr_local_mutex); mutex_exit(&thr_local_mutex);
ut_a(local->magic_n == THR_LOCAL_MAGIC_N); ut_a(local->magic_n == THR_LOCAL_MAGIC_N);
ut_ad(thr_local_validate(local));
mem_free(local); mem_free(local);
} }
...@@ -276,6 +296,7 @@ thr_local_close(void) ...@@ -276,6 +296,7 @@ thr_local_close(void)
local = HASH_GET_NEXT(hash, prev_local); local = HASH_GET_NEXT(hash, prev_local);
ut_a(prev_local->magic_n == THR_LOCAL_MAGIC_N); ut_a(prev_local->magic_n == THR_LOCAL_MAGIC_N);
ut_ad(thr_local_validate(prev_local));
mem_free(prev_local); mem_free(prev_local);
} }
} }
......
...@@ -415,6 +415,42 @@ table_cache_create_empty_row( ...@@ -415,6 +415,42 @@ table_cache_create_empty_row(
return(row); return(row);
} }
#ifdef UNIV_DEBUG
/*******************************************************************//**
Validates a row in the locks cache.
@return TRUE if valid */
static
ibool
i_s_locks_row_validate(
/*===================*/
const i_s_locks_row_t* row) /*!< in: row to validate */
{
ut_ad(row->lock_trx_id != 0);
ut_ad(row->lock_mode != NULL);
ut_ad(row->lock_type != NULL);
ut_ad(row->lock_table != NULL);
ut_ad(row->lock_table_id != 0);
if (row->lock_space == ULINT_UNDEFINED) {
/* table lock */
ut_ad(!strcmp("TABLE", row->lock_type));
ut_ad(row->lock_index == NULL);
ut_ad(row->lock_data == NULL);
ut_ad(row->lock_page == ULINT_UNDEFINED);
ut_ad(row->lock_rec == ULINT_UNDEFINED);
} else {
/* record lock */
ut_ad(!strcmp("RECORD", row->lock_type));
ut_ad(row->lock_index != NULL);
ut_ad(row->lock_data != NULL);
ut_ad(row->lock_page != ULINT_UNDEFINED);
ut_ad(row->lock_rec != ULINT_UNDEFINED);
}
return(TRUE);
}
#endif /* UNIV_DEBUG */
/*******************************************************************//** /*******************************************************************//**
Fills i_s_trx_row_t object. Fills i_s_trx_row_t object.
If memory can not be allocated then FALSE is returned. If memory can not be allocated then FALSE is returned.
...@@ -445,18 +481,15 @@ fill_trx_row( ...@@ -445,18 +481,15 @@ fill_trx_row(
row->trx_id = trx->id; row->trx_id = trx->id;
row->trx_started = (ib_time_t) trx->start_time; row->trx_started = (ib_time_t) trx->start_time;
row->trx_state = trx_get_que_state_str(trx); row->trx_state = trx_get_que_state_str(trx);
row->requested_lock_row = requested_lock_row;
ut_ad(requested_lock_row == NULL
|| i_s_locks_row_validate(requested_lock_row));
if (trx->wait_lock != NULL) { if (trx->wait_lock != NULL) {
ut_a(requested_lock_row != NULL); ut_a(requested_lock_row != NULL);
row->requested_lock_row = requested_lock_row;
row->trx_wait_started = (ib_time_t) trx->wait_started; row->trx_wait_started = (ib_time_t) trx->wait_started;
} else { } else {
ut_a(requested_lock_row == NULL); ut_a(requested_lock_row == NULL);
row->requested_lock_row = NULL;
row->trx_wait_started = 0; row->trx_wait_started = 0;
} }
...@@ -812,6 +845,7 @@ fill_locks_row( ...@@ -812,6 +845,7 @@ fill_locks_row(
row->lock_table_id = lock_get_table_id(lock); row->lock_table_id = lock_get_table_id(lock);
row->hash_chain.value = row; row->hash_chain.value = row;
ut_ad(i_s_locks_row_validate(row));
return(TRUE); return(TRUE);
} }
...@@ -832,6 +866,9 @@ fill_lock_waits_row( ...@@ -832,6 +866,9 @@ fill_lock_waits_row(
relevant blocking lock relevant blocking lock
row in innodb_locks */ row in innodb_locks */
{ {
ut_ad(i_s_locks_row_validate(requested_lock_row));
ut_ad(i_s_locks_row_validate(blocking_lock_row));
row->requested_lock_row = requested_lock_row; row->requested_lock_row = requested_lock_row;
row->blocking_lock_row = blocking_lock_row; row->blocking_lock_row = blocking_lock_row;
...@@ -903,6 +940,7 @@ locks_row_eq_lock( ...@@ -903,6 +940,7 @@ locks_row_eq_lock(
or ULINT_UNDEFINED if the lock or ULINT_UNDEFINED if the lock
is a table lock */ is a table lock */
{ {
ut_ad(i_s_locks_row_validate(row));
#ifdef TEST_NO_LOCKS_ROW_IS_EVER_EQUAL_TO_LOCK_T #ifdef TEST_NO_LOCKS_ROW_IS_EVER_EQUAL_TO_LOCK_T
return(0); return(0);
#else #else
...@@ -960,7 +998,7 @@ search_innodb_locks( ...@@ -960,7 +998,7 @@ search_innodb_locks(
/* auxiliary variable */ /* auxiliary variable */
hash_chain, hash_chain,
/* assertion on every traversed item */ /* assertion on every traversed item */
, ut_ad(i_s_locks_row_validate(hash_chain->value)),
/* this determines if we have found the lock */ /* this determines if we have found the lock */
locks_row_eq_lock(hash_chain->value, lock, heap_no)); locks_row_eq_lock(hash_chain->value, lock, heap_no));
...@@ -1000,6 +1038,7 @@ add_lock_to_cache( ...@@ -1000,6 +1038,7 @@ add_lock_to_cache(
dst_row = search_innodb_locks(cache, lock, heap_no); dst_row = search_innodb_locks(cache, lock, heap_no);
if (dst_row != NULL) { if (dst_row != NULL) {
ut_ad(i_s_locks_row_validate(dst_row));
return(dst_row); return(dst_row);
} }
#endif #endif
...@@ -1037,6 +1076,7 @@ add_lock_to_cache( ...@@ -1037,6 +1076,7 @@ add_lock_to_cache(
} /* for()-loop */ } /* for()-loop */
#endif #endif
ut_ad(i_s_locks_row_validate(dst_row));
return(dst_row); return(dst_row);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment