Commit 413b57e1 authored by unknown's avatar unknown

Better fix for myisamchk --sort-index on windows

Fixed deadlock bug when doing resize of key buffer while key buffer was in active use


myisam/mi_locking.c:
  Better fix for myisamchk --sort-index on windows
mysql-test/r/symlink.result:
  Update results
mysql-test/t/symlink.test:
  Update results
mysys/mf_keycache.c:
  Fixed deadlock bug when doing resize of key buffer while key buffer was in active use
sql/ha_myisam.cc:
  simple optimization
sql/sql_show.cc:
  Fixed theoretical buffer overrun
  Reset variable properly before calling update_create_info()
parent e8007ae7
......@@ -57,10 +57,8 @@ int mi_lock_database(MI_INFO *info, int lock_type)
DBUG_PRINT("info", ("old lock: %d", info->lock_type));
if (info->lock_type == F_RDLCK)
count= --share->r_locks;
else if (info->lock_type == F_WRLCK)
count= --share->w_locks;
else
count= 1; /* F_EXTRA_LCK */
count= --share->w_locks;
--share->tot_locks;
if (info->lock_type == F_WRLCK && !share->w_locks &&
!share->delay_key_write && flush_key_blocks(share->kfile,FLUSH_KEEP))
......@@ -110,6 +108,8 @@ int mi_lock_database(MI_INFO *info, int lock_type)
if (error)
mi_mark_crashed(info);
}
if (info->lock_type != F_EXTRA_LCK)
{
if (share->r_locks)
{ /* Only read locks left */
flag=1;
......@@ -125,6 +125,7 @@ int mi_lock_database(MI_INFO *info, int lock_type)
error=my_errno;
}
}
}
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
info->lock_type= F_UNLCK;
break;
......
......@@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` (
`b` char(16) NOT NULL default '',
`c` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM
) TYPE=MyISAM DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
alter table t9 rename t8, add column d int not null;
alter table t8 rename t7;
rename table t7 to t9;
......@@ -62,5 +62,5 @@ t9 CREATE TABLE `t9` (
`c` int(11) NOT NULL default '0',
`d` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM
) TYPE=MyISAM DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
drop database mysqltest;
......@@ -46,6 +46,7 @@ check table t9;
optimize table t9;
repair table t9;
alter table t9 add column c int not null;
--replace_result $MYSQL_TEST_DIR TEST_DIR
show create table t9;
# Test renames
......@@ -86,5 +87,6 @@ enable_query_log;
alter table t9 rename mysqltest.t9;
select count(*) from mysqltest.t9;
--replace_result $MYSQL_TEST_DIR TEST_DIR
show create table mysqltest.t9;
drop database mysqltest;
......@@ -705,11 +705,19 @@ int flush_key_blocks(File file, enum flush_type type)
static int flush_all_key_blocks()
{
int error=0;
while (_my_blocks_changed > 0)
if (flush_key_blocks_int(_my_used_first->file, FLUSH_RELEASE))
error=1;
return error;
SEC_LINK **block, **end;
for (block= changed_blocks, end= block+CHANGED_BLOCKS_HASH;
block < end;
block++
)
{
while (*block)
{
if (flush_key_blocks_int((*block)->file, FLUSH_RELEASE))
return 1;
}
}
return 0;
}
......
......@@ -1018,7 +1018,7 @@ THR_LOCK_DATA **ha_myisam::store_lock(THD *thd,
void ha_myisam::update_create_info(HA_CREATE_INFO *create_info)
{
table->file->info(HA_STATUS_AUTO | HA_STATUS_CONST);
ha_myisam::info(HA_STATUS_AUTO | HA_STATUS_CONST);
if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
{
create_info->auto_increment_value=auto_increment_value;
......
......@@ -903,6 +903,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
key_info= table->key_info;
file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME);
bzero((char*) &create_info, sizeof(create_info));
file->update_create_info(&create_info);
primary_key= table->primary_key;
......@@ -1005,10 +1006,12 @@ store_create_info(THD *thd, TABLE *table, String *packet)
}
if (file->raid_type)
{
sprintf(buff," RAID_TYPE=%s RAID_CHUNKS=%d RAID_CHUNKSIZE=%ld",
uint length;
length= my_snprintf(buff,sizeof(buff),
" RAID_TYPE=%s RAID_CHUNKS=%d RAID_CHUNKSIZE=%ld",
my_raid_type(file->raid_type), file->raid_chunks,
file->raid_chunksize/RAID_BLOCK_SIZE);
packet->append(buff);
packet->append(buff, length);
}
append_directory(thd, packet, "DATA", create_info.data_file_name);
append_directory(thd, packet, "INDEX", create_info.index_file_name);
......
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