Below is the list of changes that have just been committed into a local
5.0 repository of Kristofer Pettersson. When Kristofer Pettersson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-09-14 20:37:01+02:00, Kristofer.Pettersson@naruto. +3 -0
Bug#20789 Merge Subtable Rename Causes Crash
- When an rename is performed on windows, the files are closed and
their cached file descriptors are marked invalid. Performing
INSERT, UPDATE or SELECT on the associated merge table causes
a server crash on windows. This patch adds a test for bad file
descriptors when a merge table attempts a lock. If a bad descriptor
if found an error is thrown. An additional FLUSH TABLES will be
necessary to further operate on the associated merge table.
- REVISITED: This patch caused multi_update to fail. The check has
been moved to myrg_lock_database instead.
myisammrg/myrg_locking.c@stripped, 2006-09-14 20:36:57+02:00, Kristofer.Pettersson@naruto. +15 -1
Added check for bad file descriptors in the list of underlying tables.
Throws error if file descriptor is closed.
mysql-test/r/windows.result@stripped, 2006-09-14 20:36:57+02:00, Kristofer.Pettersson@naruto. +28 -0
Added test case for the windows built.
mysql-test/t/windows.test@stripped, 2006-09-14 20:36:58+02:00, Kristofer.Pettersson@naruto. +39 -0
Added test case for the windows built.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: Kristofer.Pettersson
# Host: naruto.
# Root: C:/cpp/bug20789/my50-bug20789
--- 1.7/myisammrg/myrg_locking.c 2006-09-14 20:37:21 +02:00
+++ 1.8/myisammrg/myrg_locking.c 2006-09-14 20:37:21 +02:00
@@ -24,7 +24,21 @@
{
int error,new_error;
MYRG_TABLE *file;
-
+#ifdef __WIN__
+ /*
+ Check if any of the cached files have a bad file descriptor.
+ This means that the files was closed and cannot be locked.
+ */
+ for (file=info->open_tables ; file != info->end_table ; file++)
+ {
+ if ( ((file->table)->s)->kfile < 0 )
+ {
+ DBUG_PRINT("warning",("File descriptor is invalid (%d)",((file->table)->s)->kfile));
+ error=HA_ERR_NO_SUCH_TABLE;
+ return(error);
+ }
+ }
+#endif
error=0;
for (file=info->open_tables ; file != info->end_table ; file++)
if ((new_error=mi_lock_database(file->table,lock_type)))
--- 1.3/mysql-test/r/windows.result 2006-09-14 20:37:21 +02:00
+++ 1.4/mysql-test/r/windows.result 2006-09-14 20:37:21 +02:00
@@ -6,3 +6,31 @@
ERROR 42000: Unknown database 'prn'
create table nu (a int);
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
--- 1.3/mysql-test/t/windows.test 2006-09-14 20:37:21 +02:00
+++ 1.4/mysql-test/t/windows.test 2006-09-14 20:37:21 +02:00
@@ -18,3 +18,42 @@
drop table nu;
# 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;
+
| Thread |
|---|
| • bk commit into 5.0 tree (Kristofer.Pettersson:1.2250) BUG#20789 | kpettersson | 14 Sep |