22
22
/* Fetch a key-page in memory */
24
unsigned char *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo,
25
internal::my_off_t page, int level,
26
unsigned char *buff, int return_buffer)
24
unsigned char *_mi_fetch_keypage(MI_INFO *info, MI_KEYDEF *keyinfo,
25
internal::my_off_t page, int, unsigned char *buff, int)
31
tmp=(unsigned char*) key_cache_read(info->s->getKeyCache(),
32
info->s->kfile, page, level, (unsigned char*) buff,
33
(uint) keyinfo->block_length,
34
(uint) keyinfo->block_length,
36
if (tmp == info->buff)
27
if (not pread(info->s->kfile, buff, keyinfo->block_length, page))
40
29
info->last_keypage=HA_OFFSET_ERROR;
41
30
mi_print_error(info->s, HA_ERR_CRASHED);
42
31
errno=HA_ERR_CRASHED;
34
unsigned char* tmp= buff;
35
if (tmp == info->buff)
45
37
info->last_keypage=page;
46
page_size=mi_getint(tmp);
38
uint32_t page_size=mi_getint(tmp);
47
39
if (page_size < 4 || page_size > keyinfo->block_length)
49
41
info->last_keypage = HA_OFFSET_ERROR;
58
50
/* Write a key-page on disk */
60
int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
61
internal::my_off_t page, int level, unsigned char *buff)
52
int _mi_write_keypage(MI_INFO *info, MI_KEYDEF *keyinfo,
53
internal::my_off_t page, int, unsigned char *buff)
63
register uint32_t length;
65
57
#ifndef FAST /* Safety check */
66
58
if (page < info->s->base.keystart ||
82
74
length=keyinfo->block_length;
85
return((key_cache_write(info->s->getKeyCache(),
86
info->s->kfile,page, level, (unsigned char*) buff,length,
87
(uint) keyinfo->block_length,
88
(int) ((info->lock_type != F_UNLCK) ||
89
info->s->delay_key_write))));
77
return not pwrite(info->s->kfile, buff, length, page);
90
78
} /* mi_write_keypage */
93
81
/* Remove page from disk */
95
int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, internal::my_off_t pos,
83
int _mi_dispose(MI_INFO *info, MI_KEYDEF *keyinfo, internal::my_off_t pos, int)
98
85
internal::my_off_t old_link;
99
86
unsigned char buff[8];
102
89
info->s->state.key_del[keyinfo->block_size_index]= pos;
103
90
mi_sizestore(buff,old_link);
104
91
info->s->state.changed|= STATE_NOT_SORTED_PAGES;
105
return(key_cache_write(info->s->getKeyCache(),
106
info->s->kfile, pos , level, buff,
108
(uint) keyinfo->block_length,
109
(int) (info->lock_type != F_UNLCK)));
92
return not pwrite(info->s->kfile, buff, sizeof(buff), pos);
110
93
} /* _mi_dispose */
113
96
/* Make new page on disk */
115
internal::my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level)
98
internal::my_off_t _mi_new(MI_INFO *info, MI_KEYDEF *keyinfo, int)
117
100
internal::my_off_t pos;
118
101
unsigned char buff[8];
129
112
pos=info->state->key_file_length;
130
113
info->state->key_file_length+= keyinfo->block_length;
115
else if (pread(info->s->kfile, buff, sizeof(buff), pos))
116
info->s->state.key_del[keyinfo->block_size_index]= mi_sizekorr(buff);
134
if (!key_cache_read(info->s->getKeyCache(),
135
info->s->kfile, pos, level,
138
(uint) keyinfo->block_length,0))
139
pos= HA_OFFSET_ERROR;
141
info->s->state.key_del[keyinfo->block_size_index]= mi_sizekorr(buff);
118
pos= HA_OFFSET_ERROR;
143
119
info->s->state.changed|= STATE_NOT_SORTED_PAGES;