Commit edc17c00 authored by unknown's avatar unknown
Browse files

More consistent handling of magic numbers


innobase/include/data0data.h:
  dtuple_struct:magic_n: Enclose in #ifdef UNIV_DEBUG
innobase/dict/dict0dict.c:
  Use magic_n only #ifdef UNIV_DEBUG
innobase/dict/dict0mem.c:
  Use magic_n only #ifdef UNIV_DEBUG
innobase/ha/hash0hash.c:
  Remove unused functions hash_mutex_enter_all and hash_mutex_exit_all
  Use magic_n only #ifdef UNIV_DEBUG
  Add ut_ad(table->magic_n == HASH_TABLE_MAGIC_N)
innobase/include/dict0mem.h:
  Use magic_n only #ifdef UNIV_DEBUG
innobase/include/hash0hash.h:
  Remove unused functions hash_mutex_enter_all and hash_mutex_exit_all
  Use magic_n only #ifdef UNIV_DEBUG
innobase/include/hash0hash.ic:
  Add ut_ad(table->magic_n == HASH_TABLE_MAGIC_N)
innobase/include/mtr0mtr.h:
  Use state, magic_n only #ifdef UNIV_DEBUG
innobase/include/row0ins.h:
  Use magic_n only #ifdef UNIV_DEBUG
innobase/include/row0upd.h:
  Use magic_n only #ifdef UNIV_DEBUG
innobase/row/row0ins.c:
  Use magic_n only #ifdef UNIV_DEBUG
  Add ut_ad(node->magic_n == INS_NODE_MAGIC_N)
innobase/row/row0upd.c:
  Use magic_n only #ifdef UNIV_DEBUG
  Add ut_ad(node->magic_n == UPD_NODE_MAGIC_N)
innobase/thr/thr0loc.c:
  Use magic_n only #ifdef UNIV_DEBUG
parent cb9f3048
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3536,9 +3536,9 @@ dict_tree_create(
	tree->id = index->id;
	
	UT_LIST_INIT(tree->tree_indexes);

#ifdef UNIV_DEBUG
	tree->magic_n = DICT_TREE_MAGIC_N;

#endif /* UNIV_DEBUG */
	rw_lock_create(&(tree->lock));

	rw_lock_set_level(&(tree->lock), SYNC_INDEX_TREE);
+4 −2
Original line number Diff line number Diff line
@@ -90,9 +90,9 @@ dict_mem_table_create(
	mutex_set_level(&(table->autoinc_mutex), SYNC_DICT_AUTOINC_MUTEX);

	table->autoinc_inited = FALSE;

#ifdef UNIV_DEBUG
	table->magic_n = DICT_TABLE_MAGIC_N;
	
#endif /* UNIV_DEBUG */
	return(table);
}

@@ -217,7 +217,9 @@ dict_mem_index_create(
	index->stat_n_diff_key_vals = NULL;

	index->cached = FALSE;
#ifdef UNIV_DEBUG
	index->magic_n = DICT_INDEX_MAGIC_N;
#endif /* UNIV_DEBUG */

	return(index);
}
+6 −32
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ hash_mutex_enter(
	hash_table_t* 	table,	/* in: hash table */
	ulint 		fold)	/* in: fold */
{
	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
	mutex_enter(hash_get_mutex(table, fold));
}

@@ -34,41 +35,10 @@ hash_mutex_exit(
	hash_table_t* 	table,	/* in: hash table */
	ulint 		fold)	/* in: fold */
{
	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
	mutex_exit(hash_get_mutex(table, fold));
}

/****************************************************************
Reserves all the mutexes of a hash table, in an ascending order. */

void
hash_mutex_enter_all(
/*=================*/
	hash_table_t* 	table)	/* in: hash table */
{
	ulint	i;

	for (i = 0; i < table->n_mutexes; i++) {

		mutex_enter(table->mutexes + i);
	}
}

/****************************************************************
Releases all the mutexes of a hash table. */

void
hash_mutex_exit_all(
/*================*/
	hash_table_t* 	table)	/* in: hash table */
{
	ulint	i;

	for (i = 0; i < table->n_mutexes; i++) {

		mutex_exit(table->mutexes + i);
	}
}

/*****************************************************************
Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */
@@ -97,7 +67,9 @@ hash_create(
	table->mutexes = NULL;
	table->heaps = NULL;
	table->heap = NULL;
#ifdef UNIV_DEBUG
	table->magic_n = HASH_TABLE_MAGIC_N;
#endif /* UNIV_DEBUG */
	
	/* Initialize the cell array */

@@ -118,6 +90,7 @@ hash_table_free(
/*============*/
	hash_table_t*	table)	/* in, own: hash table */
{
	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
	ut_a(table->mutexes == NULL);

	ut_free(table->array);
@@ -139,6 +112,7 @@ hash_create_mutexes(
	ulint	i;

	ut_a(n_mutexes == ut_2_power_up(n_mutexes));
	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);

	table->mutexes = mem_alloc(n_mutexes * sizeof(mutex_t));

+4 −2
Original line number Diff line number Diff line
@@ -402,9 +402,11 @@ struct dtuple_struct {
	UT_LIST_NODE_T(dtuple_t) tuple_list;
					/* data tuples can be linked into a
					list using this field */
#ifdef UNIV_DEBUG
	ulint		magic_n;
};
#define	DATA_TUPLE_MAGIC_N	65478679
#endif /* UNIV_DEBUG */
};

/* A slot for a field in a big rec vector */

+10 −7
Original line number Diff line number Diff line
@@ -198,10 +198,11 @@ struct dict_tree_struct{
				the list; if the tree is of the mixed
				type, the first index in the list is the
				index of the cluster which owns the tree */
#ifdef UNIV_DEBUG
	ulint		magic_n;/* magic number */
};

#define	DICT_TREE_MAGIC_N	7545676
#endif /* UNIV_DEBUG */
};

/* Data structure for an index */
struct dict_index_struct{
@@ -247,7 +248,10 @@ struct dict_index_struct{
	ulint		stat_n_leaf_pages;
				/* approximate number of leaf pages in the
				index tree */
#ifdef UNIV_DEBUG
	ulint		magic_n;/* magic number */
#define	DICT_INDEX_MAGIC_N	76789786
#endif /* UNIV_DEBUG */
};

/* Data structure for a foreign key constraint; an example:
@@ -298,9 +302,6 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */
#define DICT_FOREIGN_ON_DELETE_NO_ACTION 16
#define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32


#define	DICT_INDEX_MAGIC_N	76789786

/* Data structure for a database table */
struct dict_table_struct{
	dulint		id;	/* id of the table or cluster */
@@ -413,9 +414,11 @@ struct dict_table_struct{
				SELECT MAX(auto inc column) */
	ib_longlong	autoinc;/* autoinc counter value to give to the
				next inserted row */
#ifdef UNIV_DEBUG
	ulint		magic_n;/* magic number */
};
#define	DICT_TABLE_MAGIC_N	76333786
#endif /* UNIV_DEBUG */
};
					
/* Data structure for a stored procedure */
struct dict_proc_struct{
Loading