Below is the list of changes that have just been committed into a local
4.1 repository of andrey. When andrey 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-11-16 12:10:55+01:00, andrey@stripped +3 -0
Fix for bug#24219 ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash
There was an improper order of doing chained operations.
To the documentor: ENABLE|DISABLE KEYS combined with RENAME TO, and no other
ALTER TABLE clause, leads to server crash independent of the presence of
indices and data in the table.
mysql-test/r/alter_table.result@stripped, 2006-11-16 12:10:50+01:00, andrey@stripped +12 -0
update result
mysql-test/t/alter_table.test@stripped, 2006-11-16 12:10:50+01:00, andrey@stripped +19 -0
add test for bug#24129
sql/sql_table.cc@stripped, 2006-11-16 12:10:50+01:00, andrey@stripped +30 -23
If there is operation on the KEYS, first do it
and then do a rename if there is such. Or, we will crash because
the underlying table has changed.
# 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: andrey
# Host: example.com
# Root: /work/bug24219/my41
--- 1.309/sql/sql_table.cc 2006-11-16 12:11:06 +01:00
+++ 1.310/sql/sql_table.cc 2006-11-16 12:11:06 +01:00
@@ -2949,8 +2949,35 @@ int mysql_alter_table(THD *thd,char *new
thd->proc_info="setup";
if (alter_info->is_simple && !table->tmp_table)
{
- error=0;
- if (new_name != table_name || new_db != db)
+ switch (alter_info->keys_onoff) {
+ case LEAVE_AS_IS:
+ error= 0;
+ break;
+ case ENABLE:
+ VOID(pthread_mutex_lock(&LOCK_open));
+ wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
+ VOID(pthread_mutex_unlock(&LOCK_open));
+ error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
+ /* COND_refresh will be signaled in close_thread_tables() */
+ break;
+ case DISABLE:
+ VOID(pthread_mutex_lock(&LOCK_open));
+ wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
+ VOID(pthread_mutex_unlock(&LOCK_open));
+ error= table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
+ /* COND_refresh will be signaled in close_thread_tables() */
+ break;
+ }
+
+ if (error == HA_ERR_WRONG_COMMAND)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
+ table->table_name);
+ error= 0;
+ }
+
+ if (!error && (new_name != table_name || new_db != db))
{
thd->proc_info="rename";
VOID(pthread_mutex_lock(&LOCK_open));
@@ -2971,27 +2998,6 @@ int mysql_alter_table(THD *thd,char *new
VOID(pthread_mutex_unlock(&LOCK_open));
}
- if (!error)
- {
- switch (alter_info->keys_onoff) {
- case LEAVE_AS_IS:
- break;
- case ENABLE:
- VOID(pthread_mutex_lock(&LOCK_open));
- wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
- VOID(pthread_mutex_unlock(&LOCK_open));
- error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
- /* COND_refresh will be signaled in close_thread_tables() */
- break;
- case DISABLE:
- VOID(pthread_mutex_lock(&LOCK_open));
- wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
- VOID(pthread_mutex_unlock(&LOCK_open));
- error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
- /* COND_refresh will be signaled in close_thread_tables() */
- break;
- }
- }
if (error == HA_ERR_WRONG_COMMAND)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
@@ -2999,6 +3005,7 @@ int mysql_alter_table(THD *thd,char *new
table->table_name);
error=0;
}
+
if (!error)
{
mysql_update_log.write(thd, thd->query, thd->query_length);
--- 1.49/mysql-test/r/alter_table.result 2006-11-16 12:11:06 +01:00
+++ 1.50/mysql-test/r/alter_table.result 2006-11-16 12:11:06 +01:00
@@ -543,3 +543,15 @@ ERROR 3D000: No database selected
alter table test.t1 rename test.t1;
use test;
drop table t1;
+DROP TABLE IF EXISTS bug24219;
+DROP TABLE IF EXISTS bug24219_2;
+CREATE TABLE bug24219 (a INT, INDEX(a));
+INSERT INTO bug24219 VALUES (1), (1), (2), (3), (5), (8), (13);
+EXPLAIN SELECT a FROM bug24219 WHERE a BETWEEN 2 AND 6;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE bug24219 range a a 5 NULL 2 Using where; Using index
+ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
+EXPLAIN SELECT a FROM bug24219_2 WHERE a BETWEEN 2 AND 6;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE bug24219_2 ALL NULL NULL NULL NULL 7 Using where
+DROP TABLE bug24219_2;
--- 1.39/mysql-test/t/alter_table.test 2006-11-16 12:11:06 +01:00
+++ 1.40/mysql-test/t/alter_table.test 2006-11-16 12:11:06 +01:00
@@ -392,4 +392,23 @@ alter table test.t1 rename test.t1;
use test;
drop table t1;
+#
+# Bug#24219 - ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash
+#
+--disable_warnings
+DROP TABLE IF EXISTS bug24219;
+DROP TABLE IF EXISTS bug24219_2;
+--enable_warnings
+
+CREATE TABLE bug24219 (a INT, INDEX(a));
+INSERT INTO bug24219 VALUES (1), (1), (2), (3), (5), (8), (13);
+
+EXPLAIN SELECT a FROM bug24219 WHERE a BETWEEN 2 AND 6;
+
+ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
+
+EXPLAIN SELECT a FROM bug24219_2 WHERE a BETWEEN 2 AND 6;
+
+DROP TABLE bug24219_2;
+
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (andrey:1.2611) BUG#24219 | ahristov | 16 Nov |