mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Ensure that share->tot_locks s updated correctly
This fixes that mysamchk --sort-records works on windows.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
@ -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) ||
|
||||
|
@ -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))
|
||||
|
@ -729,6 +729,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
|
||||
}
|
||||
share=info->s;
|
||||
share->options&= ~HA_OPTION_READ_ONLY_DATA; /* We are modifing it */
|
||||
share->tot_locks-= share->r_locks;
|
||||
share->r_locks=0;
|
||||
raid_chunks=share->base.raid_chunks;
|
||||
|
||||
@ -806,6 +807,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
|
||||
rep_quick|=T_QUICK;
|
||||
}
|
||||
share=info->s;
|
||||
share->tot_locks-= share->r_locks;
|
||||
share->r_locks=0;
|
||||
}
|
||||
|
||||
@ -835,6 +837,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
|
||||
goto end2;
|
||||
}
|
||||
share->w_locks++; /* Mark for writeinfo */
|
||||
share->tot_locks++;
|
||||
info->lock_type= F_EXTRA_LCK; /* Simulate as locked */
|
||||
info->tmp_lock_type=lock_type;
|
||||
datafile=info->dfile;
|
||||
@ -1011,6 +1014,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
|
||||
info->update&= ~HA_STATE_CHANGED;
|
||||
}
|
||||
share->w_locks--;
|
||||
share->tot_locks--;
|
||||
end2:
|
||||
if (mi_close(info))
|
||||
{
|
||||
|
Reference in New Issue
Block a user