Commit 5f44dc87 authored by unknown's avatar unknown

Fix for #712 with Serg's suggestions


myisam/mi_locking.c:
  Here we use F_EXTRA_LCK
myisam/myisamchk.c:
  lines of "locking - emulation" replaced with mi_lock_database call
myisam/myisamdef.h:
  no need for MI_TEMPORARY_TABLE
sql/ha_myisam.cc:
  We use F_WRLCK instead MI_TEMPORARY_TABLE
parent d010cf2b
...@@ -39,7 +39,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -39,7 +39,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
if (share->options & HA_OPTION_READ_ONLY_DATA || if (share->options & HA_OPTION_READ_ONLY_DATA ||
info->lock_type == lock_type) info->lock_type == lock_type)
DBUG_RETURN(0); DBUG_RETURN(0);
if (lock_type == MI_TEMPORARY_TABLE) if (lock_type == F_EXTRA_LCK)
{ {
++share->w_locks; ++share->w_locks;
++share->tot_locks; ++share->tot_locks;
......
...@@ -878,10 +878,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -878,10 +878,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
param->error_printed=0; param->error_printed=0;
goto end2; goto end2;
} }
share->w_locks++; /* Mark for writeinfo */ mi_lock_database(info, F_EXTRA_LCK);
share->tot_locks++;
info->lock_type= F_EXTRA_LCK; /* Simulate as locked */
info->tmp_lock_type=lock_type;
datafile=info->dfile; datafile=info->dfile;
if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX)) if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
...@@ -1057,8 +1054,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -1057,8 +1054,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
VOID(lock_file(param, share->kfile,0L,F_UNLCK,"indexfile",filename)); VOID(lock_file(param, share->kfile,0L,F_UNLCK,"indexfile",filename));
info->update&= ~HA_STATE_CHANGED; info->update&= ~HA_STATE_CHANGED;
} }
share->w_locks--; mi_lock_database(info, F_UNLCK);
share->tot_locks--;
end2: end2:
if (mi_close(info)) if (mi_close(info))
{ {
......
...@@ -101,7 +101,6 @@ typedef struct st_mi_state_info ...@@ -101,7 +101,6 @@ typedef struct st_mi_state_info
#define MI_COLUMNDEF_SIZE (2*3+1) #define MI_COLUMNDEF_SIZE (2*3+1)
#define MI_BASE_INFO_SIZE (5*8 + 8*4 + 4 + 4*2 + 16) #define MI_BASE_INFO_SIZE (5*8 + 8*4 + 4 + 4*2 + 16)
#define MI_INDEX_BLOCK_MARGIN 16 /* Safety margin for .MYI tables */ #define MI_INDEX_BLOCK_MARGIN 16 /* Safety margin for .MYI tables */
#define MI_TEMPORARY_TABLE ((1 & ~F_RDLCK) | (2 & ~F_WRLCK) | (4 & ~F_UNLCK))
typedef struct st_mi_base_info typedef struct st_mi_base_info
{ {
......
...@@ -560,7 +560,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize) ...@@ -560,7 +560,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
// Don't lock tables if we have used LOCK TABLE // Don't lock tables if we have used LOCK TABLE
if (!thd->locked_tables && if (!thd->locked_tables &&
mi_lock_database(file, table->tmp_table ? MI_TEMPORARY_TABLE : F_WRLCK)) mi_lock_database(file, table->tmp_table ? F_EXTRA_LCK : F_WRLCK))
{ {
mi_check_print_error(&param,ER(ER_CANT_LOCK),my_errno); mi_check_print_error(&param,ER(ER_CANT_LOCK),my_errno);
DBUG_RETURN(HA_ADMIN_FAILED); DBUG_RETURN(HA_ADMIN_FAILED);
...@@ -1002,7 +1002,7 @@ int ha_myisam::external_lock(THD *thd, int lock_type) ...@@ -1002,7 +1002,7 @@ int ha_myisam::external_lock(THD *thd, int lock_type)
{ {
return mi_lock_database(file, !table->tmp_table ? return mi_lock_database(file, !table->tmp_table ?
lock_type : ((lock_type == F_UNLCK) ? lock_type : ((lock_type == F_UNLCK) ?
F_UNLCK : MI_TEMPORARY_TABLE)); F_UNLCK : F_EXTRA_LCK));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment