← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (monty:2741)

 

#At lp:maria based on revid:monty@xxxxxxxxxxxx-20091002115611-mp80efi9m4h4qyi6

 2741 Michael Widenius	2009-10-06
      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
      modified:
        storage/maria/ma_extra.c
        storage/maria/ma_locking.c
        storage/myisam/mi_extra.c

per-file messages:
  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
=== modified file 'storage/maria/ma_extra.c'
--- a/storage/maria/ma_extra.c	2009-02-19 09:01:25 +0000
+++ b/storage/maria/ma_extra.c	2009-10-06 06:13:56 +0000
@@ -323,9 +323,16 @@ int maria_extra(MARIA_HA *info, enum ha_
         error= my_errno;
       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);
+    if (share->kfile.file >= 0 && function != HA_EXTRA_PREPARE_FOR_DROP)
+      _ma_decrement_open_count(info);
     if (info->trn)
     {
       _ma_remove_table_from_trnman(share, info->trn);

=== modified file 'storage/maria/ma_locking.c'
--- a/storage/maria/ma_locking.c	2009-02-09 21:52:42 +0000
+++ b/storage/maria/ma_locking.c	2009-10-06 06:13:56 +0000
@@ -484,7 +484,7 @@ int _ma_decrement_open_count(MARIA_HA *i
   {
     uint old_lock=info->lock_type;
     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 ! */
     if (share->state.open_count > 0)
     {
@@ -499,7 +499,7 @@ int _ma_decrement_open_count(MARIA_HA *i
                                      MYF(MY_NABP));
       }
     }
-    if (!lock_error)
+    if (!lock_error && !my_disable_locking)
       lock_error=maria_lock_database(info,old_lock);
   }
   return test(lock_error || write_error);

=== modified file 'storage/myisam/mi_extra.c'
--- a/storage/myisam/mi_extra.c	2009-09-03 14:05:38 +0000
+++ b/storage/myisam/mi_extra.c	2009-10-06 06:13:56 +0000
@@ -286,9 +286,19 @@ int mi_extra(MI_INFO *info, enum ha_extr
       info->lock_type = F_UNLCK;
     }
     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);
-    if (share->kfile >= 0 && my_close(share->kfile,MYF(0)))
-      error=my_errno;
+      if (my_close(share->kfile,MYF(0)))
+        error=my_errno;
+    }
     {
       LIST *list_element ;
       for (list_element=myisam_open_list ;