diff options
Diffstat (limited to 'storage/innobase/handler/handler0alter.cc')
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 4291d32b206..96a779868fb 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -129,6 +129,7 @@ my_error_innodb( break; case DB_OUT_OF_FILE_SPACE: my_error(ER_RECORD_FILE_FULL, MYF(0), table); + ut_error; break; case DB_TEMP_FILE_WRITE_FAILURE: my_error(ER_GET_ERRMSG, MYF(0), @@ -1457,8 +1458,9 @@ innobase_create_index_field_def( if a new clustered index is not being created */ const KEY_PART_INFO* key_part, /*!< in: MySQL key definition */ - index_field_t* index_field) /*!< out: index field + index_field_t* index_field, /*!< out: index field definition for key_part */ + const Field** fields) /*!< in: MySQL table fields */ { const Field* field; ibool is_unsigned; @@ -1475,6 +1477,7 @@ innobase_create_index_field_def( ut_a(field); index_field->col_no = key_part->fieldnr; + index_field->col_name = altered_table ? field->field_name : fields[key_part->fieldnr]->field_name; col_type = get_innobase_type_from_mysql_type(&is_unsigned, field); @@ -1509,8 +1512,9 @@ innobase_create_index_def( bool key_clustered, /*!< in: true if this is the new clustered index */ index_def_t* index, /*!< out: index definition */ - mem_heap_t* heap) /*!< in: heap where memory + mem_heap_t* heap, /*!< in: heap where memory is allocated */ + const Field** fields) /*!z in: MySQL table fields */ { const KEY* key = &keys[key_number]; ulint i; @@ -1523,6 +1527,7 @@ innobase_create_index_def( index->fields = static_cast<index_field_t*>( mem_heap_alloc(heap, n_fields * sizeof *index->fields)); + memset(index->fields, 0, n_fields * sizeof *index->fields); index->ind_type = 0; index->key_number = key_number; @@ -1560,7 +1565,7 @@ innobase_create_index_def( for (i = 0; i < n_fields; i++) { innobase_create_index_field_def( - altered_table, &key->key_part[i], &index->fields[i]); + altered_table, &key->key_part[i], &index->fields[i], fields); } DBUG_VOID_RETURN; @@ -1891,7 +1896,7 @@ innobase_create_key_defs( /* Create the PRIMARY key index definition */ innobase_create_index_def( altered_table, key_info, primary_key_number, - TRUE, TRUE, indexdef++, heap); + TRUE, TRUE, indexdef++, heap, (const Field **)altered_table->field); created_clustered: n_add = 1; @@ -1903,7 +1908,7 @@ created_clustered: /* Copy the index definitions. */ innobase_create_index_def( altered_table, key_info, i, TRUE, FALSE, - indexdef, heap); + indexdef, heap, (const Field **)altered_table->field); if (indexdef->ind_type & DICT_FTS) { n_fts_add++; @@ -1948,7 +1953,7 @@ created_clustered: for (ulint i = 0; i < n_add; i++) { innobase_create_index_def( altered_table, key_info, add[i], FALSE, FALSE, - indexdef, heap); + indexdef, heap, (const Field **)altered_table->field); if (indexdef->ind_type & DICT_FTS) { n_fts_add++; @@ -1965,6 +1970,7 @@ created_clustered: index->fields = static_cast<index_field_t*>( mem_heap_alloc(heap, sizeof *index->fields)); + memset(index->fields, 0, sizeof *index->fields); index->n_fields = 1; index->fields->col_no = fts_doc_id_col; index->fields->prefix_len = 0; @@ -4463,11 +4469,15 @@ err_exit: rename_foreign: trx->op_info = "renaming column in SYS_FOREIGN_COLS"; + std::list<dict_foreign_t*> fk_evict; + bool foreign_modified; + for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin(); it != user_table->foreign_set.end(); ++it) { dict_foreign_t* foreign = *it; + foreign_modified = false; for (unsigned i = 0; i < foreign->n_fields; i++) { if (strcmp(foreign->foreign_col_names[i], from)) { @@ -4495,6 +4505,11 @@ rename_foreign: if (error != DB_SUCCESS) { goto err_exit; } + foreign_modified = true; + } + + if (foreign_modified) { + fk_evict.push_back(foreign); } } @@ -4503,7 +4518,9 @@ rename_foreign: it != user_table->referenced_set.end(); ++it) { + foreign_modified = false; dict_foreign_t* foreign = *it; + for (unsigned i = 0; i < foreign->n_fields; i++) { if (strcmp(foreign->referenced_col_names[i], from)) { continue; @@ -4530,7 +4547,17 @@ rename_foreign: if (error != DB_SUCCESS) { goto err_exit; } + foreign_modified = true; } + + if (foreign_modified) { + fk_evict.push_back(foreign); + } + } + + if (new_clustered) { + std::for_each(fk_evict.begin(), fk_evict.end(), + dict_foreign_remove_from_cache); } trx->op_info = ""; |