~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_preload.c

Merged in changes from Andrey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
int mi_preload(MI_INFO *info, uint64_t key_map, bool ignore_leaves)
42
42
{
43
 
  uint i;
 
43
  uint32_t i;
44
44
  uint32_t length, block_length= 0;
45
 
  uchar *buff= NULL;
 
45
  unsigned char *buff= NULL;
46
46
  MYISAM_SHARE* share= info->s;
47
 
  uint keys= share->state.header.keys;
 
47
  uint32_t keys= share->state.header.keys;
48
48
  MI_KEYDEF *keyinfo= share->keyinfo;
49
49
  my_off_t key_file_length= share->state.state.key_file_length;
50
50
  my_off_t pos= share->base.keystart;
69
69
  length= info->preload_buff_size/block_length * block_length;
70
70
  set_if_bigger(length, block_length);
71
71
 
72
 
  if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME))))
 
72
  if (!(buff= (unsigned char *) my_malloc(length, MYF(MY_WME))))
73
73
    return(my_errno= HA_ERR_OUT_OF_MEM);
74
74
 
75
75
  if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE))
80
80
    /* Read the next block of index file into the preload buffer */
81
81
    if ((my_off_t) length > (key_file_length-pos))
82
82
      length= (uint32_t) (key_file_length-pos);
83
 
    if (my_pread(share->kfile, (uchar*) buff, length, pos, MYF(MY_FAE|MY_FNABP)))
 
83
    if (my_pread(share->kfile, (unsigned char*) buff, length, pos, MYF(MY_FAE|MY_FNABP)))
84
84
      goto err;
85
85
 
86
86
    if (ignore_leaves)
87
87
    {
88
 
      uchar *end= buff+length;
 
88
      unsigned char *end= buff+length;
89
89
      do
90
90
      {
91
91
        if (mi_test_if_nod(buff))
92
92
        {
93
93
          if (key_cache_insert(share->key_cache,
94
94
                               share->kfile, pos, DFLT_INIT_HITS,
95
 
                              (uchar*) buff, block_length))
 
95
                              (unsigned char*) buff, block_length))
96
96
            goto err;
97
97
        }
98
98
        pos+= block_length;
104
104
    {
105
105
      if (key_cache_insert(share->key_cache,
106
106
                           share->kfile, pos, DFLT_INIT_HITS,
107
 
                           (uchar*) buff, length))
 
107
                           (unsigned char*) buff, length))
108
108
        goto err;
109
109
      pos+= length;
110
110
    }
111
111
  }
112
112
  while (pos != key_file_length);
113
113
 
114
 
  my_free((char*) buff, MYF(0));
 
114
  free((char*) buff);
115
115
  return(0);
116
116
 
117
117
err:
118
 
  my_free((char*) buff, MYF(MY_ALLOW_ZERO_PTR));
 
118
  free((char*) buff);
119
119
  return(my_errno= errno);
120
120
}
121
121