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(
dict_table_t* table, /* in: InnoDB table */
dict_index_t* index) /* in: InnoDB index */
{
dict_foreign_t* foreign = NULL;
ut_ad(index && table);
/* If the referenced list is empty, nothing to do */
if (UT_LIST_GET_LEN(table->referenced_list) == 0) {
dict_foreign_t* foreign;
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
|| foreign->referenced_index == index) {
if (foreign->referenced_index == index) {
return(foreign);
}
foreign = UT_LIST_GET_NEXT(referenced_list, foreign);
}
return(NULL);
......@@ -1987,29 +1979,20 @@ dict_table_get_foreign_constraint(
dict_table_t* table, /* in: InnoDB table */
dict_index_t* index) /* in: InnoDB index */
{
dict_foreign_t* foreign = NULL;
ut_ad(index && table);
/* If list empty then nothgin to do */
if (UT_LIST_GET_LEN(table->foreign_list) == 0) {
return(NULL);
}
dict_foreign_t* foreign;
/* 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
|| foreign->referenced_index == index) {
return(foreign);
}
foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
}
return(NULL);
......@@ -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
dict_index_t*
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 */
{
ulint i;
......
......@@ -1085,13 +1085,14 @@ dict_table_get_index_on_name(
dict_table_t* table, /* in: table */
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. */
UNIV_INTERN
dict_index_t*
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 */
/**************************************************************************
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