~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_extra.cc

  • Committer: Nathan Williams
  • Date: 2009-06-25 00:01:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1082.
  • Revision ID: nathanlws@gmail.com-20090625000126-fv99nqpec4edrchc
Converted last usage of cmin to std::min.

Removed cmin and cmax defines from global.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "myisamdef.h"
17
 
#ifdef HAVE_SYS_MMAN_H
 
17
#include <drizzled/util/test.h>
 
18
#include <sys/types.h>
18
19
#include <sys/mman.h>
19
 
#endif
 
20
 
 
21
#include <string.h>
 
22
#include <algorithm>
 
23
 
 
24
using namespace std;
20
25
 
21
26
static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function);
22
27
 
81
86
      cache_size= (extra_arg ? *(uint32_t*) extra_arg :
82
87
                   my_default_record_cache_size);
83
88
      if (!(init_io_cache(&info->rec_cache,info->dfile,
84
 
                         (uint) cmin(info->state->data_file_length+1,
 
89
                         (uint) min((uint32_t)info->state->data_file_length+1,
85
90
                                    cache_size),
86
91
                          READ_CACHE,0L,(bool) (info->lock_type != F_UNLCK),
87
92
                          MYF(share->write_flag & MY_WAIT_IF_FULL))))
138
143
      error=end_io_cache(&info->rec_cache);
139
144
      /* Sergei will insert full text index caching here */
140
145
    }
141
 
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
 
146
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) && !defined(TARGET_OS_SOLARIS)
142
147
    if (info->opt_flag & MEMMAP_USED)
143
148
      madvise((char*) share->file_map, share->state.state.data_file_length,
144
149
              MADV_RANDOM);
163
168
  case HA_EXTRA_KEYREAD:                        /* Read only keys to record */
164
169
  case HA_EXTRA_REMEMBER_POS:
165
170
    info->opt_flag |= REMEMBER_OLD_POS;
166
 
    memcpy(info->lastkey+share->base.max_key_length*2,
167
 
           info->lastkey,info->lastkey_length);
 
171
    memmove(info->lastkey+share->base.max_key_length*2,
 
172
            info->lastkey,info->lastkey_length);
168
173
    info->save_update=  info->update;
169
174
    info->save_lastinx= info->lastinx;
170
175
    info->save_lastpos= info->lastpos;
180
185
  case HA_EXTRA_RESTORE_POS:
181
186
    if (info->opt_flag & REMEMBER_OLD_POS)
182
187
    {
183
 
      memcpy(info->lastkey,
184
 
             info->lastkey+share->base.max_key_length*2,
185
 
             info->save_lastkey_length);
 
188
      memmove(info->lastkey,
 
189
              info->lastkey+share->base.max_key_length*2,
 
190
              info->save_lastkey_length);
186
191
      info->update=     info->save_update | HA_STATE_WRITTEN;
187
192
      info->lastinx=    info->save_lastinx;
188
193
      info->lastpos=    info->save_lastpos;
270
275
    if (share->kfile >= 0 && my_close(share->kfile,MYF(0)))
271
276
      error=my_errno;
272
277
    {
273
 
      LIST *list_element ;
274
 
      for (list_element=myisam_open_list ;
275
 
           list_element ;
276
 
           list_element=list_element->next)
 
278
      list<MI_INFO *>::iterator it= myisam_open_list.begin();
 
279
      while (it != myisam_open_list.end())
277
280
      {
278
 
        MI_INFO *tmpinfo=(MI_INFO*) list_element->data;
 
281
        MI_INFO *tmpinfo= *it;
279
282
        if (tmpinfo->s == info->s)
280
283
        {
281
284
          if (tmpinfo->dfile >= 0 && my_close(tmpinfo->dfile,MYF(0)))
282
285
            error = my_errno;
283
286
          tmpinfo->dfile= -1;
284
287
        }
 
288
        ++it;
285
289
      }
286
290
    }
287
291
    share->kfile= -1;                           /* Files aren't open anymore */
323
327
      info->opt_flag|= OPT_NO_ROWS;
324
328
    break;
325
329
  case HA_EXTRA_PRELOAD_BUFFER_SIZE:
326
 
    info->preload_buff_size= *((uint32_t *) extra_arg); 
 
330
    info->preload_buff_size= *((uint32_t *) extra_arg);
327
331
    break;
328
332
  case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
329
333
  case HA_EXTRA_CHANGE_KEY_TO_DUP:
412
416
  }
413
417
  if (share->base.blobs)
414
418
    mi_alloc_rec_buff(info, -1, &info->rec_buff);
415
 
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
 
419
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) && !defined(TARGET_OS_SOLARIS)
416
420
  if (info->opt_flag & MEMMAP_USED)
417
421
    madvise((char*) share->file_map, share->state.state.data_file_length,
418
422
            MADV_RANDOM);