Commit 157b8eeb authored by marko's avatar marko

branches/zip: Minor cleanup.

dict_table_get_referenced_constraint(), dict_table_get_foreign_constraint():
Simplify the iteration loop.

dict_table_find_equivalent_index(): Correct the function comment.
parent a8382891
...@@ -1948,27 +1948,19 @@ dict_table_get_referenced_constraint( ...@@ -1948,27 +1948,19 @@ dict_table_get_referenced_constraint(
dict_table_t* table, /* in: InnoDB table */ dict_table_t* table, /* in: InnoDB table */
dict_index_t* index) /* in: InnoDB index */ dict_index_t* index) /* in: InnoDB index */
{ {
dict_foreign_t* foreign = NULL; dict_foreign_t* foreign;
ut_ad(index && table);
/* If the referenced list is empty, nothing to do */
if (UT_LIST_GET_LEN(table->referenced_list) == 0) {
return(NULL); ut_ad(index != NULL)
} ut_ad(table != NULL);
foreign = UT_LIST_GET_FIRST(table->referenced_list); for (foreign = UT_LIST_GET_FIRST(table->referenced_list);
foreign;
foreign = UT_LIST_GET_NEXT(referenced_list, foreign)) {
while (foreign) { if (foreign->referenced_index == index) {
if (foreign->referenced_index == index
|| foreign->referenced_index == index) {
return(foreign); return(foreign);
} }
foreign = UT_LIST_GET_NEXT(referenced_list, foreign);
} }
return(NULL); return(NULL);
...@@ -1987,29 +1979,20 @@ dict_table_get_foreign_constraint( ...@@ -1987,29 +1979,20 @@ dict_table_get_foreign_constraint(
dict_table_t* table, /* in: InnoDB table */ dict_table_t* table, /* in: InnoDB table */
dict_index_t* index) /* in: InnoDB index */ dict_index_t* index) /* in: InnoDB index */
{ {
dict_foreign_t* foreign = NULL; dict_foreign_t* foreign;
ut_ad(index && table);
/* If list empty then nothgin to do */
if (UT_LIST_GET_LEN(table->foreign_list) == 0) {
return(NULL);
}
/* Check whether this index is defined for a foreign key */ ut_ad(index != NULL);
ut_ad(table != NULL);
foreign = UT_LIST_GET_FIRST(table->foreign_list); for (foreign = UT_LIST_GET_FIRST(table->foreign_list);
foreign;
foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) {
while (foreign) {
if (foreign->foreign_index == index if (foreign->foreign_index == index
|| foreign->referenced_index == index) { || foreign->referenced_index == index) {
return(foreign); return(foreign);
} }
foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
} }
return(NULL); return(NULL);
...@@ -4503,12 +4486,14 @@ dict_table_get_index_on_name( ...@@ -4503,12 +4486,14 @@ dict_table_get_index_on_name(
} }
/************************************************************************** /**************************************************************************
Find and index that is equivalent to the one passed in. */ Find an index that is equivalent to the one passed in and is not marked
for deletion. */
UNIV_INTERN UNIV_INTERN
dict_index_t* dict_index_t*
dict_table_find_equivalent_index( dict_table_find_equivalent_index(
/*=============================*/ /*=============================*/
dict_table_t* table, /* in/out: table */ /* out: equivalent index, or NULL */
dict_table_t* table, /* in: table */
dict_index_t* index) /* in: index to match */ dict_index_t* index) /* in: index to match */
{ {
ulint i; ulint i;
......
...@@ -1085,13 +1085,14 @@ dict_table_get_index_on_name( ...@@ -1085,13 +1085,14 @@ dict_table_get_index_on_name(
dict_table_t* table, /* in: table */ dict_table_t* table, /* in: table */
const char* name); /* in: name of the index to find */ const char* name); /* in: name of the index to find */
/************************************************************************** /**************************************************************************
Find and index that is equivalent to the one passed in and is not marked Find an index that is equivalent to the one passed in and is not marked
for deletion. */ for deletion. */
UNIV_INTERN UNIV_INTERN
dict_index_t* dict_index_t*
dict_table_find_equivalent_index( dict_table_find_equivalent_index(
/*=============================*/ /*=============================*/
dict_table_t* table, /* in/out: table */ /* out: equivalent index, or NULL */
dict_table_t* table, /* in: table */
dict_index_t* index); /* in: index to match */ dict_index_t* index); /* in: index to match */
/************************************************************************** /**************************************************************************
In case there is more than one index with the same name return the index In case there is more than one index with the same name return the index
......
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