Below is the list of changes that have just been committed into a local
5.0 repository of antony. When antony 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
1.2120 06/05/04 09:04:13 acurtis@stripped +8 -0
bug#10952
"alter table from MyISAM to MERGE lost data without errors and warnings"
Add new handlerton flag which prevent user from altering table storage
engine to storage engines which would lose data. Both 'blackhole' and
'merge' are marked with the new flag.
Tests included.
sql/sql_table.cc
1.306 06/05/04 09:04:09 acurtis@stripped +7 -0
Bug#10952
if alter is changing engine, check if new engine supports altering to it.
sql/handler.h
1.170 06/05/04 09:04:09 acurtis@stripped +1 -0
Bug#10952
new handlerton flag
sql/ha_myisammrg.cc
1.77 06/05/04 09:04:09 acurtis@stripped +1 -1
Bug#10952
shouldn't be able to alter a table into a merge
sql/ha_blackhole.cc
1.22 06/05/04 09:04:09 acurtis@stripped +1 -1
Bug#10952
shouldn't be able to alter a table into a blackhole
mysql-test/t/merge.test
1.40 06/05/04 09:04:09 acurtis@stripped +12 -0
test for bug#10952
mysql-test/t/blackhole.test
1.7 06/05/04 09:04:09 acurtis@stripped +12 -0
test for bug#10952
mysql-test/r/merge.result
1.47 06/05/04 09:04:09 acurtis@stripped +8 -0
test for bug#10952
mysql-test/r/blackhole.result
1.7 06/05/04 09:04:09 acurtis@stripped +8 -0
test for bug#10952
# 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: acurtis
# Host: localhost.(none)
# Root: /home/antony/work2/p1-bug10952.1
--- 1.76/sql/ha_myisammrg.cc 2006-02-11 10:51:37 -08:00
+++ 1.77/sql/ha_myisammrg.cc 2006-05-04 09:04:09 -07:00
@@ -55,7 +55,7 @@ handlerton myisammrg_hton= {
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
- HTON_CAN_RECREATE
+ HTON_CAN_RECREATE | HTON_ALTER_SAME_HTON_ONLY
};
--- 1.169/sql/handler.h 2006-04-13 00:25:52 -07:00
+++ 1.170/sql/handler.h 2006-05-04 09:04:09 -07:00
@@ -408,6 +408,7 @@ struct show_table_alias_st {
#define HTON_ALTER_NOT_SUPPORTED (1 << 1) //Engine does not support alter
#define HTON_CAN_RECREATE (1 << 2) //Delete all is used fro truncate
#define HTON_HIDDEN (1 << 3) //Engine does not appear in lists
+#define HTON_ALTER_SAME_HTON_ONLY (1 << 4) //Cannot alter table to engine
typedef struct st_thd_trans
{
--- 1.305/sql/sql_table.cc 2006-05-03 11:01:40 -07:00
+++ 1.306/sql/sql_table.cc 2006-05-04 09:04:09 -07:00
@@ -3319,6 +3319,13 @@ bool mysql_alter_table(THD *thd,char *ne
my_error(ER_ILLEGAL_HA, MYF(0), table_name);
DBUG_RETURN(TRUE);
}
+ if (old_db_type != new_db_type &&
+ ha_check_storage_engine_flag(new_db_type, HTON_ALTER_SAME_HTON_ONLY))
+ {
+ DBUG_PRINT("info", ("doesn't support alter"));
+ my_error(ER_ILLEGAL_HA, MYF(0), table_name);
+ DBUG_RETURN(TRUE);
+ }
thd->proc_info="setup";
if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) &&
--- 1.6/mysql-test/r/blackhole.result 2006-01-23 23:30:46 -08:00
+++ 1.7/mysql-test/r/blackhole.result 2006-05-04 09:04:09 -07:00
@@ -123,3 +123,11 @@ master-bin.000001 # Query 1 # use `test`
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t3
master-bin.000001 # Query 1 # use `test`; replace into t1 select * from t3
drop table t1,t2,t3;
+drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 't1'
+create table t1 (c char(20)) engine=MyISAM;
+insert into t1 values ("Monty"),("WAX"),("Walrus");
+alter table t1 engine=blackhole;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+drop table t1;
--- 1.6/mysql-test/t/blackhole.test 2006-02-24 08:34:08 -08:00
+++ 1.7/mysql-test/t/blackhole.test 2006-05-04 09:04:09 -07:00
@@ -128,3 +128,15 @@ show binlog events;
drop table t1,t2,t3;
# End of 4.1 tests
+
+#
+# BUG#10952 - alter table ... lost data without errors and warnings
+#
+drop table if exists t1;
+create table t1 (c char(20)) engine=MyISAM;
+insert into t1 values ("Monty"),("WAX"),("Walrus");
+--error 1031
+alter table t1 engine=blackhole;
+drop table t1;
+
+# End of 5.0 tests
--- 1.21/sql/ha_blackhole.cc 2005-10-02 20:03:41 -07:00
+++ 1.22/sql/ha_blackhole.cc 2006-05-04 09:04:09 -07:00
@@ -47,7 +47,7 @@ handlerton blackhole_hton= {
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
- HTON_CAN_RECREATE
+ HTON_CAN_RECREATE | HTON_ALTER_SAME_HTON_ONLY
};
/*****************************************************************************
--- 1.46/mysql-test/r/merge.result 2006-02-11 10:51:37 -08:00
+++ 1.47/mysql-test/r/merge.result 2006-05-04 09:04:09 -07:00
@@ -768,3 +768,11 @@ Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
drop table t1, t2, t3;
+drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 't1'
+create table t1 (c char(20)) engine=MyISAM;
+insert into t1 values ("Monty"),("WAX"),("Walrus");
+alter table t1 engine=MERGE;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+drop table t1;
--- 1.39/mysql-test/t/merge.test 2005-12-26 01:32:49 -08:00
+++ 1.40/mysql-test/t/merge.test 2006-05-04 09:04:09 -07:00
@@ -379,3 +379,15 @@ check table t1, t2;
drop table t1, t2, t3;
# End of 4.1 tests
+
+#
+# BUG#10952 - alter table ... lost data without errors and warnings
+#
+drop table if exists t1;
+create table t1 (c char(20)) engine=MyISAM;
+insert into t1 values ("Monty"),("WAX"),("Walrus");
+--error 1031
+alter table t1 engine=MERGE;
+drop table t1;
+
+# End of 5.0 tests
| Thread |
|---|
| • bk commit into 5.0 tree (acurtis:1.2120) BUG#10952 | antony | 4 May |