Commit b44b4854 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi
Browse files

Ensure that share->tot_locks s updated correctly

This fixes that mysamchk --sort-records works on windows.
parent 6d69e120
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1551,7 +1551,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name)
  old_state=share->state;			/* save state if not stored */
  r_locks=share->r_locks; w_locks=share->w_locks;
	/* Put same locks as old file */
  share->r_locks=share->w_locks=0;
  share->r_locks= share->w_locks= share->tot_locks= 0;
  (void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
  VOID(my_close(share->kfile,MYF(MY_WME)));
  share->kfile = -1;
@@ -1564,6 +1564,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name)
  _mi_readinfo(info,F_WRLCK,0);			/* Will lock the table */
  info->lock_type=F_WRLCK;
  share->r_locks=r_locks; share->w_locks=w_locks;
  share->tot_locks= r_locks+w_locks;
  share->state=old_state;			/* Restore old state */

  info->state->key_file_length=param->new_file_pos;
@@ -3139,9 +3140,11 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update)
  {						/* Force update of status */
    int error;
    uint r_locks=share->r_locks,w_locks=share->w_locks;
    share->r_locks=share->w_locks=0;
    share->r_locks= share->w_locks= share->tot_locks= 0;
    error=_mi_writeinfo(info,WRITEINFO_NO_UNLOCK);
    share->r_locks=r_locks; share->w_locks=w_locks;
    share->r_locks=r_locks;
    share->w_locks=w_locks;
    share->tot_locks=r_locks+w_locks;
    if (!error)
      return 0;
  }
+4 −2
Original line number Diff line number Diff line
@@ -29,8 +29,7 @@ int mi_close(register MI_INFO *info)
  MYISAM_SHARE *share=info->s;
  DBUG_ENTER("mi_close");
  DBUG_PRINT("enter",("base: %lx  reopen: %u  locks: %u",
		      info,(uint) share->reopen,
		      (uint) (share->w_locks+share->r_locks)));
		      info,(uint) share->reopen, (uint) share->tot_locks));

  pthread_mutex_lock(&THR_LOCK_myisam);
  if (info->lock_type == F_EXTRA_LCK)
@@ -47,7 +46,10 @@ int mi_close(register MI_INFO *info)
  pthread_mutex_lock(&share->intern_lock);

  if (share->options & HA_OPTION_READ_ONLY_DATA)
  {
    share->r_locks--;
    share->tot_locks--;
  }
  if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
  {
    if (end_io_cache(&info->rec_cache))
+1 −1
Original line number Diff line number Diff line
@@ -1275,7 +1275,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf,
  if (info->lock_type == F_UNLCK)
  {
#ifndef UNSAFE_LOCKING
    if (share->r_locks == 0 && share->w_locks == 0)
    if (share->tot_locks == 0)
    {
      if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF,
		  MYF(MY_SEEK_NOT_DONE) | info->lock_wait))
+2 −0
Original line number Diff line number Diff line
@@ -486,6 +486,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
  {
    info.lock_type=F_RDLCK;
    share->r_locks++;
    share->tot_locks++;
  }
  if ((open_flags & HA_OPEN_TMP_TABLE) ||
      (share->options & HA_OPTION_TMP_TABLE))
@@ -493,6 +494,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
    share->temporary=share->delay_key_write=1;
    share->write_flag=MYF(MY_NABP);
    share->w_locks++;			/* We don't have to update status */
    share->tot_locks++;
    info.lock_type=F_WRLCK;
  }
  if (((open_flags & HA_OPEN_DELAY_KEY_WRITE) ||
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ int _mi_read_rnd_static_record(MI_INFO *info, byte *buf,
    {						/* We don't nead new info */
#ifndef UNSAFE_LOCKING
      if ((! cache_read || share->base.reclength > cache_length) &&
	  share->r_locks == 0 && share->w_locks == 0)
	  share->tot_locks == 0)
      {						/* record not in cache */
	if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF,
		    MYF(MY_SEEK_NOT_DONE) | info->lock_wait))
Loading