~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_preload.c

  • Committer: Brian Aker
  • Date: 2008-10-12 01:59:02 UTC
  • Revision ID: brian@tangent.org-20081012015902-prhy6wsimdqr28om
Dead code around unsigned (first pass)

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
/*
17
17
  Preload indexes into key cache
18
18
*/
19
19
 
20
 
#include "myisam_priv.h"
21
 
#include <stdlib.h>
 
20
#include "myisamdef.h"
22
21
#include <drizzled/util/test.h>
23
22
 
24
 
using namespace drizzled;
 
23
 
25
24
 
26
25
/*
27
26
  Preload pages of the index file for a table into the key cache
29
28
  SYNOPSIS
30
29
    mi_preload()
31
30
      info          open table
32
 
      map           map of indexes to preload into key cache
 
31
      map           map of indexes to preload into key cache 
33
32
      ignore_leaves only non-leaves pages are to be preloaded
34
33
 
35
34
  RETURN VALUE
49
48
  MYISAM_SHARE* share= info->s;
50
49
  uint32_t keys= share->state.header.keys;
51
50
  MI_KEYDEF *keyinfo= share->keyinfo;
52
 
  internal::my_off_t key_file_length= share->state.state.key_file_length;
53
 
  internal::my_off_t pos= share->base.keystart;
 
51
  my_off_t key_file_length= share->state.state.key_file_length;
 
52
  my_off_t pos= share->base.keystart;
54
53
 
55
54
  if (!keys || !mi_is_any_key_active(key_map) || key_file_length == pos)
56
55
    return(0);
63
62
    for (i= 1 ; i < keys ; i++)
64
63
    {
65
64
      if (keyinfo[i].block_length != block_length)
66
 
        return(errno= HA_ERR_NON_UNIQUE_BLOCK_SIZE);
 
65
        return(my_errno= HA_ERR_NON_UNIQUE_BLOCK_SIZE);
67
66
    }
68
67
  }
69
68
  else
70
 
    block_length= share->getKeyCache()->key_cache_block_size;
 
69
    block_length= share->key_cache->key_cache_block_size;
71
70
 
72
71
  length= info->preload_buff_size/block_length * block_length;
73
72
  set_if_bigger(length, block_length);
74
73
 
75
 
  if (!(buff= (unsigned char *) malloc(length)))
76
 
    return(errno= HA_ERR_OUT_OF_MEM);
 
74
  if (!(buff= (unsigned char *) my_malloc(length, MYF(MY_WME))))
 
75
    return(my_errno= HA_ERR_OUT_OF_MEM);
77
76
 
78
 
  if (flush_key_blocks(share->getKeyCache(), share->kfile, FLUSH_RELEASE))
 
77
  if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE))
79
78
    goto err;
80
79
 
81
80
  do
82
81
  {
83
82
    /* Read the next block of index file into the preload buffer */
84
 
    if ((internal::my_off_t) length > (key_file_length-pos))
 
83
    if ((my_off_t) length > (key_file_length-pos))
85
84
      length= (uint32_t) (key_file_length-pos);
86
85
    if (my_pread(share->kfile, (unsigned char*) buff, length, pos, MYF(MY_FAE|MY_FNABP)))
87
86
      goto err;
93
92
      {
94
93
        if (mi_test_if_nod(buff))
95
94
        {
96
 
          if (key_cache_insert(share->getKeyCache(),
 
95
          if (key_cache_insert(share->key_cache,
97
96
                               share->kfile, pos, DFLT_INIT_HITS,
98
97
                              (unsigned char*) buff, block_length))
99
98
            goto err;
105
104
    }
106
105
    else
107
106
    {
108
 
      if (key_cache_insert(share->getKeyCache(),
 
107
      if (key_cache_insert(share->key_cache,
109
108
                           share->kfile, pos, DFLT_INIT_HITS,
110
109
                           (unsigned char*) buff, length))
111
110
        goto err;
119
118
 
120
119
err:
121
120
  free((char*) buff);
122
 
  return(errno= errno);
 
121
  return(my_errno= errno);
123
122
}
124
123