diff options
-rw-r--r-- | include/my_sys.h | 1 | ||||
-rw-r--r-- | mysys/mf_iocache2.c | 6 | ||||
-rw-r--r-- | sql/filesort.cc | 7 | ||||
-rw-r--r-- | storage/maria/ma_sort.c | 13 | ||||
-rw-r--r-- | storage/myisam/sort.c | 15 |
5 files changed, 23 insertions, 19 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 8e0e34f2796..dfd45b18f26 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -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; diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index a642e112fa0..5443d5c21c5 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -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. diff --git a/sql/filesort.cc b/sql/filesort.cc index 66087d3271e..2bce61ba3f6 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -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; diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c index d511c1e6c97..967d4a151be 100644 --- a/storage/maria/ma_sort.c +++ b/storage/maria/ma_sort.c @@ -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; diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index f65d1e8fe58..c24d0e24a11 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -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; |