diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2015-06-05 23:24:39 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2015-06-05 23:24:39 +0200 |
commit | f8fa5fe1bc9023e0e9fac5b05515b94ed04289cb (patch) | |
tree | 44bff5f7c263003693720c2f0ba79f1ede0243c5 /mysys/mf_iocache2.c | |
parent | 9dee994d992b3930f0d29197aed82771bf910c47 (diff) | |
parent | f7002c05ae4e4a09bc6859ccc568064cfd6bb268 (diff) | |
download | mariadb-git-f8fa5fe1bc9023e0e9fac5b05515b94ed04289cb.tar.gz |
Commit merge resolve
Diffstat (limited to 'mysys/mf_iocache2.c')
-rw-r--r-- | mysys/mf_iocache2.c | 60 |
1 files changed, 9 insertions, 51 deletions
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 06dfc9f2079..93caa7bc74a 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -61,7 +61,6 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file) if (my_fwrite(file, cache->read_pos, bytes_in_cache, MYF(MY_WME | MY_NABP)) == (size_t) -1) DBUG_RETURN(1); - cache->read_pos= cache->read_end; } while ((bytes_in_cache= my_b_fill(cache))); if(cache->error == -1) DBUG_RETURN(1); @@ -181,60 +180,19 @@ void my_b_seek(IO_CACHE *info,my_off_t pos) DBUG_VOID_RETURN; } - -/* - Fill buffer of the cache. - - NOTES - This assumes that you have already used all characters in the CACHE, - independent of the read_pos value! - - RETURN - 0 On error or EOF (info->error = -1 on error) - # Number of characters -*/ - - -size_t my_b_fill(IO_CACHE *info) +int my_b_pread(IO_CACHE *info, uchar *Buffer, size_t Count, my_off_t pos) { - my_off_t pos_in_file=(info->pos_in_file+ - (size_t) (info->read_end - info->buffer)); - size_t diff_length, length, max_length; - - if (info->seek_not_done) - { /* File touched, do seek */ - if (mysql_file_seek(info->file, pos_in_file, MY_SEEK_SET, MYF(0)) == - MY_FILEPOS_ERROR) - { - info->error= 0; - return 0; - } - info->seek_not_done=0; - } - diff_length=(size_t) (pos_in_file & (IO_SIZE-1)); - max_length=(info->read_length-diff_length); - if (max_length >= (info->end_of_file - pos_in_file)) - max_length= (size_t) (info->end_of_file - pos_in_file); - - if (!max_length) - { - info->error= 0; - return 0; /* EOF */ - } - DBUG_EXECUTE_IF ("simulate_my_b_fill_error", - {DBUG_SET("+d,simulate_file_read_error");}); - if ((length= mysql_file_read(info->file, info->buffer, max_length, - info->myflags)) == (size_t) -1) + if (info->myflags & MY_ENCRYPT) { - info->error= -1; - return 0; + my_b_seek(info, pos); + return my_b_read(info, Buffer, Count); } - info->read_pos=info->buffer; - info->read_end=info->buffer+length; - info->pos_in_file=pos_in_file; - return length; -} + /* backward compatibility behavior. XXX remove it? */ + 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. |