summaryrefslogtreecommitdiff
path: root/storage/xtradb/handler/handler0alter.cc
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2015-08-08 14:21:22 -0400
committerNirbhay Choubey <nirbhay@mariadb.com>2015-08-08 14:21:22 -0400
commit91acc8b16fdd8409765f32b5453851366552a709 (patch)
tree18c04064e9fc127c5e477ec08613aae7baaab2ae /storage/xtradb/handler/handler0alter.cc
parent4c69dc8116950d6bf0b09bfbc31a86d89831a364 (diff)
parent0403790722e3941779ccea26e85fcd818e2320b5 (diff)
downloadmariadb-git-91acc8b16fdd8409765f32b5453851366552a709.tar.gz
Merge tag 'mariadb-10.0.21' into 10.0-galera
Diffstat (limited to 'storage/xtradb/handler/handler0alter.cc')
-rw-r--r--storage/xtradb/handler/handler0alter.cc42
1 files changed, 36 insertions, 6 deletions
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 9255ff03bbb..138f717ea27 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -376,6 +376,35 @@ ha_innobase::check_if_supported_inplace_alter(
}
}
+ /* If we have column that has changed from NULL -> NOT NULL
+ and column default has changed we need to do additional
+ check. */
+ if ((ha_alter_info->handler_flags
+ & Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE) &&
+ (ha_alter_info->handler_flags
+ & Alter_inplace_info::ALTER_COLUMN_DEFAULT)) {
+ Alter_info *alter_info = ha_alter_info->alter_info;
+ List_iterator<Create_field> def_it(alter_info->create_list);
+ Create_field *def;
+ while ((def=def_it++)) {
+
+ /* If this is first column definition whose SQL type
+ is TIMESTAMP and it is defined as NOT NULL and
+ it has either constant default or function default
+ we must use "Copy" method. */
+ if (is_timestamp_type(def->sql_type)) {
+ if ((def->flags & NOT_NULL_FLAG) != 0 && // NOT NULL
+ (def->def != NULL || // constant default ?
+ def->unireg_check != Field::NONE)) { // function default
+ ha_alter_info->unsupported_reason = innobase_get_err_msg(
+ ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL);
+ DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
+ }
+ break;
+ }
+ }
+ }
+
/* We should be able to do the operation in-place.
See if we can do it online (LOCK=NONE). */
bool online = true;
@@ -800,7 +829,7 @@ innobase_find_fk_index(
if (!(index->type & DICT_FTS)
&& dict_foreign_qualify_index(
table, col_names, columns, n_cols,
- index, NULL, true, 0)) {
+ index, NULL, true, 0, NULL, NULL, NULL)) {
for (ulint i = 0; i < n_drop_index; i++) {
if (index == drop_index[i]) {
/* Skip to-be-dropped indexes. */
@@ -990,7 +1019,7 @@ innobase_get_foreign_key_info(
referenced_table, 0,
referenced_column_names,
i, index,
- TRUE, FALSE);
+ TRUE, FALSE, NULL, NULL, NULL);
DBUG_EXECUTE_IF(
"innodb_test_no_reference_idx",
@@ -3305,7 +3334,7 @@ innobase_check_foreign_key_index(
foreign->referenced_col_names,
foreign->n_fields, index,
/*check_charsets=*/TRUE,
- /*check_null=*/FALSE)
+ /*check_null=*/FALSE, NULL, NULL, NULL)
&& !innobase_find_equiv_index(
foreign->referenced_col_names,
foreign->n_fields,
@@ -3333,7 +3362,7 @@ innobase_check_foreign_key_index(
foreign->foreign_col_names,
foreign->n_fields, index,
/*check_charsets=*/TRUE,
- /*check_null=*/FALSE)
+ /*check_null=*/FALSE, NULL,NULL, NULL)
&& !innobase_find_equiv_index(
foreign->foreign_col_names,
foreign->n_fields,
@@ -4781,7 +4810,8 @@ innobase_update_foreign_try(
fk->n_fields, fk->referenced_index, TRUE,
fk->type
& (DICT_FOREIGN_ON_DELETE_SET_NULL
- | DICT_FOREIGN_ON_UPDATE_SET_NULL));
+ | DICT_FOREIGN_ON_UPDATE_SET_NULL),
+ NULL, NULL, NULL);
if (!fk->foreign_index) {
my_error(ER_FK_INCORRECT_OPTION,
MYF(0), table_name, fk->id);
@@ -4793,7 +4823,7 @@ innobase_update_foreign_try(
names, while the columns in ctx->old_table have not
been renamed yet. */
error = dict_create_add_foreign_to_dictionary(
- ctx->old_table->name, fk, trx);
+ (dict_table_t*)ctx->old_table, ctx->old_table->name, fk, trx);
DBUG_EXECUTE_IF(
"innodb_test_cannot_add_fk_system",