summaryrefslogtreecommitdiff
path: root/storage/innobase/handler/handler0alter.cc
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2014-12-05 12:33:02 -0500
committerNirbhay Choubey <nirbhay@mariadb.com>2014-12-05 12:33:02 -0500
commit3bb02f3e6d70687b02c6902fd6478e8c328608f8 (patch)
tree7962068cae78450246a484cf95cbe5cf2e37382a /storage/innobase/handler/handler0alter.cc
parenta4cdd20d49a5a6ca0eb7346b7b9e898ac5e7995b (diff)
parentffc0ef63164e9a121d8a02323afe32a82299171e (diff)
downloadmariadb-git-3bb02f3e6d70687b02c6902fd6478e8c328608f8.tar.gz
bzr merge -rtag:mariadb-10.0.15 maria/10.0
Diffstat (limited to 'storage/innobase/handler/handler0alter.cc')
-rw-r--r--storage/innobase/handler/handler0alter.cc55
1 files changed, 40 insertions, 15 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 6062e25233f..728c3bb2cf5 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -21,6 +21,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
Smart ALTER TABLE
*******************************************************/
+#include <my_global.h>
#include <unireg.h>
#include <mysqld_error.h>
#include <log.h>
@@ -2240,7 +2241,7 @@ innobase_check_foreigns_low(
/* Check if any FOREIGN KEY constraints are defined on this
column. */
- for (dict_foreign_set::iterator it = user_table->foreign_set.begin();
+ for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin();
it != user_table->foreign_set.end();
++it) {
@@ -2277,7 +2278,7 @@ innobase_check_foreigns_low(
/* Check if any FOREIGN KEY constraints in other tables are
referring to the column that is being dropped. */
- for (dict_foreign_set::iterator it
+ for (dict_foreign_set::const_iterator it
= user_table->referenced_set.begin();
it != user_table->referenced_set.end();
++it) {
@@ -2463,7 +2464,7 @@ innobase_build_col_map(
innobase_build_col_map_add(
heap, dtuple_get_nth_field(add_cols, i),
- altered_table->s->field[sql_idx],
+ altered_table->field[sql_idx],
dict_table_is_comp(new_table));
found_col:
i++;
@@ -3247,9 +3248,6 @@ err_exit:
delete ctx;
ha_alter_info->handler_ctx = NULL;
- /* There might be work for utility threads.*/
- srv_active_wake_master_thread();
-
DBUG_RETURN(true);
}
@@ -4275,7 +4273,6 @@ func_exit:
}
trx_commit_for_mysql(prebuilt->trx);
- srv_active_wake_master_thread();
MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE);
DBUG_RETURN(fail);
}
@@ -4449,7 +4446,7 @@ err_exit:
rename_foreign:
trx->op_info = "renaming column in SYS_FOREIGN_COLS";
- for (dict_foreign_set::iterator it = user_table->foreign_set.begin();
+ for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin();
it != user_table->foreign_set.end();
++it) {
@@ -4484,7 +4481,7 @@ rename_foreign:
}
}
- for (dict_foreign_set::iterator it
+ for (dict_foreign_set::const_iterator it
= user_table->referenced_set.begin();
it != user_table->referenced_set.end();
++it) {
@@ -4788,14 +4785,17 @@ innobase_update_foreign_try(
/** Update the foreign key constraint definitions in the data dictionary cache
after the changes to data dictionary tables were committed.
@param ctx In-place ALTER TABLE context
+@param user_thd MySQL connection
@return InnoDB error code (should always be DB_SUCCESS) */
static __attribute__((nonnull, warn_unused_result))
dberr_t
innobase_update_foreign_cache(
/*==========================*/
- ha_innobase_inplace_ctx* ctx)
+ ha_innobase_inplace_ctx* ctx,
+ THD* user_thd)
{
dict_table_t* user_table;
+ dberr_t err = DB_SUCCESS;
DBUG_ENTER("innobase_update_foreign_cache");
@@ -4830,9 +4830,34 @@ innobase_update_foreign_cache(
/* Load the old or added foreign keys from the data dictionary
and prevent the table from being evicted from the data
dictionary cache (work around the lack of WL#6049). */
- DBUG_RETURN(dict_load_foreigns(user_table->name,
- ctx->col_names, false, true,
- DICT_ERR_IGNORE_NONE));
+ err = dict_load_foreigns(user_table->name,
+ ctx->col_names, false, true,
+ DICT_ERR_IGNORE_NONE);
+
+ if (err == DB_CANNOT_ADD_CONSTRAINT) {
+ /* It is possible there are existing foreign key are
+ loaded with "foreign_key checks" off,
+ so let's retry the loading with charset_check is off */
+ err = dict_load_foreigns(user_table->name,
+ ctx->col_names, false, false,
+ DICT_ERR_IGNORE_NONE);
+
+ /* The load with "charset_check" off is successful, warn
+ the user that the foreign key has loaded with mis-matched
+ charset */
+ if (err == DB_SUCCESS) {
+ push_warning_printf(
+ user_thd,
+ Sql_condition::WARN_LEVEL_WARN,
+ ER_ALTER_INFO,
+ "Foreign key constraints for table '%s'"
+ " are loaded with charset check off",
+ user_table->name);
+
+ }
+ }
+
+ DBUG_RETURN(err);
}
/** Commit the changes made during prepare_inplace_alter_table()
@@ -5708,12 +5733,12 @@ ha_innobase::commit_inplace_alter_table(
/* Rename the tablespace files. */
commit_cache_rebuild(ctx);
- error = innobase_update_foreign_cache(ctx);
+ error = innobase_update_foreign_cache(ctx, user_thd);
if (error != DB_SUCCESS) {
goto foreign_fail;
}
} else {
- error = innobase_update_foreign_cache(ctx);
+ error = innobase_update_foreign_cache(ctx, user_thd);
if (error != DB_SUCCESS) {
foreign_fail: