Commit 318c826e authored by Sergei Golubchik's avatar Sergei Golubchik

always use my_b_pread() instead of mysql_file_pread()

when working with IO_CACHE's, don't access IO_CACHE::file directly
parent 6309a30d
......@@ -610,6 +610,7 @@ static inline size_t my_b_bytes_in_cache(const IO_CACHE *info)
int my_b_copy_to_file(IO_CACHE *cache, FILE *file);
my_off_t my_b_append_tell(IO_CACHE* info);
my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
int my_b_pread(IO_CACHE *info, uchar *Buffer, size_t Count, my_off_t pos);
typedef uint32 ha_checksum;
extern ulong my_crc_dbug_check;
......
......@@ -180,6 +180,12 @@ void my_b_seek(IO_CACHE *info,my_off_t pos)
DBUG_VOID_RETURN;
}
int my_b_pread(IO_CACHE *info, uchar *Buffer, size_t Count, my_off_t pos)
{
if (mysql_file_pread(info->file, Buffer, Count, pos, info->myflags | MY_NABP))
return info->error= -1;
return 0;
}
/*
Read a string ended by '\n' into a buffer of 'max_length' size.
......
......@@ -1483,10 +1483,9 @@ uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
if ((count=(uint) MY_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
{
if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= rec_length*count),
buffpek->file_pos, MYF_RW))
return((uint) -1); /* purecov: inspected */
if (my_b_pread(fromfile, (uchar*) buffpek->base,
(length= rec_length*count), buffpek->file_pos))
return ((uint) -1);
buffpek->key=buffpek->base;
buffpek->file_pos+= length; /* New filepos */
buffpek->count-= count;
......
......@@ -929,9 +929,8 @@ static my_off_t read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
if ((count= (ha_keys) MY_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
{
if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= sort_length * count),
buffpek->file_pos, MYF_RW))
if (my_b_pread(fromfile, (uchar*) buffpek->base,
(length= sort_length * count), buffpek->file_pos))
return(HA_OFFSET_ERROR); /* purecov: inspected */
buffpek->key=buffpek->base;
buffpek->file_pos+= length; /* New filepos */
......@@ -956,12 +955,12 @@ static my_off_t read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
for (idx=1;idx<=count;idx++)
{
uint16 length_of_key;
if (mysql_file_pread(fromfile->file,(uchar*)&length_of_key,sizeof(length_of_key),
buffpek->file_pos,MYF_RW))
if (my_b_pread(fromfile, (uchar*)&length_of_key,
sizeof(length_of_key), buffpek->file_pos))
return(HA_OFFSET_ERROR);
buffpek->file_pos+=sizeof(length_of_key);
if (mysql_file_pread(fromfile->file, buffp, length_of_key,
buffpek->file_pos,MYF_RW))
if (my_b_pread(fromfile, (uchar*) buffp,
length_of_key, buffpek->file_pos))
return((uint) -1);
buffpek->file_pos+=length_of_key;
buffp = buffp + sort_length;
......
......@@ -876,10 +876,9 @@ static my_off_t read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
if ((count= (ha_keys) MY_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
{
if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= sort_length * count),
buffpek->file_pos, MYF_RW))
return(HA_OFFSET_ERROR); /* purecov: inspected */
if (my_b_pread(fromfile, (uchar*) buffpek->base,
(length= sort_length * count), buffpek->file_pos))
return(HA_OFFSET_ERROR);
buffpek->key=buffpek->base;
buffpek->file_pos+= length; /* New filepos */
buffpek->count-= count;
......@@ -903,12 +902,12 @@ static my_off_t read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
for (idx=1;idx<=count;idx++)
{
if (mysql_file_pread(fromfile->file, (uchar*)&length_of_key,
sizeof(length_of_key), buffpek->file_pos, MYF_RW))
if (my_b_pread(fromfile, (uchar*)&length_of_key,
sizeof(length_of_key), buffpek->file_pos))
return(HA_OFFSET_ERROR);
buffpek->file_pos+=sizeof(length_of_key);
if (mysql_file_pread(fromfile->file, (uchar*) buffp,
length_of_key, buffpek->file_pos, MYF_RW))
if (my_b_pread(fromfile, (uchar*) buffp,
length_of_key, buffpek->file_pos))
return(HA_OFFSET_ERROR);
buffpek->file_pos+=length_of_key;
buffp = buffp + sort_length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment