~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_extra.c

  • Committer: Brian Aker
  • Date: 2008-07-18 22:05:16 UTC
  • Revision ID: brian@tangent.org-20080718220516-dzyjle0iqqjssphx
Dead debug code removal (and a compatible "never used") bit in the
optimizer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    mi_extra()
29
29
    info        open table
30
30
    function    operation
31
 
    extra_arg   Pointer to extra argument (normally pointer to uint32_t)
 
31
    extra_arg   Pointer to extra argument (normally pointer to ulong)
32
32
                Used when function is one of:
33
33
                HA_EXTRA_WRITE_CACHE
34
34
                HA_EXTRA_CACHE
40
40
int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
41
41
{
42
42
  int error=0;
43
 
  uint32_t cache_size;
 
43
  ulong cache_size;
44
44
  MYISAM_SHARE *share=info->s;
45
45
 
46
46
  switch (function) {
69
69
    }
70
70
    if (info->s->file_map) /* Don't use cache if mmap */
71
71
      break;
 
72
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
 
73
    if ((share->options & HA_OPTION_COMPRESS_RECORD))
 
74
    {
 
75
      pthread_mutex_lock(&share->intern_lock);
 
76
      if (_mi_memmap_file(info))
 
77
      {
 
78
        /* We don't nead MADV_SEQUENTIAL if small file */
 
79
        madvise((char*) share->file_map, share->state.state.data_file_length,
 
80
                share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ?
 
81
                MADV_RANDOM : MADV_SEQUENTIAL);
 
82
        pthread_mutex_unlock(&share->intern_lock);
 
83
        break;
 
84
      }
 
85
      pthread_mutex_unlock(&share->intern_lock);
 
86
    }
 
87
#endif
72
88
    if (info->opt_flag & WRITE_CACHE_USED)
73
89
    {
74
90
      info->opt_flag&= ~WRITE_CACHE_USED;
78
94
    if (!(info->opt_flag &
79
95
          (READ_CACHE_USED | WRITE_CACHE_USED | MEMMAP_USED)))
80
96
    {
81
 
      cache_size= (extra_arg ? *(uint32_t*) extra_arg :
 
97
      cache_size= (extra_arg ? *(ulong*) extra_arg :
82
98
                   my_default_record_cache_size);
83
99
      if (!(init_io_cache(&info->rec_cache,info->dfile,
84
 
                         (uint) cmin(info->state->data_file_length+1,
 
100
                         (uint) min(info->state->data_file_length+1,
85
101
                                    cache_size),
86
102
                          READ_CACHE,0L,(bool) (info->lock_type != F_UNLCK),
87
103
                          MYF(share->write_flag & MY_WAIT_IF_FULL))))
111
127
      break;
112
128
    }
113
129
 
114
 
    cache_size= (extra_arg ? *(uint32_t*) extra_arg :
 
130
    cache_size= (extra_arg ? *(ulong*) extra_arg :
115
131
                 my_default_record_cache_size);
116
132
    if (!(info->opt_flag &
117
133
          (READ_CACHE_USED | WRITE_CACHE_USED | OPT_NO_ROWS)) &&
163
179
  case HA_EXTRA_KEYREAD:                        /* Read only keys to record */
164
180
  case HA_EXTRA_REMEMBER_POS:
165
181
    info->opt_flag |= REMEMBER_OLD_POS;
166
 
    memcpy(info->lastkey+share->base.max_key_length*2,
167
 
           info->lastkey,info->lastkey_length);
 
182
    bmove((uchar*) info->lastkey+share->base.max_key_length*2,
 
183
          (uchar*) info->lastkey,info->lastkey_length);
168
184
    info->save_update=  info->update;
169
185
    info->save_lastinx= info->lastinx;
170
186
    info->save_lastpos= info->lastpos;
180
196
  case HA_EXTRA_RESTORE_POS:
181
197
    if (info->opt_flag & REMEMBER_OLD_POS)
182
198
    {
183
 
      memcpy(info->lastkey,
184
 
             info->lastkey+share->base.max_key_length*2,
185
 
             info->save_lastkey_length);
 
199
      bmove((uchar*) info->lastkey,
 
200
            (uchar*) info->lastkey+share->base.max_key_length*2,
 
201
            info->save_lastkey_length);
186
202
      info->update=     info->save_update | HA_STATE_WRITTEN;
187
203
      info->lastinx=    info->save_lastinx;
188
204
      info->lastpos=    info->save_lastpos;
209
225
    if (mi_is_any_key_active(share->state.key_map))
210
226
    {
211
227
      MI_KEYDEF *key=share->keyinfo;
212
 
      uint32_t i;
 
228
      uint i;
213
229
      for (i=0 ; i < share->base.keys ; i++,key++)
214
230
      {
215
231
        if (!(key->flag & HA_NOSAME) && info->s->base.auto_key != i+1)
323
339
      info->opt_flag|= OPT_NO_ROWS;
324
340
    break;
325
341
  case HA_EXTRA_PRELOAD_BUFFER_SIZE:
326
 
    info->preload_buff_size= *((uint32_t *) extra_arg); 
 
342
    info->preload_buff_size= *((ulong *) extra_arg); 
327
343
    break;
328
344
  case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
329
345
  case HA_EXTRA_CHANGE_KEY_TO_DUP:
359
375
  default:
360
376
    break;
361
377
  }
362
 
 
 
378
  {
 
379
    char tmp[1];
 
380
    tmp[0]=function;
 
381
    myisam_log_command(MI_LOG_EXTRA,info,(uchar*) tmp,1,error);
 
382
  }
363
383
  return(error);
364
384
} /* mi_extra */
365
385
 
376
396
 */
377
397
static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function)
378
398
{
379
 
  uint32_t  idx;
 
399
  uint  idx;
380
400
 
381
401
  for (idx= 0; idx< info->s->base.keys; idx++)
382
402
  {