List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:October 19 1999 12:50pm
Subject:RE: Cannot repair tables with incorrect auto-inc value
View as plain text  
>>>>> "web" == web  <web@stripped> writes:

>>>> Description:
web> I have some myisam tables that I had to recover with 
>> stage 3: difficult repair (where the index file is recreated). 
>> When I recreated them, the auto-inc value was set to 0.  Now 
>> I cannot successfully repair them or change the auto-inc value 
>> using myisamchk -A.
>> 
web> For example:
>>>> myisamchk -ddv cT
>> 
web> MyISAM file:         cT
web> Record format:       Packed
web> File-version:        1
web> Creation time:       1999-10-18 15:52:25
web> Recover time:        1999-10-18 15:56:59
web> Status:              checked
web> Auto increment key:              1  Last value:           
>> 0
web> Data records:                    7  Deleted blocks:       
>> 0
web> Datafile parts:                  7  Deleted data:         
>> 0
web> Datafile pointer (bytes):        4  Keyfile pointer 
>> (bytes):        3
web> Datafile length:               208  Keyfile length:       
>> 3072
web> Max datafile length:    4294967294  Max keyfile length:   
>> 17179868159
web> Recordlength:                  140
>> 
web> table description:
web> Key Start Len Index   Type                     Rec/key    
>> Root  Blocksize
web> 1   1     2   unique  unsigned short                 1    
>> 1024       1024
web> 2   77    64  multip. char packed stripped           0    
>> 2048       1024
>> 
>>>> myisamchk -A cT
>> 
web> Updating MyISAM file: cT
web> myisamchk: error: 0 when reading last record
web> MyISAM-table 'cT' is corrupted
web> Fix it using switch "-r" or "-o"
>> 
>> Hi!
>> 
>> Can you mail the table files to me so that I can check this?
>> 
>> Regards,
>> Monty
>> 

web> Sure, they are attached to this email! Thanks.

Thanks for the tables, it helped me to locate the problem quickly!

Here is a patch for this:

*** /my/monty/master/mysql-3.23.5-alpha/myisam/myisamchk.c	Mon Oct 18 01:53:13 1999
--- ./myisamchk.c	Tue Oct 19 15:45:51 1999
***************
*** 313,319 ****
  
  static void print_version(void)
  {
!   printf("%s  Ver 1.6 for %s at %s\n",my_progname,SYSTEM_TYPE,
  	 MACHINE_TYPE);
  }
  
--- 313,319 ----
  
  static void print_version(void)
  {
!   printf("%s  Ver 1.7 for %s at %s\n",my_progname,SYSTEM_TYPE,
  	 MACHINE_TYPE);
  }
  
***************
*** 3911,3921 ****
    }
    if (!(testflag & T_SILENT))
      printf("Updating MyISAM file: %s\n", isam_file_name);
    if (mi_rlast(info,info->rec_buff, info->s->base.auto_key-1))
    {
!     if (errno != HA_ERR_END_OF_FILE)
      {
!       print_error("%d when reading last record",errno);
        return;
      }
      info->s->state.auto_increment=auto_increment_value;
--- 3911,3924 ----
    }
    if (!(testflag & T_SILENT))
      printf("Updating MyISAM file: %s\n", isam_file_name);
+   /* We have to use keyread here as a normal read uses info->rec_buf */
+   mi_extra(info,HA_EXTRA_KEYREAD);
    if (mi_rlast(info,info->rec_buff, info->s->base.auto_key-1))
    {
!     if (my_errno != HA_ERR_END_OF_FILE)
      {
!       mi_extra(info,HA_EXTRA_NO_KEYREAD);
!       print_error("%d when reading last record",my_errno);
        return;
      }
      info->s->state.auto_increment=auto_increment_value;
***************
*** 3926,3931 ****
--- 3929,3935 ----
      update_auto_increment(info,info->rec_buff);
      set_if_bigger(info->s->state.auto_increment,auto_increment_value)
    }
+   mi_extra(info,HA_EXTRA_NO_KEYREAD);
    update_state_info(info, UPDATE_AUTO_INC);
    return;
  }


Regards,
Monty
Thread
Cannot repair tables with incorrect auto-inc valueweb18 Oct
  • Cannot repair tables with incorrect auto-inc valueMichael Widenius19 Oct
RE: Cannot repair tables with incorrect auto-inc valueMichael Widenius19 Oct