~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_extra.cc

  • Committer: Monty Taylor
  • Date: 2010-06-02 22:35:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1586.
  • Revision ID: mordred@inaugust.com-20100602223545-q8ekf9b40a85nwuf
Rearragned unittests into a single exe because of how we need to link it
(thanks lifeless)
Link with server symbols without needing to build a library.
Added an additional atomics test which tests whatever version of the atomics
lib the running platform would actually use.

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
#include "myisam_priv.h"
17
17
#include <drizzled/util/test.h>
57
57
                                        /* Next/prev gives first/last */
58
58
    if (info->opt_flag & READ_CACHE_USED)
59
59
    {
60
 
      info->rec_cache.reinit_io_cache(internal::READ_CACHE,0,
61
 
                                      (bool) (info->lock_type != F_UNLCK),
62
 
                                      (bool) test(info->update & HA_STATE_ROW_CHANGED));
 
60
      reinit_io_cache(&info->rec_cache, internal::READ_CACHE,0,
 
61
                      (bool) (info->lock_type != F_UNLCK),
 
62
                      (bool) test(info->update & HA_STATE_ROW_CHANGED)
 
63
                      );
63
64
    }
64
65
    info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND |
65
66
                   HA_STATE_PREV_FOUND);
77
78
    if (info->opt_flag & WRITE_CACHE_USED)
78
79
    {
79
80
      info->opt_flag&= ~WRITE_CACHE_USED;
80
 
      if ((error= info->rec_cache.end_io_cache()))
 
81
      if ((error=end_io_cache(&info->rec_cache)))
81
82
        break;
82
83
    }
83
84
    if (!(info->opt_flag &
85
86
    {
86
87
      cache_size= (extra_arg ? *(uint32_t*) extra_arg :
87
88
                   internal::my_default_record_cache_size);
88
 
      if (!(info->rec_cache.init_io_cache(info->dfile, (uint) min((uint32_t)info->state->data_file_length+1, cache_size),
89
 
                                          internal::READ_CACHE,0L,(bool) (info->lock_type != F_UNLCK),
90
 
                                          MYF(share->write_flag & MY_WAIT_IF_FULL))))
 
89
      if (!(init_io_cache(&info->rec_cache,info->dfile,
 
90
                         (uint) min((uint32_t)info->state->data_file_length+1,
 
91
                                    cache_size),
 
92
                          internal::READ_CACHE,0L,(bool) (info->lock_type != F_UNLCK),
 
93
                          MYF(share->write_flag & MY_WAIT_IF_FULL))))
91
94
      {
92
95
        info->opt_flag|=READ_CACHE_USED;
93
96
        info->update&= ~HA_STATE_ROW_CHANGED;
99
102
  case HA_EXTRA_REINIT_CACHE:
100
103
    if (info->opt_flag & READ_CACHE_USED)
101
104
    {
102
 
      info->rec_cache.reinit_io_cache(internal::READ_CACHE,info->nextpos,
 
105
      reinit_io_cache(&info->rec_cache,internal::READ_CACHE,info->nextpos,
103
106
                      (bool) (info->lock_type != F_UNLCK),
104
107
                      (bool) test(info->update & HA_STATE_ROW_CHANGED));
105
108
      info->update&= ~HA_STATE_ROW_CHANGED;
116
119
 
117
120
    cache_size= (extra_arg ? *(uint32_t*) extra_arg :
118
121
                 internal::my_default_record_cache_size);
119
 
    if (not (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED | OPT_NO_ROWS)) && !share->state.header.uniques)
120
 
    {
121
 
      if (not (info->rec_cache.init_io_cache(info->dfile, cache_size,
122
 
                                             internal::WRITE_CACHE,info->state->data_file_length,
123
 
                                             (bool) (info->lock_type != F_UNLCK),
124
 
                                             MYF(share->write_flag & MY_WAIT_IF_FULL))))
 
122
    if (!(info->opt_flag &
 
123
          (READ_CACHE_USED | WRITE_CACHE_USED | OPT_NO_ROWS)) &&
 
124
        !share->state.header.uniques)
 
125
      if (!(init_io_cache(&info->rec_cache,info->dfile, cache_size,
 
126
                         internal::WRITE_CACHE,info->state->data_file_length,
 
127
                          (bool) (info->lock_type != F_UNLCK),
 
128
                          MYF(share->write_flag & MY_WAIT_IF_FULL))))
125
129
      {
126
 
        info->opt_flag|=WRITE_CACHE_USED;
127
 
        info->update&= ~(HA_STATE_ROW_CHANGED |
 
130
        info->opt_flag|=WRITE_CACHE_USED;
 
131
        info->update&= ~(HA_STATE_ROW_CHANGED |
128
132
                         HA_STATE_WRITE_AT_END |
129
133
                         HA_STATE_EXTEND_BLOCK);
130
134
      }
131
 
    }
132
135
    break;
133
136
  case HA_EXTRA_PREPARE_FOR_UPDATE:
134
137
    if (info->s->data_file_type != DYNAMIC_RECORD)
138
141
    if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
139
142
    {
140
143
      info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
141
 
      error= info->rec_cache.end_io_cache();
 
144
      error=end_io_cache(&info->rec_cache);
142
145
      /* Sergei will insert full text index caching here */
143
146
    }
144
147
#if !defined(TARGET_OS_SOLARIS)
237
240
    }
238
241
    break;
239
242
  case HA_EXTRA_FORCE_REOPEN:
240
 
    THR_LOCK_myisam.lock();
 
243
    pthread_mutex_lock(&THR_LOCK_myisam);
241
244
    share->last_version= 0L;                    /* Impossible version */
242
 
    THR_LOCK_myisam.unlock();
 
245
    pthread_mutex_unlock(&THR_LOCK_myisam);
243
246
    break;
244
247
  case HA_EXTRA_PREPARE_FOR_DROP:
245
 
    THR_LOCK_myisam.lock();
 
248
    pthread_mutex_lock(&THR_LOCK_myisam);
246
249
    share->last_version= 0L;                    /* Impossible version */
247
250
#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND
248
251
    /* Close the isam and data files as Win32 can't drop an open table */
 
252
    pthread_mutex_lock(&share->intern_lock);
249
253
    if (flush_key_blocks(share->key_cache, share->kfile,
250
254
                         (function == HA_EXTRA_FORCE_REOPEN ?
251
255
                          FLUSH_RELEASE : FLUSH_IGNORE_CHANGED)))
286
290
      }
287
291
    }
288
292
    share->kfile= -1;                           /* Files aren't open anymore */
 
293
    pthread_mutex_unlock(&share->intern_lock);
289
294
#endif
290
 
    THR_LOCK_myisam.unlock();
 
295
    pthread_mutex_unlock(&THR_LOCK_myisam);
291
296
    break;
292
297
  case HA_EXTRA_FLUSH:
293
298
    if (!share->temporary)
294
 
      flush_key_blocks(share->getKeyCache(), share->kfile, FLUSH_KEEP);
 
299
      flush_key_blocks(share->key_cache, share->kfile, FLUSH_KEEP);
295
300
#ifdef HAVE_PWRITE
296
301
    _mi_decrement_open_count(info);
297
302
#endif
298
303
    if (share->not_flushed)
299
304
    {
300
 
      share->not_flushed= false;
 
305
      share->not_flushed=0;
 
306
      if (internal::my_sync(share->kfile, MYF(0)))
 
307
        error= errno;
 
308
      if (internal::my_sync(info->dfile, MYF(0)))
 
309
        error= errno;
 
310
      if (error)
 
311
      {
 
312
        share->changed=1;
 
313
        mi_print_error(info->s, HA_ERR_CRASHED);
 
314
        mi_mark_crashed(info);                  /* Fatal error found */
 
315
      }
301
316
    }
302
317
    if (share->base.blobs)
303
 
      mi_alloc_rec_buff(info, SIZE_MAX, &info->rec_buff);
 
318
      mi_alloc_rec_buff(info, -1, &info->rec_buff);
304
319
    break;
305
320
  case HA_EXTRA_NORMAL:                         /* Theese isn't in use */
306
321
    info->quick_mode=0;
366
381
  if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
367
382
  {
368
383
    info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
369
 
    error= info->rec_cache.end_io_cache();
 
384
    error= end_io_cache(&info->rec_cache);
370
385
  }
371
386
  if (share->base.blobs)
372
 
    mi_alloc_rec_buff(info, SIZE_MAX, &info->rec_buff);
 
387
    mi_alloc_rec_buff(info, -1, &info->rec_buff);
373
388
#if !defined(TARGET_OS_SOLARIS)
374
389
  if (info->opt_flag & MEMMAP_USED)
375
390
    madvise((char*) share->file_map, share->state.state.data_file_length,