Commit e469cedf authored by unknown's avatar unknown

Merge kpettersson@bk-internal:/home/bk/mysql-5.1-maint

into  naruto.:C:/cpp/mysql-5.1-maint

parents 54886b08 b5b7840b
...@@ -6,31 +6,3 @@ use prn; ...@@ -6,31 +6,3 @@ use prn;
ERROR 42000: Unknown database 'prn' ERROR 42000: Unknown database 'prn'
create table nu (a int); create table nu (a int);
drop table nu; drop table nu;
CREATE TABLE `t1` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `t2` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `mt` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST
UNION=(`t1`,`t2`);
INSERT INTO mt VALUES ('2006-01-01',0);
ALTER TABLE `t2` RENAME TO `t`;
INSERT INTO mt VALUES ('2006-01-01',0);
ERROR HY000: Can't lock file (errno: 155)
select * from mt;
ERROR HY000: Can't lock file (errno: 155)
FLUSH TABLES;
select * from mt;
ERROR HY000: Can't find file: 'mt' (errno: 2)
ALTER TABLE `t` RENAME TO `t2`;
INSERT INTO mt VALUES ('2006-01-01',0);
select * from mt;
TIM VAL
2006-01-01 00:00:00 0
2006-01-01 00:00:00 0
...@@ -18,42 +18,3 @@ create table nu (a int); ...@@ -18,42 +18,3 @@ create table nu (a int);
drop table nu; drop table nu;
# End of 4.1 tests # End of 4.1 tests
#
# Bug #20789: Merge Subtable Rename Causes Crash
#
CREATE TABLE `t1` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `t2` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `mt` (
`TIM` datetime NOT NULL,
`VAL` double default NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST
UNION=(`t1`,`t2`);
# insert into the merge table and thus open it.
INSERT INTO mt VALUES ('2006-01-01',0);
# Alter one of the tables that are part of the merge table
ALTER TABLE `t2` RENAME TO `t`;
# Insert into the merge table that has just been altered
--error 1015
INSERT INTO mt VALUES ('2006-01-01',0);
--error 1015
select * from mt;
FLUSH TABLES;
--error 1017
select * from mt;
# Alter one of the tables that are part of the merge table
ALTER TABLE `t` RENAME TO `t2`;
INSERT INTO mt VALUES ('2006-01-01',0);
select * from mt;
...@@ -236,16 +236,20 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -236,16 +236,20 @@ int mi_lock_database(MI_INFO *info, int lock_type)
default: default:
break; /* Impossible */ break; /* Impossible */
} }
} }
#ifdef __WIN__ #ifdef __WIN__
else else
{ {
/* /*
The file has been closed and kfile is -1. Check for bad file descriptors if this table is part
See mi_extra.c about implementation of of a merge union. Failing to capture this may cause
HA_EXTRA_PREPARE_FOR_DELETE. a crash on windows if the table is renamed and
*/ later on referenced by the merge table.
error=HA_ERR_NO_SUCH_TABLE; */
if( info->owned_by_merge && (info->s)->kfile < 0 )
{
error = HA_ERR_NO_SUCH_TABLE;
}
} }
#endif #endif
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
......
...@@ -291,6 +291,9 @@ struct st_myisam_info { ...@@ -291,6 +291,9 @@ struct st_myisam_info {
my_bool page_changed; /* If info->buff can't be used for rnext */ my_bool page_changed; /* If info->buff can't be used for rnext */
my_bool buff_used; /* If info->buff has to be reread for rnext */ my_bool buff_used; /* If info->buff has to be reread for rnext */
my_bool once_flags; /* For MYISAMMRG */ my_bool once_flags; /* For MYISAMMRG */
#ifdef __WIN__
my_bool owned_by_merge; /* This MyISAM table is part of a merge union */
#endif
#ifdef THREAD #ifdef THREAD
THR_LOCK_DATA lock; THR_LOCK_DATA lock;
#endif #endif
......
...@@ -26,8 +26,19 @@ int myrg_lock_database(MYRG_INFO *info, int lock_type) ...@@ -26,8 +26,19 @@ int myrg_lock_database(MYRG_INFO *info, int lock_type)
MYRG_TABLE *file; MYRG_TABLE *file;
error=0; error=0;
for (file=info->open_tables ; file != info->end_table ; file++) for (file=info->open_tables ; file != info->end_table ; file++)
{
#ifdef __WIN__
/*
Make sure this table is marked as owned by a merge table.
The semaphore is never released as long as table remains
in memory. This should be refactored into a more generic
approach (observer pattern)
*/
(file->table)->owned_by_merge = TRUE;
#endif
if ((new_error=mi_lock_database(file->table,lock_type))) if ((new_error=mi_lock_database(file->table,lock_type)))
error=new_error; error=new_error;
}
return(error); return(error);
} }
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