[MDEV-10001] my_b_seek() may not work correctly after my_b_read() hits EOF Created: 2016-04-26  Updated: 2016-10-26  Resolved: 2016-10-26

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0.24
Fix Version/s: 10.0.26

Type: Bug Priority: Major
Reporter: David Gow Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: contribution, patch
Environment:

Code inspection.


Attachments: File 0001-Fix-my_b_seek-after-reading-to-end-of-IO_CACHE.patch    
Sprint: 10.0.26

 Description   

my_b_read() tries to read within a buffer where possible, and keeps track of the position of that buffer within the file when the buffer is refilled.

However, if my_b_read() hits the end of the file, the operating system file pointer and the IO_CACHE pos_in_file may not be synchronised. A future call to my_b_seek() may not rectify this if the new position is within the buffer. At this point, further reads with my_b_read() would read from the buffer until it is empty, and then try to read from the end of the file. In essence, my_b_read() expects the OS file pointer to be at the end of the buffer (or info->seek_not_done to be set in order to trigger a seek to make this so).

The attached patch fixes this by setting info->seek_not_done when my_b_read() hits EOF, causing future reads to seek to the correct position in the file.


Generated at Thu Feb 08 07:38:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.