Commit e147ca15 authored by Michael Widenius's avatar Michael Widenius

Don't call _ma_decrement_open_count() for ma_extra(HA_EXTRA_PREPARE_FOR_DROP).

Don't call _mi_decrement_open_count() for mi_extra(HA_EXTRA_PREPARE_FOR_DROP).
This ensures that if we empty the key cache and a drop table fails later, the index will be automaticly rebuilt

storage/maria/ma_extra.c:
  Don't call _ma_decrement_open_count() for ma_extra(HA_EXTRA_PREPARE_FOR_DROP).
  This ensures that if we empty the key cache and a drop table fails later, the index will be automaticly rebuilt
storage/maria/ma_locking.c:
  Simple optimization: Don't call maria_lock_database() if locking is disabled
storage/myisam/mi_extra.c:
  Don't call _mi_decrement_open_count() for mi_extra(HA_EXTRA_PREPARE_FOR_DROP).
  Simplify code to remove if
parent 820c4902
...@@ -323,9 +323,16 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -323,9 +323,16 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
error= my_errno; error= my_errno;
info->lock_type= F_UNLCK; info->lock_type= F_UNLCK;
} }
if (share->kfile.file >= 0) /*
_ma_decrement_open_count(info); We don't need to call _mi_decrement_open_count() if we are
dropping the table, as the files will be removed anyway. If we
are aborted before the files is removed, it's better to not
call it as in that case the automatic repair on open will add
the missing index entries
*/
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
if (share->kfile.file >= 0 && function != HA_EXTRA_PREPARE_FOR_DROP)
_ma_decrement_open_count(info);
if (info->trn) if (info->trn)
{ {
_ma_remove_table_from_trnman(share, info->trn); _ma_remove_table_from_trnman(share, info->trn);
......
...@@ -484,7 +484,7 @@ int _ma_decrement_open_count(MARIA_HA *info) ...@@ -484,7 +484,7 @@ int _ma_decrement_open_count(MARIA_HA *info)
{ {
uint old_lock=info->lock_type; uint old_lock=info->lock_type;
share->global_changed=0; share->global_changed=0;
lock_error=maria_lock_database(info,F_WRLCK); lock_error= my_disable_locking ? 0 : maria_lock_database(info, F_WRLCK);
/* Its not fatal even if we couldn't get the lock ! */ /* Its not fatal even if we couldn't get the lock ! */
if (share->state.open_count > 0) if (share->state.open_count > 0)
{ {
...@@ -499,7 +499,7 @@ int _ma_decrement_open_count(MARIA_HA *info) ...@@ -499,7 +499,7 @@ int _ma_decrement_open_count(MARIA_HA *info)
MYF(MY_NABP)); MYF(MY_NABP));
} }
} }
if (!lock_error) if (!lock_error && !my_disable_locking)
lock_error=maria_lock_database(info,old_lock); lock_error=maria_lock_database(info,old_lock);
} }
return test(lock_error || write_error); return test(lock_error || write_error);
......
...@@ -286,9 +286,19 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -286,9 +286,19 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
info->lock_type = F_UNLCK; info->lock_type = F_UNLCK;
} }
if (share->kfile >= 0) if (share->kfile >= 0)
{
/*
We don't need to call _mi_decrement_open_count() if we are
dropping the table, as the files will be removed anyway. If we
are aborted before the files is removed, it's better to not
call it as in that case the automatic repair on open will add
the missing index entries
*/
if (function != HA_EXTRA_PREPARE_FOR_DROP)
_mi_decrement_open_count(info); _mi_decrement_open_count(info);
if (share->kfile >= 0 && my_close(share->kfile,MYF(0))) if (my_close(share->kfile,MYF(0)))
error=my_errno; error=my_errno;
}
{ {
LIST *list_element ; LIST *list_element ;
for (list_element=myisam_open_list ; for (list_element=myisam_open_list ;
......
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