~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_close.cc

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* close a isam-database */
17
17
/*
30
30
  int error=0,flag;
31
31
  MYISAM_SHARE *share=info->s;
32
32
 
33
 
  THR_LOCK_myisam.lock();
 
33
  pthread_mutex_lock(&THR_LOCK_myisam);
34
34
  if (info->lock_type == F_EXTRA_LCK)
35
35
    info->lock_type=F_UNLCK;                    /* HA_EXTRA_NO_USER_CHANGE */
36
36
 
42
42
    if (mi_lock_database(info,F_UNLCK))
43
43
      error=errno;
44
44
  }
 
45
  pthread_mutex_lock(&share->intern_lock);
45
46
 
46
47
  if (share->options & HA_OPTION_READ_ONLY_DATA)
47
48
  {
50
51
  }
51
52
  if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
52
53
  {
53
 
    if (info->rec_cache.end_io_cache())
 
54
    if (end_io_cache(&info->rec_cache))
54
55
      error=errno;
55
56
    info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
56
57
  }
57
58
  flag= !--share->reopen;
58
59
  myisam_open_list.remove(info);
 
60
  pthread_mutex_unlock(&share->intern_lock);
59
61
 
60
62
  void * rec_buff_ptr= mi_get_rec_buff_ptr(info, info->rec_buff);
61
63
  if (rec_buff_ptr != NULL)
63
65
  if (flag)
64
66
  {
65
67
    if (share->kfile >= 0 &&
66
 
        flush_key_blocks(share->getKeyCache(), share->kfile,
 
68
        flush_key_blocks(share->key_cache, share->kfile,
67
69
                         share->temporary ? FLUSH_IGNORE_CHANGED :
68
70
                         FLUSH_RELEASE))
69
71
      error=errno;
70
 
    end_key_cache(share->getKeyCache(), true);
71
72
    if (share->kfile >= 0)
72
73
    {
73
74
      /*
86
87
      free((unsigned char*) share->decode_trees);
87
88
      free((unsigned char*) share->decode_tables);
88
89
    }
 
90
    thr_lock_delete(&share->lock);
 
91
    pthread_mutex_destroy(&share->intern_lock);
 
92
    {
 
93
      int i,keys;
 
94
      keys = share->state.header.keys;
 
95
      pthread_rwlock_destroy(&share->mmap_lock);
 
96
      for(i=0; i<keys; i++) {
 
97
        pthread_rwlock_destroy(&share->key_root_lock[i]);
 
98
      }
 
99
    }
89
100
    delete info->s->in_use;
90
101
    free((unsigned char*) info->s);
91
102
  }
92
 
  THR_LOCK_myisam.unlock();
 
103
  pthread_mutex_unlock(&THR_LOCK_myisam);
93
104
 
94
105
  if (info->dfile >= 0 && internal::my_close(info->dfile,MYF(0)))
95
106
    error = errno;