[Commits] Rev 3022: Use _ma_set_fatal_error() in Aria also for HA_ERR_WRONG_IN_RECORD, to be able to get an assert as soon as a failure is detected. in lp:maria/5.1

Michael Widenius monty at askmonty.org
Wed Jan 26 15:29:36 EET 2011


At lp:maria/5.1

------------------------------------------------------------
revno: 3022
revision-id: monty at askmonty.org-20110126132936-3g5dyk9u6buhra1n
parent: monty at askmonty.org-20110126131746-qnivnq4vbs00q72v
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.1
timestamp: Wed 2011-01-26 15:29:36 +0200
message:
  Use _ma_set_fatal_error() in Aria also for HA_ERR_WRONG_IN_RECORD, to be able to get an assert as soon as a failure is detected.
  Fixed stack overrun failure when calling maria_chk_data_link().
-------------- next part --------------
=== modified file 'storage/maria/ma_blockrec.c'
--- a/storage/maria/ma_blockrec.c	2011-01-24 13:19:40 +0000
+++ b/storage/maria/ma_blockrec.c	2011-01-26 13:29:36 +0000
@@ -891,8 +891,7 @@ static my_bool extend_area_on_page(MARIA
           DBUG_PRINT("error", ("Not enough space: "
                                "length: %u  request_length: %u",
                                length, request_length));
-          my_errno= HA_ERR_WRONG_IN_RECORD;     /* File crashed */
-          DBUG_ASSERT(0);                       /* For debugging */
+          _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
           DBUG_RETURN(1);                       /* Error in block */
         }
         *empty_space= length;                   /* All space is here */
@@ -1777,7 +1776,7 @@ static my_bool get_head_or_tail_page(MAR
   DBUG_RETURN(0);
 
 crashed:
-  my_errno= HA_ERR_WRONG_IN_RECORD;             /* File crashed */
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);  /* File crashed */
   DBUG_RETURN(1);
 }
 
@@ -1870,7 +1869,7 @@ static my_bool get_rowpos_in_head_or_tai
   DBUG_RETURN(0);
 
 err:
-  my_errno= HA_ERR_WRONG_IN_RECORD;             /* File crashed */
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);  /* File crashed */
   DBUG_RETURN(1);
 }
 
@@ -2094,8 +2093,7 @@ static my_bool write_full_pages(MARIA_HA
     {
       if (!--sub_blocks)
       {
-        DBUG_ASSERT(0);                         /* Wrong in bitmap or UNDO */
-        my_errno= HA_ERR_WRONG_IN_RECORD;       /* File crashed */
+        _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
         DBUG_RETURN(1);
       }
 
@@ -3419,7 +3417,7 @@ static my_bool write_block_record(MARIA_
 
 crashed:
   /* Something was wrong with data on page */
-  my_errno= HA_ERR_WRONG_IN_RECORD;
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
 
 disk_err:
   /**
@@ -3891,7 +3889,7 @@ static my_bool _ma_update_at_original_pl
                ("org_empty_size: %u  head_length: %u  length_on_page: %u",
                 org_empty_size, (uint) cur_row->head_length,
                 length_on_head_page));
-    my_errno= HA_ERR_WRONG_IN_RECORD;
+    _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
     goto err;
   }
 
@@ -4523,7 +4521,7 @@ static uchar *read_next_extent(MARIA_HA
 
 
 crashed:
-  my_errno= HA_ERR_WRONG_IN_RECORD;             /* File crashed */
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
   DBUG_PRINT("error", ("wrong extent information"));
   DBUG_RETURN(0);
 }
@@ -4668,7 +4666,11 @@ int _ma_read_block_record2(MARIA_HA *inf
   {
     cur_row->trid= transid_korr(data+1);
     if (!info->trn)
-      DBUG_RETURN(my_errno= HA_ERR_WRONG_IN_RECORD);     /* File crashed */
+    {
+      /* File crashed */
+      _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
+      DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
+    }
     if (!trnman_can_read_from(info->trn, cur_row->trid))
       DBUG_RETURN(my_errno= HA_ERR_ROW_NOT_VISIBLE);
   }
@@ -4949,7 +4951,8 @@ int _ma_read_block_record2(MARIA_HA *inf
 err:
   /* Something was wrong with data on record */
   DBUG_PRINT("error", ("Found record with wrong data"));
-  DBUG_RETURN((my_errno= HA_ERR_WRONG_IN_RECORD));
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
+  DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
 }
 
 
@@ -5399,7 +5402,8 @@ int _ma_scan_block_record(MARIA_HA *info
                (uint) (uchar) info->scan.page_buff[DIR_COUNT_OFFSET]) == 0)
           {
             DBUG_PRINT("error", ("Wrong page header"));
-            DBUG_RETURN((my_errno= HA_ERR_WRONG_IN_RECORD));
+            _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
+            DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
           }
           DBUG_PRINT("info", ("Page %lu has %u rows",
                               (ulong) page, info->scan.number_of_rows));
@@ -5445,7 +5449,8 @@ int _ma_scan_block_record(MARIA_HA *info
 
 err:
   DBUG_PRINT("error", ("Wrong data on page"));
-  DBUG_RETURN((my_errno= HA_ERR_WRONG_IN_RECORD));
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
+  DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
 }
 
 
@@ -6365,7 +6370,7 @@ uint _ma_apply_redo_insert_row_head_or_t
   DBUG_RETURN(result);
 
 crashed_file:
-  my_errno= HA_ERR_WRONG_IN_RECORD;
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
 err:
   error= my_errno;
   if (unlock_method == PAGECACHE_LOCK_LEFT_WRITELOCKED)
@@ -6453,7 +6458,7 @@ uint _ma_apply_redo_purge_row_head_or_ta
 
   if (delete_dir_entry(buff, block_size, rownr, &empty_space) < 0)
   {
-    my_errno= HA_ERR_WRONG_IN_RECORD;
+    _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
     goto err;
   }
 

=== modified file 'storage/maria/ma_cache.c'
--- a/storage/maria/ma_cache.c	2008-01-12 22:30:38 +0000
+++ b/storage/maria/ma_cache.c	2011-01-26 13:29:36 +0000
@@ -35,8 +35,8 @@
 
 #include "maria_def.h"
 
-my_bool _ma_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos,
-                       size_t length, uint flag)
+my_bool _ma_read_cache(MARIA_HA *handler, IO_CACHE *info, uchar *buff,
+                       my_off_t pos, size_t length, uint flag)
 {
   size_t read_length,in_buff_length;
   my_off_t offset;
@@ -98,7 +98,7 @@ my_bool _ma_read_cache(IO_CACHE *info, u
                ("Error %d reading next-multi-part block (Got %d bytes)",
                 my_errno, (int) read_length));
     if (!my_errno || my_errno == HA_ERR_FILE_TOO_SHORT)
-      my_errno= HA_ERR_WRONG_IN_RECORD;
+      _ma_set_fatal_error(handler->s, HA_ERR_WRONG_IN_RECORD);
     DBUG_RETURN(1);
   }
   bzero(buff+read_length,MARIA_BLOCK_INFO_HEADER_LENGTH - in_buff_length -

=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c	2011-01-24 13:19:40 +0000
+++ b/storage/maria/ma_check.c	2011-01-26 13:29:36 +0000
@@ -1247,7 +1247,7 @@ static int check_dynamic_record(HA_CHECK
     block_info.next_filepos=pos;
     do
     {
-      if (_ma_read_cache(&param->read_cache, block_info.header,
+      if (_ma_read_cache(info, &param->read_cache, block_info.header,
                          (start_block=block_info.next_filepos),
                          sizeof(block_info.header),
                          (flag ? 0 : READING_NEXT) | READING_HEADER))
@@ -1265,7 +1265,7 @@ static int check_dynamic_record(HA_CHECK
                               llstr(start_block,llbuff));
         DBUG_RETURN(1);
       }
-      b_type= _ma_get_block_info(&block_info,-1,start_block);
+      b_type= _ma_get_block_info(info, &block_info,-1,start_block);
       if (b_type & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
                     BLOCK_FATAL_ERROR))
       {
@@ -1361,7 +1361,7 @@ static int check_dynamic_record(HA_CHECK
         got_error=1;
         break;
       }
-      if (_ma_read_cache(&param->read_cache, to, block_info.filepos,
+      if (_ma_read_cache(info, &param->read_cache, to, block_info.filepos,
                          (uint) block_info.data_len,
                          flag == 1 ? READING_NEXT : 0))
       {
@@ -1464,7 +1464,7 @@ static int check_compressed_record(HA_CH
     if (_ma_killed_ptr(param))
       DBUG_RETURN(-1);
 
-    if (_ma_read_cache(&param->read_cache, block_info.header, pos,
+    if (_ma_read_cache(info, &param->read_cache, block_info.header, pos,
                        share->pack.ref_length, READING_NEXT))
     {
       _ma_check_print_error(param,
@@ -1489,7 +1489,7 @@ static int check_compressed_record(HA_CH
       got_error=1;
       goto end;
     }
-    if (_ma_read_cache(&param->read_cache, info->rec_buff,
+    if (_ma_read_cache(info, &param->read_cache, info->rec_buff,
                        block_info.filepos, block_info.rec_len, READING_NEXT))
     {
       _ma_check_print_error(param,
@@ -4850,7 +4850,7 @@ static int sort_get_next_record(MARIA_SO
           _ma_check_print_info(param,"Block: %s used by record at %s",
                      llstr(param->search_after_block,llbuff),
                      llstr(sort_param->start_recpos,llbuff2));
-        if (_ma_read_cache(&sort_param->read_cache,
+        if (_ma_read_cache(info, &sort_param->read_cache,
                            block_info.header, pos,
                            MARIA_BLOCK_INFO_HEADER_LENGTH,
                            (! found_record ? READING_NEXT : 0) |
@@ -4872,7 +4872,7 @@ static int sort_get_next_record(MARIA_SO
           param->testflag|=T_RETRY_WITHOUT_QUICK;
           DBUG_RETURN(1);       /* Something wrong with data */
         }
-        b_type= _ma_get_block_info(&block_info,-1,pos);
+        b_type= _ma_get_block_info(info, &block_info,-1,pos);
         if ((b_type & (BLOCK_ERROR | BLOCK_FATAL_ERROR)) ||
            ((b_type & BLOCK_FIRST) &&
              (block_info.rec_len < (uint) share->base.min_pack_length ||
@@ -5063,7 +5063,7 @@ static int sort_get_next_record(MARIA_SO
           }
         }
         if (block_info.data_len &&
-            _ma_read_cache(&sort_param->read_cache,to,block_info.filepos,
+            _ma_read_cache(info, &sort_param->read_cache,to,block_info.filepos,
                            block_info.data_len,
                            (found_record == 1 ? READING_NEXT : 0) |
                            parallel_flag))
@@ -5133,7 +5133,7 @@ static int sort_get_next_record(MARIA_SO
   case COMPRESSED_RECORD:
     for (searching=0 ;; searching=1, sort_param->pos++)
     {
-      if (_ma_read_cache(&sort_param->read_cache, block_info.header,
+      if (_ma_read_cache(info, &sort_param->read_cache, block_info.header,
                          sort_param->pos,
                          share->pack.ref_length,READING_NEXT))
         DBUG_RETURN(-1);
@@ -5165,7 +5165,7 @@ static int sort_get_next_record(MARIA_SO
                                llstr(sort_param->pos,llbuff));
         continue;
       }
-      if (_ma_read_cache(&sort_param->read_cache, sort_param->rec_buff,
+      if (_ma_read_cache(info, &sort_param->read_cache, sort_param->rec_buff,
                          block_info.filepos, block_info.rec_len,
                          READING_NEXT))
       {
@@ -6830,7 +6830,10 @@ static void print_bitmap_description(MAR
                                      pgcache_page_no_t page,
                                      uchar *bitmap_data)
 {
-  char tmp[MAX_BITMAP_INFO_LENGTH];
+  char *tmp= my_malloc(MAX_BITMAP_INFO_LENGTH, MYF(MY_WME));
+  if (!tmp)
+    return;
   _ma_get_bitmap_description(&share->bitmap, bitmap_data, page, tmp);
   printf("Bitmap page %lu\n%s", (ulong) page, tmp);
+  my_free(tmp, MYF(0));
 }

=== modified file 'storage/maria/ma_dynrec.c'
--- a/storage/maria/ma_dynrec.c	2009-01-09 04:23:25 +0000
+++ b/storage/maria/ma_dynrec.c	2011-01-26 13:29:36 +0000
@@ -391,12 +391,12 @@ static int _ma_find_writepos(MARIA_HA *i
     *filepos=info->s->state.dellink;
     block_info.second_read=0;
     info->rec_cache.seek_not_done=1;
-    if (!(_ma_get_block_info(&block_info, info->dfile.file,
+    if (!(_ma_get_block_info(info, &block_info, info->dfile.file,
                              info->s->state.dellink) &
            BLOCK_DELETED))
     {
       DBUG_PRINT("error",("Delete link crashed"));
-      my_errno=HA_ERR_WRONG_IN_RECORD;
+      _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
       DBUG_RETURN(-1);
     }
     info->s->state.dellink=block_info.next_filepos;
@@ -452,7 +452,8 @@ static my_bool unlink_deleted_block(MARI
     MARIA_BLOCK_INFO tmp;
     tmp.second_read=0;
     /* Unlink block from the previous block */
-    if (!(_ma_get_block_info(&tmp, info->dfile.file, block_info->prev_filepos)
+    if (!(_ma_get_block_info(info, &tmp, info->dfile.file,
+                             block_info->prev_filepos)
           & BLOCK_DELETED))
       DBUG_RETURN(1);                           /* Something is wrong */
     mi_sizestore(tmp.header+4,block_info->next_filepos);
@@ -462,7 +463,7 @@ static my_bool unlink_deleted_block(MARI
     /* Unlink block from next block */
     if (block_info->next_filepos != HA_OFFSET_ERROR)
     {
-      if (!(_ma_get_block_info(&tmp, info->dfile.file,
+      if (!(_ma_get_block_info(info, &tmp, info->dfile.file,
                                block_info->next_filepos)
             & BLOCK_DELETED))
         DBUG_RETURN(1);                         /* Something is wrong */
@@ -514,7 +515,7 @@ static my_bool update_backward_delete_li
   if (delete_block != HA_OFFSET_ERROR)
   {
     block_info.second_read=0;
-    if (_ma_get_block_info(&block_info, info->dfile.file, delete_block)
+    if (_ma_get_block_info(info, &block_info, info->dfile.file, delete_block)
         & BLOCK_DELETED)
     {
       uchar buff[8];
@@ -524,7 +525,7 @@ static my_bool update_backward_delete_li
     }
     else
     {
-      my_errno=HA_ERR_WRONG_IN_RECORD;
+      _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
       DBUG_RETURN(1);                           /* Wrong delete link */
     }
   }
@@ -550,19 +551,21 @@ static my_bool delete_dynamic_record(MAR
   do
   {
     /* Remove block at 'filepos' */
-    if ((b_type= _ma_get_block_info(&block_info, info->dfile.file, filepos))
+    if ((b_type= _ma_get_block_info(info, &block_info, info->dfile.file,
+                                    filepos))
         & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
            BLOCK_FATAL_ERROR) ||
         (length=(uint) (block_info.filepos-filepos) +block_info.block_len) <
         MARIA_MIN_BLOCK_LENGTH)
     {
-      my_errno=HA_ERR_WRONG_IN_RECORD;
+      _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
       DBUG_RETURN(1);
     }
     /* Check if next block is a delete block */
     del_block.second_read=0;
     remove_next_block=0;
-    if (_ma_get_block_info(&del_block, info->dfile.file, filepos + length) &
+    if (_ma_get_block_info(info, &del_block, info->dfile.file,
+                           filepos + length) &
         BLOCK_DELETED && del_block.block_len+length <
         MARIA_DYN_MAX_BLOCK_LENGTH)
     {
@@ -722,7 +725,7 @@ int _ma_write_part_record(MARIA_HA *info
     if (next_block < info->state->data_file_length &&
         info->s->state.dellink != HA_OFFSET_ERROR)
     {
-      if ((_ma_get_block_info(&del_block, info->dfile.file, next_block)
+      if ((_ma_get_block_info(info, &del_block, info->dfile.file, next_block)
            & BLOCK_DELETED) &&
           res_length + del_block.block_len < MARIA_DYN_MAX_BLOCK_LENGTH)
       {
@@ -834,13 +837,14 @@ static my_bool update_dynamic_record(MAR
     if (filepos != info->s->state.dellink)
     {
       block_info.next_filepos= HA_OFFSET_ERROR;
-      if ((error= _ma_get_block_info(&block_info, info->dfile.file, filepos))
+      if ((error= _ma_get_block_info(info, &block_info, info->dfile.file,
+                                     filepos))
           & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
              BLOCK_FATAL_ERROR))
       {
         DBUG_PRINT("error",("Got wrong block info"));
         if (!(error & BLOCK_FATAL_ERROR))
-          my_errno=HA_ERR_WRONG_IN_RECORD;
+          _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
         goto err;
       }
       length=(ulong) (block_info.filepos-filepos) + block_info.block_len;
@@ -875,7 +879,7 @@ static my_bool update_dynamic_record(MAR
 
           MARIA_BLOCK_INFO del_block;
           del_block.second_read=0;
-          if (_ma_get_block_info(&del_block, info->dfile.file,
+          if (_ma_get_block_info(info, &del_block, info->dfile.file,
                                  block_info.filepos + block_info.block_len) &
               BLOCK_DELETED)
           {
@@ -1346,7 +1350,7 @@ ulong _ma_rec_unpack(register MARIA_HA *
     DBUG_RETURN(found_length);
 
 err:
-  my_errno= HA_ERR_WRONG_IN_RECORD;
+  _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
   DBUG_PRINT("error",("to_end: 0x%lx -> 0x%lx  from_end: 0x%lx -> 0x%lx",
                       (long) to, (long) to_end, (long) from, (long) from_end));
   DBUG_DUMP("from", info->rec_buff, info->s->base.min_pack_length);
@@ -1473,7 +1477,7 @@ int _ma_read_dynamic_record(MARIA_HA *in
         flush_io_cache(&info->rec_cache))
       goto err;
     info->rec_cache.seek_not_done=1;
-    if ((b_type= _ma_get_block_info(&block_info, file, filepos)) &
+    if ((b_type= _ma_get_block_info(info, &block_info, file, filepos)) &
         (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
          BLOCK_FATAL_ERROR))
     {
@@ -1545,7 +1549,7 @@ int _ma_read_dynamic_record(MARIA_HA *in
   DBUG_RETURN(my_errno);
 
 panic:
-  my_errno=HA_ERR_WRONG_IN_RECORD;
+  _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
   goto err;
 }
 
@@ -1627,7 +1631,7 @@ my_bool _ma_cmp_dynamic_record(register
     block_info.next_filepos=filepos;
     while (reclength > 0)
     {
-      if ((b_type= _ma_get_block_info(&block_info, info->dfile.file,
+      if ((b_type= _ma_get_block_info(info, &block_info, info->dfile.file,
                                     block_info.next_filepos))
           & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
              BLOCK_FATAL_ERROR))
@@ -1646,7 +1650,7 @@ my_bool _ma_cmp_dynamic_record(register
         }
       } else if (reclength < block_info.data_len)
       {
-        my_errno=HA_ERR_WRONG_IN_RECORD;
+        _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
         goto err;
       }
       reclength-= block_info.data_len;
@@ -1779,12 +1783,12 @@ int _ma_read_rnd_dynamic_record(MARIA_HA
     }
     if (info->opt_flag & READ_CACHE_USED)
     {
-      if (_ma_read_cache(&info->rec_cache, block_info.header, filepos,
+      if (_ma_read_cache(info, &info->rec_cache, block_info.header, filepos,
                          sizeof(block_info.header),
                          (!block_of_record && skip_deleted_blocks ?
                           READING_NEXT : 0) | READING_HEADER))
         goto panic;
-      b_type= _ma_get_block_info(&block_info,-1,filepos);
+      b_type= _ma_get_block_info(info, &block_info,-1,filepos);
     }
     else
     {
@@ -1793,7 +1797,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA
           flush_io_cache(&info->rec_cache))
         DBUG_RETURN(my_errno);
       info->rec_cache.seek_not_done=1;
-      b_type= _ma_get_block_info(&block_info, info->dfile.file, filepos);
+      b_type= _ma_get_block_info(info, &block_info, info->dfile.file, filepos);
     }
 
     if (b_type & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
@@ -1855,7 +1859,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA
     {
       if (info->opt_flag & READ_CACHE_USED)
       {
-        if (_ma_read_cache(&info->rec_cache, to,filepos,
+        if (_ma_read_cache(info, &info->rec_cache, to,filepos,
                            block_info.data_len,
                            (!block_of_record && skip_deleted_blocks) ?
                            READING_NEXT : 0))
@@ -1872,7 +1876,10 @@ int _ma_read_rnd_dynamic_record(MARIA_HA
         if (my_read(info->dfile.file, to, block_info.data_len, MYF(MY_NABP)))
         {
           if (my_errno == HA_ERR_FILE_TOO_SHORT)
-            my_errno= HA_ERR_WRONG_IN_RECORD;   /* Unexpected end of file */
+          {
+            /* Unexpected end of file */
+            _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
+          }
           goto err;
         }
       }
@@ -1899,7 +1906,8 @@ int _ma_read_rnd_dynamic_record(MARIA_HA
   DBUG_RETURN(my_errno);                        /* Wrong record */
 
 panic:
-  my_errno=HA_ERR_WRONG_IN_RECORD;              /* Something is fatal wrong */
+  /* Something is fatal wrong */
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
 err:
   fast_ma_writeinfo(info);
   DBUG_RETURN(my_errno);
@@ -1908,7 +1916,8 @@ int _ma_read_rnd_dynamic_record(MARIA_HA
 
         /* Read and process header from a dynamic-record-file */
 
-uint _ma_get_block_info(MARIA_BLOCK_INFO *info, File file, my_off_t filepos)
+uint _ma_get_block_info(MARIA_HA *handler, MARIA_BLOCK_INFO *info, File file,
+                        my_off_t filepos)
 {
   uint return_val=0;
   uchar *header=info->header;
@@ -1923,7 +1932,14 @@ uint _ma_get_block_info(MARIA_BLOCK_INFO
     VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
     if (my_read(file, header, sizeof(info->header),MYF(0)) !=
         sizeof(info->header))
-      goto err;
+    {
+      /*
+        This is either an error or just reading at end of file.
+        Don't give a fatal error for this case.
+      */
+      my_errno= HA_ERR_WRONG_IN_RECORD;
+      return BLOCK_ERROR;
+    }
   }
   DBUG_DUMP("header",header,MARIA_BLOCK_INFO_HEADER_LENGTH);
   if (info->second_read)
@@ -2037,6 +2053,6 @@ uint _ma_get_block_info(MARIA_BLOCK_INFO
   }
 
 err:
-  my_errno=HA_ERR_WRONG_IN_RECORD;       /* Garbage */
+  _ma_set_fatal_error(handler->s, HA_ERR_WRONG_IN_RECORD);
   return BLOCK_ERROR;
 }

=== modified file 'storage/maria/ma_locking.c'
--- a/storage/maria/ma_locking.c	2011-01-24 13:19:40 +0000
+++ b/storage/maria/ma_locking.c	2011-01-26 13:29:36 +0000
@@ -536,6 +536,7 @@ void _ma_mark_file_crashed(MARIA_SHARE *
 
 void _ma_set_fatal_error(MARIA_SHARE *share, int error)
 {
+  DBUG_PRINT("error", ("error: %d", error));
   maria_mark_crashed_share(share);
   if (!(share->state.changed & STATE_CRASHED_PRINTED))
   {

=== modified file 'storage/maria/ma_packrec.c'
--- a/storage/maria/ma_packrec.c	2009-05-06 12:03:24 +0000
+++ b/storage/maria/ma_packrec.c	2011-01-26 13:29:36 +0000
@@ -193,7 +193,7 @@ static my_bool _ma_read_pack_info(MARIA_
   /* Only the first three bytes of magic number are independent of version. */
   if (memcmp(header, maria_pack_file_magic, 3))
   {
-    my_errno=HA_ERR_WRONG_IN_RECORD;
+    _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
     goto err0;
   }
   share->pack.version= header[3]; /* fourth uchar of magic number */
@@ -330,7 +330,7 @@ static my_bool _ma_read_pack_info(MARIA_
   DBUG_RETURN(0);
 
 err3:
-  my_errno=HA_ERR_WRONG_IN_RECORD;
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
 err2:
   my_free(share->decode_tables, MYF(0));
 err1:
@@ -759,7 +759,7 @@ int _ma_read_pack_record(MARIA_HA *info,
   DBUG_RETURN(_ma_pack_rec_unpack(info,&info->bit_buff, buf,
                                   info->rec_buff, block_info.rec_len));
 panic:
-  my_errno=HA_ERR_WRONG_IN_RECORD;
+  _ma_set_fatal_error(info->s, HA_ERR_WRONG_IN_RECORD);
 err:
   DBUG_RETURN(my_errno);
 }
@@ -794,7 +794,8 @@ int _ma_pack_rec_unpack(register MARIA_H
       bit_buff->pos - bit_buff->bits / 8 == bit_buff->end)
     DBUG_RETURN(0);
   info->update&= ~HA_STATE_AKTIV;
-  DBUG_RETURN(my_errno=HA_ERR_WRONG_IN_RECORD);
+  _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
+  DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
 } /* _ma_pack_rec_unpack */
 
 
@@ -1359,7 +1360,7 @@ int _ma_read_rnd_pack_record(MARIA_HA *i
   file= info->dfile.file;
   if (info->opt_flag & READ_CACHE_USED)
   {
-    if (_ma_read_cache(&info->rec_cache, block_info.header,
+    if (_ma_read_cache(info, &info->rec_cache, block_info.header,
                        filepos, share->pack.ref_length,
                        skip_deleted_blocks ? READING_NEXT : 0))
       goto err;
@@ -1372,14 +1373,14 @@ int _ma_read_rnd_pack_record(MARIA_HA *i
 #ifndef DBUG_OFF
   if (block_info.rec_len > share->max_pack_length)
   {
-    my_errno=HA_ERR_WRONG_IN_RECORD;
+    _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
     goto err;
   }
 #endif
 
   if (info->opt_flag & READ_CACHE_USED)
   {
-    if (_ma_read_cache(&info->rec_cache, info->rec_buff,
+    if (_ma_read_cache(info, &info->rec_cache, info->rec_buff,
                        block_info.filepos, block_info.rec_len,
                        skip_deleted_blocks ? READING_NEXT : 0))
       goto err;
@@ -1645,7 +1646,7 @@ static int _ma_read_rnd_mempack_record(M
 #ifndef DBUG_OFF
   if (block_info.rec_len > info->s->max_pack_length)
   {
-    my_errno=HA_ERR_WRONG_IN_RECORD;
+    _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
     goto err;
   }
 #endif

=== modified file 'storage/maria/ma_statrec.c'
--- a/storage/maria/ma_statrec.c	2009-01-09 04:23:25 +0000
+++ b/storage/maria/ma_statrec.c	2011-01-26 13:29:36 +0000
@@ -297,6 +297,6 @@ int _ma_read_rnd_static_record(MARIA_HA
   }
   /* my_errno should be set if rec_cache.error == -1 */
   if (info->rec_cache.error != -1 || my_errno == 0)
-    my_errno=HA_ERR_WRONG_IN_RECORD;
+    _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
   DBUG_RETURN(my_errno);                        /* Something wrong (EOF?) */
 }

=== modified file 'storage/maria/maria_def.h'
--- a/storage/maria/maria_def.h	2011-01-24 13:19:40 +0000
+++ b/storage/maria/maria_def.h	2011-01-26 13:29:36 +0000
@@ -1018,7 +1018,7 @@ extern MARIA_KEY *_ma_pack_key(MARIA_HA
                                HA_KEYSEG ** last_used_keyseg);
 extern void _ma_copy_key(MARIA_KEY *to, const MARIA_KEY *from);
 extern int _ma_read_key_record(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS);
-extern my_bool _ma_read_cache(IO_CACHE *info, uchar *buff,
+extern my_bool _ma_read_cache(MARIA_HA *, IO_CACHE *info, uchar *buff,
                               MARIA_RECORD_POS pos, size_t length,
                               uint re_read_if_possibly);
 extern ulonglong ma_retrieve_auto_increment(const uchar *key, uint8 key_type);
@@ -1100,7 +1100,7 @@ typedef struct st_maria_block_info
 #define fast_ma_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _ma_writeinfo((INFO),0)
 #define fast_ma_readinfo(INFO) ((INFO)->lock_type == F_UNLCK) && _ma_readinfo((INFO),F_RDLCK,1)
 
-extern uint _ma_get_block_info(MARIA_BLOCK_INFO *, File, my_off_t);
+extern uint _ma_get_block_info(MARIA_HA *, MARIA_BLOCK_INFO *, File, my_off_t);
 extern uint _ma_rec_pack(MARIA_HA *info, uchar *to, const uchar *from);
 extern uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
                                     MARIA_BLOCK_INFO *info, uchar **rec_buff_p,



More information about the commits mailing list