Skip to content

Commit

Permalink
Fixed bug in Aria read cache when doing check/repair
Browse files Browse the repository at this point in the history
Reading the last page of table with "dynamic page" format would generate
an error when reading after the last row. This was never noticed as
when using Aria as a handler any error messages generated by
_ma_set_fatal_error() was ignored.
  • Loading branch information
montywi committed Jun 6, 2022
1 parent 54e501c commit 4834a0d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions storage/maria/ma_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ my_bool _ma_read_cache(MARIA_HA *handler, IO_CACHE *info, uchar *buff,
DBUG_ENTER("_ma_read_cache");
DBUG_ASSERT(!(info->myflags & MY_ENCRYPT));

if (unlikely(pos >= info->end_of_file) && (flag & READING_HEADER))
DBUG_RETURN(-1);

if (pos < info->pos_in_file)
{
read_length=length;
Expand Down Expand Up @@ -95,14 +98,17 @@ my_bool _ma_read_cache(MARIA_HA *handler, IO_CACHE *info, uchar *buff,
if (!(flag & READING_HEADER) || (int) read_length == -1 ||
read_length+in_buff_length < 3)
{
if ((flag & READING_HEADER) && read_length + in_buff_length == 0)
DBUG_RETURN(-1); /* End of file */

DBUG_PRINT("error",
("Error %d reading next-multi-part block (Got %d bytes)",
my_errno, (int) read_length));
("Error %d reading next-multi-part block (Got %d of %d bytes)",
my_errno, (int) read_length, (int) length));
if (!my_errno || my_errno == HA_ERR_FILE_TOO_SHORT)
{
if (!handler->in_check_table)
_ma_set_fatal_error(handler->s, HA_ERR_WRONG_IN_RECORD);
else
_ma_set_fatal_error(handler->s, HA_ERR_FILE_TOO_SHORT);
if (!my_errno)
my_errno= HA_ERR_WRONG_IN_RECORD;
}
DBUG_RETURN(1);
Expand Down

0 comments on commit 4834a0d

Please sign in to comment.