diff options
author | unknown <monty@hundin.mysql.fi> | 2002-06-17 12:34:19 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-06-17 12:34:19 +0300 |
commit | c99fd2caef34cab1677f44cb5c2337d7f6a5c8db (patch) | |
tree | 7fb8a56e8b7982117d32b33392e0f6e1bc56a477 | |
parent | c47044f0aeede93e17a73cdc221ca6e38cd3f125 (diff) | |
download | mariadb-git-c99fd2caef34cab1677f44cb5c2337d7f6a5c8db.tar.gz |
Ensure that share->tot_locks s updated correctly
This fixes that mysamchk --sort-records works on windows.
myisam/mi_check.c:
Ensure that share->tot_locks s updated correctly
myisam/mi_close.c:
Ensure that share->tot_locks s updated correctly
myisam/mi_dynrec.c:
Ensure that share->tot_locks s updated correctly
myisam/mi_open.c:
Ensure that share->tot_locks s updated correctly
myisam/mi_statrec.c:
Ensure that share->tot_locks s updated correctly
myisam/myisamchk.c:
Ensure that share->tot_locks s updated correctly
-rw-r--r-- | myisam/mi_check.c | 9 | ||||
-rw-r--r-- | myisam/mi_close.c | 6 | ||||
-rw-r--r-- | myisam/mi_dynrec.c | 2 | ||||
-rw-r--r-- | myisam/mi_open.c | 2 | ||||
-rw-r--r-- | myisam/mi_statrec.c | 2 | ||||
-rw-r--r-- | myisam/myisamchk.c | 4 |
6 files changed, 18 insertions, 7 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 71e22c1f56c..bae47061a04 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -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; } diff --git a/myisam/mi_close.c b/myisam/mi_close.c index bd8b9aff727..7197d0ba069 100644 --- a/myisam/mi_close.c +++ b/myisam/mi_close.c @@ -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)) diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index b5f5ca7fd33..12262cf07d6 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -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)) diff --git a/myisam/mi_open.c b/myisam/mi_open.c index bcf8369b439..e36a52db92b 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -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) || diff --git a/myisam/mi_statrec.c b/myisam/mi_statrec.c index ad00b6d2595..9afebce2ae6 100644 --- a/myisam/mi_statrec.c +++ b/myisam/mi_statrec.c @@ -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)) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index f2b5525f22a..c776c80e3ec 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -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)) { |