| 1048 | */ |
| 1049 | |
| 1050 | void tdc_remove_table(THD *thd, const char *db, const char *table_name) |
| 1051 | { |
| 1052 | TDC_element *element; |
| 1053 | DBUG_ENTER("tdc_remove_table"); |
| 1054 | DBUG_PRINT("enter", ("name: %s", table_name)); |
| 1055 | |
| 1056 | DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name, |
| 1057 | MDL_EXCLUSIVE)); |
| 1058 | |
| 1059 | mysql_mutex_lock(&LOCK_unused_shares); |
| 1060 | if (!(element= tdc_lock_share(thd, db, table_name))) |
| 1061 | { |
| 1062 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 1063 | DBUG_VOID_RETURN; |
| 1064 | } |
| 1065 | |
| 1066 | DBUG_ASSERT(element != MY_ERRPTR); // What can we do about it? |
| 1067 | |
| 1068 | if (!element->ref_count) |
| 1069 | { |
| 1070 | if (element->prev) |
| 1071 | { |
| 1072 | unused_shares.remove(element); |
| 1073 | element->prev= 0; |
| 1074 | element->next= 0; |
| 1075 | } |
| 1076 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 1077 | |
| 1078 | tdc_delete_share_from_hash(element); |
| 1079 | DBUG_VOID_RETURN; |
| 1080 | } |
| 1081 | mysql_mutex_unlock(&LOCK_unused_shares); |
| 1082 | |
| 1083 | element->ref_count++; |
| 1084 | mysql_mutex_unlock(&element->LOCK_table_share); |
| 1085 | |
| 1086 | /* We have to relock the mutex to avoid code duplication. Sigh. */ |
| 1087 | tdc_remove_referenced_share(thd, element->share); |
| 1088 | DBUG_VOID_RETURN; |
| 1089 | } |
| 1090 | |
| 1091 | |
| 1092 | /** |
no test coverage detected