3908 Marko Mäkelä 2012-04-23
WL#5545 error handling improvements.
innodb.innodb-alter-debug: Error injection testing for DROP FOREIGN KEY
and renaming columns.
innobase_drop_foreign(), innobase_rename_column(): Take the TABLE_SHARE
as a parameter, so that the user-visible table name can be reported
in an error message.
added:
mysql-test/suite/innodb/r/innodb-alter-debug.result
mysql-test/suite/innodb/t/innodb-alter-debug.test
modified:
storage/innobase/handler/handler0alter.cc
3907 Marko Mäkelä 2012-04-23
WL#5545/WL#5526 code coverage fixes.
row_merge_dict_table_get_index(): Remove. There never can be duplicate
index names. Use plain dict_table_get_index_on_name() instead.
When doing ADD INDEX and DROP INDEX in a single statement, the new index
will carry the TEMP_INDEX_PREFIX and the old one (to be dropped)
will lack it.
Approved by Jimmy Yang.
modified:
mysql-test/suite/innodb/r/innodb-index.result
mysql-test/suite/innodb/t/innodb-index.test
storage/innobase/row/row0merge.cc
=== added file 'mysql-test/suite/innodb/r/innodb-alter-debug.result'
--- a/mysql-test/suite/innodb/r/innodb-alter-debug.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result revid:marko.makela@strippeda4657xes
@@ -0,0 +1,27 @@
+SET NAMES utf8;
+CREATE TABLE ① (
+c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT,
+INDEX(c2))
+ENGINE=InnoDB;
+CREATE TABLE t1ć (c1 INT PRIMARY KEY, c2 INT, INDEX(c2),
+CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES ①(c2))
+ENGINE=InnoDB;
+INSERT INTO ① SET c1=1;
+SET DEBUG = '+d,ib_drop_foreign_error';
+ALTER TABLE t1ć DROP FOREIGN KEY t1c2, RENAME TO ②;
+ERROR HY000: The table 't1ć' is full
+SET DEBUG = '-d,ib_drop_foreign_error';
+SET DEBUG = '+d,ib_rename_column_error';
+ALTER TABLE ① CHANGE c2 š INT;
+ERROR HY000: The table '①' is full
+SET DEBUG = '-d,ib_rename_column_error';
+SHOW CREATE TABLE t1ć;
+Table Create Table
+t1ć CREATE TABLE `t1ć` (
+ `c1` int(11) NOT NULL,
+ `c2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`c1`),
+ KEY `c2` (`c2`),
+ CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `ABLE t1ć, ①;
=== added file 'mysql-test/suite/innodb/t/innodb-alter-debug.test'
--- a/mysql-test/suite/innodb/t/innodb-alter-debug.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test revid:marko.makela@stripped
@@ -0,0 +1,29 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+
+SET NAMES utf8;
+
+CREATE TABLE ① (
+ c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT,
+ INDEX(c2))
+ENGINE=InnoDB;
+
+CREATE TABLE t1ć (c1 INT PRIMARY KEY, c2 INT, INDEX(c2),
+ CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES ①(c2))
+ENGINE=InnoDB;
+
+INSERT INTO ① SET c1=1;
+
+SET DEBUG = '+d,ib_drop_foreign_error';
+--error ER_RECORD_FILE_FULL
+ALTER TABLE t1ć DROP FOREIGN KEY t1c2, RENAME TO ②;
+SET DEBUG = '-d,ib_drop_foreign_error';
+
+SET DEBUG = '+d,ib_rename_column_error';
+--error ER_RECORD_FILE_FULL
+ALTER TABLE ① CHANGE c2 š INT;
+SET DEBUG = '-d,ib_rename_column_error';
+
+SHOW CREATE TABLE t1ć;
+
+DROP TABLE t1ć, ①;
=== modified file 'storage/innobase/handler/handler0alter.cc'
--- a/storage/innobase/handler/handler0alter.cc revid:marko.makela@strippedaprznly3g72
+++ b/storage/innobase/handler/handler0alter.cc revid:marko.makela@stripped4657xes
@@ -1607,8 +1607,7 @@ col_fail:
new_table_name);
goto new_clustered_failed;
default:
- my_error_innodb(
- trx->error_state, table_name, flags);
+ my_error_innodb(trx->error_state, table_name, flags);
new_clustered_failed:
DBUG_ASSERT(trx != user_trx);
trx_rollback_to_savepoint(trx, NULL);
@@ -2447,7 +2446,7 @@ bool
rollback_inplace_alter_table(
/*=========================*/
Alter_inplace_info* ha_alter_info,
- TABLE_SHARE* table_share,
+ const TABLE_SHARE* table_share,
row_prebuilt_t* prebuilt)
{
bool fail = false;
@@ -2499,6 +2498,7 @@ func_exit:
}
/** Drop a FOREIGN KEY constraint.
+@param table_share the TABLE_SHARE
@param trx data dictionary transaction
@param foreign the foreign key constraint, will be freed
@retval true Failure
@@ -2507,8 +2507,9 @@ static __attribute__((nonnull, warn_unus
bool
innobase_drop_foreign(
/*==================*/
- trx_t* trx,
- dict_foreign_t* foreign)
+ const TABLE_SHARE* table_share,
+ trx_t* trx,
+ dict_foreign_t* foreign)
{
DBUG_ENTER("innobase_drop_foreign");
@@ -2537,8 +2538,11 @@ innobase_drop_foreign(
error = que_eval_sql(info, sql, FALSE, trx);
trx->op_info = "";
+ DBUG_EXECUTE_IF("ib_drop_foreign_error",
+ error = DB_OUT_OF_FILE_SPACE;);
+
if (error != DB_SUCCESS) {
- my_error_innodb(error, foreign->foreign_table->name, 0);
+ my_error_innodb(error, table_share->table_name.str, 0);
trx->error_state = DB_SUCCESS;
DBUG_RETURN(true);
}
@@ -2549,6 +2553,7 @@ innobase_drop_foreign(
}
/** Rename a column.
+@param table_share the TABLE_SHARE
@param prebuilt the prebuilt struct
@param trx data dictionary transaction
@param nth_col 0-based index of the column
@@ -2560,11 +2565,12 @@ static __attribute__((nonnull, warn_unus
bool
innobase_rename_column(
/*===================*/
- row_prebuilt_t* prebuilt,
- trx_t* trx,
- ulint nth_col,
- const char* from,
- const char* to)
+ const TABLE_SHARE* table_share,
+ row_prebuilt_t* prebuilt,
+ trx_t* trx,
+ ulint nth_col,
+ const char* from,
+ const char* to)
{
pars_info_t* info;
dberr_t error;
@@ -2605,9 +2611,12 @@ innobase_rename_column(
"END;\n",
FALSE, trx);
+ DBUG_EXECUTE_IF("ib_rename_column_error",
+ error = DB_OUT_OF_FILE_SPACE;);
+
if (error != DB_SUCCESS) {
err_exit:
- my_error_innodb(error, prebuilt->table->name, 0);
+ my_error_innodb(error, table_share->table_name.str, 0);
trx->error_state = DB_SUCCESS;
trx->op_info = "";
DBUG_RETURN(true);
@@ -2909,7 +2918,8 @@ ha_innobase::commit_inplace_alter_table(
DBUG_ASSERT(prebuilt->table
== ctx->drop_fk[i]->foreign_table);
- if (innobase_drop_foreign(trx, ctx->drop_fk[i])) {
+ if (innobase_drop_foreign(
+ table_share, trx, ctx->drop_fk[i])) {
err = -1;
}
}
@@ -2930,6 +2940,7 @@ ha_innobase::commit_inplace_alter_table(
while (Create_field* cf = cf_it++) {
if (cf->field == *fp) {
if (innobase_rename_column(
+ table_share,
prebuilt, trx, i,
cf->field->field_name,
cf->field_name)) {
No bundle (reason: useless for push emails).| Thread |
|---|
| • bzr push into mysql-trunk-wl5545 branch (marko.makela:3907 to 3908) WL#5545 | marko.makela | 23 Apr |