26
26
expected to hit the cache again.
28
28
Allows "partial read" errors in the record header (when READING_HEADER flag
29
is set) - unread part is zero'ed
29
is set) - unread part is bzero'ed
31
31
Note: out-of-cache reads are enabled for shared IO_CACHE's too,
32
32
as these reads will be cached by OS cache (and my_pread is always atomic)
36
#include "myisam_priv.h"
41
using namespace drizzled;
44
int _mi_read_cache(internal::IO_CACHE *info, unsigned char *buff, internal::my_off_t pos, uint32_t length,
36
#include "myisamdef.h"
38
int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length,
47
uint32_t read_length,in_buff_length;
48
internal::my_off_t offset;
49
unsigned char *in_buff_pos;
41
uint read_length,in_buff_length;
44
DBUG_ENTER("_mi_read_cache");
51
46
if (pos < info->pos_in_file)
53
48
read_length=length;
54
if ((internal::my_off_t) read_length > (internal::my_off_t) (info->pos_in_file-pos))
49
if ((my_off_t) read_length > (my_off_t) (info->pos_in_file-pos))
55
50
read_length=(uint) (info->pos_in_file-pos);
56
51
info->seek_not_done=1;
57
52
if (my_pread(info->file,buff,read_length,pos,MYF(MY_NABP)))
59
54
if (!(length-=read_length))
64
59
if (pos >= info->pos_in_file &&
65
(offset= (internal::my_off_t) (pos - info->pos_in_file)) <
66
(internal::my_off_t) (info->read_end - info->request_pos))
60
(offset= (my_off_t) (pos - info->pos_in_file)) <
61
(my_off_t) (info->read_end - info->request_pos))
68
63
in_buff_pos=info->request_pos+(uint) offset;
69
in_buff_length= min(length, (uint32_t) (info->read_end-in_buff_pos));
64
in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
70
65
memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
71
66
if (!(length-=in_buff_length))
73
68
pos+=in_buff_length;
74
69
buff+=in_buff_length;
88
83
info->read_pos=info->read_end; /* All block used */
89
84
if (!(*info->read_function)(info,buff,length))
91
86
read_length=info->error;
95
90
info->seek_not_done=1;
96
91
if ((read_length=my_pread(info->file,buff,length,pos,MYF(0))) == length)
99
94
if (!(flag & READING_HEADER) || (int) read_length == -1 ||
100
95
read_length+in_buff_length < 3)
102
if (!errno || errno == -1)
103
errno=HA_ERR_WRONG_IN_RECORD;
98
("Error %d reading next-multi-part block (Got %d bytes)",
99
my_errno, (int) read_length));
100
if (!my_errno || my_errno == -1)
101
my_errno=HA_ERR_WRONG_IN_RECORD;
106
memset(buff+read_length, 0,
107
MI_BLOCK_INFO_HEADER_LENGTH - in_buff_length - read_length);
104
bzero(buff+read_length,MI_BLOCK_INFO_HEADER_LENGTH - in_buff_length -
109
107
} /* _mi_read_cache */