~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_page.c

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

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
/* Read and write key blocks */
17
17
 
18
 
#include "myisam_priv.h"
19
 
 
20
 
using namespace drizzled;
 
18
#include "myisamdef.h"
21
19
 
22
20
        /* Fetch a key-page in memory */
23
21
 
24
22
unsigned char *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo,
25
 
                         internal::my_off_t page, int level,
 
23
                         my_off_t page, int level,
26
24
                         unsigned char *buff, int return_buffer)
27
25
{
28
26
  unsigned char *tmp;
29
27
  uint32_t page_size;
30
28
 
31
 
  tmp=(unsigned char*) key_cache_read(info->s->getKeyCache(),
 
29
  tmp=(unsigned char*) key_cache_read(info->s->key_cache,
32
30
                             info->s->kfile, page, level, (unsigned char*) buff,
33
31
                             (uint) keyinfo->block_length,
34
32
                             (uint) keyinfo->block_length,
39
37
  {
40
38
    info->last_keypage=HA_OFFSET_ERROR;
41
39
    mi_print_error(info->s, HA_ERR_CRASHED);
42
 
    errno=HA_ERR_CRASHED;
 
40
    my_errno=HA_ERR_CRASHED;
43
41
    return(0);
44
42
  }
45
43
  info->last_keypage=page;
48
46
  {
49
47
    info->last_keypage = HA_OFFSET_ERROR;
50
48
    mi_print_error(info->s, HA_ERR_CRASHED);
51
 
    errno = HA_ERR_CRASHED;
 
49
    my_errno = HA_ERR_CRASHED;
52
50
    tmp = 0;
53
51
  }
54
52
  return(tmp);
58
56
        /* Write a key-page on disk */
59
57
 
60
58
int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
61
 
                      internal::my_off_t page, int level, unsigned char *buff)
 
59
                      my_off_t page, int level, unsigned char *buff)
62
60
{
63
61
  register uint32_t length;
64
62
 
67
65
      page+keyinfo->block_length > info->state->key_file_length ||
68
66
      (page & (MI_MIN_KEY_BLOCK_LENGTH-1)))
69
67
  {
70
 
    errno=EINVAL;
 
68
    my_errno=EINVAL;
71
69
    return((-1));
72
70
  }
73
71
#endif
75
73
  if ((length=keyinfo->block_length) > IO_SIZE*2 &&
76
74
      info->state->key_file_length != page+length)
77
75
    length= ((mi_getint(buff)+IO_SIZE-1) & (uint) ~(IO_SIZE-1));
78
 
#ifdef HAVE_VALGRIND
 
76
#ifdef HAVE_purify
79
77
  {
80
78
    length=mi_getint(buff);
81
79
    memset(buff+length, 0, keyinfo->block_length-length);
82
80
    length=keyinfo->block_length;
83
81
  }
84
82
#endif
85
 
  return((key_cache_write(info->s->getKeyCache(),
 
83
  return((key_cache_write(info->s->key_cache,
86
84
                         info->s->kfile,page, level, (unsigned char*) buff,length,
87
85
                         (uint) keyinfo->block_length,
88
86
                         (int) ((info->lock_type != F_UNLCK) ||
92
90
 
93
91
        /* Remove page from disk */
94
92
 
95
 
int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, internal::my_off_t pos,
 
93
int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos,
96
94
                int level)
97
95
{
98
 
  internal::my_off_t old_link;
 
96
  my_off_t old_link;
99
97
  unsigned char buff[8];
100
98
 
101
99
  old_link= info->s->state.key_del[keyinfo->block_size_index];
102
100
  info->s->state.key_del[keyinfo->block_size_index]= pos;
103
101
  mi_sizestore(buff,old_link);
104
102
  info->s->state.changed|= STATE_NOT_SORTED_PAGES;
105
 
  return(key_cache_write(info->s->getKeyCache(),
 
103
  return(key_cache_write(info->s->key_cache,
106
104
                              info->s->kfile, pos , level, buff,
107
105
                              sizeof(buff),
108
106
                              (uint) keyinfo->block_length,
112
110
 
113
111
        /* Make new page on disk */
114
112
 
115
 
internal::my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level)
 
113
my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level)
116
114
{
117
 
  internal::my_off_t pos;
 
115
  my_off_t pos;
118
116
  unsigned char buff[8];
119
117
 
120
118
  if ((pos= info->s->state.key_del[keyinfo->block_size_index]) ==
123
121
    if (info->state->key_file_length >=
124
122
        info->s->base.max_key_file_length - keyinfo->block_length)
125
123
    {
126
 
      errno=HA_ERR_INDEX_FILE_FULL;
 
124
      my_errno=HA_ERR_INDEX_FILE_FULL;
127
125
      return(HA_OFFSET_ERROR);
128
126
    }
129
127
    pos=info->state->key_file_length;
131
129
  }
132
130
  else
133
131
  {
134
 
    if (!key_cache_read(info->s->getKeyCache(),
 
132
    if (!key_cache_read(info->s->key_cache,
135
133
                        info->s->kfile, pos, level,
136
134
                        buff,
137
135
                        (uint) sizeof(buff),