From e0009cd4dba55b5693c19f7d0df68ece46dccf68 Mon Sep 17 00:00:00 2001 From: marko Date: Mon, 13 Aug 2007 15:57:28 +0000 Subject: [PATCH] branches/zip: Add some const qualifiers to dict_index_t* and dict_table_t*. innobase_create_key_def(), row_table_got_default_clust_index(), row_get_mysql_key_number_for_index(): Add a const qualifier. dict_table_get_first_index(), dict_table_get_next_index(): Define as a const-preserving macro. Preserve the old function for UNIV_DEBUG, but add a const qualifier to the parameter and cast away the constness. --- handler/ha_innodb.cc | 4 ++-- include/dict0dict.h | 13 +++++++++---- include/dict0dict.ic | 14 ++++++++------ include/row0mysql.h | 4 ++-- row/row0mysql.c | 8 ++++---- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index ec754a06024..879aa1eff47 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -8187,7 +8187,7 @@ innobase_create_key_def( /*====================*/ /* out: key definitions or NULL */ trx_t* trx, /* in: trx */ - dict_table_t* table, /* in: table definition */ + const dict_table_t*table, /* in: table definition */ mem_heap_t* heap, /* in: heap where space for key definitions are allocated */ KEY* key_info, /* in: Indexes to be created */ @@ -8214,7 +8214,7 @@ innobase_create_key_def( key_info->name, "PRIMARY"); if (new_primary) { - dict_index_t* index; + const dict_index_t* index; /* Create the PRIMARY key index definition */ innobase_create_index_def(key_info, TRUE, indexdef++, heap); diff --git a/include/dict0dict.h b/include/dict0dict.h index ce4eb24d930..44aef1cfd61 100644 --- a/include/dict0dict.h +++ b/include/dict0dict.h @@ -496,22 +496,27 @@ dict_index_name_print( FILE* file, /* in: output stream */ trx_t* trx, /* in: transaction */ const dict_index_t* index); /* in: index to print */ +#ifdef UNIV_DEBUG /************************************************************************ Gets the first index on the table (the clustered index). */ UNIV_INLINE dict_index_t* dict_table_get_first_index( /*=======================*/ - /* out: index, NULL if none exists */ - dict_table_t* table); /* in: table */ + /* out: index, NULL if none exists */ + const dict_table_t* table); /* in: table */ /************************************************************************ Gets the next index on the table. */ UNIV_INLINE dict_index_t* dict_table_get_next_index( /*======================*/ - /* out: index, NULL if none left */ - dict_index_t* index); /* in: index */ + /* out: index, NULL if none left */ + const dict_index_t* index); /* in: index */ +#else /* UNIV_DEBUG */ +# define dict_table_get_first_index(table) UT_LIST_GET_FIRST((table)->indexes) +# define dict_table_get_next_index(index) UT_LIST_GET_NEXT(indexes, index) +#endif /* UNIV_DEBUG */ /************************************************************************ Check whether the index is the clustered index. */ UNIV_INLINE diff --git a/include/dict0dict.ic b/include/dict0dict.ic index e30b5d2ccfd..dddaa3ba761 100644 --- a/include/dict0dict.ic +++ b/include/dict0dict.ic @@ -139,19 +139,20 @@ dict_col_get_clust_pos( return(ULINT_UNDEFINED); } +#ifdef UNIV_DEBUG /************************************************************************ Gets the first index on the table (the clustered index). */ UNIV_INLINE dict_index_t* dict_table_get_first_index( /*=======================*/ - /* out: index, NULL if none exists */ - dict_table_t* table) /* in: table */ + /* out: index, NULL if none exists */ + const dict_table_t* table) /* in: table */ { ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); - return(UT_LIST_GET_FIRST(table->indexes)); + return(UT_LIST_GET_FIRST(((dict_table_t*) table)->indexes)); } /************************************************************************ @@ -160,14 +161,15 @@ UNIV_INLINE dict_index_t* dict_table_get_next_index( /*======================*/ - /* out: index, NULL if none left */ - dict_index_t* index) /* in: index */ + /* out: index, NULL if none left */ + const dict_index_t* index) /* in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); - return(UT_LIST_GET_NEXT(indexes, index)); + return(UT_LIST_GET_NEXT(indexes, (dict_index_t*) index)); } +#endif /* UNIV_DEBUG */ /************************************************************************ Check whether the index is the clustered index. */ diff --git a/include/row0mysql.h b/include/row0mysql.h index 2097358fbf5..ded396ff1e1 100644 --- a/include/row0mysql.h +++ b/include/row0mysql.h @@ -255,7 +255,7 @@ index on it (on row id). */ ibool row_table_got_default_clust_index( /*==============================*/ - dict_table_t* table); + const dict_table_t* table); /************************************************************************* Calculates the key number used inside MySQL for an Innobase index. We have to take into account if we generated a default clustered index for the table */ @@ -263,7 +263,7 @@ to take into account if we generated a default clustered index for the table */ ulint row_get_mysql_key_number_for_index( /*===============================*/ - dict_index_t* index); + const dict_index_t* index); /************************************************************************* Does an update or delete of a row for MySQL. */ diff --git a/row/row0mysql.c b/row/row0mysql.c index 4c33bb38dc7..6ff4b0edf4c 100644 --- a/row/row0mysql.c +++ b/row/row0mysql.c @@ -1783,7 +1783,7 @@ index on it (on row id). */ ibool row_table_got_default_clust_index( /*==============================*/ - dict_table_t* table) + const dict_table_t* table) { const dict_index_t* clust_index; @@ -1799,10 +1799,10 @@ to take into account if we generated a default clustered index for the table */ ulint row_get_mysql_key_number_for_index( /*===============================*/ - dict_index_t* index) + const dict_index_t* index) { - dict_index_t* ind; - ulint i; + const dict_index_t* ind; + ulint i; ut_a(index);