Commit e1418b14 authored by Ingo Struewing's avatar Ingo Struewing

Bug#46339 - crash on REPAIR TABLE merge table USE_FRM

REPAIR TABLE ... USE_FRM crashed debug servers.

A wrong assert assumed that this operation would not be executed
for MERGE tables.

Removed the assert.


mysql-test/r/merge.result:
  Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
  Added test result.
mysql-test/t/merge.test:
  Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
  Added test.
sql/sql_table.cc:
  Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
  Removed false assert.
parent 454c003a
...@@ -2298,4 +2298,45 @@ t2 WHERE b SOUNDS LIKE e AND d = 1; ...@@ -2298,4 +2298,45 @@ t2 WHERE b SOUNDS LIKE e AND d = 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t2, t1; DROP TABLE t2, t1;
#
# Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
#
DROP TABLE IF EXISTS m1, t1;
CREATE TABLE t1 (c1 INT) ENGINE=MYISAM;
CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST;
LOCK TABLE m1 READ;
REPAIR TABLE m1 USE_FRM;
Table Op Msg_type Msg_text
test.m1 repair note The storage engine for the table doesn't support repair
UNLOCK TABLES;
REPAIR TABLE m1 USE_FRM;
Table Op Msg_type Msg_text
test.m1 repair note The storage engine for the table doesn't support repair
DROP TABLE m1,t1;
CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
REPAIR TABLE m1 USE_FRM;
Table Op Msg_type Msg_text
test.m1 repair Error Can't open table
test.m1 repair error Corrupt
CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM;
REPAIR TABLE m1 USE_FRM;
Table Op Msg_type Msg_text
test.m1 repair note The storage engine for the table doesn't support repair
REPAIR TABLE m1;
Table Op Msg_type Msg_text
test.m1 repair note The storage engine for the table doesn't support repair
DROP TABLE m1, t1;
CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
REPAIR TABLE m1 USE_FRM;
Table Op Msg_type Msg_text
test.m1 repair Error Table 'test.m1' doesn't exist
test.m1 repair error Corrupt
CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM;
REPAIR TABLE m1 USE_FRM;
Table Op Msg_type Msg_text
m1 repair error Cannot repair temporary table from .frm file
REPAIR TABLE m1;
Table Op Msg_type Msg_text
test.m1 repair note The storage engine for the table doesn't support repair
DROP TABLE m1, t1;
End of 5.1 tests End of 5.1 tests
...@@ -1705,4 +1705,82 @@ t2 WHERE b SOUNDS LIKE e AND d = 1; ...@@ -1705,4 +1705,82 @@ t2 WHERE b SOUNDS LIKE e AND d = 1;
DROP TABLE t2, t1; DROP TABLE t2, t1;
--echo #
--echo # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
--echo #
--disable_warnings
DROP TABLE IF EXISTS m1, t1;
--enable_warnings
#
# Test derived from a proposal of Shane Bester.
#
CREATE TABLE t1 (c1 INT) ENGINE=MYISAM;
CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST;
#
# REPAIR ... USE_FRM with LOCK TABLES.
#
LOCK TABLE m1 READ;
REPAIR TABLE m1 USE_FRM;
UNLOCK TABLES;
#
# REPAIR ... USE_FRM without LOCK TABLES.
#
# This statement crashed the server (Bug#46339).
#
REPAIR TABLE m1 USE_FRM;
#
DROP TABLE m1,t1;
#
# Test derived from a proposal of Matthias Leich.
#
# Base table is missing.
#
CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
#
# This statement crashed the server (Bug#46339).
#
REPAIR TABLE m1 USE_FRM;
#
# Create base table.
#
CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM;
#
# This statement crashed the server (Bug#46339).
#
REPAIR TABLE m1 USE_FRM;
#
# Normal repair as reference.
#
REPAIR TABLE m1;
#
# Cleanup.
#
DROP TABLE m1, t1;
#
# Same with temporary tables.
#
# Base table is missing.
#
CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
#
# This statement crashed the server (Bug#46339).
#
REPAIR TABLE m1 USE_FRM;
#
# Create base table.
#
CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM;
#
# This statement crashed the server (Bug#46339).
#
REPAIR TABLE m1 USE_FRM;
#
# Normal repair as reference.
#
REPAIR TABLE m1;
#
# Cleanup.
#
DROP TABLE m1, t1;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -4384,9 +4384,6 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, ...@@ -4384,9 +4384,6 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
} }
/* A MERGE table must not come here. */
DBUG_ASSERT(!table->child_l);
/* /*
REPAIR TABLE ... USE_FRM for temporary tables makes little sense. REPAIR TABLE ... USE_FRM for temporary tables makes little sense.
*/ */
......
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