#At file:///home/svoj/devel/bzr-mysql/mysql-5.1-bugteam-bug48757/ based on revid:luis.soares@stripped
3372 Sergey Vojtovich 2010-02-12
BUG#48757 - missing .ARZ file causes server crash
Server crashes when accessing ARCHIVE table with missing
.ARZ file.
When opening a table, ARCHIVE didn't properly pass through
error code from lower level azopen() to higher level open()
method.
@ mysql-test/r/archive.result
A test case for BUG#48757.
@ mysql-test/t/archive.test
A test case for BUG#48757.
@ storage/archive/ha_archive.cc
Pass through error code from azopen().
modified:
mysql-test/r/archive.result
mysql-test/t/archive.test
storage/archive/ha_archive.cc
=== modified file 'mysql-test/r/archive.result'
--- a/mysql-test/r/archive.result 2009-11-11 08:03:29 +0000
+++ b/mysql-test/r/archive.result 2010-02-12 12:33:03 +0000
@@ -12728,3 +12728,12 @@ Table Op Msg_type Msg_text
test.t1 repair Error Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
test.t1 repair error Corrupt
DROP TABLE t1;
+#
+# BUG#48757 - missing .ARZ file causes server crash
+#
+CREATE TABLE t1(a INT) ENGINE=ARCHIVE;
+FLUSH TABLE t1;
+SELECT * FROM t1;
+ERROR HY000: Can't find file: 't1' (errno: 2)
+DROP TABLE t1;
+ERROR 42S02: Unknown table 't1'
=== modified file 'mysql-test/t/archive.test'
--- a/mysql-test/t/archive.test 2009-11-11 08:03:29 +0000
+++ b/mysql-test/t/archive.test 2010-02-12 12:33:03 +0000
@@ -1644,3 +1644,14 @@ INSERT INTO t1 (col1, col2) VALUES (1, "
REPAIR TABLE t1;
DROP TABLE t1;
remove_file $MYSQLD_DATADIR/test/t1.ARM;
+
+--echo #
+--echo # BUG#48757 - missing .ARZ file causes server crash
+--echo #
+CREATE TABLE t1(a INT) ENGINE=ARCHIVE;
+FLUSH TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.ARZ
+--error ER_FILE_NOT_FOUND
+SELECT * FROM t1;
+--error ER_BAD_TABLE_ERROR
+DROP TABLE t1;
=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc 2010-01-21 00:22:20 +0000
+++ b/storage/archive/ha_archive.cc 2010-02-12 12:33:03 +0000
@@ -355,6 +355,9 @@ ARCHIVE_SHARE *ha_archive::get_share(con
*/
if (!(azopen(&archive_tmp, share->data_file_name, O_RDONLY|O_BINARY)))
{
+ *rc= my_errno ? my_errno : -1;
+ pthread_mutex_unlock(&archive_mutex);
+ my_free(share, MYF(0));
DBUG_RETURN(NULL);
}
stats.auto_increment_value= archive_tmp.auto_increment + 1;
@@ -504,16 +507,18 @@ int ha_archive::open(const char *name, i
For now we have to refuse to open such table to avoid
potential data loss.
*/
- if ((rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR))
- || rc == HA_ERR_TABLE_NEEDS_UPGRADE)
+ switch (rc)
{
- /* purecov: begin inspected */
+ case 0:
+ break;
+ case HA_ERR_CRASHED_ON_USAGE:
+ if (open_options & HA_OPEN_FOR_REPAIR)
+ break;
+ /* fall through */
+ case HA_ERR_TABLE_NEEDS_UPGRADE:
free_share();
- DBUG_RETURN(rc);
- /* purecov: end */
- }
- else if (rc == HA_ERR_OUT_OF_MEM)
- {
+ /* fall through */
+ default:
DBUG_RETURN(rc);
}
Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100212123303-weodgg91urr4fg83.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (svoj:3372) Bug#48757 | Sergey Vojtovich | 12 Feb |