Bug #1498 Unimportant mistake in myisam/mi_open.c
Submitted: 7 Oct 2003 8:31 Modified: 10 Dec 2003 20:23
Reporter: Jim Bruin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:4.0.15a OS:Linux (Linux)
Assigned to: Michael Widenius CPU Architecture:Any

[7 Oct 2003 8:31] Jim Bruin
Description:
Just a slight difference between mi_state_info_write and mi_state_info_read.  If state->state_diff_length is ever non zero, then these functions will break.

uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
{
...
  ptr+=state->state_diff_length;

  for (i=0; i < keys; i++)
  {
    mi_sizestore(ptr,state->key_root[i]);	ptr +=8;
  }
  for (i=0; i < key_blocks; i++)
  {
    mi_sizestore(ptr,state->key_del[i]);	ptr +=8;
  }
...
}

char *mi_state_info_read(char *ptr, MI_STATE_INFO *state)
{
...
  for (i=0; i < keys; i++)
  {
    state->key_root[i]= mi_sizekorr(ptr);	ptr +=8;
  }
  for (i=0; i < key_blocks; i++)
  {
    state->key_del[i] = mi_sizekorr(ptr);	ptr +=8;
  }
  ptr+= state->state_diff_length;
...
}

Its rather unimportant, but figured I would post it anyway.

How to repeat:
Can't think of anything to put here, but it won't let me submit without it.  :)

Suggested fix:
Self explanatory:  Move the "ptr+=state->state_diff_length;" in mi_state_info_read above the for loops.
[11 Oct 2003 9:21] Sergei Golubchik
as far as I see state->state_diff_length is always zero in MySQL.
if it's from pre-MySQL era only Monty can know what is it for.

(and of course, the first word that comes to my mind when I see a dead code in MyISAM is "unireg")
[10 Dec 2003 20:23] Michael Widenius
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Thanks for noticing and reporting this possible problem.

state_diff_length is now always zero but in future MyISAM releases this may not be so. This variable is here to make it easy to later extend the status variable section for some key files and still be able to use the old key files.